@enonic/ui 0.22.2 → 0.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/enonic-ui.cjs +1 -1
- package/dist/enonic-ui.es.js +78 -79
- package/dist/styles/preset.css +1 -1
- package/dist/styles/style.css +1 -1
- package/dist/styles/tokens.css +1 -1
- package/dist/types/components/avatar/avatar.d.ts +1 -1
- package/dist/types/components/button/button.d.ts +1 -1
- package/dist/types/components/combobox/combobox.d.ts +3 -2
- package/dist/types/components/combobox/index.d.ts +1 -1
- package/dist/types/components/icon-button/icon-button.d.ts +3 -3
- package/dist/types/components/index.d.ts +1 -1
- package/dist/types/components/link/link.d.ts +1 -1
- package/dist/types/components/list-item/index.d.ts +1 -1
- package/dist/types/components/listbox/index.d.ts +1 -1
- package/dist/types/components/listbox/listbox.d.ts +1 -1
- package/dist/types/components/menu/index.d.ts +1 -1
- package/dist/types/components/menubar/index.d.ts +1 -1
- package/dist/types/components/search-field/search-field.d.ts +1 -1
- package/dist/types/components/selectable-list-item/selectable-list-item.d.ts +1 -1
- package/dist/types/components/toast/index.d.ts +1 -1
- package/dist/types/components/toast/toast.d.ts +1 -1
- package/dist/types/components/toggle-group/index.d.ts +1 -1
- package/dist/types/components/toggle-group/toggle-group.d.ts +1 -1
- package/dist/types/components/toolbar/toolbar-toggle-group.d.ts +1 -1
- package/dist/types/components/tree-list/index.d.ts +1 -1
- package/dist/types/components/tree-list/tree-list.d.ts +2 -2
- package/dist/types/hooks/index.d.ts +7 -7
- package/dist/types/hooks/use-controlled-state-with-null.d.ts +19 -2
- package/dist/types/hooks/use-controlled-state.d.ts +23 -8
- package/dist/types/providers/tree-list-provider.d.ts +1 -1
- package/package.json +39 -39
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SetStateAction } from 'react';
|
|
1
2
|
/**
|
|
2
3
|
* Manages state that can be either controlled or uncontrolled.
|
|
3
4
|
* Follows the React pattern for controlled/uncontrolled state management.
|
|
@@ -8,7 +9,9 @@
|
|
|
8
9
|
* @param defaultValue - The default value for uncontrolled mode (e.g., `defaultValue`, `defaultOpen`)
|
|
9
10
|
* @param onChange - Callback invoked when the value changes
|
|
10
11
|
*
|
|
11
|
-
* @returns A tuple containing the current value and a setter function
|
|
12
|
+
* @returns A tuple containing the current value and a setter function.
|
|
13
|
+
* The setter accepts either a direct value or an updater function `(prev) => next`,
|
|
14
|
+
* matching React's `useState` API. The setter reference is stable across renders.
|
|
12
15
|
*
|
|
13
16
|
* **Controlled vs Uncontrolled Detection:**
|
|
14
17
|
* - `undefined` = uncontrolled mode (prop not provided)
|
|
@@ -20,6 +23,10 @@
|
|
|
20
23
|
* - `active="item-1"` → controlled with active item
|
|
21
24
|
* - `active` not provided → uncontrolled mode
|
|
22
25
|
*
|
|
26
|
+
* **Note on function values:**
|
|
27
|
+
* If `T` is a function type, you must wrap the value in an updater function
|
|
28
|
+
* to avoid it being interpreted as an updater: `setValue(() => myFunction)`.
|
|
29
|
+
*
|
|
23
30
|
* @example
|
|
24
31
|
* ```tsx
|
|
25
32
|
* // Uncontrolled usage
|
|
@@ -34,13 +41,21 @@
|
|
|
34
41
|
* return <div>{value ? 'Open' : 'Closed'}</div>;
|
|
35
42
|
* }
|
|
36
43
|
*
|
|
37
|
-
* //
|
|
38
|
-
* function
|
|
39
|
-
* const [
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
44
|
+
* // Using updater function (safe for batched updates)
|
|
45
|
+
* function Counter() {
|
|
46
|
+
* const [count, setCount] = useControlledState(undefined, 0);
|
|
47
|
+
* const incrementTwice = () => {
|
|
48
|
+
* setCount(prev => prev + 1);
|
|
49
|
+
* setCount(prev => prev + 1); // Correctly results in +2
|
|
50
|
+
* };
|
|
51
|
+
* return <button onClick={incrementTwice}>{count}</button>;
|
|
52
|
+
* }
|
|
53
|
+
*
|
|
54
|
+
* // Toggle pattern
|
|
55
|
+
* function Toggle() {
|
|
56
|
+
* const [pressed, setPressed] = useControlledState(undefined, false);
|
|
57
|
+
* return <button onClick={() => setPressed(prev => !prev)}>{pressed ? 'On' : 'Off'}</button>;
|
|
43
58
|
* }
|
|
44
59
|
* ```
|
|
45
60
|
*/
|
|
46
|
-
export declare function useControlledState<T>(controlledValue: T | undefined, defaultValue: T, onChange?: (value: T) => void): [T, (
|
|
61
|
+
export declare function useControlledState<T>(controlledValue: T | undefined, defaultValue: T, onChange?: (value: T) => void): [T, (action: SetStateAction<T>) => void];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TreeNode } from '../components/tree-list/tree-list';
|
|
2
1
|
import { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { TreeNode } from '../components/tree-list/tree-list';
|
|
3
3
|
export type TreeListContextValue<T extends TreeNode = TreeNode> = {
|
|
4
4
|
baseId: string;
|
|
5
5
|
items: readonly T[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enonic/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.1",
|
|
4
4
|
"description": "Enonic UI Component Library",
|
|
5
5
|
"author": "Enonic",
|
|
6
6
|
"license": "MIT",
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
"bugs": {
|
|
13
13
|
"url": "https://github.com/enonic/npm-enonic-ui/issues"
|
|
14
14
|
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public",
|
|
17
|
+
"provenance": false
|
|
18
|
+
},
|
|
15
19
|
"keywords": [
|
|
16
20
|
"enonic",
|
|
17
21
|
"ui",
|
|
@@ -68,44 +72,40 @@
|
|
|
68
72
|
}
|
|
69
73
|
},
|
|
70
74
|
"devDependencies": {
|
|
75
|
+
"@biomejs/biome": "~2.3.8",
|
|
71
76
|
"@chromatic-com/storybook": "~4.1.3",
|
|
72
77
|
"@eslint/js": "~9.39.1",
|
|
73
78
|
"@preact/preset-vite": "~2.10.2",
|
|
74
|
-
"@size-limit/file": "~
|
|
75
|
-
"@size-limit/preset-small-lib": "~
|
|
76
|
-
"@storybook/addon-a11y": "~10.
|
|
77
|
-
"@storybook/addon-docs": "~10.
|
|
78
|
-
"@storybook/addon-links": "~10.
|
|
79
|
-
"@storybook/addon-themes": "~10.
|
|
80
|
-
"@storybook/preact-vite": "~10.
|
|
79
|
+
"@size-limit/file": "~12.0.0",
|
|
80
|
+
"@size-limit/preset-small-lib": "~12.0.0",
|
|
81
|
+
"@storybook/addon-a11y": "~10.1.2",
|
|
82
|
+
"@storybook/addon-docs": "~10.1.2",
|
|
83
|
+
"@storybook/addon-links": "~10.1.2",
|
|
84
|
+
"@storybook/addon-themes": "~10.1.2",
|
|
85
|
+
"@storybook/preact-vite": "~10.1.2",
|
|
81
86
|
"@tailwindcss/vite": "~4.1.17",
|
|
82
|
-
"@trivago/prettier-plugin-sort-imports": "~6.0.0",
|
|
83
87
|
"@types/node": "~24.10.1",
|
|
84
|
-
"@types/react": "~19.2.
|
|
88
|
+
"@types/react": "~19.2.7",
|
|
85
89
|
"@types/react-dom": "~19.2.3",
|
|
86
|
-
"@typescript-eslint/eslint-plugin": "~8.
|
|
87
|
-
"@typescript-eslint/parser": "~8.
|
|
90
|
+
"@typescript-eslint/eslint-plugin": "~8.48.0",
|
|
91
|
+
"@typescript-eslint/parser": "~8.48.0",
|
|
88
92
|
"eslint": "~9.39.1",
|
|
89
|
-
"eslint-import-resolver-typescript": "~4.4.4",
|
|
90
|
-
"eslint-plugin-import": "~2.32.0",
|
|
91
93
|
"eslint-plugin-jsx-a11y": "~6.10.2",
|
|
92
94
|
"eslint-plugin-react": "~7.37.5",
|
|
93
|
-
"eslint-plugin-react-hooks": "~7.0.1",
|
|
94
95
|
"husky": "~9.1.7",
|
|
95
96
|
"lint-staged": "~16.2.7",
|
|
96
|
-
"lucide-preact": "~0.
|
|
97
|
-
"lucide-react": "~0.
|
|
97
|
+
"lucide-preact": "~0.555.0",
|
|
98
|
+
"lucide-react": "~0.555.0",
|
|
98
99
|
"postcss": "~8.5.6",
|
|
99
|
-
"prettier": "~3.6.2",
|
|
100
100
|
"rollup-plugin-visualizer": "~6.0.5",
|
|
101
|
-
"size-limit": "~
|
|
102
|
-
"storybook": "~10.
|
|
101
|
+
"size-limit": "~12.0.0",
|
|
102
|
+
"storybook": "~10.1.2",
|
|
103
103
|
"tailwindcss": "~4.1.17",
|
|
104
104
|
"terser": "~5.44.1",
|
|
105
105
|
"tw-animate-css": "~1.4.0",
|
|
106
106
|
"typescript": "~5.9.3",
|
|
107
|
-
"typescript-eslint": "~8.
|
|
108
|
-
"vite": "~7.2.
|
|
107
|
+
"typescript-eslint": "~8.48.0",
|
|
108
|
+
"vite": "~7.2.6",
|
|
109
109
|
"vite-plugin-dts": "~4.5.4",
|
|
110
110
|
"vite-plugin-environment": "~1.1.3"
|
|
111
111
|
},
|
|
@@ -122,31 +122,31 @@
|
|
|
122
122
|
]
|
|
123
123
|
},
|
|
124
124
|
"engines": {
|
|
125
|
-
"node": ">=
|
|
126
|
-
"pnpm": ">=10.
|
|
127
|
-
"npm": ">=
|
|
125
|
+
"node": ">=24.11.1",
|
|
126
|
+
"pnpm": ">=10.24.0",
|
|
127
|
+
"npm": ">=11.6.2"
|
|
128
128
|
},
|
|
129
129
|
"lint-staged": {
|
|
130
|
-
"
|
|
131
|
-
"
|
|
132
|
-
"
|
|
130
|
+
"*.{ts,tsx}": [
|
|
131
|
+
"biome check --write --unsafe --no-errors-on-unmatched",
|
|
132
|
+
"eslint --cache --fix --no-warn-ignored --concurrency auto"
|
|
133
133
|
],
|
|
134
|
-
"
|
|
135
|
-
"
|
|
134
|
+
"*.{json,css}": [
|
|
135
|
+
"biome check --write --unsafe --no-errors-on-unmatched"
|
|
136
136
|
]
|
|
137
137
|
},
|
|
138
138
|
"size-limit": [
|
|
139
139
|
{
|
|
140
140
|
"path": "dist/enonic-ui.es.js",
|
|
141
|
-
"limit": "
|
|
141
|
+
"limit": "35 KB"
|
|
142
142
|
},
|
|
143
143
|
{
|
|
144
144
|
"path": "dist/enonic-ui.cjs",
|
|
145
|
-
"limit": "
|
|
145
|
+
"limit": "35 KB"
|
|
146
146
|
},
|
|
147
147
|
{
|
|
148
148
|
"path": "dist/styles/style.css",
|
|
149
|
-
"limit": "
|
|
149
|
+
"limit": "12 KB"
|
|
150
150
|
},
|
|
151
151
|
{
|
|
152
152
|
"path": "dist/styles/preset.css",
|
|
@@ -166,14 +166,14 @@
|
|
|
166
166
|
"typecheck": "pnpm typecheck:app && pnpm typecheck:node",
|
|
167
167
|
"typecheck:app": "tsc --noEmit --project tsconfig.app.json",
|
|
168
168
|
"typecheck:node": "tsc --noEmit --project tsconfig.node.json",
|
|
169
|
-
"lint": "eslint --
|
|
170
|
-
"lint:fix": "eslint --cache '
|
|
171
|
-
"
|
|
172
|
-
"format
|
|
169
|
+
"lint": "biome check . && eslint --cache '**/*.{ts,tsx}' --max-warnings 0 --concurrency auto",
|
|
170
|
+
"lint:fix": "biome check --write --unsafe . && eslint --cache 'src/**/*.{ts,tsx}' --fix --concurrency auto",
|
|
171
|
+
"lint:ci": "biome check . && eslint --no-cache 'src/**/*.{ts,tsx}' --max-warnings 0 --concurrency auto",
|
|
172
|
+
"format": "biome format --write .",
|
|
173
|
+
"format:check": "biome format .",
|
|
173
174
|
"test": "exit 0",
|
|
174
175
|
"test:ci": "exit 0",
|
|
175
|
-
"release": "pnpm publish --
|
|
176
|
-
"release:dry": "pnpm publish --dry-run --access public --no-git-checks",
|
|
176
|
+
"release:dry": "pnpm publish --dry-run --no-git-checks",
|
|
177
177
|
"analyze": "pnpm build && open dist/stats.html",
|
|
178
178
|
"size": "size-limit",
|
|
179
179
|
"preview": "pnpm dlx serve . -p 4000"
|