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