idea-react 3.0.0-beta.2 → 3.0.0-beta.3
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/AGENTS.md +3 -2
- package/dist/index.d.mts +47 -48
- package/dist/index.d.ts +47 -48
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +13 -13
- package/source/Form/Switch.tsx +60 -38
- package/source/Form/inputProps.ts +184 -0
- package/source/ToggleButton.tsx +49 -41
- package/tsconfig.json +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "idea-react",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.3",
|
|
4
4
|
"license": "LGPL-3.0-or-later",
|
|
5
5
|
"author": "shiy2008@gmail.com",
|
|
6
6
|
"description": "A React advanced components library based on TypeScript & Bootstrap, built by idea2app remote developers team.",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"@editorjs/editorjs": "^2.31.7",
|
|
32
32
|
"@editorjs/paragraph": "^2.11.7",
|
|
33
33
|
"@react-editor-js/core": "^2.1.0",
|
|
34
|
-
"@shikijs/langs": "^4.
|
|
35
|
-
"@shikijs/themes": "^4.
|
|
36
|
-
"@swc/helpers": "^0.5.
|
|
34
|
+
"@shikijs/langs": "^4.6.0",
|
|
35
|
+
"@shikijs/themes": "^4.6.0",
|
|
36
|
+
"@swc/helpers": "^0.5.24",
|
|
37
37
|
"bootstrap": "6.0.0-alpha.1",
|
|
38
38
|
"classnames": "^2.5.1",
|
|
39
39
|
"editorjs-html": "^4.0.5",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"mobx-react-helper": "^0.5.4",
|
|
44
44
|
"react-editor-js": "^2.1.0",
|
|
45
45
|
"react-live": "^5.0.1",
|
|
46
|
-
"shiki": "^4.
|
|
46
|
+
"shiki": "^4.6.0",
|
|
47
47
|
"vanilla-calendar-pro": "3.4.0",
|
|
48
48
|
"web-utility": "^4.8.1"
|
|
49
49
|
},
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"react-element-to-jsx-string": ">=15"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@cspell/eslint-plugin": "^10.4.
|
|
58
|
+
"@cspell/eslint-plugin": "^10.4.1",
|
|
59
59
|
"@eslint/js": "^10.0.1",
|
|
60
60
|
"@parcel/config-default": "~2.16.4",
|
|
61
61
|
"@parcel/packager-ts": "~2.16.4",
|
|
@@ -63,10 +63,10 @@
|
|
|
63
63
|
"@parcel/transformer-typescript-tsc": "~2.16.4",
|
|
64
64
|
"@parcel/transformer-typescript-types": "~2.16.4",
|
|
65
65
|
"@softonus/prettier-plugin-duplicate-remover": "^1.1.2",
|
|
66
|
-
"@swc/core": "^1.16.
|
|
66
|
+
"@swc/core": "^1.16.22",
|
|
67
67
|
"@testing-library/dom": "^10.4.2",
|
|
68
68
|
"@testing-library/react": "^16.3.3",
|
|
69
|
-
"@tsdown/css": "^0.23.
|
|
69
|
+
"@tsdown/css": "^0.23.7",
|
|
70
70
|
"@types/lodash": "^4.17.27",
|
|
71
71
|
"@types/node": "^26.6.6",
|
|
72
72
|
"@types/react": "^19.3.0",
|
|
@@ -76,14 +76,14 @@
|
|
|
76
76
|
"eslint-config-prettier": "^10.1.8",
|
|
77
77
|
"eslint-plugin-react": "^7.37.5",
|
|
78
78
|
"eslint-plugin-simple-import-sort": "^14.0.0",
|
|
79
|
-
"globals": "^17.
|
|
79
|
+
"globals": "^17.14.0",
|
|
80
80
|
"happy-dom": "^21.0.4",
|
|
81
81
|
"husky": "^9.1.7",
|
|
82
82
|
"jiti": "^2.7.0",
|
|
83
83
|
"koapache": "^3.0.0",
|
|
84
84
|
"less": "^4.9.1",
|
|
85
85
|
"lint-staged": "^17.6.0",
|
|
86
|
-
"mobx": "^7.1.
|
|
86
|
+
"mobx": "^7.1.5",
|
|
87
87
|
"mobx-react": "^10.0.3",
|
|
88
88
|
"parcel": "~2.16.4",
|
|
89
89
|
"postcss": "^8.5.32",
|
|
@@ -94,11 +94,11 @@
|
|
|
94
94
|
"react": "^19.3.1",
|
|
95
95
|
"react-dom": "^19.3.1",
|
|
96
96
|
"react-element-to-jsx-string": "^18.0.0",
|
|
97
|
-
"rimraf": "^6.1.
|
|
98
|
-
"tsdown": "^0.23.
|
|
97
|
+
"rimraf": "^6.1.4",
|
|
98
|
+
"tsdown": "^0.23.7",
|
|
99
99
|
"typedoc": "^0.28.20",
|
|
100
100
|
"typedoc-plugin-mdn-links": "^5.1.1",
|
|
101
|
-
"typescript": "~
|
|
101
|
+
"typescript": "~6.0.3",
|
|
102
102
|
"typescript-eslint": "^8.72.1",
|
|
103
103
|
"unplugin-swc": "^2.0.0",
|
|
104
104
|
"unrun": "^0.3.1"
|
package/source/Form/Switch.tsx
CHANGED
|
@@ -1,61 +1,83 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
|
-
import { ComponentPropsWithRef, CSSProperties, PropsWithChildren } from 'react';
|
|
2
|
+
import { ComponentPropsWithRef, CSSProperties, PropsWithChildren, Ref } from 'react';
|
|
3
3
|
|
|
4
4
|
import type { ComponentTheme } from '../Button';
|
|
5
5
|
import { polymorphic } from '../Polymorphic';
|
|
6
|
+
import { splitInputProps } from './inputProps';
|
|
6
7
|
import { FormValidationProps } from './Primitives';
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
type NativeInputProps = Omit<ComponentPropsWithRef<'input'>, 'ref' | 'type' | 'size'>;
|
|
10
|
+
|
|
11
|
+
export type FormSwitchProps = Omit<
|
|
12
|
+
ComponentPropsWithRef<'label'>,
|
|
13
|
+
keyof NativeInputProps | 'children'
|
|
14
|
+
> &
|
|
9
15
|
PropsWithChildren<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
NativeInputProps &
|
|
17
|
+
FormValidationProps & {
|
|
18
|
+
size?: 'sm' | 'lg';
|
|
19
|
+
theme?: ComponentTheme;
|
|
20
|
+
indicatorWidth?: string;
|
|
21
|
+
inputRef?: Ref<HTMLInputElement>;
|
|
22
|
+
inputId?: string;
|
|
23
|
+
inputClassName?: string;
|
|
24
|
+
inputStyle?: CSSProperties;
|
|
25
|
+
}
|
|
17
26
|
>;
|
|
18
27
|
|
|
19
28
|
export const FormSwitch = polymorphic<FormSwitchProps>(
|
|
20
29
|
({
|
|
21
30
|
as: Root = 'label',
|
|
31
|
+
id,
|
|
22
32
|
className,
|
|
23
|
-
inputProps,
|
|
24
33
|
size,
|
|
25
34
|
theme,
|
|
26
35
|
validation,
|
|
27
36
|
width,
|
|
28
37
|
indicatorWidth,
|
|
38
|
+
inputRef,
|
|
39
|
+
inputId,
|
|
40
|
+
inputClassName,
|
|
41
|
+
inputStyle,
|
|
29
42
|
style,
|
|
30
43
|
children,
|
|
31
44
|
...props
|
|
32
|
-
}) =>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
className
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
45
|
+
}) => {
|
|
46
|
+
const { inputProps, rootProps } = splitInputProps(props);
|
|
47
|
+
const { 'aria-invalid': ariaInvalid } = inputProps;
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<Root
|
|
51
|
+
id={id}
|
|
52
|
+
{...rootProps}
|
|
53
|
+
className={classNames(
|
|
54
|
+
'switch',
|
|
55
|
+
size && `switch-${size}`,
|
|
56
|
+
theme && `theme-${theme}`,
|
|
57
|
+
validation && `is-${validation}`,
|
|
58
|
+
className
|
|
59
|
+
)}
|
|
60
|
+
style={
|
|
61
|
+
{
|
|
62
|
+
'--bs-switch-width': width,
|
|
63
|
+
'--bs-switch-indicator-width': indicatorWidth,
|
|
64
|
+
...style
|
|
65
|
+
} as CSSProperties
|
|
66
|
+
}
|
|
67
|
+
>
|
|
68
|
+
<input
|
|
69
|
+
{...inputProps}
|
|
70
|
+
ref={inputRef}
|
|
71
|
+
id={inputId}
|
|
72
|
+
role="switch"
|
|
73
|
+
type="checkbox"
|
|
74
|
+
className={classNames(validation && `is-${validation}`, inputClassName)}
|
|
75
|
+
style={inputStyle}
|
|
76
|
+
aria-invalid={validation ? validation === 'invalid' : ariaInvalid}
|
|
77
|
+
/>
|
|
78
|
+
{children}
|
|
79
|
+
</Root>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
60
82
|
);
|
|
61
83
|
FormSwitch.displayName = 'FormSwitch';
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { ComponentPropsWithRef } from 'react';
|
|
2
|
+
|
|
3
|
+
type InputProps = Partial<ComponentPropsWithRef<'input'>> & Record<string, unknown>;
|
|
4
|
+
|
|
5
|
+
const inputPropNames = new Set(
|
|
6
|
+
[
|
|
7
|
+
'accessKey',
|
|
8
|
+
'accept',
|
|
9
|
+
'alt',
|
|
10
|
+
'autoCapitalize',
|
|
11
|
+
'autoComplete',
|
|
12
|
+
'autoFocus',
|
|
13
|
+
'capture',
|
|
14
|
+
'checked',
|
|
15
|
+
'contentEditable',
|
|
16
|
+
'contextMenu',
|
|
17
|
+
'defaultChecked',
|
|
18
|
+
'defaultValue',
|
|
19
|
+
'dir',
|
|
20
|
+
'dirName',
|
|
21
|
+
'disabled',
|
|
22
|
+
'draggable',
|
|
23
|
+
'enterKeyHint',
|
|
24
|
+
'form',
|
|
25
|
+
'formAction',
|
|
26
|
+
'formEncType',
|
|
27
|
+
'formMethod',
|
|
28
|
+
'formNoValidate',
|
|
29
|
+
'formTarget',
|
|
30
|
+
'hidden',
|
|
31
|
+
'height',
|
|
32
|
+
'id',
|
|
33
|
+
// cspell:ignore inlist
|
|
34
|
+
'inlist',
|
|
35
|
+
'inputMode',
|
|
36
|
+
'is',
|
|
37
|
+
'itemID',
|
|
38
|
+
'itemProp',
|
|
39
|
+
'itemRef',
|
|
40
|
+
'itemScope',
|
|
41
|
+
'itemType',
|
|
42
|
+
'lang',
|
|
43
|
+
'list',
|
|
44
|
+
'max',
|
|
45
|
+
'maxLength',
|
|
46
|
+
'min',
|
|
47
|
+
'minLength',
|
|
48
|
+
'multiple',
|
|
49
|
+
'name',
|
|
50
|
+
'nonce',
|
|
51
|
+
'pattern',
|
|
52
|
+
'part',
|
|
53
|
+
'popover',
|
|
54
|
+
'popoverTarget',
|
|
55
|
+
'popoverTargetAction',
|
|
56
|
+
'placeholder',
|
|
57
|
+
'about',
|
|
58
|
+
'content',
|
|
59
|
+
'datatype',
|
|
60
|
+
'prefix',
|
|
61
|
+
'property',
|
|
62
|
+
'radioGroup',
|
|
63
|
+
'readOnly',
|
|
64
|
+
'rel',
|
|
65
|
+
'resource',
|
|
66
|
+
'results',
|
|
67
|
+
'rev',
|
|
68
|
+
'role',
|
|
69
|
+
'required',
|
|
70
|
+
'slot',
|
|
71
|
+
'spellCheck',
|
|
72
|
+
'src',
|
|
73
|
+
'step',
|
|
74
|
+
'tabIndex',
|
|
75
|
+
'title',
|
|
76
|
+
'typeof',
|
|
77
|
+
'translate',
|
|
78
|
+
'value',
|
|
79
|
+
'vocab',
|
|
80
|
+
'width',
|
|
81
|
+
'autoCorrect',
|
|
82
|
+
'autoSave',
|
|
83
|
+
'color',
|
|
84
|
+
'security',
|
|
85
|
+
'unselectable',
|
|
86
|
+
'exportparts',
|
|
87
|
+
'inert',
|
|
88
|
+
'onAnimationEnd',
|
|
89
|
+
'onAnimationIteration',
|
|
90
|
+
'onAnimationStart',
|
|
91
|
+
'onAbort',
|
|
92
|
+
'onAuxClick',
|
|
93
|
+
'onBeforeInput',
|
|
94
|
+
'onBeforeToggle',
|
|
95
|
+
'onBlur',
|
|
96
|
+
'onCanPlay',
|
|
97
|
+
'onCanPlayThrough',
|
|
98
|
+
'onChange',
|
|
99
|
+
'onClick',
|
|
100
|
+
'onCompositionEnd',
|
|
101
|
+
'onCompositionStart',
|
|
102
|
+
'onCompositionUpdate',
|
|
103
|
+
'onContextMenu',
|
|
104
|
+
'onCopy',
|
|
105
|
+
'onCut',
|
|
106
|
+
'onDoubleClick',
|
|
107
|
+
'onDrag',
|
|
108
|
+
'onDragEnd',
|
|
109
|
+
'onDragEnter',
|
|
110
|
+
'onDragExit',
|
|
111
|
+
'onDragLeave',
|
|
112
|
+
'onDragOver',
|
|
113
|
+
'onDragStart',
|
|
114
|
+
'onDrop',
|
|
115
|
+
'onDurationChange',
|
|
116
|
+
'onEmptied',
|
|
117
|
+
'onEncrypted',
|
|
118
|
+
'onEnded',
|
|
119
|
+
'onError',
|
|
120
|
+
'onFocus',
|
|
121
|
+
'onGotPointerCapture',
|
|
122
|
+
'onInput',
|
|
123
|
+
'onInvalid',
|
|
124
|
+
'onKeyDown',
|
|
125
|
+
'onKeyPress',
|
|
126
|
+
'onKeyUp',
|
|
127
|
+
'onLoad',
|
|
128
|
+
'onLoadedData',
|
|
129
|
+
'onLoadedMetadata',
|
|
130
|
+
'onLoadStart',
|
|
131
|
+
'onLostPointerCapture',
|
|
132
|
+
'onMouseDown',
|
|
133
|
+
'onMouseEnter',
|
|
134
|
+
'onMouseLeave',
|
|
135
|
+
'onMouseMove',
|
|
136
|
+
'onMouseOut',
|
|
137
|
+
'onMouseOver',
|
|
138
|
+
'onMouseUp',
|
|
139
|
+
'onPaste',
|
|
140
|
+
'onPause',
|
|
141
|
+
'onPlay',
|
|
142
|
+
'onPlaying',
|
|
143
|
+
'onPointerCancel',
|
|
144
|
+
'onPointerDown',
|
|
145
|
+
'onPointerEnter',
|
|
146
|
+
'onPointerLeave',
|
|
147
|
+
'onPointerMove',
|
|
148
|
+
'onPointerOut',
|
|
149
|
+
'onPointerOver',
|
|
150
|
+
'onPointerUp',
|
|
151
|
+
'onProgress',
|
|
152
|
+
'onRateChange',
|
|
153
|
+
'onScroll',
|
|
154
|
+
'onSeeked',
|
|
155
|
+
'onSeeking',
|
|
156
|
+
'onSelect',
|
|
157
|
+
'onScrollEnd',
|
|
158
|
+
'onStalled',
|
|
159
|
+
'onSuspend',
|
|
160
|
+
'onTimeUpdate',
|
|
161
|
+
'onToggle',
|
|
162
|
+
'onTransitionCancel',
|
|
163
|
+
'onTransitionEnd',
|
|
164
|
+
'onTransitionRun',
|
|
165
|
+
'onTransitionStart',
|
|
166
|
+
'onTouchCancel',
|
|
167
|
+
'onTouchEnd',
|
|
168
|
+
'onTouchMove',
|
|
169
|
+
'onTouchStart',
|
|
170
|
+
'onVolumeChange',
|
|
171
|
+
'onWaiting',
|
|
172
|
+
'onWheel'
|
|
173
|
+
].flatMap(name => [name, `${name}Capture`])
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
export function splitInputProps(props: Record<string, unknown>) {
|
|
177
|
+
const inputProps: InputProps = {};
|
|
178
|
+
const rootProps: Record<string, unknown> = {};
|
|
179
|
+
|
|
180
|
+
for (const [name, value] of Object.entries(props))
|
|
181
|
+
(inputPropNames.has(name) || name.startsWith('aria-') ? inputProps : rootProps)[name] =
|
|
182
|
+
value;
|
|
183
|
+
return { inputProps, rootProps };
|
|
184
|
+
}
|
package/source/ToggleButton.tsx
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
|
-
import { ComponentPropsWithRef } from 'react';
|
|
2
|
+
import { ComponentPropsWithRef, CSSProperties, Ref } from 'react';
|
|
3
3
|
|
|
4
4
|
import type { ComponentTheme } from './Button';
|
|
5
|
+
import { splitInputProps } from './Form/inputProps';
|
|
5
6
|
import { polymorphic } from './Polymorphic';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
onChange?: ComponentPropsWithRef<'input'>['onChange'];
|
|
23
|
-
}
|
|
8
|
+
type NativeInputProps = Omit<ComponentPropsWithRef<'input'>, 'ref' | 'type' | 'size'>;
|
|
9
|
+
|
|
10
|
+
export type ToggleButtonProps = Omit<
|
|
11
|
+
ComponentPropsWithRef<'label'>,
|
|
12
|
+
keyof NativeInputProps | 'onChange'
|
|
13
|
+
> &
|
|
14
|
+
NativeInputProps & {
|
|
15
|
+
type?: 'checkbox' | 'radio';
|
|
16
|
+
variant?: 'solid' | 'outline' | 'subtle' | 'text';
|
|
17
|
+
theme?: ComponentTheme;
|
|
18
|
+
size?: 'xs' | 'sm' | 'lg';
|
|
19
|
+
inputRef?: Ref<HTMLInputElement>;
|
|
20
|
+
inputClassName?: string;
|
|
21
|
+
inputStyle?: CSSProperties;
|
|
22
|
+
};
|
|
24
23
|
|
|
25
24
|
export const ToggleButton = polymorphic<ToggleButtonProps>(
|
|
26
25
|
({
|
|
27
26
|
as: Root = 'label',
|
|
28
27
|
type = 'checkbox',
|
|
29
28
|
variant = 'solid',
|
|
29
|
+
className,
|
|
30
30
|
theme,
|
|
31
31
|
name,
|
|
32
32
|
value,
|
|
@@ -35,30 +35,38 @@ export const ToggleButton = polymorphic<ToggleButtonProps>(
|
|
|
35
35
|
disabled,
|
|
36
36
|
required,
|
|
37
37
|
size,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
inputRef,
|
|
39
|
+
inputClassName,
|
|
40
|
+
inputStyle,
|
|
41
41
|
children,
|
|
42
|
+
onChange,
|
|
42
43
|
...props
|
|
43
|
-
}) =>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
44
|
+
}) => {
|
|
45
|
+
const { inputProps, rootProps } = splitInputProps(props);
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<Root
|
|
49
|
+
{...rootProps}
|
|
50
|
+
className={classNames(
|
|
51
|
+
'btn-check',
|
|
52
|
+
`btn-${variant}`,
|
|
53
|
+
theme && `theme-${theme}`,
|
|
54
|
+
size && `btn-${size}`,
|
|
55
|
+
className
|
|
56
|
+
)}
|
|
57
|
+
>
|
|
58
|
+
<input
|
|
59
|
+
{...inputProps}
|
|
60
|
+
ref={inputRef}
|
|
61
|
+
className={inputClassName}
|
|
62
|
+
style={inputStyle}
|
|
63
|
+
{...{ type, name, value, checked, defaultChecked, disabled, required }}
|
|
64
|
+
autoComplete={inputProps.autoComplete ?? 'off'}
|
|
65
|
+
onChange={onChange}
|
|
66
|
+
/>
|
|
67
|
+
{children}
|
|
68
|
+
</Root>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
63
71
|
);
|
|
64
72
|
ToggleButton.displayName = 'ToggleButton';
|
package/tsconfig.json
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
"module": "ES2020",
|
|
5
5
|
"moduleResolution": "bundler",
|
|
6
6
|
"esModuleInterop": true,
|
|
7
|
-
"downlevelIteration": true,
|
|
8
7
|
"useDefineForClassFields": true,
|
|
9
8
|
"jsx": "react-jsx",
|
|
10
9
|
"skipLibCheck": true,
|
|
11
|
-
"lib": ["ES2024", "DOM", "DOM.Iterable"]
|
|
10
|
+
"lib": ["ES2024", "DOM", "DOM.Iterable"],
|
|
11
|
+
"types": ["node"]
|
|
12
12
|
},
|
|
13
13
|
"include": ["*.ts", "source/**/*"],
|
|
14
14
|
"typedocOptions": {
|