@kakadu/components 4.0.0 → 4.0.2

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.
@@ -1,87 +1,79 @@
1
1
  import { j as e } from "../jsx-runtime-B4hRZ52C.mjs";
2
- import { cx as C } from "@kuma-ui/core";
3
- import { useMemo as h, useState as M, useCallback as v, useEffect as S, useRef as D } from "react";
4
- import { buttonResetStyles as z } from "../theme.mjs";
2
+ import { cx as F } from "@kuma-ui/core";
3
+ import { useMemo as j, useState as A, useCallback as h, useEffect as K, useRef as z } from "react";
4
+ import { buttonResetStyles as C } from "../theme.mjs";
5
5
  import b from "../icons/icon.mjs";
6
- import H, { PopoverContainer as T, usePopover as V, usePopoverContext as E } from "./popover.mjs";
6
+ import { u as D } from "../use-synchronized-value-XnIpeq1s.mjs";
7
+ import V, { PopoverContainer as H, usePopover as T, usePopoverContext as N } from "./popover.mjs";
7
8
  import R from "./atom.mjs";
8
- import { Span as F } from "./text.mjs";
9
+ import { Span as M } from "./text.mjs";
9
10
  import B, { normalBlendStyles as G } from "./hover-gradient.mjs";
10
11
  import U from "./click-ripples.mjs";
11
12
  import q from "./separator.mjs";
12
13
  import J from "./decorators.mjs";
13
- import N from "./spinner.mjs";
14
+ import I from "./spinner.mjs";
14
15
  import { SkeletonInstance as O } from "./skeleton.mjs";
15
16
  import Q from "./aria-text.mjs";
