@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.
- package/build/components/combobox.d.ts +25 -0
- package/build/components/combobox.js +1 -0
- package/build/components/combobox.mjs +324 -0
- package/build/components/input.d.ts +11 -18
- package/build/components/input.js +2 -2
- package/build/components/input.mjs +124 -147
- package/build/components/modal.js +1 -1
- package/build/components/modal.mjs +1 -1
- package/build/components/popover-menu.js +1 -1
- package/build/components/popover-menu.mjs +98 -106
- package/build/components/popover.js +1 -1
- package/build/components/popover.mjs +1 -1
- package/build/components/select.d.ts +12 -0
- package/build/components/select.js +1 -0
- package/build/components/select.mjs +36 -0
- package/build/components/theme-setter.d.ts +1 -1
- package/build/components.css +1 -1
- package/build/{focus-trap-react-CcpTuiJi.js → focus-trap-react-CkKg4ubd.js} +5 -5
- package/build/{focus-trap-react-DYXrtbDH.mjs → focus-trap-react-DATIi_Ob.mjs} +34 -29
- package/build/hooks/use-synchronized-value.d.ts +4 -0
- package/build/icons/icon.d.ts +2 -1
- package/build/icons/icon.js +1 -1
- package/build/icons/icon.mjs +90 -89
- package/build/index.d.ts +4 -0
- package/build/index.js +1 -1
- package/build/index.mjs +233 -227
- package/build/use-synchronized-value-D0_rS5Wp.js +1 -0
- package/build/use-synchronized-value-XnIpeq1s.mjs +28 -0
- package/package.json +3 -1
|
@@ -1,87 +1,79 @@
|
|
|
1
1
|
import { j as e } from "../jsx-runtime-B4hRZ52C.mjs";
|
|
2
|
-
import { cx as
|
|
3
|
-
import { useMemo as
|
|
4
|
-
import { buttonResetStyles as
|
|
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
|
|
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
|
|
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
|
|
14
|
+
import I from "./spinner.mjs";
|
|
14
15
|
import { SkeletonInstance as O } from "./skeleton.mjs";
|
|
15
16
|
import Q from "./aria-text.mjs";
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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:
|
|
33
|
-
}), [n,
|
|
24
|
+
setIsKeyboardNavigating: t
|
|
25
|
+
}), [n, t]);
|
|
34
26
|
}
|
|
35
|
-
const
|
|
27
|
+
const fe = "kakadu-components-949294122";
|
|
36
28
|
function W({
|
|
37
29
|
isLoading: n,
|
|
38
|
-
label:
|
|
39
|
-
iconLeft:
|
|
40
|
-
iconRight:
|
|
41
|
-
href:
|
|
42
|
-
target:
|
|
43
|
-
shouldCloseOnClick:
|
|
44
|
-
decorators:
|
|
45
|
-
submenu:
|
|
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:
|
|
39
|
+
onClick: c,
|
|
48
40
|
...m
|
|
49
41
|
}) {
|
|
50
42
|
const {
|
|
51
43
|
isVisible: f,
|
|
52
|
-
isPreparingFocus:
|
|
53
|
-
isFocused:
|
|
54
|
-
close:
|
|
55
|
-
} =
|
|
56
|
-
isKeyboardNavigating:
|
|
57
|
-
} =
|
|
58
|
-
y.current =
|
|
59
|
-
}, [
|
|
60
|
-
!
|
|
61
|
-
}, [
|
|
62
|
-
/* @__PURE__ */ e.jsx(
|
|
63
|
-
/* @__PURE__ */ e.jsx(Q, { children:
|
|
64
|
-
|
|
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
|
-
|
|
58
|
+
u ? /* @__PURE__ */ e.jsx(I, { size: 12 }) : null
|
|
67
59
|
] }) : /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
|
|
68
|
-
|
|
69
|
-
/* @__PURE__ */ e.jsx("span", { className: "kakadu-components-4055589237", children:
|
|
70
|
-
|
|
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
|
-
|
|
73
|
-
/* @__PURE__ */ e.jsx(U, { isActive:
|
|
74
|
-
/* @__PURE__ */ e.jsx(B, { isActive:
|
|
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
|
-
] }), [
|
|
77
|
-
return /* @__PURE__ */ e.jsx(J, { decorators:
|
|
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(
|
|
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:
|
|
93
|
-
} =
|
|
94
|
-
setIsKeyboardNavigating:
|
|
95
|
-
} =
|
|
96
|
-
|
|
97
|
-
}, []),
|
|
98
|
-
|
|
99
|
-
}, [
|
|
100
|
-
return
|
|
101
|
-
if (!
|
|
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
|
|
104
|
-
const d =
|
|
105
|
-
if (
|
|
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
|
|
110
|
-
switch (
|
|
101
|
+
let p = f ? d.indexOf(f) : -1;
|
|
102
|
+
switch (p === -1 && (p = 0), r.key) {
|
|
111
103
|
case "ArrowDown": {
|
|
112
|
-
m = (
|
|
104
|
+
m = (p + 1) % c;
|
|
113
105
|
break;
|
|
114
106
|
}
|
|
115
107
|
case "ArrowUp": {
|
|
116
|
-
m = (
|
|
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 =
|
|
116
|
+
m = c - 1;
|
|
125
117
|
break;
|
|
126
118
|
}
|
|
127
119
|
case "Tab": {
|
|
128
|
-
|
|
120
|
+
o(!0);
|
|
129
121
|
return;
|
|
130
122
|
}
|
|
131
123
|
}
|
|
132
124
|
if (m !== void 0) {
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
|
|
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",
|
|
130
|
+
return window.addEventListener("keydown", i, {
|
|
139
131
|
capture: !0
|
|
140
132
|
}), () => {
|
|
141
|
-
window.removeEventListener("keydown",
|
|
133
|
+
window.removeEventListener("keydown", i, {
|
|
142
134
|
capture: !0
|
|
143
135
|
});
|
|
144
136
|
};
|
|
145
|
-
}, [
|
|
137
|
+
}, [t, a, o]), /* @__PURE__ */ e.jsx(e.Fragment, { children: n.map((i, r) => /* @__PURE__ */ e.jsx(
|
|
146
138
|
X,
|
|
147
139
|
{
|
|
148
|
-
...
|
|
149
|
-
reference:
|
|
150
|
-
onMouseEnter:
|
|
140
|
+
...i,
|
|
141
|
+
reference: l,
|
|
142
|
+
onMouseEnter: x
|
|
151
143
|
},
|
|
152
|
-
|
|
144
|
+
r
|
|
153
145
|
)) });
|
|
154
146
|
}
|
|
155
147
|
function Z({
|
|
156
148
|
items: n,
|
|
157
|
-
...
|
|
149
|
+
...t
|
|
158
150
|
}) {
|
|
159
|
-
return /* @__PURE__ */ e.jsx(
|
|
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
|
|
162
|
-
const
|
|
153
|
+
function ve(n) {
|
|
154
|
+
const t = j(() => ({
|
|
163
155
|
items: n
|
|
164
156
|
}), [n]), {
|
|
165
|
-
isVisible:
|
|
166
|
-
show:
|
|
167
|
-
close:
|
|
168
|
-
popover:
|
|
169
|
-
} =
|
|
170
|
-
return
|
|
171
|
-
isVisible:
|
|
172
|
-
show:
|
|
173
|
-
close:
|
|
174
|
-
popoverMenu:
|
|
175
|
-
}), [
|
|
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:
|
|
180
|
-
children:
|
|
171
|
+
className: t,
|
|
172
|
+
children: a
|
|
181
173
|
}) {
|
|
182
|
-
return /* @__PURE__ */ e.jsxs(
|
|
183
|
-
|
|
174
|
+
return /* @__PURE__ */ e.jsxs(H, { className: t, children: [
|
|
175
|
+
a,
|
|
184
176
|
n
|
|
185
177
|
] });
|
|
186
178
|
}
|
|
187
179
|
export {
|
|
188
|
-
|
|
180
|
+
fe as dangerPopoverMenuItemStyles,
|
|
189
181
|
_ as default,
|
|
190
|
-
|
|
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-
|
|
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-
|
|
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):
|
|
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;
|