Compare commits

..

18 Commits

Author SHA1 Message Date
5a4e0c0137 Merge pull request 'dev' (#1) from dev into main
Some checks failed
Publish to npm / publish (push) Failing after 23s
Reviewed-on: #1
2025-02-20 04:29:20 +00:00
397103b636
fix: update example in README to use SingleDatePicker instead of WeekPicker
All checks were successful
Publish to npm / publish (push) Successful in 24s
2025-02-20 15:27:14 +11:00
2c48ddbdb2
fix: update types path in package.json to point to the correct location
All checks were successful
Publish to npm / publish (push) Successful in 25s
2025-02-20 15:19:24 +11:00
70bb0b14af
fix: update package.json to correct main entry point and improve type definitions
All checks were successful
Publish to npm / publish (push) Successful in 26s
2025-02-20 15:06:02 +11:00
dcdf8ccdbe
fix: update export paths in package.json for consistency in module formats
All checks were successful
Publish to npm / publish (push) Successful in 28s
2025-02-20 14:56:48 +11:00
9f8c6c9156
fix: update main and module entry points in package.json for UMD and ES module formats
Some checks failed
Publish to npm / publish (push) Has been cancelled
2025-02-20 14:56:35 +11:00
6fdcd80710
feat: add vite-plugin-css-injected-by-js for improved CSS handling and update app import path
All checks were successful
Publish to npm / publish (push) Successful in 26s
2025-02-20 14:52:48 +11:00
c0b833be6f
fix: update import path for SingleDatePicker and adjust Vite configuration for output filenames
All checks were successful
Publish to npm / publish (push) Successful in 29s
2025-02-20 14:46:29 +11:00
952b053e9c
fix: update TypeScript definition path in package.json and configure dts plugin with tsconfig path
All checks were successful
Publish to npm / publish (push) Successful in 28s
2025-02-20 14:07:01 +11:00
69dcbd282f
feat: update TypeScript configuration and enhance SingleDatePicker component with improved typing
All checks were successful
Publish to npm / publish (push) Successful in 25s
2025-02-20 13:46:44 +11:00
d2c9e4aeeb
fix: update import from WeekPicker to SingleDatePicker in app.tsx
All checks were successful
Publish to npm / publish (push) Successful in 22s
2025-02-20 13:18:27 +11:00
622e3a8200
fix: rename export from WeekPicker to SingleDatePicker in index.ts
Some checks failed
Publish to npm / publish (push) Has been cancelled
2025-02-20 13:18:11 +11:00
9c95a54363
feat: enable type entry insertion in dts plugin for Vite configuration
All checks were successful
Publish to npm / publish (push) Successful in 24s
2025-02-20 13:12:53 +11:00
d0d0aa6cf5
docs: improve clarity in README regarding the testing React hot-reload server
All checks were successful
Publish to npm / publish (push) Successful in 24s
2025-02-20 11:43:29 +11:00
ee0e9d430c
docs: add contribution and development instructions to README
All checks were successful
Publish to npm / publish (push) Successful in 25s
2025-02-20 11:42:18 +11:00
0eb95f05ae
feat: update npm publishing workflow to set access level based on branch
All checks were successful
Publish to npm / publish (push) Successful in 23s
2025-02-20 11:25:28 +11:00
c55f5d0bfd
fix: remove access level settings from npm publishing workflow
Some checks failed
Publish to npm / publish (push) Failing after 23s
2025-02-20 11:23:18 +11:00
1b22a04392
feat: enhance npm publishing workflow for dev branch with conditional package name and access level
Some checks failed
Publish to npm / publish (push) Failing after 21s
2025-02-20 11:21:46 +11:00
11 changed files with 113 additions and 45 deletions

View File

@ -4,6 +4,7 @@ on:
push: push:
branches: branches:
- main - main
- dev
jobs: jobs:
publish: publish:
@ -22,7 +23,24 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: npm install run: npm install
- name: Determine package name
id: package_name
run: |
if [ "${{ gitea.ref }}" == "refs/heads/main" ]; then
echo "PACKAGE_NAME=datenel-react" >> $GITEA_ENV
echo "ACCESS_LEVEL=public" >> $GITEA_ENV
elif [ "${{ gitea.ref }}" == "refs/heads/dev" ]; then
echo "PACKAGE_NAME=@astrian/datenel-react-dev" >> $GITEA_ENV
echo "ACCESS_LEVEL=restricted" >> $GITEA_ENV
fi
- name: Update package.json for dev releases
if: GITEA.ref == 'refs/heads/dev'
run: |
jq --arg name "@astrian/datenel-react-dev" '.name=$name' package.json > temp.json && mv temp.json package.json
jq --arg version "0.0.0-dev.$(date +%s)" '.version=$version' package.json > temp.json && mv temp.json package.json
- name: Publish to npm - name: Publish to npm
run: npm publish run: npm publish --access $ACCESS_LEVEL
env: env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

View File

@ -30,8 +30,7 @@ Here is an example of how to use Datenel in your React application:
```tsx ```tsx
import React from 'react' import React from 'react'
import { WeekPicker } from 'datenel-react' import { SingleDatePicker } from 'datenel-react'
import './app.scss'
export default () => { export default () => {
function onSelect(value) { function onSelect(value) {
@ -41,7 +40,7 @@ export default () => {
return ( return (
<div className='app'> <div className='app'>
<div className="border"> <div className="border">
<WeekPicker <SingleDatePicker
value={{ value={{
year: 2025, year: 2025,
month: 1, month: 1,
@ -64,6 +63,15 @@ export default () => {
More features are on the roadmap. More features are on the roadmap.
## Contribution & Development
```zsh
npm i # or `yarn`
npm run dev # or `yarn dev`
```
Then the package will launch a testing React hot-reload server on `localhost:1926`. The server file is available in the `playground` folder, feel free to modify the content inside it.
## License ## License
MIT MIT

11
package-lock.json generated
View File

@ -23,6 +23,7 @@
"typescript": "~5.7.2", "typescript": "~5.7.2",
"typescript-eslint": "^8.22.0", "typescript-eslint": "^8.22.0",
"vite": "^6.1.0", "vite": "^6.1.0",
"vite-plugin-css-injected-by-js": "^3.5.2",
"vite-plugin-dts": "^4.5.0" "vite-plugin-dts": "^4.5.0"
}, },
"peerDependencies": { "peerDependencies": {
@ -4523,6 +4524,16 @@
} }
} }
}, },
"node_modules/vite-plugin-css-injected-by-js": {
"version": "3.5.2",
"resolved": "https://registry.npmjs.org/vite-plugin-css-injected-by-js/-/vite-plugin-css-injected-by-js-3.5.2.tgz",
"integrity": "sha512-2MpU/Y+SCZyWUB6ua3HbJCrgnF0KACAsmzOQt1UvRVJCGF6S8xdA3ZUhWcWdM9ivG4I5az8PnQmwwrkC2CAQrQ==",
"dev": true,
"license": "MIT",
"peerDependencies": {
"vite": ">2.0.0-0"
}
},
"node_modules/vite-plugin-dts": { "node_modules/vite-plugin-dts": {
"version": "4.5.0", "version": "4.5.0",
"resolved": "https://registry.npmjs.org/vite-plugin-dts/-/vite-plugin-dts-4.5.0.tgz", "resolved": "https://registry.npmjs.org/vite-plugin-dts/-/vite-plugin-dts-4.5.0.tgz",

View File

@ -22,21 +22,25 @@
"eslint-plugin-react-hooks": "^5.0.0", "eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-react-refresh": "^0.4.18", "eslint-plugin-react-refresh": "^0.4.18",
"globals": "^15.14.0", "globals": "^15.14.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"sass-embedded": "^1.85.0", "sass-embedded": "^1.85.0",
"typescript": "~5.7.2", "typescript": "~5.7.2",
"typescript-eslint": "^8.22.0", "typescript-eslint": "^8.22.0",
"vite": "^6.1.0", "vite": "^6.1.0",
"vite-plugin-dts": "^4.5.0", "vite-plugin-css-injected-by-js": "^3.5.2",
"react": "^19.0.0", "vite-plugin-dts": "^4.5.0"
"react-dom": "^19.0.0"
}, },
"exports": { "exports": {
"import": "./dist/datenel.es.js", "types": "./dist/src/index.d.ts",
"import": "./dist/index.es.js",
"require": "./dist/index.cjs.js", "require": "./dist/index.cjs.js",
"default": "./dist/datenel.es.js" "default": "./dist/index.es.js"
}, },
"main": "dist/index.cjs.js", "main": "dist/index.cjs.js",
"module": "dist/datenel.es.js", "module": "dist/index.es.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",
"files": ["dist"] "files": [
"dist"
]
} }

View File

@ -1,5 +1,5 @@
import React from 'react' import React from 'react'
import { WeekPicker } from "../src/index.ts" import { SingleDatePicker } from "../dist/index.es"
import './app.scss' import './app.scss'
export default () => { export default () => {
@ -11,7 +11,7 @@ export default () => {
return (<div className='app'> return (<div className='app'>
<div className="border"> <div className="border">
<WeekPicker <SingleDatePicker
value={{ value={{
year: 2025, year: 2025,
month: 1, month: 1,

View File

@ -1,7 +1,7 @@
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { getCalendarDates, getL10Weekday, generateUniqueId, applyColor } from '../utils' import { getCalendarDates, getL10Weekday, generateUniqueId, applyColor } from '../utils'
interface Props { export interface SingleDatePickerProps {
/** /**
* Control the selected * Control the selected
* date programmatically, including situations like provide a default value or control the selected * date programmatically, including situations like provide a default value or control the selected
@ -78,9 +78,9 @@ interface Props {
* *
* @component * @component
* *
* @param {Props} props * @param {SingleDatePickerProps} props
*/ */
export default ({ value, onSelect, localization, onClose, mainColor = '#000000', accentColor = '#000000', reversedColor = '#ffffff', hoverColor = '#00000017', borderColor = '#e0e0e0' }: Props) => { const SingleDatePicker: React.FC = ({ value, onSelect, localization, onClose, mainColor = '#000000', accentColor = '#000000', reversedColor = '#ffffff', hoverColor = '#00000017', borderColor = '#e0e0e0' }: SingleDatePickerProps) => {
const [currentMonth, setCurrentMonth] = useState(new Date().getMonth()) const [currentMonth, setCurrentMonth] = useState(new Date().getMonth())
const [currentYear, setCurrentYear] = useState(new Date().getFullYear()) const [currentYear, setCurrentYear] = useState(new Date().getFullYear())
const [selectedDate, setSelectedDate] = useState(new Date()) const [selectedDate, setSelectedDate] = useState(new Date())
@ -225,3 +225,5 @@ export default ({ value, onSelect, localization, onClose, mainColor = '#000000',
</div> </div>
) )
} }
export default SingleDatePicker

View File

@ -1,3 +1,3 @@
import './style.scss' import './style.scss'
export {default as WeekPicker} from './components/SingleDatePicker.tsx' export {default as SingleDatePicker} from './components/SingleDatePicker'

View File

@ -10,9 +10,10 @@
/* Bundler mode */ /* Bundler mode */
"moduleResolution": "bundler", "moduleResolution": "bundler",
"allowImportingTsExtensions": true, "allowImportingTsExtensions": true,
"emitDeclarationOnly": true,
"declaration": true,
"isolatedModules": true, "isolatedModules": true,
"moduleDetection": "force", "moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx", "jsx": "react-jsx",
/* Linting */ /* Linting */
@ -20,7 +21,10 @@
"noUnusedLocals": true, "noUnusedLocals": true,
"noUnusedParameters": true, "noUnusedParameters": true,
"noFallthroughCasesInSwitch": true, "noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true "noUncheckedSideEffectImports": true,
"composite": true,
"outDir": "./dist" //
}, },
"include": ["src"] "include": ["src", "tsconfig.app.json", "tsconfig.node.json"]
} }

View File

@ -9,6 +9,9 @@
"baseUrl": ".", "baseUrl": ".",
"paths": { "paths": {
"@/*": ["src/*"] "@/*": ["src/*"]
} },
} "declaration": true,
"outDir": "./dist"
},
"include": ["src/**/*", "tsconfig.app.json", "tsconfig.node.json"]
} }

View File

@ -9,16 +9,19 @@
/* Bundler mode */ /* Bundler mode */
"moduleResolution": "bundler", "moduleResolution": "bundler",
"allowImportingTsExtensions": true, "allowImportingTsExtensions": true,
"emitDeclarationOnly": true,
"declaration": true,
"isolatedModules": true, "isolatedModules": true,
"moduleDetection": "force", "moduleDetection": "force",
"noEmit": true,
/* Linting */ /* Linting */
"strict": true, "strict": true,
"noUnusedLocals": true, "noUnusedLocals": true,
"noUnusedParameters": true, "noUnusedParameters": true,
"noFallthroughCasesInSwitch": true, "noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true "noUncheckedSideEffectImports": true,
"composite": true
}, },
"include": ["vite.config.ts"] "include": ["vite.config.ts"]
} }

View File

@ -2,24 +2,39 @@ import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react' import react from '@vitejs/plugin-react'
import dts from 'vite-plugin-dts' import dts from 'vite-plugin-dts'
import path from "path" import path from "path"
import cssInjectedByJsPlugin from "vite-plugin-css-injected-by-js"
export default defineConfig(({mode}) => ({ export default defineConfig(({mode}) => ({
build: { build: {
lib: { lib: {
entry: "src/index.ts", entry: "src/index.ts",
name: "datenel-react", name: "datenel-react",
fileName: format => `datenel.${format}.js`, fileName: format => `index.${format}.js`,
}, },
rollupOptions: { rollupOptions: {
preserveEntrySignatures: "strict",
external: ["react"], external: ["react"],
output: { output: {
globals: { globals: {
react: "React", react: "React",
"react-dom": "ReactDOM",
},
assetFileNames: assetInfo => {
if (assetInfo.names[0].endsWith(".css")) {
return "index.css";
}
return `assets/${assetInfo.names[0]}`;
}
}, },
}, },
}, },
}, plugins: [
plugins: [react(), dts()], react(),
dts({
tsconfigPath: "./tsconfig.app.json"
}),
cssInjectedByJsPlugin()
],
resolve: { resolve: {
alias: { alias: {
"@": path.resolve(__dirname, "./src"), "@": path.resolve(__dirname, "./src"),