@clubmed/trident-ui 2.0.0-beta.30 → 2.0.0-beta.33
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/chunks/DateField.js +4 -4
- package/examples/checkbox-select-demo.d.ts +1 -0
- package/examples/checkbox-select-demo.js +101 -0
- package/examples/checkbox-select-demo.js.map +1 -0
- package/examples/checkboxes-with-form-control-demo.js +4 -4
- package/package.json +1 -1
- package/styles/ui/button.css +1 -1
- package/styles/ui/range.css +1 -1
- package/ui/forms/CheckboxSelect.d.ts +31 -0
- package/ui/forms/CheckboxSelect.js +119 -0
- package/ui/forms/CheckboxSelect.js.map +1 -0
- package/ui/forms/NumberField.js +8 -8
- package/ui/forms/Select.js +4 -4
- package/ui/forms/TextField.js +4 -4
- package/ui/forms/password/Password.js +4 -4
package/chunks/DateField.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as e } from "./clsx.js";
|
|
2
2
|
import { useInternalStatus as t } from "../ui/hooks/useInternalStatus.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { FormControl as n } from "../ui/forms/FormControl.js";
|
|
4
|
+
import { useValue as r } from "../ui/hooks/useValue.js";
|
|
5
5
|
import { useCallback as i, useEffect as a, useId as o, useRef as s, useState as c } from "react";
|
|
6
6
|
import { Icon as l } from "@clubmed/trident-icons";
|
|
7
7
|
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
@@ -74,7 +74,7 @@ var S = (e) => !e || !v(new Date(e)) ? "" : x(new Date(e), { representation: "da
|
|
|
74
74
|
let p = o(), { id: m = p, name: h = m, label: g, description: _, openDatepicker: v, validationStatus: b = "default", icon: x = "CalendarDefault", iconType: w, errorMessage: T, disabled: E = !1, required: D = !1, hideRequiredStar: O, dataTestId: k = "DateField", value: A, min: j, max: M, onChange: N, className: P, ...F } = f, I = s(null), [L, R] = c(!1), z = t({
|
|
75
75
|
isDisabled: E,
|
|
76
76
|
validationStatus: b
|
|
77
|
-
}), { setValue: B, value: V } =
|
|
77
|
+
}), { setValue: B, value: V } = r({
|
|
78
78
|
name: h,
|
|
79
79
|
formatter: S,
|
|
80
80
|
initialValue: A,
|
|
@@ -113,7 +113,7 @@ var S = (e) => !e || !v(new Date(e)) ? "" : x(new Date(e), { representation: "da
|
|
|
113
113
|
j,
|
|
114
114
|
L,
|
|
115
115
|
V
|
|
116
|
-
]), /* @__PURE__ */ u(
|
|
116
|
+
]), /* @__PURE__ */ u(n, {
|
|
117
117
|
id: m,
|
|
118
118
|
label: g,
|
|
119
119
|
description: _,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function CheckboxSelectDemo(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { CheckboxSelect as e } from "../ui/forms/CheckboxSelect.js";
|
|
3
|
+
import { useState as t } from "react";
|
|
4
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
5
|
+
//#region lib/examples/checkbox-select-demo.tsx
|
|
6
|
+
var i = [
|
|
7
|
+
{
|
|
8
|
+
value: "open",
|
|
9
|
+
label: "Open"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
value: "fixed",
|
|
13
|
+
label: "Fixed"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
value: "in-progress",
|
|
17
|
+
label: "In Progress"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
value: "closed",
|
|
21
|
+
label: "Closed"
|
|
22
|
+
}
|
|
23
|
+
];
|
|
24
|
+
function a() {
|
|
25
|
+
let [a, o] = t(["open"]), [s, c] = t([]);
|
|
26
|
+
return /* @__PURE__ */ r("div", {
|
|
27
|
+
className: "space-y-24",
|
|
28
|
+
style: { minWidth: 300 },
|
|
29
|
+
children: [
|
|
30
|
+
/* @__PURE__ */ n(e, {
|
|
31
|
+
label: "Status",
|
|
32
|
+
placeholder: "Select statuses...",
|
|
33
|
+
options: i,
|
|
34
|
+
value: a,
|
|
35
|
+
onChange: (e, t) => o(t)
|
|
36
|
+
}),
|
|
37
|
+
/* @__PURE__ */ n(e, {
|
|
38
|
+
label: "Category",
|
|
39
|
+
placeholder: "Select categories...",
|
|
40
|
+
groups: [{
|
|
41
|
+
label: "Travel",
|
|
42
|
+
options: [{
|
|
43
|
+
value: "flight",
|
|
44
|
+
label: "Flight"
|
|
45
|
+
}, {
|
|
46
|
+
value: "hotel",
|
|
47
|
+
label: "Hotel"
|
|
48
|
+
}]
|
|
49
|
+
}, {
|
|
50
|
+
label: "Activities",
|
|
51
|
+
options: [
|
|
52
|
+
{
|
|
53
|
+
value: "ski",
|
|
54
|
+
label: "Ski"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
value: "golf",
|
|
58
|
+
label: "Golf"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
value: "spa",
|
|
62
|
+
label: "Spa"
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
}],
|
|
66
|
+
value: s,
|
|
67
|
+
onChange: (e, t) => c(t),
|
|
68
|
+
renderValue: (e) => `${e.length} selected`
|
|
69
|
+
}),
|
|
70
|
+
/* @__PURE__ */ n(e, {
|
|
71
|
+
label: "Priority",
|
|
72
|
+
options: [
|
|
73
|
+
{
|
|
74
|
+
value: "high",
|
|
75
|
+
label: "High"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
value: "medium",
|
|
79
|
+
label: "Medium"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
value: "low",
|
|
83
|
+
label: "Low"
|
|
84
|
+
}
|
|
85
|
+
],
|
|
86
|
+
validationStatus: "error",
|
|
87
|
+
errorMessage: "Please select at least one priority"
|
|
88
|
+
}),
|
|
89
|
+
/* @__PURE__ */ n(e, {
|
|
90
|
+
label: "Tags",
|
|
91
|
+
options: i,
|
|
92
|
+
value: ["open"],
|
|
93
|
+
disabled: !0
|
|
94
|
+
})
|
|
95
|
+
]
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
export { a as default };
|
|
100
|
+
|
|
101
|
+
//# sourceMappingURL=checkbox-select-demo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox-select-demo.js","names":[],"sources":["../../lib/examples/checkbox-select-demo.tsx"],"sourcesContent":["'use client';\n\nimport { useState } from 'react';\nimport { CheckboxSelect } from '@/ui/forms/CheckboxSelect';\n\nconst statusOptions = [\n { value: 'open', label: 'Open' },\n { value: 'fixed', label: 'Fixed' },\n { value: 'in-progress', label: 'In Progress' },\n { value: 'closed', label: 'Closed' },\n];\n\nexport default function CheckboxSelectDemo() {\n const [status, setStatus] = useState<string[]>(['open']);\n const [categories, setCategories] = useState<string[]>([]);\n\n return (\n <div className=\"space-y-24\" style={{ minWidth: 300 }}>\n <CheckboxSelect\n label=\"Status\"\n placeholder=\"Select statuses...\"\n options={statusOptions}\n value={status}\n onChange={(_, v) => setStatus(v)}\n />\n\n <CheckboxSelect\n label=\"Category\"\n placeholder=\"Select categories...\"\n groups={[\n {\n label: 'Travel',\n options: [\n { value: 'flight', label: 'Flight' },\n { value: 'hotel', label: 'Hotel' },\n ],\n },\n {\n label: 'Activities',\n options: [\n { value: 'ski', label: 'Ski' },\n { value: 'golf', label: 'Golf' },\n { value: 'spa', label: 'Spa' },\n ],\n },\n ]}\n value={categories}\n onChange={(_, v) => setCategories(v)}\n renderValue={(vals) => `${vals.length} selected`}\n />\n\n <CheckboxSelect\n label=\"Priority\"\n options={[\n { value: 'high', label: 'High' },\n { value: 'medium', label: 'Medium' },\n { value: 'low', label: 'Low' },\n ]}\n validationStatus=\"error\"\n errorMessage=\"Please select at least one priority\"\n />\n\n <CheckboxSelect label=\"Tags\" options={statusOptions} value={['open']} disabled />\n </div>\n );\n}\n"],"mappings":";;;;;AAKA,IAAM,IAAgB;CACpB;EAAE,OAAO;EAAQ,OAAO;EAAQ;CAChC;EAAE,O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{ FormControl as t } from "../ui/forms/FormControl.js";
|
|
4
|
+
import { Checkboxes as n } from "../ui/forms/checkboxes/Checkboxes.js";
|
|
5
5
|
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
6
6
|
//#region lib/examples/checkboxes-with-form-control-demo.tsx
|
|
7
7
|
function a() {
|
|
8
|
-
return /* @__PURE__ */ r(
|
|
8
|
+
return /* @__PURE__ */ r(t, {
|
|
9
9
|
label: "Select options",
|
|
10
10
|
description: "Choose one or more options",
|
|
11
|
-
children: /* @__PURE__ */ i(
|
|
11
|
+
children: /* @__PURE__ */ i(n, {
|
|
12
12
|
name: "options",
|
|
13
13
|
"aria-labelledby": "options-label",
|
|
14
14
|
children: [
|
package/package.json
CHANGED
package/styles/ui/button.css
CHANGED
package/styles/ui/range.css
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ValidationStatus } from '../hooks/useInternalStatus';
|
|
3
|
+
export interface CheckboxSelectOption<Value = string> {
|
|
4
|
+
value: Value;
|
|
5
|
+
label: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export interface CheckboxSelectGroup<Value = string> {
|
|
8
|
+
label?: ReactNode;
|
|
9
|
+
options: CheckboxSelectOption<Value>[];
|
|
10
|
+
}
|
|
11
|
+
export interface CheckboxSelectProps<Value = string> {
|
|
12
|
+
id?: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
label?: ReactNode;
|
|
15
|
+
description?: string;
|
|
16
|
+
placeholder?: string;
|
|
17
|
+
value?: Value[];
|
|
18
|
+
options?: CheckboxSelectOption<Value>[];
|
|
19
|
+
groups?: CheckboxSelectGroup<Value>[];
|
|
20
|
+
onChange?: (name: string, value: Value[]) => void;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
required?: boolean;
|
|
23
|
+
hideRequiredStar?: boolean;
|
|
24
|
+
validationStatus?: ValidationStatus;
|
|
25
|
+
errorMessage?: string;
|
|
26
|
+
className?: string;
|
|
27
|
+
'data-testid'?: string;
|
|
28
|
+
/** Renders the selected values summary in the trigger */
|
|
29
|
+
renderValue?: (selected: Value[]) => ReactNode;
|
|
30
|
+
}
|
|
31
|
+
export declare function CheckboxSelect<Value = string>({ id: idProp, name: nameProp, label, description, placeholder, value: controlledValue, options, groups, onChange, disabled, required, hideRequiredStar, validationStatus, errorMessage, className, 'data-testid': dataTestId, renderValue, }: CheckboxSelectProps<Value>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as e } from "../../chunks/clsx.js";
|
|
3
|
+
import { Checkbox as t } from "./checkboxes/Checkbox.js";
|
|
4
|
+
import { FormControl as n } from "./FormControl.js";
|
|
5
|
+
import { useDropdown as r } from "../Dropdown.js";
|
|
6
|
+
import { useEffect as i, useId as a, useState as o } from "react";
|
|
7
|
+
import { Icon as s } from "@clubmed/trident-icons";
|
|
8
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
9
|
+
//#region lib/ui/forms/CheckboxSelect.tsx
|
|
10
|
+
function u({ children: t, selected: n }) {
|
|
11
|
+
return /* @__PURE__ */ c("span", {
|
|
12
|
+
ref: (e) => {
|
|
13
|
+
e && (e.title = e.textContent ?? "");
|
|
14
|
+
},
|
|
15
|
+
className: e("text-b3 text-black truncate", { "font-semibold": n }),
|
|
16
|
+
children: t
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function d({ id: d, name: f, label: p, description: m, placeholder: h = "Select...", value: g, options: _, groups: v, onChange: y, disabled: b = !1, required: x = !1, hideRequiredStar: S, validationStatus: C = "default", errorMessage: w, className: T, "data-testid": E, renderValue: D }) {
|
|
20
|
+
let O = a(), k = d ?? O, A = f ?? k, { open: j, toggle: M, containerRef: N, isLeaving: P } = r(), [F, I] = o(g ?? []);
|
|
21
|
+
i(() => {
|
|
22
|
+
g !== void 0 && I(g);
|
|
23
|
+
}, [g]);
|
|
24
|
+
let L = (e) => {
|
|
25
|
+
let t = F.includes(e) ? F.filter((t) => t !== e) : [...F, e];
|
|
26
|
+
I(t), y?.(A, t);
|
|
27
|
+
}, R = _ || (v ?? []).flatMap((e) => e.options), z = F.length === 0 ? /* @__PURE__ */ c("span", {
|
|
28
|
+
className: "text-darkGrey",
|
|
29
|
+
children: h
|
|
30
|
+
}) : D ? D(F) : /* @__PURE__ */ c("span", { children: R.filter((e) => F.includes(e.value)).map((e) => e.label).join(", ") }), B = C === "error", V = C === "success", H = b, U = (e) => /* @__PURE__ */ c("div", {
|
|
31
|
+
className: "flex flex-col gap-12",
|
|
32
|
+
children: e.map((e, n) => /* @__PURE__ */ c(t, {
|
|
33
|
+
name: A,
|
|
34
|
+
value: String(e.value),
|
|
35
|
+
checked: F.includes(e.value),
|
|
36
|
+
disabled: b,
|
|
37
|
+
onChange: () => L(e.value),
|
|
38
|
+
children: /* @__PURE__ */ c(u, {
|
|
39
|
+
selected: F.includes(e.value),
|
|
40
|
+
children: e.label
|
|
41
|
+
})
|
|
42
|
+
}, n))
|
|
43
|
+
});
|
|
44
|
+
return /* @__PURE__ */ c(n, {
|
|
45
|
+
id: k,
|
|
46
|
+
label: p,
|
|
47
|
+
description: m,
|
|
48
|
+
className: T,
|
|
49
|
+
dataName: "CheckboxSelect",
|
|
50
|
+
"data-testid": E,
|
|
51
|
+
disabled: b,
|
|
52
|
+
required: x,
|
|
53
|
+
hideRequiredStar: S,
|
|
54
|
+
validationStatus: C,
|
|
55
|
+
errorMessage: w,
|
|
56
|
+
children: /* @__PURE__ */ l("div", {
|
|
57
|
+
ref: N,
|
|
58
|
+
className: "relative",
|
|
59
|
+
children: [/* @__PURE__ */ l("button", {
|
|
60
|
+
type: "button",
|
|
61
|
+
id: k,
|
|
62
|
+
"aria-haspopup": "listbox",
|
|
63
|
+
"aria-expanded": j,
|
|
64
|
+
"aria-disabled": H,
|
|
65
|
+
disabled: H,
|
|
66
|
+
onClick: M,
|
|
67
|
+
className: e("text-b3 rounded-pill w-full border overflow-hidden px-20 py-12 font-normal outline-none text-left flex items-center justify-between gap-8", {
|
|
68
|
+
"bg-white text-black border-middleGrey focus:border-black active:border-black": !H && !B && !V,
|
|
69
|
+
"bg-pearl border-middleGrey text-grey": H,
|
|
70
|
+
"border-red bg-white": B,
|
|
71
|
+
"border-green bg-white": V
|
|
72
|
+
}),
|
|
73
|
+
children: [/* @__PURE__ */ c("span", {
|
|
74
|
+
className: "truncate flex-1",
|
|
75
|
+
children: z
|
|
76
|
+
}), /* @__PURE__ */ l("span", {
|
|
77
|
+
className: "flex items-center gap-8 shrink-0",
|
|
78
|
+
children: [
|
|
79
|
+
B && /* @__PURE__ */ c(s, {
|
|
80
|
+
name: "CrossDefault",
|
|
81
|
+
width: "24px",
|
|
82
|
+
className: "text-red"
|
|
83
|
+
}),
|
|
84
|
+
V && /* @__PURE__ */ c(s, {
|
|
85
|
+
name: "CheckDefault",
|
|
86
|
+
width: "24px",
|
|
87
|
+
className: "text-green"
|
|
88
|
+
}),
|
|
89
|
+
/* @__PURE__ */ c(s, {
|
|
90
|
+
name: "ArrowDefaultDown",
|
|
91
|
+
width: "24px",
|
|
92
|
+
className: e("text-black transition-transform", { "rotate-180": j })
|
|
93
|
+
})
|
|
94
|
+
]
|
|
95
|
+
})]
|
|
96
|
+
}), /* @__PURE__ */ c("div", {
|
|
97
|
+
role: "listbox",
|
|
98
|
+
"aria-multiselectable": "true",
|
|
99
|
+
"aria-hidden": !j && !P,
|
|
100
|
+
className: e("absolute z-10 top-[calc(100%+8px)] left-0 right-0 bg-white rounded-16 border border-lightGrey shadow-md p-12 origin-top will-change-[transform,opacity]", {
|
|
101
|
+
"animate-zoom-in": j,
|
|
102
|
+
"animate-zoom-out": !j && P,
|
|
103
|
+
"opacity-0 scale-90 pointer-events-none": !j && !P
|
|
104
|
+
}),
|
|
105
|
+
children: v ? v.map((t, n) => /* @__PURE__ */ l("div", {
|
|
106
|
+
className: e({ "mt-16 first:mt-0": n > 0 }),
|
|
107
|
+
children: [t.label && /* @__PURE__ */ c("p", {
|
|
108
|
+
className: "text-b4 text-darkGrey font-semibold mb-8 ps-4",
|
|
109
|
+
children: t.label
|
|
110
|
+
}), U(t.options)]
|
|
111
|
+
}, n)) : U(R)
|
|
112
|
+
})]
|
|
113
|
+
})
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
117
|
+
export { d as CheckboxSelect };
|
|
118
|
+
|
|
119
|
+
//# sourceMappingURL=CheckboxSelect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CheckboxSelect.js","names":[],"sources":["../../../lib/ui/forms/CheckboxSelect.tsx"],"sourcesContent":["'use client';\n\nimport { useId, useState, useEffect, type ReactNode } from 'react';\nimport clsx from 'clsx';\nimport { Icon } from '@clubmed/trident-icons';\nimport { Checkbox } from './checkboxes/Checkbox';\nimport type { ValidationStatus } from '../hooks/useInternalStatus';\nimport { FormControl } from './FormControl';\nimport { useDropdown } from '../Dropdown';\n\nfunction OptionLabel({ children, selected }: { children: ReactNode; selected: boolean }) {\n return (\n <span\n ref={(el) => {\n if (el) el.title = el.textContent ?? '';\n }}\n className={clsx('text-b3 text-black truncate', { 'font-semibold': selected })}\n >\n {children}\n </span>\n );\n}\n\nexport interface CheckboxSelectOption<Value = string> {\n value: Value;\n label: ReactNode;\n}\n\nexport interface CheckboxSelectGroup<Value = string> {\n label?: ReactNode;\n options: CheckboxSelectOption<Value>[];\n}\n\nexport interface CheckboxSelectProps<Value = string> {\n id?: string;\n name?: string;\n label?: ReactNode;\n description?: string;\n placeholder?: string;\n value?: Value[];\n options?: CheckboxSelectOption<Value>[];\n groups?: CheckboxSelectGroup<Value>[];\n onChange?: (name: string, value: Value[]) => void;\n disabled?: boolean;\n required?: boolean;\n hideRequiredStar?: boolean;\n validationStatus?: ValidationStatus;\n errorMessage?: string;\n className?: string;\n 'data-testid'?: string;\n /** Renders the selected values summary in the trigger */\n renderValue?: (selected: Value[]) => ReactNode;\n}\n\nexport function CheckboxSelect<Value = string>({\n id: idProp,\n name: nameProp,\n label,\n description,\n placeholder = 'Select...',\n value: controlledValue,\n options,\n groups,\n onChange,\n disabled = false,\n required = false,\n hideRequiredStar,\n validationStatus = 'default',\n errorMessage,\n className,\n 'data-testid': dataTestId,\n renderValue,\n}: CheckboxSelectProps<Value>) {\n const internalId = useId();\n const id = idProp ?? internalId;\n const name = nameProp ?? id;\n\n const { open, toggle, containerRef, isLeaving } = useDropdown();\n const [selected, setSelected] = useState<Value[]>(controlledValue ?? []);\n\n useEffect(() => {\n if (controlledValue !== undefined) {\n setSelected(controlledValue);\n }\n }, [controlledValue]);\n\n const toggleOption = (val: Value) => {\n const next = selected.includes(val) ? selected.filter((v) => v !== val) : [...selected, val];\n setSelected(next);\n onChange?.(name, next);\n };\n\n const allOptions: CheckboxSelectOption<Value>[] = options\n ? options\n : (groups ?? []).flatMap((g) => g.options);\n\n const triggerLabel =\n selected.length === 0 ? (\n <span className=\"text-darkGrey\">{placeholder}</span>\n ) : renderValue ? (\n renderValue(selected)\n ) : (\n <span>\n {allOptions\n .filter((o) => selected.includes(o.value))\n .map((o) => o.label)\n .join(', ')}\n </span>\n );\n\n const isError = validationStatus === 'error';\n const isSuccess = validationStatus === 'success';\n const isDisabled = disabled;\n\n const renderOptions = (opts: CheckboxSelectOption<Value>[]) => (\n <div className=\"flex flex-col gap-12\">\n {opts.map((option, i) => (\n <Checkbox\n key={i}\n name={name}\n value={String(option.value)}\n checked={selected.includes(option.value)}\n disabled={disabled}\n onChange={() => toggleOption(option.value)}\n >\n <OptionLabel selected={selected.includes(option.value)}>{option.label}</OptionLabel>\n </Checkbox>\n ))}\n </div>\n );\n\n return (\n <FormControl\n id={id}\n label={label}\n description={description}\n className={className}\n dataName=\"CheckboxSelect\"\n data-testid={dataTestId}\n disabled={disabled}\n required={required}\n hideRequiredStar={hideRequiredStar}\n validationStatus={validationStatus}\n errorMessage={errorMessage}\n >\n <div ref={containerRef} className=\"relative\">\n <button\n type=\"button\"\n id={id}\n aria-haspopup=\"listbox\"\n aria-expanded={open}\n aria-disabled={isDisabled}\n disabled={isDisabled}\n onClick={toggle}\n className={clsx(\n 'text-b3 rounded-pill w-full border overflow-hidden px-20 py-12 font-normal outline-none text-left flex items-center justify-between gap-8',\n {\n 'bg-white text-black border-middleGrey focus:border-black active:border-black':\n !isDisabled && !isError && !isSuccess,\n 'bg-pearl border-middleGrey text-grey': isDisabled,\n 'border-red bg-white': isError,\n 'border-green bg-white': isSuccess,\n },\n )}\n >\n <span className=\"truncate flex-1\">{triggerLabel}</span>\n <span className=\"flex items-center gap-8 shrink-0\">\n {isError && <Icon name=\"CrossDefault\" width=\"24px\" className=\"text-red\" />}\n {isSuccess && <Icon name=\"CheckDefault\" width=\"24px\" className=\"text-green\" />}\n <Icon\n name=\"ArrowDefaultDown\"\n width=\"24px\"\n className={clsx('text-black transition-transform', { 'rotate-180': open })}\n />\n </span>\n </button>\n\n <div\n role=\"listbox\"\n aria-multiselectable=\"true\"\n aria-hidden={!open && !isLeaving}\n className={clsx(\n 'absolute z-10 top-[calc(100%+8px)] left-0 right-0 bg-white rounded-16 border border-lightGrey shadow-md p-12 origin-top will-change-[transform,opacity]',\n {\n 'animate-zoom-in': open,\n 'animate-zoom-out': !open && isLeaving,\n 'opacity-0 scale-90 pointer-events-none': !open && !isLeaving,\n },\n )}\n >\n {groups\n ? groups.map((group, gi) => (\n <div key={gi} className={clsx({ 'mt-16 first:mt-0': gi > 0 })}>\n {group.label && (\n <p className=\"text-b4 text-darkGrey font-semibold mb-8 ps-4\">{group.label}</p>\n )}\n {renderOptions(group.options)}\n </div>\n ))\n : renderOptions(allOptions)}\n </div>\n </div>\n </FormControl>\n );\n}\n"],"mappings":";;;;;;;;;AAUA,SAAS,EAAY,EAAE,aAAU,eAAwD;AACvF,QACE,kBAAC,QAAD;EACE,MAAM,MAAO;AACX,GAAI,MAAI,EAAG,QAAQ,EAAG,eAAe;;EAEvC,WAAW,EAAK,+BAA+B,EAAE,iBAA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ui/forms/NumberField.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as e } from "../../chunks/clsx.js";
|
|
2
2
|
import { Button as t } from "../buttons/Button.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { FormControl as n } from "./FormControl.js";
|
|
4
|
+
import { useValue as r } from "../hooks/useValue.js";
|
|
5
5
|
import { useId as i } from "react";
|
|
6
6
|
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
7
7
|
//#region lib/ui/forms/NumberField.tsx
|
|
@@ -10,7 +10,7 @@ var s = {
|
|
|
10
10
|
height: "28px"
|
|
11
11
|
};
|
|
12
12
|
function c(e) {
|
|
13
|
-
let t = i(), { id:
|
|
13
|
+
let t = i(), { id: n = t, name: a = n, value: o = 0, onChange: s, min: c = 0, max: l = 10, disabled: u = !1, dataTestId: d = "NumberField", inline: f = !0, labels: p, ...m } = e, { value: h, setValue: g } = r({
|
|
14
14
|
name: a,
|
|
15
15
|
defaultValue: o,
|
|
16
16
|
formatter: Number,
|
|
@@ -25,7 +25,7 @@ function c(e) {
|
|
|
25
25
|
};
|
|
26
26
|
return {
|
|
27
27
|
...m,
|
|
28
|
-
id:
|
|
28
|
+
id: n,
|
|
29
29
|
min: c,
|
|
30
30
|
max: l,
|
|
31
31
|
name: a,
|
|
@@ -39,13 +39,13 @@ function c(e) {
|
|
|
39
39
|
decrease: y
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
-
var l = (
|
|
43
|
-
let { disabled: i, min: l, max: u, label: d, description: f, id: p, dataTestId: m, value: h, handleChange: g, increase: _, decrease: v, errorMessage: y, validationStatus: b, hideRequiredStar: x, required: S, inline: C, labels: w, ...T } = c(
|
|
44
|
-
return /* @__PURE__ */ a(
|
|
42
|
+
var l = (r) => {
|
|
43
|
+
let { disabled: i, min: l, max: u, label: d, description: f, id: p, dataTestId: m, value: h, handleChange: g, increase: _, decrease: v, errorMessage: y, validationStatus: b, hideRequiredStar: x, required: S, inline: C, labels: w, ...T } = c(r);
|
|
44
|
+
return /* @__PURE__ */ a(n, {
|
|
45
45
|
id: p,
|
|
46
46
|
label: d,
|
|
47
47
|
description: f,
|
|
48
|
-
className: e("flex items-center",
|
|
48
|
+
className: e("flex items-center", r.className),
|
|
49
49
|
dataName: "NumberField",
|
|
50
50
|
dataTestId: m,
|
|
51
51
|
errorMessage: y,
|
package/ui/forms/Select.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { t as e } from "../../chunks/clsx.js";
|
|
2
2
|
import { useInternalStatus as t } from "../hooks/useInternalStatus.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { FormControl as n } from "./FormControl.js";
|
|
4
|
+
import { useValue as r } from "../hooks/useValue.js";
|
|
5
5
|
import { useId as i } from "react";
|
|
6
6
|
import { Icon as a } from "@clubmed/trident-icons";
|
|
7
7
|
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
8
8
|
//#region lib/ui/forms/Select.tsx
|
|
9
9
|
var c = (c) => {
|
|
10
|
-
let l = i(), { id: u = l, name: d = u, label: f, value: p, description: m, validationStatus: h = "default", iconType: g, errorMessage: _, disabled: v = !1, required: y = !1, hideRequiredStar: b, className: x, dataTestId: S = u, onChange: C, children: w, ...T } = c, { value: E, setValue: D } =
|
|
10
|
+
let l = i(), { id: u = l, name: d = u, label: f, value: p, description: m, validationStatus: h = "default", iconType: g, errorMessage: _, disabled: v = !1, required: y = !1, hideRequiredStar: b, className: x, dataTestId: S = u, onChange: C, children: w, ...T } = c, { value: E, setValue: D } = r({
|
|
11
11
|
name: d,
|
|
12
12
|
initialValue: p,
|
|
13
13
|
onChange: C
|
|
@@ -15,7 +15,7 @@ var c = (c) => {
|
|
|
15
15
|
isDisabled: v,
|
|
16
16
|
validationStatus: h
|
|
17
17
|
});
|
|
18
|
-
return /* @__PURE__ */ o(
|
|
18
|
+
return /* @__PURE__ */ o(n, {
|
|
19
19
|
id: u,
|
|
20
20
|
className: x,
|
|
21
21
|
label: f,
|
package/ui/forms/TextField.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { t as e } from "../../chunks/clsx.js";
|
|
2
2
|
import { useInternalStatus as t } from "../hooks/useInternalStatus.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { FormControl as n } from "./FormControl.js";
|
|
4
|
+
import { useValue as r } from "../hooks/useValue.js";
|
|
5
5
|
import { useId as i } from "react";
|
|
6
6
|
import { Icon as a } from "@clubmed/trident-icons";
|
|
7
7
|
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
8
8
|
//#region lib/ui/forms/TextField.tsx
|
|
9
9
|
var c = (c) => {
|
|
10
|
-
let l = i(), { id: u = l, name: d = u, label: f, value: p, description: m, validationStatus: h = "default", icon: g, iconType: _, errorMessage: v, disabled: y = !1, required: b = !1, hideRequiredStar: x, className: S, dataTestId: C = "TextField", hasDropdown: w = !1, clear: T = "", iconFirst: E = !0, onChange: D, formatter: O, ...k } = c, { value: A, setValue: j } =
|
|
10
|
+
let l = i(), { id: u = l, name: d = u, label: f, value: p, description: m, validationStatus: h = "default", icon: g, iconType: _, errorMessage: v, disabled: y = !1, required: b = !1, hideRequiredStar: x, className: S, dataTestId: C = "TextField", hasDropdown: w = !1, clear: T = "", iconFirst: E = !0, onChange: D, formatter: O, ...k } = c, { value: A, setValue: j } = r({
|
|
11
11
|
name: d,
|
|
12
12
|
initialValue: p,
|
|
13
13
|
onChange: D,
|
|
@@ -16,7 +16,7 @@ var c = (c) => {
|
|
|
16
16
|
isDisabled: y,
|
|
17
17
|
validationStatus: h
|
|
18
18
|
}), N = !y && A !== "" && A != null && !!T;
|
|
19
|
-
return /* @__PURE__ */ o(
|
|
19
|
+
return /* @__PURE__ */ o(n, {
|
|
20
20
|
id: u,
|
|
21
21
|
label: f,
|
|
22
22
|
className: S,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as e } from "../../../chunks/clsx.js";
|
|
2
2
|
import { useInternalStatus as t } from "../../hooks/useInternalStatus.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { FormControl as n } from "../FormControl.js";
|
|
4
|
+
import { useValue as r } from "../../hooks/useValue.js";
|
|
5
5
|
import { ValidationMessage as i } from "./ValidationMessage.js";
|
|
6
6
|
import { useEffect as a, useId as o, useState as s } from "react";
|
|
7
7
|
import { Icon as c } from "@clubmed/trident-icons";
|
|
@@ -11,7 +11,7 @@ function d(d) {
|
|
|
11
11
|
let f = o(), { id: p = f, name: m = p, label: h, value: g, disabled: _ = !1, required: v = !1, hideRequiredStar: y, validationStatus: b = "default", errorMessage: x, validationMessages: S = [], withoutFieldValidation: C = !1, className: w, onChange: T, dataTestId: E = "Password", ...D } = d, O = t({
|
|
12
12
|
isDisabled: _,
|
|
13
13
|
validationStatus: b
|
|
14
|
-
}), { value: k, setValue: A } =
|
|
14
|
+
}), { value: k, setValue: A } = r({
|
|
15
15
|
name: m,
|
|
16
16
|
initialValue: g,
|
|
17
17
|
onChange: T
|
|
@@ -20,7 +20,7 @@ function d(d) {
|
|
|
20
20
|
M(_ ? "password" : j);
|
|
21
21
|
}, [j, _]);
|
|
22
22
|
let N = () => M(j === "password" ? "text" : "password");
|
|
23
|
-
return /* @__PURE__ */ u(
|
|
23
|
+
return /* @__PURE__ */ u(n, {
|
|
24
24
|
className: w,
|
|
25
25
|
id: p,
|
|
26
26
|
label: h,
|