@vkzstudio/muza-ui 1.0.40 → 1.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Accordion/Accordion.js +26 -26
- package/dist/components/DatePicker/DatePicker.d.ts +12 -0
- package/dist/components/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/components/DatePicker/DatePicker.js +68 -67
- package/dist/components/Flex/Flex.d.ts +17 -17
- package/dist/components/MultiSelect/MultiSelect.d.ts +2 -0
- package/dist/components/MultiSelect/MultiSelect.d.ts.map +1 -1
- package/dist/components/MultiSelect/MultiSelect.js +96 -84
- package/dist/components/MultiSelect/MultiSelect.stories.d.ts +1 -0
- package/dist/components/MultiSelect/MultiSelect.stories.d.ts.map +1 -1
- package/dist/components/Select/Select.d.ts +2 -0
- package/dist/components/Select/Select.d.ts.map +1 -1
- package/dist/components/Select/Select.js +80 -70
- package/dist/components/Select/Select.stories.d.ts +1 -0
- package/dist/components/Select/Select.stories.d.ts.map +1 -1
- package/dist/muza-ui.css +1 -1
- package/dist/styles/token-colors.css +27 -3
- package/dist/styles/token-sizes.css +286 -62
- package/dist/translations/locales/cs.d.ts.map +1 -1
- package/dist/translations/locales/cs.js +2 -1
- package/dist/translations/locales/en.d.ts.map +1 -1
- package/dist/translations/locales/en.js +2 -1
- package/dist/translations/locales/sk.d.ts.map +1 -1
- package/dist/translations/locales/sk.js +2 -1
- package/dist/translations/types.d.ts +2 -0
- package/dist/translations/types.d.ts.map +1 -1
- package/dist/utils/cn.d.ts.map +1 -1
- package/dist/utils/cn.js +135 -17
- package/package.json +1 -1
|
@@ -1,47 +1,48 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { triggerWrapperVariants as
|
|
4
|
-
import { useMuzaTranslations as
|
|
5
|
-
import { Tag as
|
|
6
|
-
import { FormField as
|
|
7
|
-
import { DropdownMenu as
|
|
8
|
-
import { Typography as
|
|
9
|
-
import { Flex as
|
|
10
|
-
import { AltArrowUpOutline as
|
|
11
|
-
import { cn as
|
|
12
|
-
const
|
|
13
|
-
(
|
|
14
|
-
const
|
|
15
|
-
label:
|
|
16
|
-
hint:
|
|
17
|
-
error:
|
|
18
|
-
options:
|
|
19
|
-
onChange:
|
|
20
|
-
value:
|
|
1
|
+
import { jsx as t, jsxs as p } from "react/jsx-runtime";
|
|
2
|
+
import u, { forwardRef as L, useId as U, useMemo as k, useRef as G, useEffect as H } from "react";
|
|
3
|
+
import { triggerWrapperVariants as J } from "../Select/utils.js";
|
|
4
|
+
import { useMuzaTranslations as K } from "../../translations/TranslationContext.js";
|
|
5
|
+
import { Tag as f } from "../Tag/Tag.js";
|
|
6
|
+
import { FormField as Q } from "../FormField/FormField.js";
|
|
7
|
+
import { DropdownMenu as X, DropdownMenuTrigger as Y, DropdownMenuContent as Z, DropdownMenuCheckboxItem as ee } from "../DropdownMenu/DropdownMenu.js";
|
|
8
|
+
import { Typography as I } from "../Typography/Typography.js";
|
|
9
|
+
import { Flex as z } from "../Flex/Flex.js";
|
|
10
|
+
import { AltArrowUpOutline as te } from "@solar-icons/react-perf";
|
|
11
|
+
import { cn as re } from "../../utils/cn.js";
|
|
12
|
+
const ne = L(
|
|
13
|
+
(D, h) => {
|
|
14
|
+
const g = K(), {
|
|
15
|
+
label: x,
|
|
16
|
+
hint: b,
|
|
17
|
+
error: w,
|
|
18
|
+
options: i,
|
|
19
|
+
onChange: s,
|
|
20
|
+
value: r,
|
|
21
21
|
disabled: c,
|
|
22
22
|
prefix: d,
|
|
23
|
-
maxNumberOfVisibleTags:
|
|
24
|
-
size:
|
|
23
|
+
maxNumberOfVisibleTags: o = 2,
|
|
24
|
+
size: O,
|
|
25
25
|
placeholder: S,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
emptyMessage: W,
|
|
27
|
+
required: v,
|
|
28
|
+
disableRequiredAsterisk: j,
|
|
29
|
+
labelExtra: A,
|
|
30
|
+
infoTooltip: C,
|
|
31
|
+
collisionPadding: F
|
|
32
|
+
} = D, y = S ?? g.select.placeholder, q = W ?? g.select.noOptions, N = U(), E = x ? `${N}-label` : void 0, P = b ? `${N}-hint` : void 0, M = k(() => new Map(i.map((e) => [e.value, e.label])), [i]), V = k(() => {
|
|
33
|
+
const e = r && r.map((n) => M.get(n));
|
|
34
|
+
return e != null && e.length ? e.length <= o ? /* @__PURE__ */ t(
|
|
35
|
+
z,
|
|
35
36
|
{
|
|
36
37
|
gap: "xs",
|
|
37
38
|
justify: "start",
|
|
38
39
|
align: "start",
|
|
39
40
|
flex: 1,
|
|
40
41
|
className: "min-w-0",
|
|
41
|
-
children: e.map((n,
|
|
42
|
+
children: e.map((n, a) => /* @__PURE__ */ t(f, { variant: "info", className: "min-w-[50px] shrink-1", children: n }, a))
|
|
42
43
|
}
|
|
43
|
-
) : /* @__PURE__ */
|
|
44
|
-
|
|
44
|
+
) : /* @__PURE__ */ t(
|
|
45
|
+
z,
|
|
45
46
|
{
|
|
46
47
|
gap: "xs",
|
|
47
48
|
justify: "start",
|
|
@@ -49,61 +50,61 @@ const re = P(
|
|
|
49
50
|
flex: 1,
|
|
50
51
|
className: "min-w-0",
|
|
51
52
|
children: [
|
|
52
|
-
...e.slice(0,
|
|
53
|
-
|
|
53
|
+
...e.slice(0, o).map((n, a) => /* @__PURE__ */ t(
|
|
54
|
+
f,
|
|
54
55
|
{
|
|
55
56
|
variant: "info",
|
|
56
57
|
className: "min-w-[50px] shrink-1 overflow-hidden",
|
|
57
|
-
children: /* @__PURE__ */
|
|
58
|
+
children: /* @__PURE__ */ t("span", { className: "truncate", children: n })
|
|
58
59
|
},
|
|
59
|
-
|
|
60
|
+
a
|
|
60
61
|
)),
|
|
61
|
-
/* @__PURE__ */
|
|
62
|
-
e.length -
|
|
62
|
+
/* @__PURE__ */ p(f, { variant: "info", children: [
|
|
63
|
+
e.length - o,
|
|
63
64
|
"+"
|
|
64
65
|
] }, "more")
|
|
65
66
|
]
|
|
66
67
|
}
|
|
67
|
-
) : /* @__PURE__ */
|
|
68
|
-
|
|
68
|
+
) : /* @__PURE__ */ t(
|
|
69
|
+
I,
|
|
69
70
|
{
|
|
70
71
|
size: "input",
|
|
71
72
|
className: "grow-1 fix-y-text truncate text-left text-comp-select-text-placeholder",
|
|
72
73
|
weight: "regular",
|
|
73
74
|
component: "span",
|
|
74
|
-
children:
|
|
75
|
+
children: y
|
|
75
76
|
}
|
|
76
77
|
);
|
|
77
|
-
}, [
|
|
78
|
-
return
|
|
78
|
+
}, [r, y, o, M]), [R, $] = u.useState(!1), [T, _] = u.useState(0), m = u.useRef(!1), B = G(null), l = (typeof h == "function" ? null : h) ?? B;
|
|
79
|
+
return H(() => {
|
|
79
80
|
const e = () => {
|
|
80
|
-
l.current &&
|
|
81
|
+
l.current && _(l.current.offsetWidth);
|
|
81
82
|
};
|
|
82
83
|
e();
|
|
83
84
|
const n = new ResizeObserver(e);
|
|
84
85
|
return l.current && n.observe(l.current), () => {
|
|
85
86
|
n.disconnect();
|
|
86
87
|
};
|
|
87
|
-
}, [l]), /* @__PURE__ */
|
|
88
|
-
|
|
88
|
+
}, [l]), /* @__PURE__ */ t(
|
|
89
|
+
Q,
|
|
89
90
|
{
|
|
90
|
-
label:
|
|
91
|
-
hint:
|
|
92
|
-
error:
|
|
93
|
-
required:
|
|
94
|
-
disableRequiredAsterisk:
|
|
95
|
-
labelId:
|
|
96
|
-
hintId:
|
|
97
|
-
labelExtra:
|
|
98
|
-
infoTooltip:
|
|
99
|
-
children: /* @__PURE__ */
|
|
100
|
-
|
|
91
|
+
label: x,
|
|
92
|
+
hint: b,
|
|
93
|
+
error: w,
|
|
94
|
+
required: v,
|
|
95
|
+
disableRequiredAsterisk: j,
|
|
96
|
+
labelId: E,
|
|
97
|
+
hintId: P,
|
|
98
|
+
labelExtra: A,
|
|
99
|
+
infoTooltip: C,
|
|
100
|
+
children: /* @__PURE__ */ p(
|
|
101
|
+
X,
|
|
101
102
|
{
|
|
102
103
|
onOpenChange: (e) => {
|
|
103
|
-
|
|
104
|
+
$(e);
|
|
104
105
|
},
|
|
105
106
|
children: [
|
|
106
|
-
/* @__PURE__ */
|
|
107
|
+
/* @__PURE__ */ t(Y, { disabled: c, asChild: !0, children: /* @__PURE__ */ t(
|
|
107
108
|
"button",
|
|
108
109
|
{
|
|
109
110
|
ref: l,
|
|
@@ -111,53 +112,64 @@ const re = P(
|
|
|
111
112
|
role: "input",
|
|
112
113
|
tabIndex: 0,
|
|
113
114
|
disabled: c,
|
|
114
|
-
"aria-required":
|
|
115
|
-
className:
|
|
116
|
-
size:
|
|
117
|
-
error:
|
|
118
|
-
expanded:
|
|
119
|
-
hasIcon: !!d || (
|
|
115
|
+
"aria-required": v,
|
|
116
|
+
className: J({
|
|
117
|
+
size: O,
|
|
118
|
+
error: w,
|
|
119
|
+
expanded: R,
|
|
120
|
+
hasIcon: !!d || (r == null ? void 0 : r.length) === 0
|
|
120
121
|
}),
|
|
121
|
-
children: /* @__PURE__ */
|
|
122
|
-
d && /* @__PURE__ */
|
|
122
|
+
children: /* @__PURE__ */ p("div", { className: "flex min-w-0 flex-1 items-center gap-sm", children: [
|
|
123
|
+
d && /* @__PURE__ */ t(
|
|
123
124
|
"span",
|
|
124
125
|
{
|
|
125
126
|
className: c ? "text-comp-select-icon-disabled" : "text-comp-select-icon-brand-def",
|
|
126
127
|
children: d
|
|
127
128
|
}
|
|
128
129
|
),
|
|
129
|
-
|
|
130
|
-
/* @__PURE__ */
|
|
131
|
-
|
|
130
|
+
V,
|
|
131
|
+
/* @__PURE__ */ t(
|
|
132
|
+
te,
|
|
132
133
|
{
|
|
133
|
-
className:
|
|
134
|
+
className: re(
|
|
134
135
|
"shrink-0 transition-transform duration-200",
|
|
135
|
-
|
|
136
|
+
R ? "rotate-0" : "rotate-180"
|
|
136
137
|
)
|
|
137
138
|
}
|
|
138
139
|
)
|
|
139
140
|
] })
|
|
140
141
|
}
|
|
141
142
|
) }),
|
|
142
|
-
/* @__PURE__ */
|
|
143
|
-
|
|
143
|
+
/* @__PURE__ */ t(
|
|
144
|
+
Z,
|
|
144
145
|
{
|
|
145
146
|
className: "mt-1",
|
|
146
147
|
style: {
|
|
147
|
-
width:
|
|
148
|
+
width: T > 0 ? `${T}px` : void 0
|
|
148
149
|
},
|
|
149
150
|
onCloseAutoFocus: (e) => {
|
|
150
151
|
m.current || e.preventDefault(), m.current = !1;
|
|
151
152
|
},
|
|
152
|
-
collisionPadding:
|
|
153
|
-
children:
|
|
154
|
-
|
|
153
|
+
collisionPadding: F,
|
|
154
|
+
children: i.length === 0 ? /* @__PURE__ */ t("div", { className: "px-lg py-md", role: "presentation", children: /* @__PURE__ */ t(
|
|
155
|
+
I,
|
|
155
156
|
{
|
|
156
|
-
|
|
157
|
+
component: "span",
|
|
158
|
+
size: "input",
|
|
159
|
+
weight: "regular",
|
|
160
|
+
className: "text-comp-select-text-secondary",
|
|
161
|
+
children: q
|
|
162
|
+
}
|
|
163
|
+
) }) : i.map((e) => /* @__PURE__ */ t(
|
|
164
|
+
ee,
|
|
165
|
+
{
|
|
166
|
+
checked: r == null ? void 0 : r.includes(e.value),
|
|
157
167
|
disabled: e.disabled,
|
|
158
168
|
icon: e.icon,
|
|
159
169
|
onCheckedChange: (n) => {
|
|
160
|
-
n ?
|
|
170
|
+
n ? s == null || s([...r || [], e.value]) : s == null || s(
|
|
171
|
+
(r || []).filter((a) => a !== e.value)
|
|
172
|
+
), m.current = !0;
|
|
161
173
|
},
|
|
162
174
|
children: e.label
|
|
163
175
|
},
|
|
@@ -172,7 +184,7 @@ const re = P(
|
|
|
172
184
|
);
|
|
173
185
|
}
|
|
174
186
|
);
|
|
175
|
-
|
|
187
|
+
ne.displayName = "MultiSelect";
|
|
176
188
|
export {
|
|
177
|
-
|
|
189
|
+
ne as MultiSelect
|
|
178
190
|
};
|
|
@@ -15,4 +15,5 @@ export declare const ManyOptions: Story;
|
|
|
15
15
|
export declare const WithLongLabels: Story;
|
|
16
16
|
export declare const WithIconsInOptions: Story;
|
|
17
17
|
export declare const WithDisabledOptions: Story;
|
|
18
|
+
export declare const NoOptions: Story;
|
|
18
19
|
//# sourceMappingURL=MultiSelect.stories.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiSelect.stories.d.ts","sourceRoot":"","sources":["../../../src/components/MultiSelect/MultiSelect.stories.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAQ3D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAqB3C,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,WAAW,
|
|
1
|
+
{"version":3,"file":"MultiSelect.stories.d.ts","sourceRoot":"","sources":["../../../src/components/MultiSelect/MultiSelect.stories.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAQ3D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAqB3C,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,WAAW,CA4HlC,CAAA;AAED,eAAe,IAAI,CAAA;AACnB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAA;AAsBlC,eAAO,MAAM,OAAO,EAAE,KAerB,CAAA;AAED,eAAO,MAAM,gBAAgB,EAAE,KAmB9B,CAAA;AAED,eAAO,MAAM,SAAS,EAAE,KAkBvB,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,KAgBtB,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,KA4DtB,CAAA;AAED,eAAO,MAAM,WAAW,EAAE,KAoBzB,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,KAqB5B,CAAA;AAED,eAAO,MAAM,UAAU,EAAE,KAgBxB,CAAA;AAED,eAAO,MAAM,WAAW,EAAE,KAuBzB,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,KA2C5B,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,KAoDhC,CAAA;AAED,eAAO,MAAM,mBAAmB,EAAE,KAkCjC,CAAA;AAED,eAAO,MAAM,SAAS,EAAE,KAqBvB,CAAA"}
|
|
@@ -17,6 +17,8 @@ export interface ISelectProps {
|
|
|
17
17
|
prefix?: ReactNode;
|
|
18
18
|
/** Text shown when no option is selected. @default translations.select.placeholder */
|
|
19
19
|
placeholder?: string;
|
|
20
|
+
/** Text shown inside the dropdown when `options` is empty. @default translations.select.noOptions */
|
|
21
|
+
emptyMessage?: string;
|
|
20
22
|
/** Controls trigger height and padding. @default 'base' */
|
|
21
23
|
size?: 'xs' | 'sm' | 'base' | 'lg';
|
|
22
24
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../src/components/Select/Select.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,KAAK,SAAS,EAMf,MAAM,OAAO,CAAA;AAed,uDAAuD;AACvD,MAAM,WAAW,YAAY;IAC3B,qDAAqD;IACrD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,2FAA2F;IAC3F,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,gFAAgF;IAChF,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,mCAAmC;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,+EAA+E;IAC/E,uBAAuB,CAAC,EAAE,OAAO,CAAA;IACjC,kDAAkD;IAClD,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,2DAA2D;IAC3D,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,sFAAsF;IACtF,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,2DAA2D;IAC3D,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAAA;IAClC;;;;;;;;;;OAUG;IACH,OAAO,EAAE,KAAK,CAAC;QACb,KAAK,EAAE,MAAM,CAAA;QACb,KAAK,EAAE,SAAS,CAAA;QAChB,QAAQ,CAAC,EAAE,OAAO,CAAA;QAClB,IAAI,CAAC,EAAE,SAAS,CAAA;KACjB,CAAC,CAAA;IACF,wEAAwE;IACxE,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,6CAA6C;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAClC,8EAA8E;IAC9E,4BAA4B,CAAC,EAAE,OAAO,CAAA;IACtC,gHAAgH;IAChH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,6EAA6E;IAC7E,UAAU,CAAC,EAAE,SAAS,CAAA;IACtB,gHAAgH;IAChH,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../src/components/Select/Select.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,KAAK,SAAS,EAMf,MAAM,OAAO,CAAA;AAed,uDAAuD;AACvD,MAAM,WAAW,YAAY;IAC3B,qDAAqD;IACrD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,2FAA2F;IAC3F,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,gFAAgF;IAChF,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,mCAAmC;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,+EAA+E;IAC/E,uBAAuB,CAAC,EAAE,OAAO,CAAA;IACjC,kDAAkD;IAClD,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,2DAA2D;IAC3D,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,sFAAsF;IACtF,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,qGAAqG;IACrG,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,2DAA2D;IAC3D,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAAA;IAClC;;;;;;;;;;OAUG;IACH,OAAO,EAAE,KAAK,CAAC;QACb,KAAK,EAAE,MAAM,CAAA;QACb,KAAK,EAAE,SAAS,CAAA;QAChB,QAAQ,CAAC,EAAE,OAAO,CAAA;QAClB,IAAI,CAAC,EAAE,SAAS,CAAA;KACjB,CAAC,CAAA;IACF,wEAAwE;IACxE,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,6CAA6C;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAClC,8EAA8E;IAC9E,4BAA4B,CAAC,EAAE,OAAO,CAAA;IACtC,gHAAgH;IAChH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,6EAA6E;IAC7E,UAAU,CAAC,EAAE,SAAS,CAAA;IACtB,gHAAgH;IAChH,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,eAAO,MAAM,MAAM,wFAyMlB,CAAA"}
|
|
@@ -1,35 +1,36 @@
|
|
|
1
|
-
import { jsx as t, jsxs as
|
|
2
|
-
import u, { forwardRef as
|
|
3
|
-
import { triggerWrapperVariants as
|
|
4
|
-
import { useMuzaTranslations as
|
|
5
|
-
import { FormField as
|
|
6
|
-
import { Typography as
|
|
7
|
-
import { DropdownMenu as
|
|
8
|
-
import { AltArrowUpOutline as
|
|
9
|
-
import { cn as
|
|
10
|
-
const
|
|
11
|
-
(
|
|
12
|
-
const
|
|
13
|
-
label:
|
|
14
|
-
hint:
|
|
15
|
-
error:
|
|
16
|
-
options:
|
|
17
|
-
onChange:
|
|
1
|
+
import { jsx as t, jsxs as M } from "react/jsx-runtime";
|
|
2
|
+
import u, { forwardRef as _, useId as B, useMemo as G, useRef as S, useEffect as T } from "react";
|
|
3
|
+
import { triggerWrapperVariants as L } from "./utils.js";
|
|
4
|
+
import { useMuzaTranslations as U } from "../../translations/TranslationContext.js";
|
|
5
|
+
import { FormField as H } from "../FormField/FormField.js";
|
|
6
|
+
import { Typography as p } from "../Typography/Typography.js";
|
|
7
|
+
import { DropdownMenu as J, DropdownMenuTrigger as K, DropdownMenuContent as Q, DropdownMenuRadioGroup as X, DropdownMenuRadioItem as Y } from "../DropdownMenu/DropdownMenu.js";
|
|
8
|
+
import { AltArrowUpOutline as Z } from "@solar-icons/react-perf";
|
|
9
|
+
import { cn as ee } from "../../utils/cn.js";
|
|
10
|
+
const te = _(
|
|
11
|
+
(z, m) => {
|
|
12
|
+
const f = U(), {
|
|
13
|
+
label: h,
|
|
14
|
+
hint: g,
|
|
15
|
+
error: x,
|
|
16
|
+
options: l,
|
|
17
|
+
onChange: i,
|
|
18
18
|
value: r,
|
|
19
19
|
disabled: a,
|
|
20
|
-
prefix:
|
|
21
|
-
size:
|
|
22
|
-
placeholder:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
prefix: b,
|
|
21
|
+
size: I,
|
|
22
|
+
placeholder: O,
|
|
23
|
+
emptyMessage: D,
|
|
24
|
+
shouldScrollToSelectedOption: w,
|
|
25
|
+
collisionPadding: W,
|
|
26
|
+
required: y,
|
|
27
|
+
disableRequiredAsterisk: A,
|
|
28
|
+
labelExtra: C,
|
|
29
|
+
infoTooltip: V
|
|
30
|
+
} = z, v = O ?? f.select.placeholder, q = D ?? f.select.noOptions, R = B(), E = h ? `${R}-label` : void 0, F = g ? `${R}-hint` : void 0, P = G(() => {
|
|
31
|
+
const e = r && l.find((o) => o.value === r);
|
|
31
32
|
return e ? typeof e.label != "function" ? /* @__PURE__ */ t(
|
|
32
|
-
|
|
33
|
+
p,
|
|
33
34
|
{
|
|
34
35
|
size: "input",
|
|
35
36
|
className: "grow-1 fix-y-text truncate text-left text-comp-select-text-primary",
|
|
@@ -38,49 +39,49 @@ const Z = k(
|
|
|
38
39
|
children: e.label
|
|
39
40
|
}
|
|
40
41
|
) : e.label : /* @__PURE__ */ t(
|
|
41
|
-
|
|
42
|
+
p,
|
|
42
43
|
{
|
|
43
44
|
size: "input",
|
|
44
45
|
className: "grow-1 fix-y-text truncate text-left text-comp-select-text-placeholder",
|
|
45
46
|
weight: "regular",
|
|
46
47
|
component: "span",
|
|
47
|
-
children:
|
|
48
|
+
children: v
|
|
48
49
|
}
|
|
49
50
|
);
|
|
50
|
-
}, [
|
|
51
|
-
return
|
|
51
|
+
}, [l, r, v]), [s, $] = u.useState(!1), [N, j] = u.useState(0), c = u.useRef(!1), k = S(null), d = S({}), n = (typeof m == "function" ? null : m) ?? k;
|
|
52
|
+
return T(() => {
|
|
52
53
|
const e = () => {
|
|
53
|
-
n.current &&
|
|
54
|
+
n.current && j(n.current.offsetWidth);
|
|
54
55
|
};
|
|
55
56
|
e();
|
|
56
57
|
const o = new ResizeObserver(e);
|
|
57
58
|
return n.current && o.observe(n.current), () => {
|
|
58
59
|
o.disconnect();
|
|
59
60
|
};
|
|
60
|
-
}, [n]),
|
|
61
|
+
}, [n]), T(() => {
|
|
61
62
|
var e;
|
|
62
|
-
|
|
63
|
-
}, [
|
|
64
|
-
|
|
63
|
+
s && r && d.current[r] && w && ((e = d.current[r]) == null || e.scrollIntoView({ block: "nearest" }));
|
|
64
|
+
}, [s, w, r]), /* @__PURE__ */ t(
|
|
65
|
+
H,
|
|
65
66
|
{
|
|
66
|
-
label:
|
|
67
|
-
hint:
|
|
68
|
-
error:
|
|
69
|
-
required:
|
|
70
|
-
disableRequiredAsterisk:
|
|
71
|
-
labelId:
|
|
72
|
-
hintId:
|
|
73
|
-
labelExtra:
|
|
74
|
-
infoTooltip:
|
|
67
|
+
label: h,
|
|
68
|
+
hint: g,
|
|
69
|
+
error: x,
|
|
70
|
+
required: y,
|
|
71
|
+
disableRequiredAsterisk: A,
|
|
72
|
+
labelId: E,
|
|
73
|
+
hintId: F,
|
|
74
|
+
labelExtra: C,
|
|
75
|
+
infoTooltip: V,
|
|
75
76
|
className: "flex-1",
|
|
76
|
-
children: /* @__PURE__ */
|
|
77
|
-
|
|
77
|
+
children: /* @__PURE__ */ M(
|
|
78
|
+
J,
|
|
78
79
|
{
|
|
79
80
|
onOpenChange: (e) => {
|
|
80
|
-
|
|
81
|
+
$(e);
|
|
81
82
|
},
|
|
82
83
|
children: [
|
|
83
|
-
/* @__PURE__ */ t(
|
|
84
|
+
/* @__PURE__ */ t(K, { disabled: a, asChild: !0, children: /* @__PURE__ */ t(
|
|
84
85
|
"button",
|
|
85
86
|
{
|
|
86
87
|
ref: n,
|
|
@@ -88,23 +89,23 @@ const Z = k(
|
|
|
88
89
|
role: "input",
|
|
89
90
|
tabIndex: 0,
|
|
90
91
|
disabled: a,
|
|
91
|
-
"aria-required":
|
|
92
|
-
className:
|
|
93
|
-
children: /* @__PURE__ */
|
|
94
|
-
|
|
92
|
+
"aria-required": y,
|
|
93
|
+
className: L({ size: I, error: x, expanded: s }),
|
|
94
|
+
children: /* @__PURE__ */ M("div", { className: "flex min-w-0 flex-1 items-center gap-sm", children: [
|
|
95
|
+
b && /* @__PURE__ */ t(
|
|
95
96
|
"span",
|
|
96
97
|
{
|
|
97
98
|
className: a ? "text-comp-select-icon-disabled" : "text-comp-select-icon-brand-def",
|
|
98
|
-
children:
|
|
99
|
+
children: b
|
|
99
100
|
}
|
|
100
101
|
),
|
|
101
|
-
|
|
102
|
+
P,
|
|
102
103
|
/* @__PURE__ */ t(
|
|
103
|
-
|
|
104
|
+
Z,
|
|
104
105
|
{
|
|
105
|
-
className:
|
|
106
|
+
className: ee(
|
|
106
107
|
"transition-transform duration-200",
|
|
107
|
-
|
|
108
|
+
s ? "rotate-0" : "rotate-180"
|
|
108
109
|
)
|
|
109
110
|
}
|
|
110
111
|
)
|
|
@@ -112,25 +113,34 @@ const Z = k(
|
|
|
112
113
|
}
|
|
113
114
|
) }),
|
|
114
115
|
/* @__PURE__ */ t(
|
|
115
|
-
|
|
116
|
+
Q,
|
|
116
117
|
{
|
|
117
118
|
className: "mt-1",
|
|
118
119
|
style: {
|
|
119
|
-
width:
|
|
120
|
+
width: N > 0 ? `${N}px` : void 0
|
|
120
121
|
},
|
|
121
122
|
onCloseAutoFocus: (e) => {
|
|
122
123
|
c.current || e.preventDefault(), c.current = !1;
|
|
123
124
|
},
|
|
124
|
-
collisionPadding:
|
|
125
|
-
children: /* @__PURE__ */ t(
|
|
126
|
-
|
|
125
|
+
collisionPadding: W,
|
|
126
|
+
children: l.length === 0 ? /* @__PURE__ */ t("div", { className: "px-lg py-md", role: "presentation", children: /* @__PURE__ */ t(
|
|
127
|
+
p,
|
|
128
|
+
{
|
|
129
|
+
component: "span",
|
|
130
|
+
size: "input",
|
|
131
|
+
weight: "regular",
|
|
132
|
+
className: "text-comp-select-text-secondary",
|
|
133
|
+
children: q
|
|
134
|
+
}
|
|
135
|
+
) }) : /* @__PURE__ */ t(
|
|
136
|
+
X,
|
|
127
137
|
{
|
|
128
138
|
value: r,
|
|
129
139
|
onValueChange: (e) => {
|
|
130
|
-
c.current = !0,
|
|
140
|
+
c.current = !0, i == null || i(e);
|
|
131
141
|
},
|
|
132
|
-
children:
|
|
133
|
-
|
|
142
|
+
children: l.map((e) => /* @__PURE__ */ t(
|
|
143
|
+
Y,
|
|
134
144
|
{
|
|
135
145
|
value: e.value.toString(),
|
|
136
146
|
disabled: e.disabled,
|
|
@@ -153,7 +163,7 @@ const Z = k(
|
|
|
153
163
|
);
|
|
154
164
|
}
|
|
155
165
|
);
|
|
156
|
-
|
|
166
|
+
te.displayName = "Select";
|
|
157
167
|
export {
|
|
158
|
-
|
|
168
|
+
te as Select
|
|
159
169
|
};
|
|
@@ -15,4 +15,5 @@ export declare const Interactive: Story;
|
|
|
15
15
|
export declare const WithPrefix: Story;
|
|
16
16
|
export declare const WithIconsInOptions: Story;
|
|
17
17
|
export declare const WithDisabledOptions: Story;
|
|
18
|
+
export declare const NoOptions: Story;
|
|
18
19
|
//# sourceMappingURL=Select.stories.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.stories.d.ts","sourceRoot":"","sources":["../../../src/components/Select/Select.stories.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAS3D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"Select.stories.d.ts","sourceRoot":"","sources":["../../../src/components/Select/Select.stories.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAS3D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,MAAM,CAsH7B,CAAA;AAED,eAAe,IAAI,CAAA;AACnB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,MAAM,CAAC,CAAA;AA6BpC,eAAO,MAAM,OAAO,EAAE,KAwBrB,CAAA;AAED,eAAO,MAAM,gBAAgB,EAAE,KA0B9B,CAAA;AAED,eAAO,MAAM,SAAS,EAAE,KA0BvB,CAAA;AAED,eAAO,MAAM,iBAAiB,EAAE,KAwB/B,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,KA0BtB,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,KA0BtB,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,KA6DtB,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,KA0C7B,CAAA;AAED,eAAO,MAAM,WAAW,EAAE,KAgCzB,CAAA;AAED,eAAO,MAAM,UAAU,EAAE,KAyBxB,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,KAqDhC,CAAA;AAED,eAAO,MAAM,mBAAmB,EAAE,KAkCjC,CAAA;AAED,eAAO,MAAM,SAAS,EAAE,KAqBvB,CAAA"}
|