@okam/stack-ui 2.0.0 → 2.0.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/CHANGELOG.md +35 -0
- package/components/fields/ComboBox/interface.d.ts +6 -0
- package/components/fields/ListBox/interface.d.ts +1 -1
- package/index12.js +1 -1
- package/index12.mjs +6 -6
- package/index122.js +1 -1
- package/index122.mjs +2 -2
- package/index127.js +1 -1
- package/index127.mjs +10 -10
- package/index131.js +1 -1
- package/index131.mjs +1 -1
- package/index151.js +3 -2
- package/index151.mjs +5 -4
- package/index17.js +1 -1
- package/index17.mjs +14 -14
- package/index170.js +1 -1
- package/index170.mjs +10 -6
- package/index171.js +1 -2
- package/index171.mjs +6 -47
- package/index172.js +2 -1
- package/index172.mjs +47 -10
- package/index18.js +1 -1
- package/index18.mjs +7 -7
- package/index26.js +1 -1
- package/index26.mjs +15 -15
- package/index27.js +1 -1
- package/index27.mjs +15 -15
- package/index32.js +1 -1
- package/index32.mjs +105 -85
- package/index35.js +1 -1
- package/index35.mjs +14 -14
- package/index38.js +1 -1
- package/index38.mjs +114 -106
- package/index40.js +1 -1
- package/index40.mjs +11 -11
- package/index56.js +1 -1
- package/index56.mjs +33 -32
- package/package.json +2 -2
package/index32.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";const
|
|
2
|
+
"use strict";const n=require("react/jsx-runtime"),ae=require("radashi"),s=require("react"),y=require("react-aria");require("react-hook-form");const pe=require("react-stately"),fe=require("./index78.js"),de=require("./index88.js"),m=require("./index7.js"),me=require("./index48.js"),he=require("./index93.js"),xe=require("./index99.js"),Re=require("./index56.js"),v=require("./index74.js"),be=require("./index38.js"),Pe=require("./index127.js");function Be(i){const{children:I,hookFormRef:h,errorMessage:x,themeName:t="comboBox",tokens:R,customTheme:N,label:b,icon:S=n.jsx(he,{}),closeIcon:V=n.jsx(xe,{}),isDisabled:F=!1,isRequired:M=!1,isReadOnly:E=!1,defaultFilter:T,onInputChange:c,onSelectionChange:w,inputRef:D,buttonRef:O,popoverRef:A,listBoxRef:W,debounceDelay:z=200,isNonModal:P=!0}=i,L=s.useRef(null),a=D??L,K=s.useRef(null),B=O??K,G=s.useRef(null),q=A??G,H=s.useRef(null),g=W??H,u=s.useRef(null),{contains:J}=y.useFilter({sensitivity:"base"}),Q=T??J,p=i.inputValue!==void 0,e=pe.useComboBoxState({...i,defaultFilter:Q,onInputChange:p?c:void 0,onSelectionChange:w}),C=fe.useDebounce(e.inputValue,z);s.useEffect(()=>{p||c?.(C)},[C,p,c]);const{inputProps:U,listBoxProps:X,labelProps:Y,buttonProps:Z,errorMessageProps:_,isInvalid:$}=y.useComboBox({...i,inputRef:a,buttonRef:B,popoverRef:q,listBoxRef:g},e),{onPress:ee,onPressStart:j,onPressEnd:qe,onPressChange:ge,preventFocusOnPress:ne,...te}=Z,{isOpen:l,selectedItem:f,selectionManager:oe}=e,{isFocused:se,isSelectAll:re,isEmpty:ie}=oe,d=!ae.isEmpty(e.inputValue),k=!ie,o={...R,isInvalid:$,isOpen:l,isFocused:se,hasValue:d,hasSelectedItem:k,isSelectAll:re,isReadOnly:E,isDisabled:F,isRequired:M},ue=s.useCallback(r=>{r!=null&&(h?.(r),a.current=r)},[h,a]),le=s.useMemo(()=>f!=null&&!l?f.rendered:e.inputValue,[f,e.inputValue,l]),ce=de(`${t}.input`,R);return n.jsxs(m.Box,{themeName:`${t}.wrapper`,tokens:o,customTheme:N,children:[b!=null&&n.jsx(v.Typography,{...Y,as:"label",themeName:`${t}.label`,tokens:o,children:b}),n.jsxs(m.Box,{themeName:`${t}.container`,children:[n.jsxs(m.BoxWithForwardRef,{ref:u,themeName:`${t}.inputWrapper`,tokens:o,children:[n.jsx("input",{...U,ref:ue,value:le,className:ce}),n.jsx(Pe,{state:e,themeName:`${t}.button`,tokens:o,...te,preventFocusOnPress:ne,ref:B,handlePress:r=>{if(d||k){e.setSelectedKey(null),e.selectionManager.clearSelection(),e.setInputValue("");return}j!=null?j(r):ee?.(r)},children:n.jsx(me,{themeName:`${t}.icon`,tokens:o,icon:d?V:S})})]}),l&&u.current!=null&&e.collection.size>0&&n.jsx(Re.Popover,{themeName:`${t}.popover`,tokens:o,state:e,triggerRef:u,placement:"bottom",sizeRef:u,popoverRef:q,isNonModal:P,autoFocus:!1,contain:!P,children:n.jsx(be.ControlledListBox,{...X,themeName:`${t}.list`,tokens:o,state:e,ref:g,children:I})}),$&&x!=null&&n.jsx(v.Typography,{tokens:o,themeName:`${t}.errorMessage`,..._,children:x})]})]})}module.exports=Be;
|
package/index32.mjs
CHANGED
|
@@ -1,114 +1,134 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as t, jsxs as
|
|
3
|
-
import { isEmpty as
|
|
4
|
-
import { useRef as s,
|
|
5
|
-
import { useFilter as
|
|
2
|
+
import { jsx as t, jsxs as h } from "react/jsx-runtime";
|
|
3
|
+
import { isEmpty as ce } from "radashi";
|
|
4
|
+
import { useRef as s, useEffect as pe, useCallback as me, useMemo as fe } from "react";
|
|
5
|
+
import { useFilter as he, useComboBox as de } from "react-aria";
|
|
6
6
|
import "react-hook-form";
|
|
7
|
-
import { useComboBoxState as
|
|
8
|
-
import { useDebounce as
|
|
9
|
-
import
|
|
10
|
-
import { Box as
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import { Popover as
|
|
15
|
-
import { Typography as
|
|
16
|
-
import { ControlledListBox as
|
|
17
|
-
import
|
|
18
|
-
function
|
|
7
|
+
import { useComboBoxState as Re } from "react-stately";
|
|
8
|
+
import { useDebounce as be } from "./index78.mjs";
|
|
9
|
+
import Pe from "./index88.mjs";
|
|
10
|
+
import { Box as y, BoxWithForwardRef as xe } from "./index7.mjs";
|
|
11
|
+
import Be from "./index48.mjs";
|
|
12
|
+
import Ce from "./index93.mjs";
|
|
13
|
+
import ge from "./index99.mjs";
|
|
14
|
+
import { Popover as Ie } from "./index56.mjs";
|
|
15
|
+
import { Typography as S } from "./index74.mjs";
|
|
16
|
+
import { ControlledListBox as ke } from "./index38.mjs";
|
|
17
|
+
import ve from "./index127.mjs";
|
|
18
|
+
function Ke(l) {
|
|
19
19
|
const {
|
|
20
|
-
children:
|
|
21
|
-
hookFormRef:
|
|
22
|
-
errorMessage:
|
|
23
|
-
themeName:
|
|
24
|
-
tokens:
|
|
25
|
-
customTheme:
|
|
26
|
-
label:
|
|
27
|
-
icon:
|
|
28
|
-
closeIcon:
|
|
29
|
-
isDisabled:
|
|
30
|
-
isRequired:
|
|
31
|
-
isReadOnly:
|
|
32
|
-
defaultFilter:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
20
|
+
children: V,
|
|
21
|
+
hookFormRef: d,
|
|
22
|
+
errorMessage: R,
|
|
23
|
+
themeName: o = "comboBox",
|
|
24
|
+
tokens: b,
|
|
25
|
+
customTheme: $,
|
|
26
|
+
label: P,
|
|
27
|
+
icon: F = /* @__PURE__ */ t(Ce, {}),
|
|
28
|
+
closeIcon: M = /* @__PURE__ */ t(ge, {}),
|
|
29
|
+
isDisabled: D = !1,
|
|
30
|
+
isRequired: E = !1,
|
|
31
|
+
isReadOnly: T = !1,
|
|
32
|
+
defaultFilter: w,
|
|
33
|
+
onInputChange: a,
|
|
34
|
+
onSelectionChange: O,
|
|
35
|
+
inputRef: W,
|
|
36
|
+
buttonRef: j,
|
|
37
|
+
popoverRef: z,
|
|
38
|
+
listBoxRef: A,
|
|
39
|
+
debounceDelay: L = 200,
|
|
40
|
+
isNonModal: x = !0
|
|
41
|
+
} = l, q = s(null), c = W ?? q, K = s(null), B = j ?? K, G = s(null), C = z ?? G, H = s(null), g = A ?? H, i = s(null), { contains: J } = he({ sensitivity: "base" }), Q = w ?? J, p = l.inputValue !== void 0, e = Re({
|
|
42
|
+
...l,
|
|
43
|
+
defaultFilter: Q,
|
|
44
|
+
onInputChange: p ? a : void 0,
|
|
45
|
+
onSelectionChange: O
|
|
46
|
+
}), I = be(e.inputValue, L);
|
|
47
|
+
pe(() => {
|
|
48
|
+
p || a?.(I);
|
|
49
|
+
}, [I, p, a]);
|
|
50
|
+
const { inputProps: U, listBoxProps: X, labelProps: Y, buttonProps: Z, errorMessageProps: _, isInvalid: k } = de(
|
|
51
|
+
{ ...l, inputRef: c, buttonRef: B, popoverRef: C, listBoxRef: g },
|
|
52
|
+
e
|
|
53
|
+
), {
|
|
54
|
+
onPress: ee,
|
|
55
|
+
onPressStart: v,
|
|
56
|
+
onPressEnd: Ne,
|
|
57
|
+
onPressChange: ye,
|
|
58
|
+
preventFocusOnPress: oe,
|
|
59
|
+
...te
|
|
60
|
+
} = Z, { isOpen: u, selectedItem: m, selectionManager: ne } = e, { isFocused: re, isSelectAll: se, isEmpty: le } = ne, f = !ce(e.inputValue), N = !le, n = {
|
|
61
|
+
...b,
|
|
62
|
+
isInvalid: k,
|
|
63
|
+
isOpen: u,
|
|
64
|
+
isFocused: re,
|
|
65
|
+
hasValue: f,
|
|
66
|
+
hasSelectedItem: N,
|
|
67
|
+
isSelectAll: se,
|
|
68
|
+
isReadOnly: T,
|
|
69
|
+
isDisabled: D,
|
|
70
|
+
isRequired: E
|
|
71
|
+
}, ie = me(
|
|
59
72
|
(r) => {
|
|
60
|
-
r != null && (
|
|
73
|
+
r != null && (d?.(r), c.current = r);
|
|
61
74
|
},
|
|
62
|
-
[
|
|
63
|
-
),
|
|
64
|
-
return /* @__PURE__ */
|
|
65
|
-
|
|
66
|
-
/* @__PURE__ */
|
|
67
|
-
/* @__PURE__ */
|
|
68
|
-
/* @__PURE__ */ t("input", { ...
|
|
75
|
+
[d, c]
|
|
76
|
+
), ue = fe(() => m != null && !u ? m.rendered : e.inputValue, [m, e.inputValue, u]), ae = Pe(`${o}.input`, b);
|
|
77
|
+
return /* @__PURE__ */ h(y, { themeName: `${o}.wrapper`, tokens: n, customTheme: $, children: [
|
|
78
|
+
P != null && /* @__PURE__ */ t(S, { ...Y, as: "label", themeName: `${o}.label`, tokens: n, children: P }),
|
|
79
|
+
/* @__PURE__ */ h(y, { themeName: `${o}.container`, children: [
|
|
80
|
+
/* @__PURE__ */ h(xe, { ref: i, themeName: `${o}.inputWrapper`, tokens: n, children: [
|
|
81
|
+
/* @__PURE__ */ t("input", { ...U, ref: ie, value: ue, className: ae }),
|
|
69
82
|
/* @__PURE__ */ t(
|
|
70
|
-
|
|
83
|
+
ve,
|
|
71
84
|
{
|
|
72
|
-
state:
|
|
73
|
-
themeName: `${
|
|
85
|
+
state: e,
|
|
86
|
+
themeName: `${o}.button`,
|
|
74
87
|
tokens: n,
|
|
75
|
-
...
|
|
76
|
-
|
|
88
|
+
...te,
|
|
89
|
+
preventFocusOnPress: oe,
|
|
90
|
+
ref: B,
|
|
77
91
|
handlePress: (r) => {
|
|
78
|
-
|
|
92
|
+
if (f || N) {
|
|
93
|
+
e.setSelectedKey(null), e.selectionManager.clearSelection(), e.setInputValue("");
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
v != null ? v(r) : ee?.(r);
|
|
79
97
|
},
|
|
80
|
-
children: /* @__PURE__ */ t(
|
|
98
|
+
children: /* @__PURE__ */ t(Be, { themeName: `${o}.icon`, tokens: n, icon: f ? M : F })
|
|
81
99
|
}
|
|
82
100
|
)
|
|
83
101
|
] }),
|
|
84
|
-
|
|
85
|
-
|
|
102
|
+
u && i.current != null && e.collection.size > 0 && /* @__PURE__ */ t(
|
|
103
|
+
Ie,
|
|
86
104
|
{
|
|
87
|
-
themeName: `${
|
|
105
|
+
themeName: `${o}.popover`,
|
|
88
106
|
tokens: n,
|
|
89
|
-
state:
|
|
90
|
-
triggerRef:
|
|
107
|
+
state: e,
|
|
108
|
+
triggerRef: i,
|
|
91
109
|
placement: "bottom",
|
|
92
|
-
sizeRef:
|
|
93
|
-
popoverRef:
|
|
110
|
+
sizeRef: i,
|
|
111
|
+
popoverRef: C,
|
|
112
|
+
isNonModal: x,
|
|
94
113
|
autoFocus: !1,
|
|
114
|
+
contain: !x,
|
|
95
115
|
children: /* @__PURE__ */ t(
|
|
96
|
-
|
|
116
|
+
ke,
|
|
97
117
|
{
|
|
98
|
-
...
|
|
99
|
-
themeName: `${
|
|
118
|
+
...X,
|
|
119
|
+
themeName: `${o}.list`,
|
|
100
120
|
tokens: n,
|
|
101
|
-
state:
|
|
102
|
-
ref:
|
|
103
|
-
children:
|
|
121
|
+
state: e,
|
|
122
|
+
ref: g,
|
|
123
|
+
children: V
|
|
104
124
|
}
|
|
105
125
|
)
|
|
106
126
|
}
|
|
107
127
|
),
|
|
108
|
-
|
|
128
|
+
k && R != null && /* @__PURE__ */ t(S, { tokens: n, themeName: `${o}.errorMessage`, ..._, children: R })
|
|
109
129
|
] })
|
|
110
130
|
] });
|
|
111
131
|
}
|
|
112
132
|
export {
|
|
113
|
-
|
|
133
|
+
Ke as default
|
|
114
134
|
};
|
package/index35.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("react"),r=require("react-aria"),i=require("./index7.js");function p({themeName:o="datePicker",tokens:s,...t}){const a=u.useRef(null),{state:n,children:c}={...t},{popoverProps:l,underlayProps:d}=r.usePopover({...t,popoverRef:a},n);return e.jsx(r.Overlay,{children:e.jsxs(i.Box,{themeName:`${o}.calendarPopoverWrapper`,tokens:s,children:[e.jsx(i.Box,{themeName:`${o}.calendarUnderlay`,tokens:s,...d}),e.jsxs(i.BoxWithForwardRef,{themeName:`${o}.calendarPopover`,tokens:s,...l,ref:a,children:[e.jsx(r.DismissButton,{onDismiss:n.close}),c,e.jsx(r.DismissButton,{onDismiss:n.close})]})]})})}exports.CalendarPopover=p;
|
package/index35.mjs
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { useRef as
|
|
4
|
-
import { usePopover as
|
|
5
|
-
import { Box as
|
|
6
|
-
function B({ themeName:
|
|
7
|
-
const i =
|
|
2
|
+
import { jsx as r, jsxs as p } from "react/jsx-runtime";
|
|
3
|
+
import { useRef as d } from "react";
|
|
4
|
+
import { usePopover as f, Overlay as u, DismissButton as a } from "react-aria";
|
|
5
|
+
import { Box as l, BoxWithForwardRef as v } from "./index7.mjs";
|
|
6
|
+
function B({ themeName: o = "datePicker", tokens: e, ...n }) {
|
|
7
|
+
const i = d(null), { state: s, children: c } = { ...n }, { popoverProps: t, underlayProps: m } = f(
|
|
8
8
|
{
|
|
9
9
|
...n,
|
|
10
10
|
popoverRef: i
|
|
11
11
|
},
|
|
12
|
-
|
|
12
|
+
s
|
|
13
13
|
);
|
|
14
|
-
return /* @__PURE__ */
|
|
15
|
-
/* @__PURE__ */ r(
|
|
16
|
-
/* @__PURE__ */
|
|
17
|
-
/* @__PURE__ */ r(
|
|
18
|
-
|
|
19
|
-
/* @__PURE__ */ r(
|
|
14
|
+
return /* @__PURE__ */ r(u, { children: /* @__PURE__ */ p(l, { themeName: `${o}.calendarPopoverWrapper`, tokens: e, children: [
|
|
15
|
+
/* @__PURE__ */ r(l, { themeName: `${o}.calendarUnderlay`, tokens: e, ...m }),
|
|
16
|
+
/* @__PURE__ */ p(v, { themeName: `${o}.calendarPopover`, tokens: e, ...t, ref: i, children: [
|
|
17
|
+
/* @__PURE__ */ r(a, { onDismiss: s.close }),
|
|
18
|
+
c,
|
|
19
|
+
/* @__PURE__ */ r(a, { onDismiss: s.close })
|
|
20
20
|
] })
|
|
21
|
-
] });
|
|
21
|
+
] }) });
|
|
22
22
|
}
|
|
23
23
|
export {
|
|
24
24
|
B as CalendarPopover
|
package/index38.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),O=require("radashi"),E=require("react"),M=require("react-aria"),v=require("react-hook-form"),H=require("react-stately"),I=require("./index89.js"),N=require("./index7.js"),V=require("./index8.js"),S=require("./index74.js"),K=require("./index40.js"),A=require("./index39.js"),W={item:K,section:A};function k({ref:e,...o}){const{state:r,themeName:c="listBox",tokens:m,customTheme:b,label:d,escapeKeyBehavior:h="clearSelection",linkElementType:R=V.Anchor,isDisabled:n=!1,isRequired:C=!1,isInvalid:L=!1,isError:x=!1,errorMessage:f,disabledKeys:y,fieldRef:q,...B}=o,g=r.collection.getKeys(),a=t=>{if(t!=null){if(q?.(t),e==null)return;typeof e=="function"?e(t):typeof e=="object"&&(e.current=t)}},{listBoxProps:j,labelProps:i}=M.useListBox({...B,escapeKeyBehavior:h,label:d,disabledKeys:n?g:y},r,a),l={...m,isDisabled:n,isRequired:C,isInvalid:L};return s.jsxs(N.Box,{themeName:`${c}.wrapper`,tokens:l,customTheme:b,children:[d!=null&&s.jsx(S.Typography,{...i,themeName:`${c}.label`,tokens:l,children:d}),s.jsx(N.BoxWithForwardRef,{ref:e,as:"ul",...j,themeName:`${c}.list`,tokens:l,children:[...r.collection].map(t=>{const{key:F}=t,u=t.type??"item",p=W[u]??K;return s.jsx(p,{[u]:t,state:r,tokens:{...m,type:u},themeName:`${c}.${u}`,linkElementType:R},F)})}),x&&f!=null&&s.jsx(S.Typography,{themeName:`${c}.errorMessage`,tokens:{...l,isError:x},children:f})]})}k.displayName="ControlledListBox";function Q(e){const o=H.useListState(e),r=E.useRef(null);return s.jsx(k,{...e,state:o,ref:r})}function $({ref:e,...o}){const{name:r,rules:c,isRequired:m,isDisabled:b,tokens:d,selectionMode:h="single",errorMessage:R,...n}=o,{control:C,setValue:L,watch:x,getValues:f}=v.useFormContext(),{selectedKeys:y=x(r),defaultSelectedKeys:q=f(r)}=n,{t:B}=I.useTranslation(),g=E.useRef(null),a={required:m?B("FORM.ERROR.REQUIRED")??"required":!1,disabled:b,...c},j=H.useListState({...n,selectionMode:h,selectedKeys:y,children:o.children,onSelectionChange:i=>{n.onSelectionChange?.(i),L(r,i,{shouldDirty:!0,shouldTouch:!0}),g.current?.(i)}});return s.jsx(v.Controller,{...n,defaultValue:q,name:r,control:C,rules:a,disabled:a?.disabled,render:({field:i,fieldState:l})=>{const{ref:t,onChange:F,...u}=i;g.current=F;const p=!O.isEmpty(l.error),T={isDisabled:i.disabled??!1,isRequired:a?.required===!0||a?.required==="required",isInvalid:l.invalid,isError:p},{isError:_,...D}=T,P={...d,...D};return s.jsx(k,{...M.mergeProps(n,u,T),state:j,tokens:P,isError:p,selectionMode:h,selectedKeys:y,defaultSelectedKeys:q,errorMessage:R??l.error?.message,ref:e})}})}$.displayName="ControlledReactHookFormListBox";function U(e){const o=E.useRef(null);return s.jsx($,{...e,ref:o})}exports.ControlledListBox=k;exports.ControlledReactHookFormListBox=$;exports.ListBox=Q;exports.ReactHookFormListBox=U;
|
package/index38.mjs
CHANGED
|
@@ -1,130 +1,138 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { isEmpty as
|
|
4
|
-
import { useRef as
|
|
5
|
-
import { useListBox as
|
|
6
|
-
import { useFormContext as
|
|
7
|
-
import { useListState as
|
|
8
|
-
import { useTranslation as
|
|
9
|
-
import { Box as
|
|
10
|
-
import { Anchor as
|
|
11
|
-
import { Typography as
|
|
2
|
+
import { jsxs as P, jsx as l } from "react/jsx-runtime";
|
|
3
|
+
import { isEmpty as S } from "radashi";
|
|
4
|
+
import { useRef as F } from "react";
|
|
5
|
+
import { useListBox as j, mergeProps as H } from "react-aria";
|
|
6
|
+
import { useFormContext as I, Controller as V } from "react-hook-form";
|
|
7
|
+
import { useListState as K } from "react-stately";
|
|
8
|
+
import { useTranslation as W } from "./index89.mjs";
|
|
9
|
+
import { Box as A, BoxWithForwardRef as Q } from "./index7.mjs";
|
|
10
|
+
import { Anchor as U } from "./index8.mjs";
|
|
11
|
+
import { Typography as T } from "./index74.mjs";
|
|
12
12
|
import M from "./index40.mjs";
|
|
13
|
-
import
|
|
14
|
-
const
|
|
13
|
+
import _ from "./index39.mjs";
|
|
14
|
+
const w = {
|
|
15
15
|
item: M,
|
|
16
|
-
section:
|
|
16
|
+
section: _
|
|
17
17
|
};
|
|
18
|
-
function
|
|
18
|
+
function N({ ref: e, ...t }) {
|
|
19
19
|
const {
|
|
20
|
-
|
|
20
|
+
state: o,
|
|
21
|
+
themeName: a = "listBox",
|
|
21
22
|
tokens: u,
|
|
22
|
-
customTheme:
|
|
23
|
-
label:
|
|
24
|
-
escapeKeyBehavior:
|
|
25
|
-
linkElementType:
|
|
26
|
-
isDisabled:
|
|
27
|
-
isRequired:
|
|
28
|
-
isInvalid:
|
|
23
|
+
customTheme: x,
|
|
24
|
+
label: d,
|
|
25
|
+
escapeKeyBehavior: f = "clearSelection",
|
|
26
|
+
linkElementType: C = U,
|
|
27
|
+
isDisabled: s = !1,
|
|
28
|
+
isRequired: E = !1,
|
|
29
|
+
isInvalid: R = !1,
|
|
29
30
|
isError: p = !1,
|
|
30
|
-
errorMessage:
|
|
31
|
-
disabledKeys:
|
|
32
|
-
fieldRef:
|
|
33
|
-
...
|
|
34
|
-
} =
|
|
35
|
-
if (
|
|
36
|
-
if (
|
|
31
|
+
errorMessage: h,
|
|
32
|
+
disabledKeys: y,
|
|
33
|
+
fieldRef: g,
|
|
34
|
+
...B
|
|
35
|
+
} = t, k = o.collection.getKeys(), c = (r) => {
|
|
36
|
+
if (r != null) {
|
|
37
|
+
if (g?.(r), e == null)
|
|
37
38
|
return;
|
|
38
|
-
typeof e == "function" ? e(
|
|
39
|
+
typeof e == "function" ? e(r) : typeof e == "object" && (e.current = r);
|
|
39
40
|
}
|
|
40
|
-
}, { listBoxProps:
|
|
41
|
+
}, { listBoxProps: L, labelProps: n } = j(
|
|
41
42
|
{
|
|
42
|
-
...
|
|
43
|
-
escapeKeyBehavior:
|
|
44
|
-
label:
|
|
45
|
-
disabledKeys:
|
|
43
|
+
...B,
|
|
44
|
+
escapeKeyBehavior: f,
|
|
45
|
+
label: d,
|
|
46
|
+
disabledKeys: s ? k : y
|
|
46
47
|
},
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
),
|
|
48
|
+
o,
|
|
49
|
+
c
|
|
50
|
+
), i = {
|
|
50
51
|
...u,
|
|
51
|
-
isDisabled:
|
|
52
|
-
isRequired:
|
|
53
|
-
isInvalid:
|
|
54
|
-
isError: p
|
|
52
|
+
isDisabled: s,
|
|
53
|
+
isRequired: E,
|
|
54
|
+
isInvalid: R
|
|
55
55
|
};
|
|
56
|
-
return /* @__PURE__ */
|
|
57
|
-
|
|
58
|
-
/* @__PURE__ */
|
|
59
|
-
|
|
56
|
+
return /* @__PURE__ */ P(A, { themeName: `${a}.wrapper`, tokens: i, customTheme: x, children: [
|
|
57
|
+
d != null && /* @__PURE__ */ l(T, { ...n, themeName: `${a}.label`, tokens: i, children: d }),
|
|
58
|
+
/* @__PURE__ */ l(
|
|
59
|
+
Q,
|
|
60
60
|
{
|
|
61
61
|
ref: e,
|
|
62
62
|
as: "ul",
|
|
63
|
-
...
|
|
64
|
-
themeName: `${
|
|
65
|
-
tokens:
|
|
66
|
-
children: [...
|
|
67
|
-
const { key:
|
|
68
|
-
return /* @__PURE__ */
|
|
69
|
-
|
|
63
|
+
...L,
|
|
64
|
+
themeName: `${a}.list`,
|
|
65
|
+
tokens: i,
|
|
66
|
+
children: [...o.collection].map((r) => {
|
|
67
|
+
const { key: q } = r, m = r.type ?? "item", b = w[m] ?? M;
|
|
68
|
+
return /* @__PURE__ */ l(
|
|
69
|
+
b,
|
|
70
70
|
{
|
|
71
|
-
[
|
|
72
|
-
state:
|
|
73
|
-
tokens: { ...u, type:
|
|
74
|
-
themeName: `${
|
|
75
|
-
linkElementType:
|
|
71
|
+
[m]: r,
|
|
72
|
+
state: o,
|
|
73
|
+
tokens: { ...u, type: m },
|
|
74
|
+
themeName: `${a}.${m}`,
|
|
75
|
+
linkElementType: C
|
|
76
76
|
},
|
|
77
|
-
|
|
77
|
+
q
|
|
78
78
|
);
|
|
79
79
|
})
|
|
80
80
|
}
|
|
81
81
|
),
|
|
82
|
-
p &&
|
|
82
|
+
p && h != null && /* @__PURE__ */ l(T, { themeName: `${a}.errorMessage`, tokens: { ...i, isError: p }, children: h })
|
|
83
83
|
] });
|
|
84
84
|
}
|
|
85
|
-
|
|
86
|
-
function
|
|
87
|
-
const
|
|
88
|
-
return /* @__PURE__ */
|
|
85
|
+
N.displayName = "ControlledListBox";
|
|
86
|
+
function le(e) {
|
|
87
|
+
const t = K(e), o = F(null);
|
|
88
|
+
return /* @__PURE__ */ l(N, { ...e, state: t, ref: o });
|
|
89
89
|
}
|
|
90
|
-
function
|
|
91
|
-
const { name: o, rules:
|
|
92
|
-
required:
|
|
93
|
-
disabled:
|
|
94
|
-
...
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
90
|
+
function $({ ref: e, ...t }) {
|
|
91
|
+
const { name: o, rules: a, isRequired: u, isDisabled: x, tokens: d, selectionMode: f = "single", errorMessage: C, ...s } = t, { control: E, setValue: R, watch: p, getValues: h } = I(), { selectedKeys: y = p(o), defaultSelectedKeys: g = h(o) } = s, { t: B } = W(), k = F(null), c = {
|
|
92
|
+
required: u ? B("FORM.ERROR.REQUIRED") ?? "required" : !1,
|
|
93
|
+
disabled: x,
|
|
94
|
+
...a
|
|
95
|
+
}, L = K({
|
|
96
|
+
...s,
|
|
97
|
+
selectionMode: f,
|
|
98
|
+
selectedKeys: y,
|
|
99
|
+
children: t.children,
|
|
100
|
+
onSelectionChange: (n) => {
|
|
101
|
+
s.onSelectionChange?.(n), R(o, n, { shouldDirty: !0, shouldTouch: !0 }), k.current?.(n);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
return /* @__PURE__ */ l(
|
|
105
|
+
V,
|
|
98
106
|
{
|
|
99
|
-
...
|
|
100
|
-
defaultValue:
|
|
107
|
+
...s,
|
|
108
|
+
defaultValue: g,
|
|
101
109
|
name: o,
|
|
102
|
-
control:
|
|
103
|
-
rules:
|
|
104
|
-
disabled:
|
|
105
|
-
render: ({ field:
|
|
106
|
-
const { ref:
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
control: E,
|
|
111
|
+
rules: c,
|
|
112
|
+
disabled: c?.disabled,
|
|
113
|
+
render: ({ field: n, fieldState: i }) => {
|
|
114
|
+
const { ref: r, onChange: q, ...m } = n;
|
|
115
|
+
k.current = q;
|
|
116
|
+
const b = !S(i.error), v = {
|
|
117
|
+
isDisabled: n.disabled ?? !1,
|
|
118
|
+
isRequired: c?.required === !0 || c?.required === "required",
|
|
119
|
+
isInvalid: i.invalid,
|
|
120
|
+
isError: b
|
|
121
|
+
}, { isError: z, ...D } = v, O = {
|
|
122
|
+
...d,
|
|
123
|
+
...D
|
|
114
124
|
};
|
|
115
|
-
return /* @__PURE__ */
|
|
116
|
-
|
|
125
|
+
return /* @__PURE__ */ l(
|
|
126
|
+
N,
|
|
117
127
|
{
|
|
118
|
-
...
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
defaultSelectedKeys: h,
|
|
127
|
-
errorMessage: f ?? d.error?.message,
|
|
128
|
+
...H(s, m, v),
|
|
129
|
+
state: L,
|
|
130
|
+
tokens: O,
|
|
131
|
+
isError: b,
|
|
132
|
+
selectionMode: f,
|
|
133
|
+
selectedKeys: y,
|
|
134
|
+
defaultSelectedKeys: g,
|
|
135
|
+
errorMessage: C ?? i.error?.message,
|
|
128
136
|
ref: e
|
|
129
137
|
}
|
|
130
138
|
);
|
|
@@ -132,14 +140,14 @@ function T({ ref: e, ...r }) {
|
|
|
132
140
|
}
|
|
133
141
|
);
|
|
134
142
|
}
|
|
135
|
-
|
|
136
|
-
function
|
|
137
|
-
const
|
|
138
|
-
return /* @__PURE__ */
|
|
143
|
+
$.displayName = "ControlledReactHookFormListBox";
|
|
144
|
+
function ae(e) {
|
|
145
|
+
const t = F(null);
|
|
146
|
+
return /* @__PURE__ */ l($, { ...e, ref: t });
|
|
139
147
|
}
|
|
140
148
|
export {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
149
|
+
N as ControlledListBox,
|
|
150
|
+
$ as ControlledReactHookFormListBox,
|
|
151
|
+
le as ListBox,
|
|
152
|
+
ae as ReactHookFormListBox
|
|
145
153
|
};
|
package/index40.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";const n=require("react/jsx-runtime"),e=require("react"),l=require("react-aria"),w=require("./index77.js"),a=require("./index7.js"),M=require("./index8.js");function O({item:d,state:o,...f}){const{key:t,rendered:s,type:k}=d,{themeName:i="option",tokens:g,as:b="li",customTheme:C,linkElementType:P=M.Anchor,...j}=w.mergeDefaultComponentProps(f,d.props),m=e.useRef(null),{optionProps:q,isFocused:
|
|
2
|
+
"use strict";const n=require("react/jsx-runtime"),e=require("react"),l=require("react-aria"),w=require("./index77.js"),a=require("./index7.js"),M=require("./index8.js");function O({item:d,state:o,...f}){const{key:t,rendered:s,type:k}=d,{themeName:i="option",tokens:g,as:b="li",customTheme:C,linkElementType:P=M.Anchor,...j}=w.mergeDefaultComponentProps(f,d.props),m=e.useRef(null),{optionProps:q,isFocused:E,isDisabled:y,isFocusVisible:F,isPressed:R,isSelected:V,allowsSelection:A,descriptionProps:D,labelProps:L,hasAction:N}=l.useOption({key:t},o,m),r=o.selectionManager.isLink(t),S=o.selectionManager.canSelectItem(t),c={...g,type:k,isFocused:E,isDisabled:y,isFocusVisible:F,isPressed:R,isSelected:V,allowsSelection:A,hasAction:N,isLink:r,isSelectable:S},T=r?P:a.BoxWithForwardRef,$=r?"a":b,B=()=>{if(e.Children.count(s)>1){const[p,u]=e.Children.toArray(s),h=e.isValidElement(p),x=e.isValidElement(u);return!h&&!x?s:n.jsxs(n.Fragment,{children:[h&&n.jsx(a.Box,{themeName:`${i}.label`,tokens:c,children:e.cloneElement(p,L)}),x&&n.jsx(a.Box,{themeName:`${i}.description`,tokens:c,children:e.cloneElement(u,D)})]})}return s};return n.jsx(l.FocusRing,{focusRingClass:"has-focus-ring",children:n.jsx(T,{as:$,...l.mergeProps(j,q),ref:m,themeName:`${i}.option`,tokens:c,customTheme:C,children:B()})})}module.exports=O;
|