@ensi-platform/admin-ui 0.5.0 → 0.6.0
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/Component-CBWeJZfB.js +92 -0
- package/dist/Component-CBWeJZfB.js.map +1 -0
- package/dist/Component-DFwWbzFS.js +128 -0
- package/dist/Component-DFwWbzFS.js.map +1 -0
- package/dist/{Component-Bk0VFhAQ.js → Component-DhhrZEMr.js} +2 -2
- package/dist/{Component-Bk0VFhAQ.js.map → Component-DhhrZEMr.js.map} +1 -1
- package/dist/Component-Dkvzqo0L.js +155 -0
- package/dist/Component-Dkvzqo0L.js.map +1 -0
- package/dist/action-popup/index.js +1 -1
- package/dist/arrangement-settings/index.js +1 -1
- package/dist/assets/Component16.css +1 -1
- package/dist/assets/Component5.css +1 -1
- package/dist/assets/Component7.css +1 -1
- package/dist/assets/Component9.css +1 -1
- package/dist/assets/index.css +1 -1
- package/dist/assets/index17.css +1 -1
- package/dist/assets/index26.css +1 -1
- package/dist/assets/index27.css +1 -1
- package/dist/autocomplete/index.js +1 -1
- package/dist/autocomplete-async/index.js +1 -1
- package/dist/button/Component.d.ts +1 -1
- package/dist/button/Component.d.ts.map +1 -1
- package/dist/button/index.js +1 -1
- package/dist/button/theme.d.ts +1 -0
- package/dist/button/theme.d.ts.map +1 -1
- package/dist/button/types.d.ts +2 -0
- package/dist/button/types.d.ts.map +1 -1
- package/dist/checkbox/index.js +1 -1
- package/dist/checkbox-group/index.js +1 -1
- package/dist/data-table/index.js +1 -1
- package/dist/date-picker/index.js +1 -1
- package/dist/date-range-picker/index.js +1 -1
- package/dist/form/Component.d.ts +1 -1
- package/dist/form/Component.d.ts.map +1 -1
- package/dist/form/context.d.ts +3 -1
- package/dist/form/context.d.ts.map +1 -1
- package/dist/form/hooks/useFieldHook.d.ts +2 -1
- package/dist/form/hooks/useFieldHook.d.ts.map +1 -1
- package/dist/form/index.js +84 -74
- package/dist/form/index.js.map +1 -1
- package/dist/form/types.d.ts +15 -2
- package/dist/form/types.d.ts.map +1 -1
- package/dist/form/utils.d.ts +3 -0
- package/dist/form/utils.d.ts.map +1 -1
- package/dist/input/Component.d.ts +1 -1
- package/dist/input/Component.d.ts.map +1 -1
- package/dist/input/FormInput.d.ts +1 -1
- package/dist/input/FormInput.d.ts.map +1 -1
- package/dist/input/index.js +27 -25
- package/dist/input/index.js.map +1 -1
- package/dist/input/types.d.ts +5 -1
- package/dist/input/types.d.ts.map +1 -1
- package/dist/multi-autocomplete/index.js +1 -1
- package/dist/multi-autocomplete-async/index.js +1 -1
- package/dist/multi-select/index.js +1 -1
- package/dist/number-input/Component.d.ts +1 -1
- package/dist/number-input/Component.d.ts.map +1 -1
- package/dist/number-input/FormNumberInput.d.ts +1 -1
- package/dist/number-input/FormNumberInput.d.ts.map +1 -1
- package/dist/number-input/index.js +41 -39
- package/dist/number-input/index.js.map +1 -1
- package/dist/number-input/types.d.ts +5 -1
- package/dist/number-input/types.d.ts.map +1 -1
- package/dist/number-range/index.js +2 -2
- package/dist/select/index.js +1 -1
- package/dist/slider/index.js +1 -1
- package/dist/suggest-checklist/index.js +1 -1
- package/dist/switch/index.js +1 -1
- package/dist/table/index.js +1 -1
- package/dist/textarea/Component.d.ts +1 -1
- package/dist/textarea/Component.d.ts.map +1 -1
- package/dist/textarea/FormTextArea.d.ts +1 -1
- package/dist/textarea/FormTextArea.d.ts.map +1 -1
- package/dist/textarea/index.js +91 -86
- package/dist/textarea/index.js.map +1 -1
- package/dist/textarea/types.d.ts +5 -1
- package/dist/textarea/types.d.ts.map +1 -1
- package/dist/time-field/index.js +1 -1
- package/dist/useFieldHook-Bt9nST7g.js +52 -0
- package/dist/useFieldHook-Bt9nST7g.js.map +1 -0
- package/docs/README.md +3 -4
- package/docs/ai.md +42 -28
- package/docs/architecture.md +23 -23
- package/docs/design-language.md +103 -0
- package/docs/skills/SKILL.md +64 -25
- package/package.json +10 -6
- package/scripts/sync-agents-consumer.ts +2 -1
- package/src/button/docs/{Description.en.md → Description.md} +1 -0
- package/src/button/types.ts +2 -0
- package/src/cascade-menu/docs/cssVariables.ts +2 -1
- package/src/combobox/docs/Description.md +27 -0
- package/src/combobox/docs/Example.md +11 -0
- package/src/docs/ai/Description.md +60 -0
- package/src/docs/getting-started/Description.md +81 -0
- package/src/ds/tokens/docs/Description.md +30 -0
- package/src/ds/typography/docs/{Description.en.md → Description.md} +3 -3
- package/src/form/docs/{Description.en.md → Description.md} +2 -1
- package/src/form/types.ts +18 -3
- package/src/hooks/docs/Description.md +30 -0
- package/src/hooks/docs/Example.md +9 -0
- package/src/icons/docs/Description.md +23 -0
- package/src/icons/docs/Example.md +5 -0
- package/src/input/docs/{Description.en.md → Description.md} +3 -1
- package/src/input/docs/cssVariables.ts +1 -0
- package/src/input/types.ts +5 -1
- package/src/link/docs/cssVariables.ts +1 -1
- package/src/number-input/docs/{Description.en.md → Description.md} +3 -1
- package/src/number-input/docs/cssVariables.ts +1 -0
- package/src/number-input/types.ts +5 -0
- package/src/table/docs/cssVariables.ts +3 -3
- package/src/tabs/docs/{Description.en.md → Description.md} +17 -0
- package/src/textarea/docs/{Description.en.md → Description.md} +3 -1
- package/src/textarea/docs/cssVariables.ts +1 -0
- package/src/textarea/types.ts +5 -1
- package/src/toast/docs/cssVariables.ts +1 -1
- package/src/tooltip/docs/cssVariables.ts +2 -2
- package/dist/Component-BBFBVrTt.js +0 -152
- package/dist/Component-BBFBVrTt.js.map +0 -1
- package/dist/Component-C4pVS7OW.js +0 -125
- package/dist/Component-C4pVS7OW.js.map +0 -1
- package/dist/Component-VS3iDpxE.js +0 -85
- package/dist/Component-VS3iDpxE.js.map +0 -1
- package/dist/utils-CizYZV2a.js +0 -50
- package/dist/utils-CizYZV2a.js.map +0 -1
- package/docs/skills/evals/evals.json +0 -23
- package/src/action-popup/docs/Description.ru.md +0 -40
- package/src/action-popup/docs/Example.ru.md +0 -14
- package/src/active-filters/docs/Description.ru.md +0 -49
- package/src/active-filters/docs/Example.ru.md +0 -15
- package/src/arrangement-settings/docs/Description.ru.md +0 -25
- package/src/arrangement-settings/docs/Example.ru.md +0 -15
- package/src/autocomplete/docs/Description.ru.md +0 -51
- package/src/autocomplete/docs/Example.ru.md +0 -17
- package/src/autocomplete-async/docs/Description.ru.md +0 -71
- package/src/autocomplete-async/docs/Example.ru.md +0 -19
- package/src/avatar/docs/Description.ru.md +0 -23
- package/src/avatar/docs/Example.ru.md +0 -7
- package/src/badge/docs/Description.ru.md +0 -22
- package/src/badge/docs/Example.ru.md +0 -8
- package/src/bottom-sheet/docs/Description.ru.md +0 -27
- package/src/bottom-sheet/docs/Example.ru.md +0 -14
- package/src/button/docs/Description.ru.md +0 -24
- package/src/button/docs/Example.ru.md +0 -11
- package/src/cascade-menu/docs/Description.ru.md +0 -43
- package/src/cascade-menu/docs/Example.ru.md +0 -107
- package/src/checkbox/docs/Description.ru.md +0 -42
- package/src/checkbox/docs/Example.ru.md +0 -13
- package/src/checkbox-group/docs/Description.ru.md +0 -39
- package/src/checkbox-group/docs/Example.ru.md +0 -17
- package/src/context-menu/docs/Description.ru.md +0 -44
- package/src/context-menu/docs/Example.ru.md +0 -22
- package/src/data-table/docs/Description.ru.md +0 -33
- package/src/data-table/docs/Example.ru.md +0 -82
- package/src/date-picker/docs/Description.ru.md +0 -43
- package/src/date-picker/docs/Example.ru.md +0 -15
- package/src/date-range-picker/docs/Description.ru.md +0 -39
- package/src/date-range-picker/docs/Example.ru.md +0 -19
- package/src/drawer/docs/Description.ru.md +0 -28
- package/src/drawer/docs/Example.ru.md +0 -14
- package/src/ds/typography/docs/Description.ru.md +0 -35
- package/src/field/docs/Description.ru.md +0 -28
- package/src/field/docs/Example.ru.md +0 -16
- package/src/filters/docs/Description.ru.md +0 -40
- package/src/filters/docs/Example.ru.md +0 -21
- package/src/form/docs/Description.ru.md +0 -33
- package/src/form/docs/Example.ru.md +0 -18
- package/src/input/docs/Description.ru.md +0 -41
- package/src/input/docs/Example.ru.md +0 -21
- package/src/link/docs/Description.ru.md +0 -21
- package/src/link/docs/Example.ru.md +0 -16
- package/src/loader/docs/Description.ru.md +0 -21
- package/src/loader/docs/Example.ru.md +0 -10
- package/src/menu-list/docs/Description.ru.md +0 -45
- package/src/menu-list/docs/Example.ru.md +0 -14
- package/src/modal/docs/Description.ru.md +0 -25
- package/src/modal/docs/Example.ru.md +0 -15
- package/src/modal-hub/docs/Description.ru.md +0 -35
- package/src/modal-hub/docs/Example.ru.md +0 -20
- package/src/multi-autocomplete/docs/Description.ru.md +0 -52
- package/src/multi-autocomplete/docs/Example.ru.md +0 -12
- package/src/multi-autocomplete-async/docs/Description.ru.md +0 -55
- package/src/multi-autocomplete-async/docs/Example.ru.md +0 -5
- package/src/multi-select/docs/Description.ru.md +0 -46
- package/src/multi-select/docs/Example.ru.md +0 -20
- package/src/number-input/docs/Description.ru.md +0 -46
- package/src/number-input/docs/Example.ru.md +0 -19
- package/src/number-range/docs/Description.ru.md +0 -49
- package/src/number-range/docs/Example.ru.md +0 -25
- package/src/popover/docs/Description.ru.md +0 -33
- package/src/popover/docs/Example.ru.md +0 -13
- package/src/provider/docs/Description.ru.md +0 -27
- package/src/provider/docs/Example.ru.md +0 -10
- package/src/select/docs/Description.ru.md +0 -46
- package/src/select/docs/Example.ru.md +0 -20
- package/src/slider/docs/Description.ru.md +0 -45
- package/src/slider/docs/Example.ru.md +0 -17
- package/src/suggest-checklist/docs/Description.ru.md +0 -26
- package/src/suggest-checklist/docs/Example.ru.md +0 -11
- package/src/switch/docs/Description.ru.md +0 -39
- package/src/switch/docs/Example.ru.md +0 -13
- package/src/table/docs/Description.ru.md +0 -32
- package/src/table/docs/Example.ru.md +0 -67
- package/src/tabs/docs/Description.ru.md +0 -24
- package/src/tabs/docs/Example.ru.md +0 -12
- package/src/tag/docs/Description.ru.md +0 -24
- package/src/tag/docs/Example.ru.md +0 -6
- package/src/textarea/docs/Description.ru.md +0 -40
- package/src/textarea/docs/Example.ru.md +0 -21
- package/src/time-field/docs/Description.ru.md +0 -41
- package/src/time-field/docs/Example.ru.md +0 -9
- package/src/toast/docs/Description.ru.md +0 -57
- package/src/toast/docs/Example.ru.md +0 -25
- package/src/tooltip/docs/Description.ru.md +0 -34
- package/src/tooltip/docs/Example.ru.md +0 -10
- /package/src/action-popup/docs/{Description.en.md → Description.md} +0 -0
- /package/src/action-popup/docs/{Example.en.md → Example.md} +0 -0
- /package/src/active-filters/docs/{Description.en.md → Description.md} +0 -0
- /package/src/active-filters/docs/{Example.en.md → Example.md} +0 -0
- /package/src/arrangement-settings/docs/{Description.en.md → Description.md} +0 -0
- /package/src/arrangement-settings/docs/{Example.en.md → Example.md} +0 -0
- /package/src/autocomplete/docs/{Description.en.md → Description.md} +0 -0
- /package/src/autocomplete/docs/{Example.en.md → Example.md} +0 -0
- /package/src/autocomplete-async/docs/{Description.en.md → Description.md} +0 -0
- /package/src/autocomplete-async/docs/{Example.en.md → Example.md} +0 -0
- /package/src/avatar/docs/{Description.en.md → Description.md} +0 -0
- /package/src/avatar/docs/{Example.en.md → Example.md} +0 -0
- /package/src/badge/docs/{Description.en.md → Description.md} +0 -0
- /package/src/badge/docs/{Example.en.md → Example.md} +0 -0
- /package/src/bottom-sheet/docs/{Description.en.md → Description.md} +0 -0
- /package/src/bottom-sheet/docs/{Example.en.md → Example.md} +0 -0
- /package/src/button/docs/{Example.en.md → Example.md} +0 -0
- /package/src/cascade-menu/docs/{Description.en.md → Description.md} +0 -0
- /package/src/cascade-menu/docs/{Example.en.md → Example.md} +0 -0
- /package/src/checkbox/docs/{Description.en.md → Description.md} +0 -0
- /package/src/checkbox/docs/{Example.en.md → Example.md} +0 -0
- /package/src/checkbox-group/docs/{Description.en.md → Description.md} +0 -0
- /package/src/checkbox-group/docs/{Example.en.md → Example.md} +0 -0
- /package/src/context-menu/docs/{Description.en.md → Description.md} +0 -0
- /package/src/context-menu/docs/{Example.en.md → Example.md} +0 -0
- /package/src/data-table/docs/{Description.en.md → Description.md} +0 -0
- /package/src/data-table/docs/{Example.en.md → Example.md} +0 -0
- /package/src/date-picker/docs/{Description.en.md → Description.md} +0 -0
- /package/src/date-picker/docs/{Example.en.md → Example.md} +0 -0
- /package/src/date-range-picker/docs/{Description.en.md → Description.md} +0 -0
- /package/src/date-range-picker/docs/{Example.en.md → Example.md} +0 -0
- /package/src/drawer/docs/{Description.en.md → Description.md} +0 -0
- /package/src/drawer/docs/{Example.en.md → Example.md} +0 -0
- /package/src/field/docs/{Description.en.md → Description.md} +0 -0
- /package/src/field/docs/{Example.en.md → Example.md} +0 -0
- /package/src/filters/docs/{Description.en.md → Description.md} +0 -0
- /package/src/filters/docs/{Example.en.md → Example.md} +0 -0
- /package/src/form/docs/{Example.en.md → Example.md} +0 -0
- /package/src/input/docs/{Example.en.md → Example.md} +0 -0
- /package/src/link/docs/{Description.en.md → Description.md} +0 -0
- /package/src/link/docs/{Example.en.md → Example.md} +0 -0
- /package/src/loader/docs/{Description.en.md → Description.md} +0 -0
- /package/src/loader/docs/{Example.en.md → Example.md} +0 -0
- /package/src/menu-list/docs/{Description.en.md → Description.md} +0 -0
- /package/src/menu-list/docs/{Example.en.md → Example.md} +0 -0
- /package/src/modal/docs/{Description.en.md → Description.md} +0 -0
- /package/src/modal/docs/{Example.en.md → Example.md} +0 -0
- /package/src/modal-hub/docs/{Description.en.md → Description.md} +0 -0
- /package/src/modal-hub/docs/{Example.en.md → Example.md} +0 -0
- /package/src/multi-autocomplete/docs/{Description.en.md → Description.md} +0 -0
- /package/src/multi-autocomplete/docs/{Example.en.md → Example.md} +0 -0
- /package/src/multi-autocomplete-async/docs/{Description.en.md → Description.md} +0 -0
- /package/src/multi-autocomplete-async/docs/{Example.en.md → Example.md} +0 -0
- /package/src/multi-select/docs/{Description.en.md → Description.md} +0 -0
- /package/src/multi-select/docs/{Example.en.md → Example.md} +0 -0
- /package/src/number-input/docs/{Example.en.md → Example.md} +0 -0
- /package/src/number-range/docs/{Description.en.md → Description.md} +0 -0
- /package/src/number-range/docs/{Example.en.md → Example.md} +0 -0
- /package/src/popover/docs/{Description.en.md → Description.md} +0 -0
- /package/src/popover/docs/{Example.en.md → Example.md} +0 -0
- /package/src/provider/docs/{Description.en.md → Description.md} +0 -0
- /package/src/provider/docs/{Example.en.md → Example.md} +0 -0
- /package/src/select/docs/{Description.en.md → Description.md} +0 -0
- /package/src/select/docs/{Example.en.md → Example.md} +0 -0
- /package/src/slider/docs/{Description.en.md → Description.md} +0 -0
- /package/src/slider/docs/{Example.en.md → Example.md} +0 -0
- /package/src/suggest-checklist/docs/{Description.en.md → Description.md} +0 -0
- /package/src/suggest-checklist/docs/{Example.en.md → Example.md} +0 -0
- /package/src/switch/docs/{Description.en.md → Description.md} +0 -0
- /package/src/switch/docs/{Example.en.md → Example.md} +0 -0
- /package/src/table/docs/{Description.en.md → Description.md} +0 -0
- /package/src/table/docs/{Example.en.md → Example.md} +0 -0
- /package/src/tabs/docs/{Example.en.md → Example.md} +0 -0
- /package/src/tag/docs/{Description.en.md → Description.md} +0 -0
- /package/src/tag/docs/{Example.en.md → Example.md} +0 -0
- /package/src/textarea/docs/{Example.en.md → Example.md} +0 -0
- /package/src/time-field/docs/{Description.en.md → Description.md} +0 -0
- /package/src/time-field/docs/{Example.en.md → Example.md} +0 -0
- /package/src/toast/docs/{Description.en.md → Description.md} +0 -0
- /package/src/toast/docs/{Example.en.md → Example.md} +0 -0
- /package/src/tooltip/docs/{Description.en.md → Description.md} +0 -0
- /package/src/tooltip/docs/{Example.en.md → Example.md} +0 -0
package/dist/textarea/index.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as E, jsx as s } from "react/jsx-runtime";
|
|
2
2
|
import { useRef as N, useState as V } from "react";
|
|
3
|
-
import
|
|
3
|
+
import x from "classnames";
|
|
4
4
|
import { Group as w, TextArea as H } from "react-aria-components";
|
|
5
|
-
import { s as
|
|
5
|
+
import { s as F } from "../index-h8z54aFR.js";
|
|
6
6
|
import { C as B } from "../Clear-DcxADxz6.js";
|
|
7
|
-
import { u as
|
|
7
|
+
import { u as O } from "../hooks-BAkrGC45.js";
|
|
8
8
|
import { cva as j } from "class-variance-authority";
|
|
9
|
-
import { typographyStyles as
|
|
10
|
-
import { F as
|
|
11
|
-
import { u as L, g as M } from "../
|
|
12
|
-
import '../assets/index17.css';const
|
|
13
|
-
root:
|
|
14
|
-
block:
|
|
15
|
-
sm:
|
|
16
|
-
md:
|
|
17
|
-
lg:
|
|
18
|
-
fieldInput:
|
|
19
|
-
clear:
|
|
20
|
-
clearIcon:
|
|
21
|
-
primary:
|
|
22
|
-
},
|
|
9
|
+
import { typographyStyles as k } from "../typography/index.js";
|
|
10
|
+
import { F as g, u as z } from "../Component-BPN5FgKq.js";
|
|
11
|
+
import { u as L, g as M } from "../useFieldHook-Bt9nST7g.js";
|
|
12
|
+
import '../assets/index17.css';const G = "aub_styles-module_root_6dcd6", U = "aub_styles-module_block_9fd7b", $ = "aub_styles-module_sm_8e3c9", q = "aub_styles-module_md_9f5d6", J = "aub_styles-module_lg_459d3", K = "aub_styles-module_fieldInput_f9bcf", Q = "aub_styles-module_clear_97555", W = "aub_styles-module_clearIcon_dd0fc", X = "aub_styles-module_primary_af5fb", o = {
|
|
13
|
+
root: G,
|
|
14
|
+
block: U,
|
|
15
|
+
sm: $,
|
|
16
|
+
md: q,
|
|
17
|
+
lg: J,
|
|
18
|
+
fieldInput: K,
|
|
19
|
+
clear: Q,
|
|
20
|
+
clearIcon: W,
|
|
21
|
+
primary: X
|
|
22
|
+
}, Y = j(o.root, {
|
|
23
23
|
variants: {
|
|
24
24
|
size: {
|
|
25
|
-
sm:
|
|
26
|
-
md:
|
|
27
|
-
lg:
|
|
25
|
+
sm: x(o.sm, k.bodyS),
|
|
26
|
+
md: x(o.md, k.bodyS),
|
|
27
|
+
lg: x(o.lg, k.bodyM)
|
|
28
28
|
},
|
|
29
29
|
variant: {
|
|
30
30
|
primary: o.primary
|
|
@@ -39,22 +39,22 @@ import '../assets/index17.css';const O = "aub_styles-module_root_6dcd6", G = "au
|
|
|
39
39
|
variant: "primary",
|
|
40
40
|
block: !0
|
|
41
41
|
}
|
|
42
|
-
}),
|
|
42
|
+
}), Z = (e) => ({
|
|
43
43
|
target: e ?? { value: "" },
|
|
44
44
|
currentTarget: e ?? { value: "" }
|
|
45
|
-
}),
|
|
45
|
+
}), ee = (e) => {
|
|
46
46
|
if (!e)
|
|
47
47
|
return;
|
|
48
48
|
Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, "value")?.set?.call(e, "");
|
|
49
|
-
},
|
|
49
|
+
}, D = (e) => e == null ? "" : String(e), te = (e, t) => {
|
|
50
50
|
if (typeof e == "function") {
|
|
51
51
|
e(t);
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
54
|
e && (e.current = t);
|
|
55
|
-
},
|
|
56
|
-
const { clear: t } =
|
|
57
|
-
return /* @__PURE__ */
|
|
55
|
+
}, re = ({ onClear: e }) => {
|
|
56
|
+
const { clear: t } = O();
|
|
57
|
+
return /* @__PURE__ */ s(
|
|
58
58
|
"button",
|
|
59
59
|
{
|
|
60
60
|
type: "button",
|
|
@@ -66,108 +66,113 @@ import '../assets/index17.css';const O = "aub_styles-module_root_6dcd6", G = "au
|
|
|
66
66
|
onClick: (r) => {
|
|
67
67
|
r.preventDefault(), r.stopPropagation(), e();
|
|
68
68
|
},
|
|
69
|
-
children: /* @__PURE__ */
|
|
69
|
+
children: /* @__PURE__ */ s(B, { className: o.clearIcon })
|
|
70
70
|
}
|
|
71
71
|
);
|
|
72
|
-
},
|
|
72
|
+
}, P = F(
|
|
73
73
|
({
|
|
74
74
|
ref: e,
|
|
75
75
|
size: t = "md",
|
|
76
76
|
variant: r = "primary",
|
|
77
|
-
block:
|
|
77
|
+
block: i = !0,
|
|
78
78
|
invalid: l = !1,
|
|
79
|
-
disabled:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
disabled: u = !1,
|
|
80
|
+
readOnly: n = !1,
|
|
81
|
+
clear: h = !1,
|
|
82
|
+
className: v,
|
|
83
|
+
dataTestId: A,
|
|
84
|
+
value: c,
|
|
84
85
|
defaultValue: p,
|
|
85
|
-
onChange:
|
|
86
|
-
...
|
|
86
|
+
onChange: f,
|
|
87
|
+
...C
|
|
87
88
|
}) => {
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
},
|
|
91
|
-
const
|
|
92
|
-
|
|
89
|
+
const y = N(null), m = c !== void 0, [T, b] = V(() => D(p)), _ = m ? D(c) : T, I = h && !u && !n && _ !== "", R = (a) => {
|
|
90
|
+
m || b(a.target.value), f?.(a);
|
|
91
|
+
}, d = () => {
|
|
92
|
+
const a = y.current, S = Z(a);
|
|
93
|
+
ee(a), m || b(""), f?.(S);
|
|
93
94
|
};
|
|
94
|
-
return /* @__PURE__ */
|
|
95
|
+
return /* @__PURE__ */ E(
|
|
95
96
|
w,
|
|
96
97
|
{
|
|
97
|
-
className:
|
|
98
|
-
"data-test-id":
|
|
98
|
+
className: x(Y({ size: t, variant: r, block: i }), v),
|
|
99
|
+
"data-test-id": A,
|
|
99
100
|
isInvalid: l,
|
|
100
|
-
isDisabled:
|
|
101
|
+
isDisabled: u,
|
|
102
|
+
isReadOnly: n,
|
|
101
103
|
children: [
|
|
102
|
-
/* @__PURE__ */
|
|
104
|
+
/* @__PURE__ */ s(
|
|
103
105
|
H,
|
|
104
106
|
{
|
|
105
|
-
...
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
...C,
|
|
108
|
+
readOnly: n,
|
|
109
|
+
ref: (a) => {
|
|
110
|
+
y.current = a, te(e, a);
|
|
108
111
|
},
|
|
109
|
-
value:
|
|
112
|
+
value: c,
|
|
110
113
|
defaultValue: p,
|
|
111
|
-
onChange:
|
|
112
|
-
disabled:
|
|
114
|
+
onChange: R,
|
|
115
|
+
disabled: u,
|
|
113
116
|
"aria-invalid": l || void 0,
|
|
114
117
|
className: o.fieldInput
|
|
115
118
|
}
|
|
116
119
|
),
|
|
117
|
-
|
|
120
|
+
I ? /* @__PURE__ */ s(re, { onClear: d }) : null
|
|
118
121
|
]
|
|
119
122
|
}
|
|
120
123
|
);
|
|
121
124
|
}
|
|
122
125
|
);
|
|
123
|
-
|
|
124
|
-
const
|
|
125
|
-
const { controlProps: t, size: r, invalid:
|
|
126
|
-
return /* @__PURE__ */
|
|
127
|
-
}),
|
|
126
|
+
P.displayName = "TextArea";
|
|
127
|
+
const oe = F((e) => {
|
|
128
|
+
const { controlProps: t, size: r, invalid: i, disabled: l } = z();
|
|
129
|
+
return /* @__PURE__ */ s(P, { ...e, ...t, size: r, invalid: i, disabled: l });
|
|
130
|
+
}), se = ({
|
|
128
131
|
name: e,
|
|
129
132
|
label: t,
|
|
130
133
|
hint: r,
|
|
131
|
-
size:
|
|
134
|
+
size: i = "md",
|
|
132
135
|
block: l = !0,
|
|
133
|
-
disabled:
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
136
|
+
disabled: u,
|
|
137
|
+
readOnly: n,
|
|
138
|
+
className: h,
|
|
139
|
+
dataTestId: v,
|
|
140
|
+
...A
|
|
137
141
|
}) => {
|
|
138
|
-
const { field:
|
|
139
|
-
return /* @__PURE__ */
|
|
140
|
-
|
|
142
|
+
const { field: c, fieldState: p, inputProps: f, onChangeHandler: C, onBlurHandler: y } = L({ name: e }), { disabled: m, readOnly: T, ...b } = f, _ = M(p.error)?.message, I = u ?? m, R = n !== void 0 ? n : T;
|
|
143
|
+
return /* @__PURE__ */ E(
|
|
144
|
+
g,
|
|
141
145
|
{
|
|
142
|
-
invalid: !!
|
|
143
|
-
disabled:
|
|
144
|
-
size:
|
|
146
|
+
invalid: !!_,
|
|
147
|
+
disabled: I,
|
|
148
|
+
size: i,
|
|
145
149
|
block: l,
|
|
146
|
-
className:
|
|
147
|
-
dataTestId:
|
|
150
|
+
className: h,
|
|
151
|
+
dataTestId: v,
|
|
148
152
|
children: [
|
|
149
|
-
t ? /* @__PURE__ */
|
|
150
|
-
/* @__PURE__ */
|
|
151
|
-
|
|
153
|
+
t ? /* @__PURE__ */ s(g.Label, { children: t }) : null,
|
|
154
|
+
/* @__PURE__ */ s(
|
|
155
|
+
oe,
|
|
152
156
|
{
|
|
153
|
-
...
|
|
154
|
-
...
|
|
157
|
+
...A,
|
|
158
|
+
...b,
|
|
159
|
+
readOnly: R || void 0,
|
|
155
160
|
block: l,
|
|
156
|
-
ref:
|
|
157
|
-
value:
|
|
158
|
-
onChange: (
|
|
159
|
-
onBlur: (
|
|
161
|
+
ref: c.ref,
|
|
162
|
+
value: c.value ?? "",
|
|
163
|
+
onChange: (d) => C(d),
|
|
164
|
+
onBlur: (d) => y(d)
|
|
160
165
|
}
|
|
161
166
|
),
|
|
162
|
-
r ? /* @__PURE__ */
|
|
163
|
-
/* @__PURE__ */
|
|
167
|
+
r ? /* @__PURE__ */ s(g.Hint, { children: r }) : null,
|
|
168
|
+
/* @__PURE__ */ s(g.Error, { children: _ })
|
|
164
169
|
]
|
|
165
170
|
}
|
|
166
171
|
);
|
|
167
172
|
};
|
|
168
|
-
|
|
173
|
+
se.displayName = "FormTextArea";
|
|
169
174
|
export {
|
|
170
|
-
|
|
171
|
-
|
|
175
|
+
se as FormTextArea,
|
|
176
|
+
P as TextArea
|
|
172
177
|
};
|
|
173
178
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/textarea/theme.ts","../../src/textarea/utils.ts","../../src/textarea/Component.tsx","../../src/textarea/FormTextArea.tsx"],"sourcesContent":["import { cva } from 'class-variance-authority';\nimport cn from 'classnames';\n\nimport { typographyStyles } from '@ds/typography';\n\nimport styles from './styles.module.css';\n\nexport const textAreaVariants = cva(styles.root, {\n variants: {\n size: {\n sm: cn(styles.sm, typographyStyles.bodyS),\n md: cn(styles.md, typographyStyles.bodyS),\n lg: cn(styles.lg, typographyStyles.bodyM),\n },\n variant: {\n primary: styles.primary,\n },\n block: {\n true: styles.block,\n false: null,\n },\n },\n defaultVariants: {\n size: 'md',\n variant: 'primary',\n block: true,\n },\n});\n","import { type ChangeEvent } from 'react';\n\n/** Synthetic change event used by clear control. */\nexport const toEmptyTextAreaChangeEvent = (el: HTMLTextAreaElement | null): ChangeEvent<HTMLTextAreaElement> =>\n ({\n target: el ?? { value: '' },\n currentTarget: el ?? { value: '' },\n }) as ChangeEvent<HTMLTextAreaElement>;\n\n/** Sets native textarea value via the prototype setter when the node exists. */\nexport const clearTextAreaElementValue = (el: HTMLTextAreaElement | null) => {\n if (!el) {\n return;\n }\n\n const setter = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, 'value')?.set;\n setter?.call(el, '');\n};\n","import { type ChangeEventHandler, useRef, useState } from 'react';\n\nimport cn from 'classnames';\nimport { Group, TextArea as RacTextArea } from 'react-aria-components';\n\nimport { supportRef } from '@ds/common/support-ref';\n\nimport { Clear } from '@/icons';\nimport { useAuiLabels } from '@/provider';\n\nimport { textAreaVariants } from './theme';\nimport { type ITextAreaProps } from './types';\nimport { clearTextAreaElementValue, toEmptyTextAreaChangeEvent } from './utils';\n\nimport styles from './styles.module.css';\n\nconst toStringValue = (value: unknown) => (value == null ? '' : String(value));\n\nconst assignRef = <T,>(ref: ITextAreaProps['ref'], node: T | null) => {\n if (typeof ref === 'function') {\n ref(node as never);\n return;\n }\n\n if (ref) {\n ref.current = node as never;\n }\n};\n\nconst TextAreaClearButton = ({ onClear }: { onClear: () => void }) => {\n const { clear } = useAuiLabels();\n\n return (\n <button\n type=\"button\"\n className={styles.clear}\n aria-label={clear}\n onPointerDown={event => {\n event.preventDefault();\n event.stopPropagation();\n }}\n onClick={event => {\n event.preventDefault();\n event.stopPropagation();\n onClear();\n }}\n >\n <Clear className={styles.clearIcon} />\n </button>\n );\n};\n\nexport const TextArea = supportRef(\n ({\n ref,\n size = 'md',\n variant = 'primary',\n block = true,\n invalid = false,\n disabled = false,\n clear = false,\n className,\n dataTestId,\n value,\n defaultValue,\n onChange,\n ...props\n }: ITextAreaProps) => {\n const textAreaRef = useRef<HTMLTextAreaElement | null>(null);\n const isControlled = value !== undefined;\n const [uncontrolledValue, setUncontrolledValue] = useState(() => toStringValue(defaultValue));\n const currentValue = isControlled ? toStringValue(value) : uncontrolledValue;\n const showClear = clear && !disabled && currentValue !== '';\n\n const handleChange: ChangeEventHandler<HTMLTextAreaElement> = event => {\n if (!isControlled) {\n setUncontrolledValue(event.target.value);\n }\n\n onChange?.(event);\n };\n\n const emitEmptyChange = () => {\n const el = textAreaRef.current;\n const event = toEmptyTextAreaChangeEvent(el);\n\n clearTextAreaElementValue(el);\n\n if (!isControlled) {\n setUncontrolledValue('');\n }\n\n onChange?.(event);\n };\n\n return (\n <Group\n className={cn(textAreaVariants({ size, variant, block }), className)}\n data-test-id={dataTestId}\n isInvalid={invalid}\n isDisabled={disabled}\n >\n <RacTextArea\n {...props}\n ref={node => {\n textAreaRef.current = node;\n assignRef(ref, node);\n }}\n value={value}\n defaultValue={defaultValue}\n onChange={handleChange}\n disabled={disabled}\n aria-invalid={invalid || undefined}\n className={styles.fieldInput}\n />\n {showClear ? <TextAreaClearButton onClear={emitEmptyChange} /> : null}\n </Group>\n );\n }\n);\n\nTextArea.displayName = 'TextArea';\n","import { type ComponentProps } from 'react';\n\nimport { supportRef } from '@ds/common/support-ref';\n\nimport { Field, useField } from '@/field';\nimport { useFieldHook } from '@/form/hooks/useFieldHook';\nimport { getError } from '@/form/utils';\n\nimport { TextArea } from './Component';\nimport { type IFormTextAreaProps } from './types';\n\ntype TFormTextAreaControlProps = Omit<ComponentProps<typeof TextArea>, 'size' | 'invalid' | 'disabled'>;\n\nconst FormTextAreaControl = supportRef((props: TFormTextAreaControlProps) => {\n const { controlProps, size, invalid, disabled } = useField();\n\n return <TextArea {...controlProps} size={size} invalid={invalid} disabled={disabled} {...props} />;\n});\n\nexport const FormTextArea = ({\n name,\n label,\n hint,\n size = 'md',\n block = true,\n disabled,\n className,\n dataTestId,\n ...textAreaProps\n}: IFormTextAreaProps) => {\n const { field, fieldState, inputProps: rhfInputProps, onChangeHandler, onBlurHandler } = useFieldHook({ name });\n const error = getError(fieldState.error)?.message;\n const isDisabled = disabled ?? rhfInputProps.disabled;\n\n return (\n <Field\n invalid={Boolean(error)}\n disabled={isDisabled}\n size={size}\n block={block}\n className={className}\n dataTestId={dataTestId}\n >\n {label ? <Field.Label>{label}</Field.Label> : null}\n <FormTextAreaControl\n {...textAreaProps}\n {...rhfInputProps}\n block={block}\n ref={field.ref}\n value={field.value ?? ''}\n onChange={e => onChangeHandler(e)}\n onBlur={e => onBlurHandler(e)}\n />\n {hint ? <Field.Hint>{hint}</Field.Hint> : null}\n <Field.Error>{error}</Field.Error>\n </Field>\n );\n};\n\nFormTextArea.displayName = 'FormTextArea';\n"],"names":["textAreaVariants","cva","styles","cn","typographyStyles","toEmptyTextAreaChangeEvent","el","clearTextAreaElementValue","toStringValue","value","assignRef","ref","node","TextAreaClearButton","onClear","clear","useAuiLabels","jsx","event","Clear","TextArea","supportRef","size","variant","block","invalid","disabled","className","dataTestId","defaultValue","onChange","props","textAreaRef","useRef","isControlled","uncontrolledValue","setUncontrolledValue","useState","currentValue","showClear","handleChange","emitEmptyChange","jsxs","Group","RacTextArea","FormTextAreaControl","controlProps","useField","FormTextArea","name","label","hint","textAreaProps","field","fieldState","rhfInputProps","onChangeHandler","onBlurHandler","useFieldHook","error","getError","isDisabled","Field","e"],"mappings":";;;;;;;;;;;;;;;;;;;;;GAOaA,IAAmBC,EAAIC,EAAO,MAAM;AAAA,EAC7C,UAAU;AAAA,IACN,MAAM;AAAA,MACF,IAAIC,EAAGD,EAAO,IAAIE,EAAiB,KAAK;AAAA,MACxC,IAAID,EAAGD,EAAO,IAAIE,EAAiB,KAAK;AAAA,MACxC,IAAID,EAAGD,EAAO,IAAIE,EAAiB,KAAK;AAAA,IAAA;AAAA,IAE5C,SAAS;AAAA,MACL,SAASF,EAAO;AAAA,IAAA;AAAA,IAEpB,OAAO;AAAA,MACH,MAAM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BO,CAAC;AAAA,YAChC,QAAQ,CAAAA,MAAKN,EAAcM,CAAC;AAAA,UAAA;AAAA,QAAA;AAAA,QAE/BZ,IAAO,gBAAAlC,EAAC6C,EAAM,MAAN,EAAY,aAAK,IAAgB;AAAA,QAC1C,gBAAA7C,EAAC6C,EAAM,OAAN,EAAa,UAAAH,EAAA,CAAM;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGhC;AAEAX,GAAa,cAAc;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/textarea/theme.ts","../../src/textarea/utils.ts","../../src/textarea/Component.tsx","../../src/textarea/FormTextArea.tsx"],"sourcesContent":["import { cva } from 'class-variance-authority';\nimport cn from 'classnames';\n\nimport { typographyStyles } from '@ds/typography';\n\nimport styles from './styles.module.css';\n\nexport const textAreaVariants = cva(styles.root, {\n variants: {\n size: {\n sm: cn(styles.sm, typographyStyles.bodyS),\n md: cn(styles.md, typographyStyles.bodyS),\n lg: cn(styles.lg, typographyStyles.bodyM),\n },\n variant: {\n primary: styles.primary,\n },\n block: {\n true: styles.block,\n false: null,\n },\n },\n defaultVariants: {\n size: 'md',\n variant: 'primary',\n block: true,\n },\n});\n","import { type ChangeEvent } from 'react';\n\n/** Synthetic change event used by clear control. */\nexport const toEmptyTextAreaChangeEvent = (el: HTMLTextAreaElement | null): ChangeEvent<HTMLTextAreaElement> =>\n ({\n target: el ?? { value: '' },\n currentTarget: el ?? { value: '' },\n }) as ChangeEvent<HTMLTextAreaElement>;\n\n/** Sets native textarea value via the prototype setter when the node exists. */\nexport const clearTextAreaElementValue = (el: HTMLTextAreaElement | null) => {\n if (!el) {\n return;\n }\n\n const setter = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, 'value')?.set;\n setter?.call(el, '');\n};\n","import { type ChangeEventHandler, useRef, useState } from 'react';\n\nimport cn from 'classnames';\nimport { Group, TextArea as RacTextArea } from 'react-aria-components';\n\nimport { supportRef } from '@ds/common/support-ref';\n\nimport { Clear } from '@/icons';\nimport { useAuiLabels } from '@/provider';\n\nimport { textAreaVariants } from './theme';\nimport { type ITextAreaProps } from './types';\nimport { clearTextAreaElementValue, toEmptyTextAreaChangeEvent } from './utils';\n\nimport styles from './styles.module.css';\n\nconst toStringValue = (value: unknown) => (value == null ? '' : String(value));\n\nconst assignRef = <T,>(ref: ITextAreaProps['ref'], node: T | null) => {\n if (typeof ref === 'function') {\n ref(node as never);\n return;\n }\n\n if (ref) {\n ref.current = node as never;\n }\n};\n\nconst TextAreaClearButton = ({ onClear }: { onClear: () => void }) => {\n const { clear } = useAuiLabels();\n\n return (\n <button\n type=\"button\"\n className={styles.clear}\n aria-label={clear}\n onPointerDown={event => {\n event.preventDefault();\n event.stopPropagation();\n }}\n onClick={event => {\n event.preventDefault();\n event.stopPropagation();\n onClear();\n }}\n >\n <Clear className={styles.clearIcon} />\n </button>\n );\n};\n\nexport const TextArea = supportRef(\n ({\n ref,\n size = 'md',\n variant = 'primary',\n block = true,\n invalid = false,\n disabled = false,\n readOnly = false,\n clear = false,\n className,\n dataTestId,\n value,\n defaultValue,\n onChange,\n ...props\n }: ITextAreaProps) => {\n const textAreaRef = useRef<HTMLTextAreaElement | null>(null);\n const isControlled = value !== undefined;\n const [uncontrolledValue, setUncontrolledValue] = useState(() => toStringValue(defaultValue));\n const currentValue = isControlled ? toStringValue(value) : uncontrolledValue;\n const showClear = clear && !disabled && !readOnly && currentValue !== '';\n\n const handleChange: ChangeEventHandler<HTMLTextAreaElement> = event => {\n if (!isControlled) {\n setUncontrolledValue(event.target.value);\n }\n\n onChange?.(event);\n };\n\n const emitEmptyChange = () => {\n const el = textAreaRef.current;\n const event = toEmptyTextAreaChangeEvent(el);\n\n clearTextAreaElementValue(el);\n\n if (!isControlled) {\n setUncontrolledValue('');\n }\n\n onChange?.(event);\n };\n\n return (\n <Group\n className={cn(textAreaVariants({ size, variant, block }), className)}\n data-test-id={dataTestId}\n isInvalid={invalid}\n isDisabled={disabled}\n isReadOnly={readOnly}\n >\n <RacTextArea\n {...props}\n readOnly={readOnly}\n ref={node => {\n textAreaRef.current = node;\n assignRef(ref, node);\n }}\n value={value}\n defaultValue={defaultValue}\n onChange={handleChange}\n disabled={disabled}\n aria-invalid={invalid || undefined}\n className={styles.fieldInput}\n />\n {showClear ? <TextAreaClearButton onClear={emitEmptyChange} /> : null}\n </Group>\n );\n }\n);\n\nTextArea.displayName = 'TextArea';\n","import { type ComponentProps } from 'react';\n\nimport { supportRef } from '@ds/common/support-ref';\n\nimport { Field, useField } from '@/field';\nimport { useFieldHook } from '@/form/hooks/useFieldHook';\nimport { getError } from '@/form/utils';\n\nimport { TextArea } from './Component';\nimport { type IFormTextAreaProps } from './types';\n\ntype TFormTextAreaControlProps = Omit<ComponentProps<typeof TextArea>, 'size' | 'invalid' | 'disabled'>;\n\nconst FormTextAreaControl = supportRef((props: TFormTextAreaControlProps) => {\n const { controlProps, size, invalid, disabled } = useField();\n\n return <TextArea {...props} {...controlProps} size={size} invalid={invalid} disabled={disabled} />;\n});\n\nexport const FormTextArea = ({\n name,\n label,\n hint,\n size = 'md',\n block = true,\n disabled,\n readOnly,\n className,\n dataTestId,\n ...textAreaProps\n}: IFormTextAreaProps) => {\n const { field, fieldState, inputProps: rhfInputProps, onChangeHandler, onBlurHandler } = useFieldHook({ name });\n const { disabled: formDisabled, readOnly: formReadOnly, ...restRhf } = rhfInputProps;\n const error = getError(fieldState.error)?.message;\n const isDisabled = disabled ?? formDisabled;\n const isReadOnly = readOnly !== undefined ? readOnly : formReadOnly;\n\n return (\n <Field\n invalid={Boolean(error)}\n disabled={isDisabled}\n size={size}\n block={block}\n className={className}\n dataTestId={dataTestId}\n >\n {label ? <Field.Label>{label}</Field.Label> : null}\n <FormTextAreaControl\n {...textAreaProps}\n {...restRhf}\n readOnly={isReadOnly || undefined}\n block={block}\n ref={field.ref}\n value={field.value ?? ''}\n onChange={e => onChangeHandler(e)}\n onBlur={e => onBlurHandler(e)}\n />\n {hint ? <Field.Hint>{hint}</Field.Hint> : null}\n <Field.Error>{error}</Field.Error>\n </Field>\n );\n};\n\nFormTextArea.displayName = 'FormTextArea';\n"],"names":["textAreaVariants","cva","styles","cn","typographyStyles","toEmptyTextAreaChangeEvent","el","clearTextAreaElementValue","toStringValue","value","assignRef","ref","node","TextAreaClearButton","onClear","clear","useAuiLabels","jsx","event","Clear","TextArea","supportRef","size","variant","block","invalid","disabled","readOnly","className","dataTestId","defaultValue","onChange","props","textAreaRef","useRef","isControlled","uncontrolledValue","setUncontrolledValue","useState","currentValue","showClear","handleChange","emitEmptyChange","jsxs","Group","RacTextArea","FormTextAreaControl","controlProps","useField","FormTextArea","name","label","hint","textAreaProps","field","fieldState","rhfInputProps","onChangeHandler","onBlurHandler","useFieldHook","formDisabled","formReadOnly","restRhf","error","getError","isDisabled","isReadOnly","Field","e"],"mappings":";;;;;;;;;;;;;;;;;;;;;GAOaA,IAAmBC,EAAIC,EAAO,MAAM;AAAA,EAC7C,UAAU;AAAA,IACN,MAAM;AAAA,MACF,IAAIC,EAAGD,EAAO,IAAIE,EAAiB,KAAK;AAAA,MACxC,IAAID,EAAGD,EAAO,IAAIE,EAAiB,KAAK;AAAA,MACxC,IAAID,EAAGD,EAAO,IAAIE,EAAiB,KAAK;AAAA,IAAA;AAAA,IAE5C,SAAS;AAAA,MACL,SAASF,EAAO;AAAA,IAAA;AAAA,IAEpB,OAAO;AAAA,MACH,MAAMA,EAAO;AAAA,MACb,OAAO;AAAA,IAAA;AAAA,EACX;AAAA,EAEJ,iBAAiB;AAAA,IACb,MAAM;AAAA,IACN,SAAS;AAAA,IACT,OAAO;AAAA,EAAA;AAEf,CAAC,GCxBYG,IAA6B,CAACC,OACtC;AAAA,EACG,QAAQA,KAAM,EAAE,OAAO,GAAA;AAAA,EACvB,eAAeA,KAAM,EAAE,OAAO,GAAA;AAClC,IAGSC,KAA4B,CAACD,MAAmC;AACzE,MAAI,CAACA;AACD;AAIJ,EADe,OAAO,yBAAyB,OAAO,oBAAoB,WAAW,OA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,gBAAAlD,EAACkD,EAAM,OAAN,EAAa,UAAAJ,EAAA,CAAM;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGhC;AAEAd,GAAa,cAAc;"}
|
package/dist/textarea/types.d.ts
CHANGED
|
@@ -16,18 +16,22 @@ export interface ITextAreaThemeProps {
|
|
|
16
16
|
export interface ITextAreaOwnProps extends IDataTestIdProps {
|
|
17
17
|
/** Clear button for the current value. */
|
|
18
18
|
clear?: boolean;
|
|
19
|
+
/** Visible and copyable, but not editable. Not `disabled`. */
|
|
20
|
+
readOnly?: boolean;
|
|
19
21
|
/** Ref to the native textarea (React 19 prop). */
|
|
20
22
|
ref?: Ref<HTMLTextAreaElement>;
|
|
21
23
|
}
|
|
22
24
|
export interface ITextAreaBaseProps extends ITextAreaThemeProps, IFieldStateProps, ITextAreaOwnProps {
|
|
23
25
|
}
|
|
24
|
-
export type TTextAreaRacOmit = 'disabled' | 'isDisabled' | 'isInvalid';
|
|
26
|
+
export type TTextAreaRacOmit = 'disabled' | 'readOnly' | 'isDisabled' | 'isInvalid' | 'isReadOnly';
|
|
25
27
|
export interface ITextAreaProps extends ITextAreaBaseProps, Omit<RacTextAreaProps, keyof ITextAreaBaseProps | TTextAreaRacOmit> {
|
|
26
28
|
}
|
|
27
29
|
/** className belongs on the Field shell. */
|
|
28
30
|
export type TTextAreaFormRacOmit = TTextAreaRacOmit | keyof ITextAreaBaseProps | 'value' | 'defaultValue' | 'onChange' | 'onBlur' | 'name' | 'className';
|
|
29
31
|
export interface ITextAreaContentProps extends Omit<RacTextAreaProps, TTextAreaFormRacOmit> {
|
|
30
32
|
clear?: boolean;
|
|
33
|
+
/** Visible and copyable, but not editable. Not `disabled`. */
|
|
34
|
+
readOnly?: boolean;
|
|
31
35
|
}
|
|
32
36
|
export interface IFormTextAreaProps extends IFormFieldLayoutProps, Pick<ITextAreaThemeProps, 'variant'>, ITextAreaContentProps {
|
|
33
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/textarea/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,EAAE,KAAK,aAAa,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE/E,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAE1D,MAAM,MAAM,aAAa,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE/C,MAAM,MAAM,gBAAgB,GAAG,SAAS,CAAC;AAEzC,oBAAoB;AACpB,MAAM,WAAW,mBAAmB;IAChC,sEAAsE;IACtE,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,sBAAsB;IACtB,OAAO,CAAC,EAAE,gBAAgB,CAAC;CAC9B;AAED,yCAAyC;AACzC,MAAM,WAAW,iBAAkB,SAAQ,gBAAgB;IACvD,0CAA0C;IAC1C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kDAAkD;IAClD,GAAG,CAAC,EAAE,GAAG,CAAC,mBAAmB,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,kBAAmB,SAAQ,mBAAmB,EAAE,gBAAgB,EAAE,iBAAiB;CAAG;AAEvG,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,YAAY,GAAG,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/textarea/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,EAAE,KAAK,aAAa,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE/E,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,O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BACb,SAAQ,qBAAqB,EAAE,IAAI,CAAC,mBAAmB,EAAE,SAAS,CAAC,EAAE,qBAAqB;CAAG"}
|
package/dist/time-field/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import { u as M } from "../hooks-BAkrGC45.js";
|
|
|
8
8
|
import { cva as O } from "class-variance-authority";
|
|
9
9
|
import { typographyStyles as C } from "../typography/index.js";
|
|
10
10
|
import { F as _, u as R } from "../Component-BPN5FgKq.js";
|
|
11
|
-
import { u as U, g as $ } from "../
|
|
11
|
+
import { u as U, g as $ } from "../useFieldHook-Bt9nST7g.js";
|
|
12
12
|
import '../assets/index12.css';const q = "aub_styles-module_root_184e6", J = "aub_styles-module_block_45f0f", K = "aub_styles-module_group_9f460", Q = "aub_styles-module_sm_f51c2", W = "aub_styles-module_md_be9a9", X = "aub_styles-module_lg_8553c", Y = "aub_styles-module_primary_43afd", Z = "aub_styles-module_input_f5120", ee = "aub_styles-module_segment_b8349", le = "aub_styles-module_clear_04e5c", oe = "aub_styles-module_icon_2d638", e = {
|
|
13
13
|
root: q,
|
|
14
14
|
block: J,
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { createContext as x, useContext as y, useCallback as l } from "react";
|
|
2
|
+
import { useFormContext as b, useController as B } from "react-hook-form";
|
|
3
|
+
const m = x(void 0), w = () => {
|
|
4
|
+
const o = y(m);
|
|
5
|
+
if (!o)
|
|
6
|
+
throw new Error("This component must be used within a <Form> component");
|
|
7
|
+
return o;
|
|
8
|
+
}, T = (o) => Array.isArray(o) ? o[0] : o, a = (o, e) => typeof o == "boolean" ? o : o == null ? !1 : o[e] ?? !1, k = ({ name: o }) => {
|
|
9
|
+
const { onChange: e, onBlur: c, disabled: d, readOnly: f } = w(), { control: C, setValue: F } = b(), { field: t, fieldState: g } = B({
|
|
10
|
+
name: o,
|
|
11
|
+
control: C
|
|
12
|
+
}), i = l(
|
|
13
|
+
(r) => {
|
|
14
|
+
t.onBlur();
|
|
15
|
+
const n = r?.currentTarget, u = n && "value" in n && typeof n.value == "string" ? n.value : t.value;
|
|
16
|
+
c(o, u);
|
|
17
|
+
},
|
|
18
|
+
[t, o, c]
|
|
19
|
+
), p = {
|
|
20
|
+
name: o,
|
|
21
|
+
onBlur: i,
|
|
22
|
+
disabled: a(d, o),
|
|
23
|
+
readOnly: a(f, o) || void 0
|
|
24
|
+
}, s = l(
|
|
25
|
+
(r) => {
|
|
26
|
+
t.onChange(r), e(o, r);
|
|
27
|
+
},
|
|
28
|
+
[t, o, e]
|
|
29
|
+
), h = l(
|
|
30
|
+
(r, n) => {
|
|
31
|
+
if (n !== void 0) {
|
|
32
|
+
s(n);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (!r)
|
|
36
|
+
return;
|
|
37
|
+
t.onChange(r);
|
|
38
|
+
const u = r.currentTarget, { value: v } = u;
|
|
39
|
+
e(o, v);
|
|
40
|
+
},
|
|
41
|
+
[t, o, e, s]
|
|
42
|
+
);
|
|
43
|
+
return { field: t, onChange: e, setValue: F, fieldState: g, inputProps: p, setFieldValue: s, onChangeHandler: h, onBlurHandler: i };
|
|
44
|
+
};
|
|
45
|
+
export {
|
|
46
|
+
m as F,
|
|
47
|
+
w as a,
|
|
48
|
+
T as g,
|
|
49
|
+
a as r,
|
|
50
|
+
k as u
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=useFieldHook-Bt9nST7g.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFieldHook-Bt9nST7g.js","sources":["../src/form/context.ts","../src/form/utils.ts","../src/form/hooks/useFieldHook.ts"],"sourcesContent":["import { type BaseSyntheticEvent, createContext, useContext } from 'react';\n\nimport { type NativeFieldValue } from 'react-hook-form';\n\nimport { type TFormFieldFlag } from './types';\n\nexport interface IFormContextValue {\n onChange: (key: string, value: NativeFieldValue) => void;\n onBlur: (key: string, value: NativeFieldValue) => void;\n onSubmitHandler: (event?: BaseSyntheticEvent) => void;\n disabled?: TFormFieldFlag;\n readOnly?: TFormFieldFlag;\n}\n\nexport const FormContext = createContext<IFormContextValue | undefined>(undefined);\n\nexport const useAuiForm = (): IFormContextValue => {\n const context = useContext(FormContext);\n\n if (!context) {\n throw new Error('This component must be used within a <Form> component');\n }\n\n return context;\n};\n","import { type FieldError } from 'react-hook-form';\n\nimport { type TFormFieldFlag } from './types';\n\nexport const getError = (value?: FieldError) => (Array.isArray(value) ? value[0] : value);\n\n/** Resolves a form-level boolean or a per-field map. Keys are exact RHF names. */\nexport const resolveFieldFlag = (flag: TFormFieldFlag | undefined, name: string): boolean => {\n if (typeof flag === 'boolean') {\n return flag;\n }\n\n if (flag == null) {\n return false;\n }\n\n return flag[name] ?? false;\n};\n","import { type FocusEvent, type SyntheticEvent, useCallback } from 'react';\n\nimport { type NativeFieldValue, useController, useFormContext } from 'react-hook-form';\n\nimport { useAuiForm } from '../context';\nimport { type IFormFieldComponent } from '../types';\nimport { resolveFieldFlag } from '../utils';\n\n/** Builds controlled field wiring by `name` for FormInput / FormSelect / …. */\nexport const useFieldHook = <TElement extends HTMLElement = HTMLElement>({ name }: IFormFieldComponent) => {\n const { onChange, onBlur: onFormBlur, disabled, readOnly } = useAuiForm();\n const { control, setValue } = useFormContext();\n\n const { field, fieldState } = useController({\n name,\n control,\n });\n\n const onBlurHandler = useCallback(\n (e?: FocusEvent<TElement>) => {\n field.onBlur();\n const target = e?.currentTarget;\n const value = target && 'value' in target && typeof target.value === 'string' ? target.value : field.value;\n onFormBlur(name, value);\n },\n [field, name, onFormBlur]\n );\n\n const inputProps = {\n name,\n onBlur: onBlurHandler,\n disabled: resolveFieldFlag(disabled, name),\n readOnly: resolveFieldFlag(readOnly, name) || undefined,\n };\n\n const setFieldValue = useCallback(\n (value: NativeFieldValue) => {\n field.onChange(value);\n onChange(name, value);\n },\n [field, name, onChange]\n );\n\n const onChangeHandler = useCallback(\n <T extends HTMLInputElement | HTMLTextAreaElement, E extends Event>(\n e?: SyntheticEvent<T, E>,\n val?: NativeFieldValue\n ) => {\n if (val !== undefined) {\n setFieldValue(val);\n return;\n }\n\n if (!e) {\n return;\n }\n\n field.onChange(e);\n const target = e.currentTarget;\n const { value } = target as HTMLInputElement | HTMLTextAreaElement;\n onChange(name, value);\n },\n [field, name, onChange, setFieldValue]\n );\n\n return { field, onChange, setValue, fieldState, inputProps, setFieldValue, onChangeHandler, onBlurHandler };\n};\n"],"names":["FormContext","createContext","useAuiForm","context","useContext","getError","value","resolveFieldFlag","flag","name","useFieldHook","onChange","onFormBlur","disabled","readOnly","control","setValue","useFormContext","field","fieldState","useController","onBlurHandler","useCallback","e","target","inputProps","setFieldValue","onChangeHandler","val"],"mappings":";;AAcO,MAAMA,IAAcC,EAA6C,MAAS,GAEpEC,IAAa,MAAyB;AAC/C,QAAMC,IAAUC,EAAWJ,CAAW;AAEtC,MAAI,CAACG;AACD,UAAM,IAAI,MAAM,uDAAuD;AAG3E,SAAOA;AACX,GCpBaE,IAAW,CAACC,MAAwB,MAAM,QAAQA,CAAK,IAAIA,EAAM,CAAC,IAAIA,GAGtEC,IAAmB,CAACC,GAAkCC,MAC3D,OAAOD,KAAS,YACTA,IAGPA,KAAQ,OACD,KAGJA,EAAKC,CAAI,KAAK,ICPZC,IAAe,CAA6C,EAAE,MAAAD,QAAgC;AACvG,QAAM,EAAE,UAAAE,GAAU,QAAQC,GAAY,UAAAC,GAAU,UAAAC,EAAA,IAAaZ,EAAA,GACvD,EAAE,SAAAa,GAAS,UAAAC,EAAA,IAAaC,EAAA,GAExB,EAAE,OAAAC,GAAO,YAAAC,EAAA,IAAeC,EAAc;AAAA,IACxC,MAAAX;AAAA,IACA,SAAAM;AAAA,EAAA,CACH,GAEKM,IAAgBC;AAAA,IAClB,CAACC,MAA6B;AAC1B,MAAAL,EAAM,OAAA;AACN,YAAMM,IAASD,GAAG,eACZjB,IAAQkB,KAAU,WAAWA,KAAU,OAAOA,EAAO,SAAU,WAAWA,EAAO,QAAQN,EAAM;AACrG,MAAAN,EAAWH,GAAMH,CAAK;AAAA,IAC1B;AAAA,IACA,CAACY,GAAOT,GAAMG,CAAU;AAAA,EAAA,GAGtBa,IAAa;AAAA,IACf,MAAAhB;AAAA,IACA,QAAQY;AAAA,IACR,UAAUd,EAAiBM,GAAUJ,CAAI;AAAA,IACzC,UAAUF,EAAiBO,GAAUL,CAAI,KAAK;AAAA,EAAA,GAG5CiB,IAAgBJ;AAAA,IAClB,CAAChB,MAA4B;AACzB,MAAAY,EAAM,SAASZ,CAAK,GACpBK,EAASF,GAAMH,CAAK;AAAA,IACxB;AAAA,IACA,CAACY,GAAOT,GAAME,CAAQ;AAAA,EAAA,GAGpBgB,IAAkBL;AAAA,IACpB,CACIC,GACAK,MACC;AACD,UAAIA,MAAQ,QAAW;AACnB,QAAAF,EAAcE,CAAG;AACjB;AAAA,MACJ;AAEA,UAAI,CAACL;AACD;AAGJ,MAAAL,EAAM,SAASK,CAAC;AAChB,YAAMC,IAASD,EAAE,eACX,EAAE,OAAAjB,MAAUkB;AAClB,MAAAb,EAASF,GAAMH,CAAK;AAAA,IACxB;AAAA,IACA,CAACY,GAAOT,GAAME,GAAUe,CAAa;AAAA,EAAA;AAGzC,SAAO,EAAE,OAAAR,GAAO,UAAAP,GAAU,UAAAK,GAAU,YAAAG,GAAY,YAAAM,GAAY,eAAAC,GAAe,iBAAAC,GAAiB,eAAAN,EAAA;AAChG;"}
|
package/docs/README.md
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
# Документация пакета
|
|
2
2
|
|
|
3
|
-
Карта каналов. API примитивов сюда **не** пишем — source of truth
|
|
3
|
+
Карта каналов. API примитивов сюда **не** пишем — source of truth в репо: `src/<name>/docs/Description.ru.md` / `Description.en.md` и `types.ts`. В npm для агента английский файл называется `Description.md`.
|
|
4
4
|
|
|
5
5
|
| Канал | Где | Для кого |
|
|
6
6
|
| --- | --- | --- |
|
|
7
7
|
| Онбординг / API примитивов | Storybook + `src/<name>/docs/` | люди + агенты |
|
|
8
8
|
| Пакет (этот каталог) | `docs/*.md`, `docs/skills/` | контрибьюторы, АП |
|
|
9
|
-
| Визуал АП | [`design-language.md`](./design-language.md)
|
|
9
|
+
| Визуал АП (текст) | [`design-language.md`](./design-language.md) | продукт / дизайн (в npm публикуется) |
|
|
10
10
|
|
|
11
11
|
## В этом каталоге
|
|
12
12
|
|
|
13
13
|
- [architecture.md](./architecture.md) — стек, токены, Form, exports
|
|
14
14
|
- [ai.md](./ai.md) — канал для АП / skills
|
|
15
|
-
- [design-language.md](./design-language.md) — визуальный канон (слои, CascadeMenu WIP, list/detail);
|
|
15
|
+
- [design-language.md](./design-language.md) — визуальный канон (слои, CascadeMenu WIP, list/detail); в npm уходит [design-language.en.md](./design-language.en.md)
|
|
16
16
|
- [skills/](./skills/) — skill `admin-ui` (публикуется с пакетом; автосинк в `.cursor/skills`, `.claude/skills` и маркер-блок в `AGENTS.md` через postinstall, см. [ai.md](./ai.md))
|
|
17
|
-
- [concepts/](./concepts/) — скриншоты-референсы интерфейса АП (индекс: [concepts/README.md](./concepts/README.md))
|
|
18
17
|
|
|
19
18
|
## Storybook
|
|
20
19
|
|
package/docs/ai.md
CHANGED
|
@@ -1,46 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Как агенты (Cursor и др.) опираются на `@ensi-platform/admin-ui`.
|
|
1
|
+
How agents (Cursor and others) use `@ensi-platform/admin-ui`.
|
|
4
2
|
|
|
5
3
|
## Source of truth
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
Per primitive, the contract in this repo (Storybook) is:
|
|
8
6
|
|
|
9
7
|
- `src/<name>/docs/Description.ru.md` / `Description.en.md`
|
|
10
|
-
- `Example
|
|
11
|
-
- `types.ts`
|
|
8
|
+
- `Example.ru.md` / `Example.en.md`, and `cssVariables.ts` when needed
|
|
9
|
+
- `types.ts` when present
|
|
10
|
+
- screen visual canon — `docs/design-language.md`
|
|
11
|
+
|
|
12
|
+
Storybook Docs reads both languages. Do not duplicate component API under package `docs/`.
|
|
13
|
+
|
|
14
|
+
The npm package ships English only, renamed for agents:
|
|
15
|
+
|
|
16
|
+
- `Description.en.md` → `src/<name>/docs/Description.md`
|
|
17
|
+
- `Example.en.md` → `Example.md`
|
|
18
|
+
- getting started → `src/docs/getting-started/Description.md`
|
|
19
|
+
|
|
20
|
+
`*.ru.md` and stories stay in the repo. Read the published files from `node_modules/@ensi-platform/admin-ui/...`.
|
|
21
|
+
|
|
22
|
+
## Skill
|
|
12
23
|
|
|
13
|
-
|
|
24
|
+
Thin router for **consuming** the UI kit (pick a primitive, then read its Description). Authoring Description / stories — separate skill `write-component-docs`.
|
|
14
25
|
|
|
15
|
-
|
|
26
|
+
Location in the package: `docs/skills/` (`SKILL.md`).
|
|
16
27
|
|
|
17
|
-
|
|
28
|
+
In a consumer app:
|
|
18
29
|
|
|
19
|
-
|
|
30
|
+
- skill — `node_modules/@ensi-platform/admin-ui/docs/skills/`
|
|
31
|
+
- contract — `node_modules/@ensi-platform/admin-ui/src/<name>/docs/`, `…/types.ts` (`icons`, `hooks`, `combobox` included)
|
|
20
32
|
|
|
21
|
-
- skill:
|
|
22
|
-
- контракт: `node_modules/@ensi-platform/admin-ui/src/<name>/docs/`, `…/types.ts`
|
|
33
|
+
`postinstall` (`scripts/sync-consumer.ts`) copies the skill and writes a pointer. No manual path setup:
|
|
23
34
|
|
|
24
|
-
|
|
35
|
+
- `.cursor/skills/admin-ui/SKILL.md`
|
|
36
|
+
- `.claude/skills/admin-ui/SKILL.md` — same file
|
|
37
|
+
- marker `<!-- @ensi-platform/admin-ui:start -->` … `:end` in the consumer repo `AGENTS.md` (rest of the file stays)
|
|
25
38
|
|
|
26
|
-
|
|
27
|
-
- короткая таблица выбора примитива (Button vs Badge vs Tag, …)
|
|
28
|
-
- указание: читай Description / types / Example — без копипасты длинных текстов
|
|
39
|
+
Limits:
|
|
29
40
|
|
|
30
|
-
|
|
41
|
+
- consumer root is the nearest `.git` from `INIT_CWD`; if none, the script does nothing
|
|
42
|
+
- **pnpm ≥ 9** ignores dependency lifecycle scripts until `pnpm approve-builds @ensi-platform/admin-ui` (or `pnpm.onlyBuiltDependencies`), then `pnpm install` again
|
|
43
|
+
- manual run: `node node_modules/@ensi-platform/admin-ui/scripts/sync-consumer.ts`
|
|
44
|
+
- opt out of all three: `ADMIN_UI_SKIP_CONSUMER_SYNC=1`
|
|
31
45
|
|
|
32
|
-
|
|
46
|
+
Updating a Description does not require editing the skill.
|
|
33
47
|
|
|
34
|
-
|
|
35
|
-
- `.claude/skills/admin-ui/SKILL.md` — Claude Code (тот же контент, тот же frontmatter-формат Agent Skills);
|
|
36
|
-
- маркер-блок `<!-- @ensi-platform/admin-ui:start -->…:end` в `AGENTS.md` в корне consumer-репо — для агентов без концепции skills (Codex CLI, Copilot coding agent и др.), которые читают только `AGENTS.md` целиком. Блок создаётся/обновляется идемпотентно; остальной `AGENTS.md` не трогается.
|
|
48
|
+
## Rules for agents
|
|
37
49
|
|
|
38
|
-
|
|
50
|
+
- do not invent API — read Description / types first;
|
|
51
|
+
- assemble screens (lists, filters, detail pages) from `docs/design-language.md`;
|
|
52
|
+
- app layout colours — `src/ds/tokens/docs/Description.md` (control chrome stays on the primitive);
|
|
53
|
+
- imports only via subpaths (`@ensi-platform/admin-ui/button`, …) — no package root barrel;
|
|
54
|
+
- setup (tokens, Provider, theme) — see **Getting started**.
|
|
39
55
|
|
|
40
|
-
|
|
41
|
-
- **pnpm ≥ 9** по умолчанию блокирует lifecycle-скрипты зависимостей («ignored build scripts»). Если синк не сработал сам — один раз выполнить `pnpm approve-builds @ensi-platform/admin-ui` (или добавить пакет в `pnpm.onlyBuiltDependencies` в корневом `package.json` consumer-репо), затем `pnpm install` ещё раз;
|
|
42
|
-
- ручной запуск без переустановки: `node node_modules/@ensi-platform/admin-ui/scripts/sync-consumer.ts`;
|
|
43
|
-
- опт-аут (отключает все три канала сразу): `ADMIN_UI_SKIP_CONSUMER_SYNC=1`;
|
|
44
|
-
- в самом репозитории admin-ui `.cursor/skills/admin-ui`, `.claude/skills/admin-ui` и корневой `AGENTS.md` не трогаем — скрипт детектит dev-режим и ничего не пишет.
|
|
56
|
+
## Next
|
|
45
57
|
|
|
46
|
-
|
|
58
|
+
- **Getting started** — install and first screen
|
|
59
|
+
- `Base/Button`, `Form/Input`, `Overlays/Modal` — primitives
|
|
60
|
+
- Package docs: `docs/ai.md`, `docs/architecture.md`
|
package/docs/architecture.md
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Architecture
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@ensi-platform/admin-ui` is the UI for the Ensi admin panel: controls, forms, overlays, table, tokens, typography.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Component layers
|
|
6
6
|
|
|
7
|
-
|
|
|
7
|
+
| Layer | Storybook | Examples | Role |
|
|
8
8
|
| --- | --- | --- | --- |
|
|
9
|
-
| Base | `Base/*` | `Button`, `MenuList`, `Avatar`, `Table`, … |
|
|
10
|
-
| App | `App/*` | `CascadeMenu` |
|
|
9
|
+
| Base | `Base/*` | `Button`, `MenuList`, `Avatar`, `Table`, … | primitives and their parts |
|
|
10
|
+
| App | `App/*` | `CascadeMenu` | ready-made admin chrome |
|
|
11
11
|
|
|
12
|
-
App
|
|
12
|
+
App is built from Base. The `sidebar | page` layout stays in the consumer app (there is no `AppShell`). List and detail page frames are application code; the package does not ship them. Screen visuals — `docs/design-language.md`.
|
|
13
13
|
|
|
14
|
-
##
|
|
14
|
+
## Stack
|
|
15
15
|
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
16
|
+
- styles — `--aui-*` CSS variables (CSS Modules on primitives)
|
|
17
|
+
- behavior — [React Aria Components](https://react-aria.adobe.com) inside; the public API is ours (`size` / `variant` / `dataTestId`, …)
|
|
18
|
+
- not shadcn and not Tailwind recipes
|
|
19
19
|
|
|
20
|
-
##
|
|
20
|
+
## Setup
|
|
21
21
|
|
|
22
|
-
1.
|
|
23
|
-
2. `AdminUiProvider`
|
|
24
|
-
3.
|
|
22
|
+
1. Tokens **once** in the app entry: `import '@ensi-platform/admin-ui/tokens'`
|
|
23
|
+
2. `AdminUiProvider` at the UI root — locale, portals, built-in a11y strings, page substrate (`--aui-page-bg-primary` / `--aui-page-fg-primary`; content inset stays on the host)
|
|
24
|
+
3. Theme on `document.documentElement`: `data-theme="light"` | `"dark"`
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
Components do not know the theme — they only read `--aui-*`. Light is `semantic.css`, dark is a remap in `semantic.dark.css`.
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
Import only via subpath: `@ensi-platform/admin-ui/button`, `@ensi-platform/admin-ui/provider`, … There is no package root barrel.
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
Onboarding with examples — Storybook **Getting started** and the root [README](../README.md).
|
|
31
31
|
|
|
32
32
|
## Form
|
|
33
33
|
|
|
34
|
-
- `Form` (RHF + zod) — state / submit / validation
|
|
35
|
-
- FormX (`FormInput`, `FormSelect`, …) —
|
|
36
|
-
- `FormControl
|
|
34
|
+
- `Form` (RHF + zod) — state / submit / validation live in the package
|
|
35
|
+
- FormX (`FormInput`, `FormSelect`, …) — next to the control, not a separate `FormFieldWrapper`
|
|
36
|
+
- no `FormControl`: label / hint / error belong to `Field` (+ RAC `Label` / `Text`)
|
|
37
37
|
|
|
38
|
-
Peers
|
|
38
|
+
Peers for Form*: `react-hook-form`, `@hookform/resolvers`, `zod`.
|
|
39
39
|
|
|
40
40
|
## Exports
|
|
41
41
|
|
|
42
|
-
`exports`
|
|
42
|
+
`exports` in the root `package.json` are **not** the source of truth: `pnpm build` / `prepublishOnly` runs `sync-package` and writes only subpath `exports` (`./button`, `./tokens`, …) from `src/*/index.ts` (plus nested `tokens` / `typography`). There is no `"."` key. Without a build, workspace subpath imports do not resolve.
|