16
- const w = /* @__PURE__ */ new Set();
17
- function A() {
18
- const [n, r] = M(!1), s = v((a) => {
19
- r(a);
20
- for (const t of w)
21
- t(a);
22
- }, []);
23
- return S(() => {
24
- const a = (t) => {
25
- r(t);
26
- };
27
- return w.add(a), () => {
28
- w.delete(a);
29
- };
30
- }, []), h(() => ({
17
+ function E() {
18
+ const {
19
+ value: n,
20
+ setValue: t
21
+ } = D("isKeyboardNavigating");
22
+ return j(() => ({
31
23
  isKeyboardNavigating: n,
32
- setIsKeyboardNavigating: s
33
- }), [n, s]);
24
+ setIsKeyboardNavigating: t
25
+ }), [n, t]);
34
26
  }
35
- const de = "kakadu-components-949294122";
27
+ const fe = "kakadu-components-949294122";
36
28
  function W({
37
29
  isLoading: n,
38
- label: r,
39
- iconLeft: s,
40
- iconRight: a,
41
- href: t,
42
- target: p,
43
- shouldCloseOnClick: k = !0,
44
- decorators: c = [],
45
- submenu: o,
30
+ label: t,
31
+ iconLeft: a,
32
+ iconRight: u,
33
+ href: o,
34
+ target: l,
35
+ shouldCloseOnClick: x = !0,
36
+ decorators: i = [],
37
+ submenu: r,
46
38
  className: d,
47
- onClick: u,
39
+ onClick: c,
48
40
  ...m
49
41
  }) {
50
42
  const {
51
43
  isVisible: f,
52
- isPreparingFocus: l,
53
- isFocused: i,
54
- close: j
55
- } = E(), {
56
- isKeyboardNavigating: x
57
- } = A(), y = D(!0), g = v(() => {
58
- y.current = i;
59
- }, [i]), I = v((K) => {
60
- !x && !y.current || i && (u == null || u(K), o ? o.show() : k && (j == null || j()));
61
- }, [x, i, u, o, k, j]), P = h(() => /* @__PURE__ */ e.jsxs(R, { as: t && !n ? "a" : "button", ...m, type: t && !n ? void 0 : "button", role: "menuitem", href: t, target: p, inert: !f && !l || n, disabled: t ? void 0 : !f && !l || n, className: C(z, "kakadu-components-1772835671", i && "kakadu-components-3160069815", x ? "kakadu-components-2254977234" : i && "kakadu-components-278139688", d), onClick: I, onPointerDownCapture: g, children: [
62
- /* @__PURE__ */ e.jsx(F, { className: "kakadu-components-1109353535", children: n ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
63
- /* @__PURE__ */ e.jsx(Q, { children: r }),
64
- s ? /* @__PURE__ */ e.jsx(N, { size: 12 }) : null,
44
+ isPreparingFocus: p,
45
+ isFocused: s,
46
+ close: k
47
+ } = N(), {
48
+ isKeyboardNavigating: v
49
+ } = E(), y = z(!0), w = h(() => {
50
+ y.current = s;
51
+ }, [s]), g = h((S) => {
52
+ !v && !y.current || s && (c == null || c(S), r ? r.show() : x && (k == null || k()));
53
+ }, [v, s, c, r, x, k]), P = j(() => /* @__PURE__ */ e.jsxs(R, { as: o && !n ? "a" : "button", ...m, type: o && !n ? void 0 : "button", role: "menuitem", href: o, target: l, inert: !f && !p || n, disabled: o ? void 0 : !f && !p || n, className: F(C, "kakadu-components-1772835671", s && "kakadu-components-3160069815", v ? "kakadu-components-2254977234" : s && "kakadu-components-278139688", d), onClick: g, onPointerDownCapture: w, children: [
54
+ /* @__PURE__ */ e.jsx(M, { className: "kakadu-components-1109353535", children: n ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
55
+ /* @__PURE__ */ e.jsx(Q, { children: t }),
56
+ a ? /* @__PURE__ */ e.jsx(I, { size: 12 }) : null,
65
57
  /* @__PURE__ */ e.jsx(O, { height: "1em", width: "100%" }),
66
- a ? /* @__PURE__ */ e.jsx(N, { size: 12 }) : null
58
+ u ? /* @__PURE__ */ e.jsx(I, { size: 12 }) : null
67
59
  ] }) : /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
68
- s ? /* @__PURE__ */ e.jsx(b, { width: 12, height: 12, type: s }) : null,
69
- /* @__PURE__ */ e.jsx("span", { className: "kakadu-components-4055589237", children: r }),
70
- a ? /* @__PURE__ */ e.jsx(b, { width: 12, height: 12, type: a }) : null
60
+ a ? /* @__PURE__ */ e.jsx(b, { width: 12, height: 12, type: a }) : null,
61
+ /* @__PURE__ */ e.jsx("span", { className: "kakadu-components-4055589237", children: t }),
62
+ u ? /* @__PURE__ */ e.jsx(b, { width: 12, height: 12, type: u }) : null
71
63
  ] }) }),
72
- x || n ? null : /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
73
- /* @__PURE__ */ e.jsx(U, { isActive: i, size: 100 }),
74
- /* @__PURE__ */ e.jsx(B, { isActive: i, size: 150, className: G })
64
+ v || n ? null : /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
65
+ /* @__PURE__ */ e.jsx(U, { isActive: s, size: 100 }),
66
+ /* @__PURE__ */ e.jsx(B, { isActive: s, size: 150, className: G })
75
67
  ] })
76
- ] }), [t, p, n, m, f, l, x, d, I, g, s, r, a, i]);
77
- return /* @__PURE__ */ e.jsx(J, { decorators: c, children: o ? /* @__PURE__ */ e.jsx(_, { menu: o.popoverMenu, className: "kakadu-components-1861176543", children: P }) : P });
68
+ ] }), [o, n, m, l, f, p, s, v, d, g, w, a, t, u]);
69
+ return /* @__PURE__ */ e.jsx(J, { decorators: i, children: r ? /* @__PURE__ */ e.jsx(_, { menu: r.popoverMenu, className: "kakadu-components-1861176543", children: P }) : P });
78
70
  }
79
71
  function X(n) {
80
72
  if ("type" in n) {
81
73
  if (n.type === "separator")
82
74
  return /* @__PURE__ */ e.jsx(q, {});
83
75
  if (n.type === "group")
84
- return /* @__PURE__ */ e.jsx(F, { className: "kakadu-components-1499037363", children: n.label });
76
+ return /* @__PURE__ */ e.jsx(M, { className: "kakadu-components-1499037363", children: n.label });
85
77
  }
86
78
  return /* @__PURE__ */ e.jsx(W, { ...n });
87
79
  }
@@ -89,31 +81,31 @@ function Y({
89
81
  items: n
90
82
  }) {
91
83
  const {
92
- isFocused: r
93
- } = E(), [s, a] = M([]), {
94
- setIsKeyboardNavigating: t
95
- } = A(), p = v((c) => {
96
- c && a((o) => o.includes(c) ? o : [...o, c]);
97
- }, []), k = v((c) => {
98
- r && (c.currentTarget.focus(), t(!1));
99
- }, [r, t]);
100
- return S(() => {
101
- if (!r)
84
+ isFocused: t
85
+ } = N(), [a, u] = A([]), {
86
+ setIsKeyboardNavigating: o
87
+ } = E(), l = h((i) => {
88
+ i && u((r) => r.includes(i) ? r : [...r, i]);
89
+ }, []), x = h((i) => {
90
+ t && (i.currentTarget.focus(), o(!1));
91
+ }, [t, o]);
92
+ return K(() => {
93
+ if (!t)
102
94
  return;
103
- const c = (o) => {
104
- const d = s.filter((i) => i.isConnected), u = d.length;
105
- if (u === 0)
95
+ const i = (r) => {
96
+ const d = a.filter((s) => s.isConnected), c = d.length;
97
+ if (c === 0)
106
98
  return;
107
99
  let m;
108
100
  const f = document.activeElement;
109
- let l = f ? d.indexOf(f) : -1;
110
- switch (l === -1 && (l = 0), o.key) {
101
+ let p = f ? d.indexOf(f) : -1;
102
+ switch (p === -1 && (p = 0), r.key) {
111
103
  case "ArrowDown": {
112
- m = (l + 1) % u;
104
+ m = (p + 1) % c;
113
105
  break;
114
106
  }
115
107
  case "ArrowUp": {
116
- m = (l - 1 + u) % u;
108
+ m = (p - 1 + c) % c;
117
109
  break;
118
110
  }
119
111
  case "Home": {
@@ -121,71 +113,71 @@ function Y({
121
113
  break;
122
114
  }
123
115
  case "End": {
124
- m = u - 1;
116
+ m = c - 1;
125
117
  break;
126
118
  }
127
119
  case "Tab": {
128
- t(!0);
120
+ o(!0);
129
121
  return;
130
122
  }
131
123
  }
132
124
  if (m !== void 0) {
133
- o.preventDefault(), o.stopPropagation();
134
- const i = d[m];
135
- i && (i.focus(), t(!0));
125
+ r.preventDefault(), r.stopPropagation();
126
+ const s = d[m];
127
+ s && (s.focus(), o(!0));
136
128
  }
137
129
  };
138
- return window.addEventListener("keydown", c, {
130
+ return window.addEventListener("keydown", i, {
139
131
  capture: !0
140
132
  }), () => {
141
- window.removeEventListener("keydown", c, {
133
+ window.removeEventListener("keydown", i, {
142
134
  capture: !0
143
135
  });
144
136
  };
145
- }, [r, s, t]), /* @__PURE__ */ e.jsx(e.Fragment, { children: n.map((c, o) => /* @__PURE__ */ e.jsx(
137
+ }, [t, a, o]), /* @__PURE__ */ e.jsx(e.Fragment, { children: n.map((i, r) => /* @__PURE__ */ e.jsx(
146
138
  X,
147
139
  {
148
- ...c,
149
- reference: p,
150
- onMouseEnter: k
140
+ ...i,
141
+ reference: l,
142
+ onMouseEnter: x
151
143
  },
152
- o
144
+ r
153
145
  )) });
154
146
  }
155
147
  function Z({
156
148
  items: n,
157
- ...r
149
+ ...t
158
150
  }) {
159
- return /* @__PURE__ */ e.jsx(H, { ...r, as: "nav", role: "menu", innerClassName: "kakadu-components-3600436535", children: /* @__PURE__ */ e.jsx(Y, { items: n }) });
151
+ return /* @__PURE__ */ e.jsx(V, { ...t, as: "nav", role: "menu", innerClassName: "kakadu-components-3600436535", children: /* @__PURE__ */ e.jsx(Y, { items: n }) });
160
152
  }
161
- function fe(n) {
162
- const r = h(() => ({
153
+ function ve(n) {
154
+ const t = j(() => ({
163
155
  items: n
164
156
  }), [n]), {
165
- isVisible: s,
166
- show: a,
167
- close: t,
168
- popover: p
169
- } = V(Z, r);
170
- return h(() => ({
171
- isVisible: s,
172
- show: a,
173
- close: t,
174
- popoverMenu: p
175
- }), [s, a, t, p]);
157
+ isVisible: a,
158
+ show: u,
159
+ close: o,
160
+ popover: l
161
+ } = T(Z, t);
162
+ return j(() => ({
163
+ isVisible: a,
164
+ show: u,
165
+ close: o,
166
+ popoverMenu: l
167
+ }), [a, u, o, l]);
176
168
  }
177
169
  function _({
178
170
  menu: n,
179
- className: r,
180
- children: s
171
+ className: t,
172
+ children: a
181
173
  }) {
182
- return /* @__PURE__ */ e.jsxs(T, { className: r, children: [
183
- s,
174
+ return /* @__PURE__ */ e.jsxs(H, { className: t, children: [
175
+ a,
184
176
  n
185
177
  ] });
186
178
  }
187
179
  export {
188
- de as dangerPopoverMenuItemStyles,
180
+ fe as dangerPopoverMenuItemStyles,
189
181
  _ as default,
190
- fe as usePopoverMenu
182
+ ve as usePopoverMenu
191
183
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("../jsx-runtime-BB_1_6y_.js"),f=require("@kuma-ui/core"),e=require("react"),K=require("../focus-trap-react-CcpTuiJi.js"),R=require("./atom.js"),$=e.createContext({isVisible:!1,isPreparingFocus:!1,isFocused:!1}),{Provider:Q}=$;function X(){return e.useContext($)}function Y({as:i,className:s,...o}){return n.jsxRuntimeExports.jsx(R.default,{as:i??R.defaultAtomElementType,...o,className:f.cx("kakadu-components-2845019685",s)})}function Z({as:i,isVisible:s,label:o,shouldCloseOnOutsideClick:d=!0,shouldCloseOnEscapePress:a=!0,children:p,className:u,innerClassName:x,onClose:r,...v}){const I=e.useRef(null),S=e.useRef(null),[q,h]=e.useState(!1),[A,k]=e.useState(!1),[C,H]=e.useState(!1),[c,g]=e.useState(!1),[U,j]=e.useState(!1),M=e.useCallback(t=>{I.current=t,g(!1)},[]),E=e.useRef(null),N=e.useCallback(t=>{t&&(E.current=t)},[]),G=e.useMemo(()=>({initialFocus:()=>E.current??void 0,onPostActivate(){var t;k(!0),h(!1),(t=E.current)==null||t.focus()},clickOutsideDeactivates:d,escapeDeactivates:a,onPostUnpause(){k(!0)},onPause(){k(!1)},onDeactivate(){j(!1),g(!1),k(!1)}}),[d,a]),[L,O]=e.useState(s??!1),J=e.useMemo(()=>({isVisible:L,isPreparingFocus:q,isFocused:A,setInitialFocus:N,close:M}),[L,q,A,N,M]),[l,y]=e.useState("center");return e.useEffect(()=>{const t=S.current;if(t){const P=()=>{const D=t.offsetParent,F=D instanceof HTMLElement?D.getBoundingClientRect():null,V=t.getBoundingClientRect();if(!F){y("center");return}const T=16,_=window.innerWidth-T,b=F.left+F.width/2-V.width/2,z=b+V.width,B=b<T,W=z>_;let m="center";if(B&&W){const w=T-b;m=z-_>w?"right":"left"}else W?m="right":B&&(m="left");y(w=>w===m?w:m)};return P(),window.addEventListener("resize",P),()=>{window.removeEventListener("resize",P)}}},[]),e.useEffect(()=>{s&&(H(!0),O(!0))},[s]),e.useEffect(()=>{if(s){const t=setTimeout(()=>{g(!0)},100);return()=>{clearTimeout(t)}}g(!1)},[s]),e.useEffect(()=>{if(!c){j(!1),h(!1);return}h(!0);const t=window.requestAnimationFrame(()=>{j(!0)});return()=>{window.cancelAnimationFrame(t)}},[c]),e.useEffect(()=>{if(C&&!c){const t=setTimeout(()=>{r==null||r(I.current??void 0),O(!1)},370);return()=>{clearTimeout(t)}}},[C,c,r]),n.jsxRuntimeExports.jsx(R.default,{reference:S,as:i??R.defaultAtomElementType,role:"dialog","aria-hidden":!c,"aria-label":o??"Popover",...v,className:f.cx("kakadu-components-3920007758",l==="left"&&"kakadu-components-611400930",l==="right"&&"kakadu-components-944244368",c&&"kakadu-components-1399012551",u),children:n.jsxRuntimeExports.jsxs("div",{className:f.cx("kakadu-components-1118152266",c&&"kakadu-components-231244945"),children:[n.jsxRuntimeExports.jsx("div",{className:f.cx("kakadu-components-1951789226",l==="left"&&"kakadu-components-1495725644",l==="right"&&"kakadu-components-4235689197")}),n.jsxRuntimeExports.jsx(K.focusTrapReactExports.FocusTrap,{active:U,focusTrapOptions:G,children:n.jsxRuntimeExports.jsxs("div",{className:f.cx("kakadu-components-2488426662",x),children:[n.jsxRuntimeExports.jsx(Q,{value:J,children:p}),n.jsxRuntimeExports.jsx("div",{className:f.cx("kakadu-components-3252390100",l==="left"&&"kakadu-components-3754561431",l==="right"&&"kakadu-components-2265262600")})]})})]})})}function ee(i,s){const[o,d]=e.useState(!1),a=e.useRef(void 0),p=e.useCallback(async()=>(d(!0),new Promise(r=>{a.current=r})),[]),u=e.useCallback(r=>{var v;d(!1),(v=a.current)==null||v.call(a,r),a.current=void 0},[]),x=e.useMemo(()=>n.jsxRuntimeExports.jsx(i,{...s,isVisible:o,onClose:u}),[i,s,o,u]);return e.useMemo(()=>({isVisible:o,show:p,close:u,popover:x}),[o,p,u,x])}exports.PopoverContainer=Y;exports.default=Z;exports.usePopover=ee;exports.usePopoverContext=X;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("../jsx-runtime-BB_1_6y_.js"),f=require("@kuma-ui/core"),e=require("react"),K=require("../focus-trap-react-CkKg4ubd.js"),R=require("./atom.js"),$=e.createContext({isVisible:!1,isPreparingFocus:!1,isFocused:!1}),{Provider:Q}=$;function X(){return e.useContext($)}function Y({as:i,className:s,...o}){return n.jsxRuntimeExports.jsx(R.default,{as:i??R.defaultAtomElementType,...o,className:f.cx("kakadu-components-2845019685",s)})}function Z({as:i,isVisible:s,label:o,shouldCloseOnOutsideClick:d=!0,shouldCloseOnEscapePress:a=!0,children:p,className:u,innerClassName:x,onClose:r,...v}){const I=e.useRef(null),S=e.useRef(null),[q,h]=e.useState(!1),[A,k]=e.useState(!1),[C,H]=e.useState(!1),[c,g]=e.useState(!1),[U,j]=e.useState(!1),M=e.useCallback(t=>{I.current=t,g(!1)},[]),E=e.useRef(null),N=e.useCallback(t=>{t&&(E.current=t)},[]),G=e.useMemo(()=>({initialFocus:()=>E.current??void 0,onPostActivate(){var t;k(!0),h(!1),(t=E.current)==null||t.focus()},clickOutsideDeactivates:d,escapeDeactivates:a,onPostUnpause(){k(!0)},onPause(){k(!1)},onDeactivate(){j(!1),g(!1),k(!1)}}),[d,a]),[L,O]=e.useState(s??!1),J=e.useMemo(()=>({isVisible:L,isPreparingFocus:q,isFocused:A,setInitialFocus:N,close:M}),[L,q,A,N,M]),[l,y]=e.useState("center");return e.useEffect(()=>{const t=S.current;if(t){const P=()=>{const D=t.offsetParent,F=D instanceof HTMLElement?D.getBoundingClientRect():null,V=t.getBoundingClientRect();if(!F){y("center");return}const T=16,_=window.innerWidth-T,b=F.left+F.width/2-V.width/2,z=b+V.width,B=b<T,W=z>_;let m="center";if(B&&W){const w=T-b;m=z-_>w?"right":"left"}else W?m="right":B&&(m="left");y(w=>w===m?w:m)};return P(),window.addEventListener("resize",P),()=>{window.removeEventListener("resize",P)}}},[]),e.useEffect(()=>{s&&(H(!0),O(!0))},[s]),e.useEffect(()=>{if(s){const t=setTimeout(()=>{g(!0)},100);return()=>{clearTimeout(t)}}g(!1)},[s]),e.useEffect(()=>{if(!c){j(!1),h(!1);return}h(!0);const t=window.requestAnimationFrame(()=>{j(!0)});return()=>{window.cancelAnimationFrame(t)}},[c]),e.useEffect(()=>{if(C&&!c){const t=setTimeout(()=>{r==null||r(I.current??void 0),O(!1)},370);return()=>{clearTimeout(t)}}},[C,c,r]),n.jsxRuntimeExports.jsx(R.default,{reference:S,as:i??R.defaultAtomElementType,role:"dialog","aria-hidden":!c,"aria-label":o??"Popover",...v,className:f.cx("kakadu-components-3920007758",l==="left"&&"kakadu-components-611400930",l==="right"&&"kakadu-components-944244368",c&&"kakadu-components-1399012551",u),children:n.jsxRuntimeExports.jsxs("div",{className:f.cx("kakadu-components-1118152266",c&&"kakadu-components-231244945"),children:[n.jsxRuntimeExports.jsx("div",{className:f.cx("kakadu-components-1951789226",l==="left"&&"kakadu-components-1495725644",l==="right"&&"kakadu-components-4235689197")}),n.jsxRuntimeExports.jsx(K.focusTrapReactExports.FocusTrap,{active:U,focusTrapOptions:G,children:n.jsxRuntimeExports.jsxs("div",{className:f.cx("kakadu-components-2488426662",x),children:[n.jsxRuntimeExports.jsx(Q,{value:J,children:p}),n.jsxRuntimeExports.jsx("div",{className:f.cx("kakadu-components-3252390100",l==="left"&&"kakadu-components-3754561431",l==="right"&&"kakadu-components-2265262600")})]})})]})})}function ee(i,s){const[o,d]=e.useState(!1),a=e.useRef(void 0),p=e.useCallback(async()=>(d(!0),new Promise(r=>{a.current=r})),[]),u=e.useCallback(r=>{var v;d(!1),(v=a.current)==null||v.call(a,r),a.current=void 0},[]),x=e.useMemo(()=>n.jsxRuntimeExports.jsx(i,{...s,isVisible:o,onClose:u}),[i,s,o,u]);return e.useMemo(()=>({isVisible:o,show:p,close:u,popover:x}),[o,p,u,x])}exports.PopoverContainer=Y;exports.default=Z;exports.usePopover=ee;exports.usePopoverContext=X;
@@ -1,7 +1,7 @@
1
1
  import { j as s } from "../jsx-runtime-B4hRZ52C.mjs";
2
2
  import { cx as f } from "@kuma-ui/core";
3
3
  import { createContext as ee, useRef as F, useState as r, useCallback as P, useMemo as j, useEffect as p, useContext as te } from "react";
4
- import { f as se } from "../focus-trap-react-DYXrtbDH.mjs";
4
+ import { f as se } from "../focus-trap-react-DATIi_Ob.mjs";
5
5
  import K, { defaultAtomElementType as Q } from "./atom.mjs";
6
6
  const X = ee({
7
7
  isVisible: !1,
@@ -0,0 +1,12 @@
1
+ import { type ChangeEvent, type HTMLProps, type ReactNode } from 'react';
2
+ import { type InputLabelControllerProperties } from './input';
3
+ export type SelectOption<Type extends string = string> = {
4
+ readonly value: Type;
5
+ readonly label: ReactNode | string;
6
+ readonly disabled?: boolean;
7
+ };
8
+ export type SelectProperties<Type extends string = string> = Omit<InputLabelControllerProperties & HTMLProps<HTMLSelectElement>, 'onChange'> & {
9
+ readonly options: Array<SelectOption<Type>>;
10
+ readonly onChange?: (value: Type, event: ChangeEvent<HTMLSelectElement>) => void;
11
+ };
12
+ export default function Select<Type extends string = string>({ label, options, error, warning, information, footnote, className, onChange, ...properties }: SelectProperties<Type>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("../jsx-runtime-BB_1_6y_.js"),r=require("react"),S=require("@kuma-ui/core"),$=require("../icons/chevron-up.js"),p=require("./input.js");function B({label:h,options:I,error:l,warning:u,information:c,footnote:q,className:E,onChange:t,...d}){const o=r.useId(),m=`${o}-error`,x=`${o}-warning`,v=`${o}-information`,s=!!l,i=!s&&!!u,b=!s&&!i&&!!c,g=s?m:i?x:b?v:void 0,{value:n}=d,[k,f]=r.useState(""),y=n??k;r.useEffect(()=>{f(typeof n=="string"?n:"")},[n]);const R=r.useCallback(e=>{const{value:j}=e.target;f(j),t==null||t(j,e)},[t]);return a.jsxRuntimeExports.jsxs(p.InputLabel,{label:h,error:l,errorId:m,warning:u,warningId:x,information:c,informationId:v,footnote:q,children:[a.jsxRuntimeExports.jsx("select",{...d,value:y,"aria-invalid":s,"data-warning":i,"data-information":b,"aria-describedby":g,className:S.cx(p.inputStyles,"kakadu-components-4228384787",E),onChange:R,children:I.map(e=>a.jsxRuntimeExports.jsx("option",{value:e.value,disabled:e.disabled,children:e.label},e.value))}),a.jsxRuntimeExports.jsx($.default,{width:14,height:14,className:"kakadu-components-158931186"})]})}exports.default=B;
@@ -0,0 +1,36 @@
1
+ import { j as n } from "../jsx-runtime-B4hRZ52C.mjs";
2
+ import { useId as S, useState as w, useEffect as E, useCallback as V } from "react";
3
+ import { cx as $ } from "@kuma-ui/core";
4
+ import N from "../icons/chevron-up.mjs";
5
+ import { InputLabel as L, inputStyles as R } from "./input.mjs";
6
+ function D({
7
+ label: b,
8
+ options: h,
9
+ error: l,
10
+ warning: i,
11
+ information: c,
12
+ footnote: I,
13
+ className: j,
14
+ onChange: e,
15
+ ...d
16
+ }) {
17
+ const o = S(), u = `${o}-error`, m = `${o}-warning`, f = `${o}-information`, t = !!l, r = !t && !!i, p = !t && !r && !!c, k = t ? u : r ? m : p ? f : void 0, {
18
+ value: s
19
+ } = d, [g, v] = w(""), y = s ?? g;
20
+ E(() => {
21
+ v(typeof s == "string" ? s : "");
22
+ }, [s]);
23
+ const B = V((a) => {
24
+ const {
25
+ value: x
26
+ } = a.target;
27
+ v(x), e == null || e(x, a);
28
+ }, [e]);
29
+ return /* @__PURE__ */ n.jsxs(L, { label: b, error: l, errorId: u, warning: i, warningId: m, information: c, informationId: f, footnote: I, children: [
30
+ /* @__PURE__ */ n.jsx("select", { ...d, value: y, "aria-invalid": t, "data-warning": r, "data-information": p, "aria-describedby": k, className: $(R, "kakadu-components-4228384787", j), onChange: B, children: h.map((a) => /* @__PURE__ */ n.jsx("option", { value: a.value, disabled: a.disabled, children: a.label }, a.value)) }),
31
+ /* @__PURE__ */ n.jsx(N, { width: 14, height: 14, className: "kakadu-components-158931186" })
32
+ ] });
33
+ }
34
+ export {
35
+ D as default
36
+ };
@@ -2,7 +2,7 @@ import { type RefObject } from 'react';
2
2
  export declare const themePreferences: string[];
3
3
  type ThemePreference = (typeof themePreferences)[number];
4
4
  type ThemeElement = HTMLElement | RefObject<HTMLElement | null>;
5
- export declare function useTheme(element?: ThemeElement): string;
5
+ export declare function useTheme(element?: ThemeElement): ThemePreference;
6
6
  export declare function useIsLightMode(element?: ThemeElement): boolean;
7
7
  export declare function useIsDarkMode(element?: ThemeElement): boolean;
8
8
  export declare function getThemePreference(): string;