@clubmed/trident-ui 1.3.0-beta.5 → 1.3.0-beta.6
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/CHANGELOG.md +7 -0
- package/chunks/_commonjsHelpers.js +24 -4
- package/chunks/_commonjsHelpers.js.map +1 -1
- package/chunks/index.js.map +1 -1
- package/chunks/plugin.js.map +1 -1
- package/contexts/Device.d.ts +2 -22
- package/contexts/Device.js +5 -59
- package/contexts/Device.js.map +1 -1
- package/contexts/Devices/Device.d.ts +11 -0
- package/contexts/Devices/Device.js +23 -0
- package/contexts/Devices/Device.js.map +1 -0
- package/contexts/Devices/hooks/useQueries.d.ts +6 -0
- package/contexts/Devices/hooks/useQueries.js +24 -0
- package/contexts/Devices/hooks/useQueries.js.map +1 -0
- package/contexts/Devices/reducers/reducer.d.ts +25 -0
- package/contexts/Devices/reducers/reducer.js +50 -0
- package/contexts/Devices/reducers/reducer.js.map +1 -0
- package/contexts/TridentUIConfig.js +228 -228
- package/contexts/TridentUIConfig.js.map +1 -1
- package/hooks/keyboard.constants.js.map +1 -1
- package/hooks/useInternalStatus.js.map +1 -1
- package/hooks/useKeyboardControls.js.map +1 -1
- package/hooks/useSafeBoop.js.map +1 -1
- package/hooks/useValue.js.map +1 -1
- package/molecules/Arrows/Arrows.js.map +1 -1
- package/molecules/Avatar.js.map +1 -1
- package/molecules/Backdrop.js.map +1 -1
- package/molecules/Breadcrumb.js.map +1 -1
- package/molecules/Buttons/ArrowButton.js +3 -3
- package/molecules/Buttons/ArrowButton.js.map +1 -1
- package/molecules/Buttons/Button.js.map +1 -1
- package/molecules/Buttons/ButtonAnchor.js +3 -3
- package/molecules/Buttons/ButtonAnchor.js.map +1 -1
- package/molecules/Buttons/ButtonContent.js.map +1 -1
- package/molecules/Buttons/{v2/FakeButton.d.ts → FakeButton.d.ts} +2 -2
- package/molecules/Buttons/{v2/FakeButton.js → FakeButton.js} +4 -4
- package/molecules/Buttons/FakeButton.js.map +1 -0
- package/molecules/Buttons/InertButton.js +4 -4
- package/molecules/Buttons/InertButton.js.map +1 -1
- package/molecules/Buttons/v2/Button.js.map +1 -1
- package/molecules/Buttons/v2/ButtonAnchor.js.map +1 -1
- package/molecules/Card.js.map +1 -1
- package/molecules/ElasticHeight.js.map +1 -1
- package/molecules/Forms/Checkboxes/Checkbox.js.map +1 -1
- package/molecules/Forms/Checkboxes/Checkboxes.js.map +1 -1
- package/molecules/Forms/DateField.js +142 -115
- package/molecules/Forms/DateField.js.map +1 -1
- package/molecules/Forms/Filter.js.map +1 -1
- package/molecules/Forms/FormControl.js.map +1 -1
- package/molecules/Forms/FormLabel.js.map +1 -1
- package/molecules/Forms/NumberField.d.ts +1 -1
- package/molecules/Forms/NumberField.js.map +1 -1
- package/molecules/Forms/Password/Password.js.map +1 -1
- package/molecules/Forms/Password/ValidationMessage.js.map +1 -1
- package/molecules/Forms/Radios/Radio.js.map +1 -1
- package/molecules/Forms/Radios/RadioGroup.js +2 -2
- package/molecules/Forms/Radios/RadioGroup.js.map +1 -1
- package/molecules/Forms/Range.js.map +1 -1
- package/molecules/Forms/Select.js.map +1 -1
- package/molecules/Forms/Switch.js.map +1 -1
- package/molecules/Forms/TextField.js.map +1 -1
- package/molecules/HamburgerIcon.js.map +1 -1
- package/molecules/Link.js.map +1 -1
- package/molecules/Loader.js.map +1 -1
- package/molecules/Pagination.helper.js.map +1 -1
- package/molecules/Pagination.js +3 -3
- package/molecules/Pagination.js.map +1 -1
- package/molecules/Popin.js.map +1 -1
- package/molecules/Spinner.js.map +1 -1
- package/molecules/Tabs/Tab.js.map +1 -1
- package/molecules/Tabs/TabList.js.map +1 -1
- package/molecules/Tabs/TabPanel.js.map +1 -1
- package/molecules/Tabs/Tabs.js.map +1 -1
- package/molecules/Tabs/TabsBody.js.map +1 -1
- package/molecules/Tabs/context/TabControl.js.map +1 -1
- package/molecules/Tabs/hooks/tabControl.js.map +1 -1
- package/molecules/Tabs/theme.js.map +1 -1
- package/package.json +1 -1
- package/tailwind/plugins/animationDelay.js.map +1 -1
- package/tailwind/plugins/lineClampFix.js.map +1 -1
- package/tailwind/plugins/transitionBehavior.js.map +1 -1
- package/tailwind/tailwind.preset.js.map +1 -1
- package/types/Devices.d.ts +8 -0
- package/types/Devices.js +11 -0
- package/types/Devices.js.map +1 -0
- package/types/Direction.d.js +2 -0
- package/types/Direction.d.js.map +1 -0
- package/molecules/Buttons/v2/FakeButton.js.map +0 -1
|
@@ -1,154 +1,181 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { c as
|
|
3
|
-
import { useId as
|
|
4
|
-
import { Icon as
|
|
1
|
+
import { jsx as p, jsxs as T } from "react/jsx-runtime";
|
|
2
|
+
import { c as q } from "../../chunks/index.js";
|
|
3
|
+
import { useId as A, useRef as B, useState as H, useCallback as L, useEffect as J } from "react";
|
|
4
|
+
import { Icon as E } from "../../atoms/Icons/Icon.js";
|
|
5
5
|
import "@clubmed/trident-icons";
|
|
6
|
-
import { useValue as
|
|
7
|
-
import { useInternalStatus as
|
|
8
|
-
import { FormControl as
|
|
9
|
-
function
|
|
6
|
+
import { useValue as K } from "../../hooks/useValue.js";
|
|
7
|
+
import { useInternalStatus as Q } from "../../hooks/useInternalStatus.js";
|
|
8
|
+
import { FormControl as U } from "./FormControl.js";
|
|
9
|
+
function V(t) {
|
|
10
10
|
"@babel/helpers - typeof";
|
|
11
|
-
return
|
|
11
|
+
return V = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
|
|
12
12
|
return typeof e;
|
|
13
13
|
} : function(e) {
|
|
14
14
|
return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
|
|
15
|
-
},
|
|
15
|
+
}, V(t);
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function P(t, e) {
|
|
18
18
|
if (e.length < t)
|
|
19
|
-
throw new TypeError(t + " argument required, but only " + e.length + " present");
|
|
19
|
+
throw new TypeError(t + " argument" + (t > 1 ? "s" : "") + " required, but only " + e.length + " present");
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
|
|
21
|
+
function z(t) {
|
|
22
|
+
P(1, arguments);
|
|
23
23
|
var e = Object.prototype.toString.call(t);
|
|
24
|
-
return t instanceof Date ||
|
|
24
|
+
return t instanceof Date || V(t) === "object" && e === "[object Date]" ? new Date(t.getTime()) : typeof t == "number" || e === "[object Number]" ? new Date(t) : ((typeof t == "string" || e === "[object String]") && typeof console < "u" && (console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"), console.warn(new Error().stack)), /* @__PURE__ */ new Date(NaN));
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
n = "0" + n;
|
|
29
|
-
return i + n;
|
|
26
|
+
function G(t, e) {
|
|
27
|
+
return P(2, arguments), z(t).getTime() - z(e).getTime();
|
|
30
28
|
}
|
|
31
|
-
function
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
function m(t, e) {
|
|
30
|
+
for (var n = t < 0 ? "-" : "", r = Math.abs(t).toString(); r.length < e; )
|
|
31
|
+
r = "0" + r;
|
|
32
|
+
return n + r;
|
|
33
|
+
}
|
|
34
|
+
function W(t, e) {
|
|
35
|
+
var n, r;
|
|
36
|
+
P(1, arguments);
|
|
37
|
+
var a = z(t);
|
|
38
|
+
if (isNaN(a.getTime()))
|
|
36
39
|
throw new RangeError("Invalid time value");
|
|
37
|
-
var
|
|
38
|
-
if (
|
|
40
|
+
var l = String((n = e == null ? void 0 : e.format) !== null && n !== void 0 ? n : "extended"), i = String((r = e == null ? void 0 : e.representation) !== null && r !== void 0 ? r : "complete");
|
|
41
|
+
if (l !== "extended" && l !== "basic")
|
|
39
42
|
throw new RangeError("format must be 'extended' or 'basic'");
|
|
40
|
-
if (
|
|
43
|
+
if (i !== "date" && i !== "time" && i !== "complete")
|
|
41
44
|
throw new RangeError("representation must be 'date', 'time', or 'complete'");
|
|
42
|
-
var
|
|
43
|
-
if (
|
|
44
|
-
var
|
|
45
|
-
|
|
45
|
+
var f = "", g = "", y = l === "extended" ? "-" : "", j = l === "extended" ? ":" : "";
|
|
46
|
+
if (i !== "time") {
|
|
47
|
+
var o = m(a.getDate(), 2), w = m(a.getMonth() + 1, 2), C = m(a.getFullYear(), 4);
|
|
48
|
+
f = "".concat(C).concat(y).concat(w).concat(y).concat(o);
|
|
46
49
|
}
|
|
47
|
-
if (
|
|
48
|
-
var
|
|
49
|
-
if (
|
|
50
|
-
var
|
|
51
|
-
|
|
50
|
+
if (i !== "date") {
|
|
51
|
+
var b = a.getTimezoneOffset();
|
|
52
|
+
if (b !== 0) {
|
|
53
|
+
var x = Math.abs(b), u = m(Math.floor(x / 60), 2), d = m(x % 60, 2), v = b < 0 ? "+" : "-";
|
|
54
|
+
g = "".concat(v).concat(u, ":").concat(d);
|
|
52
55
|
} else
|
|
53
|
-
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
+
g = "Z";
|
|
57
|
+
var F = m(a.getHours(), 2), S = m(a.getMinutes(), 2), M = m(a.getSeconds(), 2), N = f === "" ? "" : "T", s = [F, S, M].join(j);
|
|
58
|
+
f = "".concat(f).concat(N).concat(s).concat(g);
|
|
56
59
|
}
|
|
57
|
-
return
|
|
60
|
+
return f;
|
|
58
61
|
}
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}),
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
(
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
62
|
+
const O = (t) => t ? W(new Date(t), { representation: "date" }) : "", X = (t, e, n) => {
|
|
63
|
+
if (!t)
|
|
64
|
+
return !0;
|
|
65
|
+
const r = (i) => new Date(i.getFullYear(), i.getMonth(), i.getDate()), a = new Date(t), l = r(a);
|
|
66
|
+
return !(e && l < r(e) || n && l > r(n));
|
|
67
|
+
}, ce = (t) => {
|
|
68
|
+
const e = A(), {
|
|
69
|
+
id: n = e,
|
|
70
|
+
name: r = n,
|
|
71
|
+
label: a,
|
|
72
|
+
description: l,
|
|
73
|
+
openDatepicker: i,
|
|
74
|
+
validationStatus: f = "default",
|
|
75
|
+
icon: g = "CalendarDefault",
|
|
76
|
+
iconType: y,
|
|
77
|
+
errorMessage: j,
|
|
78
|
+
disabled: o = !1,
|
|
79
|
+
required: w = !1,
|
|
80
|
+
hideRequiredStar: C,
|
|
81
|
+
dataTestId: b = "DateField",
|
|
82
|
+
value: x,
|
|
83
|
+
min: u,
|
|
84
|
+
max: d,
|
|
85
|
+
onChange: v,
|
|
86
|
+
...F
|
|
87
|
+
} = t, S = B(null), [M, N] = H(!1), s = Q({
|
|
88
|
+
isDisabled: o,
|
|
89
|
+
validationStatus: f
|
|
90
|
+
}), { setValue: h, value: D } = K({
|
|
91
|
+
name: r,
|
|
92
|
+
formatter: O,
|
|
93
|
+
initialValue: x,
|
|
94
|
+
onChange: (c, R) => v == null ? void 0 : v(c, new Date(R))
|
|
95
|
+
}), k = O(u), I = O(d), Y = (c) => {
|
|
96
|
+
h(c.target.value);
|
|
97
|
+
}, Z = () => {
|
|
98
|
+
var c;
|
|
99
|
+
(c = S.current) == null || c.showPicker();
|
|
100
|
+
}, _ = L(() => {
|
|
101
|
+
const c = new Date(D);
|
|
102
|
+
if (u && d) {
|
|
103
|
+
const R = Math.abs(G(c, u)), $ = Math.abs(G(c, d));
|
|
104
|
+
h(R <= $ ? k : I);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (u) {
|
|
108
|
+
h(k);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (d) {
|
|
112
|
+
h(I);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
}, [d, u, I, k, h, D]);
|
|
116
|
+
return J(() => {
|
|
117
|
+
!X(D, u, d) && !M && _();
|
|
118
|
+
}, [_, d, u, M, D]), /* @__PURE__ */ p(
|
|
119
|
+
U,
|
|
95
120
|
{
|
|
96
|
-
id:
|
|
97
|
-
label:
|
|
98
|
-
description:
|
|
121
|
+
id: n,
|
|
122
|
+
label: a,
|
|
123
|
+
description: l,
|
|
99
124
|
dataName: "DateField",
|
|
100
|
-
dataTestId:
|
|
101
|
-
disabled:
|
|
102
|
-
required:
|
|
103
|
-
hideRequiredStar:
|
|
104
|
-
validationStatus:
|
|
105
|
-
errorMessage:
|
|
106
|
-
children: /* @__PURE__ */
|
|
107
|
-
/* @__PURE__ */
|
|
125
|
+
dataTestId: b,
|
|
126
|
+
disabled: o,
|
|
127
|
+
required: w,
|
|
128
|
+
hideRequiredStar: C,
|
|
129
|
+
validationStatus: f,
|
|
130
|
+
errorMessage: j,
|
|
131
|
+
children: /* @__PURE__ */ T("div", { className: "relative", children: [
|
|
132
|
+
/* @__PURE__ */ p(
|
|
108
133
|
"input",
|
|
109
134
|
{
|
|
110
|
-
...
|
|
135
|
+
...F,
|
|
111
136
|
type: "date",
|
|
112
|
-
className:
|
|
137
|
+
className: q(
|
|
113
138
|
"text-b3 rounded-pill date-field min-h-[50px] w-full border px-20 py-12 ps-[52px] font-normal outline-none",
|
|
114
139
|
{
|
|
115
|
-
"border-lightGrey focus:border-black active:border-black":
|
|
116
|
-
"pe-[52px]":
|
|
117
|
-
"bg-pearl text-grey":
|
|
118
|
-
"bg-white text-black": !
|
|
119
|
-
"border-red": !
|
|
120
|
-
"border-green": !
|
|
140
|
+
"border-lightGrey focus:border-black active:border-black": s === "default",
|
|
141
|
+
"pe-[52px]": s === "error" || s === "success",
|
|
142
|
+
"bg-pearl text-grey": o,
|
|
143
|
+
"bg-white text-black": !o,
|
|
144
|
+
"border-red": !o && s === "error",
|
|
145
|
+
"border-green": !o && s === "success"
|
|
121
146
|
}
|
|
122
147
|
),
|
|
123
|
-
id:
|
|
124
|
-
disabled:
|
|
125
|
-
required:
|
|
126
|
-
ref:
|
|
127
|
-
value:
|
|
128
|
-
min:
|
|
129
|
-
max:
|
|
130
|
-
onChange:
|
|
148
|
+
id: n,
|
|
149
|
+
disabled: o,
|
|
150
|
+
required: w,
|
|
151
|
+
ref: S,
|
|
152
|
+
value: D,
|
|
153
|
+
min: k,
|
|
154
|
+
max: I,
|
|
155
|
+
onChange: Y,
|
|
156
|
+
onFocus: () => N(!0),
|
|
157
|
+
onBlur: () => N(!1)
|
|
131
158
|
}
|
|
132
159
|
),
|
|
133
|
-
/* @__PURE__ */
|
|
160
|
+
/* @__PURE__ */ T(
|
|
134
161
|
"div",
|
|
135
162
|
{
|
|
136
|
-
className:
|
|
163
|
+
className: q(
|
|
137
164
|
"pointer-events-none absolute inset-0 flex items-center justify-between px-20 py-12",
|
|
138
165
|
{
|
|
139
|
-
"text-grey":
|
|
140
|
-
"text-red": !
|
|
141
|
-
"text-green": !
|
|
166
|
+
"text-grey": o,
|
|
167
|
+
"text-red": !o && s === "error",
|
|
168
|
+
"text-green": !o && s === "success"
|
|
142
169
|
}
|
|
143
170
|
),
|
|
144
171
|
children: [
|
|
145
|
-
/* @__PURE__ */
|
|
146
|
-
/* @__PURE__ */
|
|
147
|
-
/* @__PURE__ */
|
|
172
|
+
/* @__PURE__ */ T("button", { className: "pointer-events-auto leading-none", onClick: Z, children: [
|
|
173
|
+
/* @__PURE__ */ p(E, { name: g, iconType: y, width: "24px" }),
|
|
174
|
+
/* @__PURE__ */ p("span", { className: "sr-only", children: i })
|
|
148
175
|
] }),
|
|
149
|
-
/* @__PURE__ */
|
|
150
|
-
|
|
151
|
-
|
|
176
|
+
/* @__PURE__ */ T("span", { className: "ms-auto flex gap-x-8", children: [
|
|
177
|
+
s === "error" && /* @__PURE__ */ p(E, { name: "CrossDefault", width: "24px" }),
|
|
178
|
+
s === "success" && /* @__PURE__ */ p(E, { name: "CheckDefault", width: "24px" })
|
|
152
179
|
] })
|
|
153
180
|
]
|
|
154
181
|
}
|
|
@@ -158,6 +185,6 @@ const M = (t) => t ? H(new Date(t), { representation: "date" }) : "", X = (t) =>
|
|
|
158
185
|
);
|
|
159
186
|
};
|
|
160
187
|
export {
|
|
161
|
-
|
|
188
|
+
ce as DateField
|
|
162
189
|
};
|
|
163
190
|
//# sourceMappingURL=DateField.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateField.js","sources":["../../../node_modules/@babel/runtime/helpers/esm/typeof.js","../../../node_modules/date-fns/esm/_lib/requiredArgs/index.js","../../../node_modules/date-fns/esm/toDate/index.js","../../../node_modules/date-fns/esm/_lib/addLeadingZeros/index.js","../../../node_modules/date-fns/esm/formatISO/index.js","../../../lib/molecules/Forms/DateField.tsx"],"sourcesContent":["export default function _typeof(o) {\n \"@babel/helpers - typeof\";\n\n return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) {\n return typeof o;\n } : function (o) {\n return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o;\n }, _typeof(o);\n}","export default function requiredArgs(required, args) {\n if (args.length < required) {\n throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');\n }\n}","import _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport requiredArgs from \"../_lib/requiredArgs/index.js\";\n/**\n * @name toDate\n * @category Common Helpers\n * @summary Convert the given argument to an instance of Date.\n *\n * @description\n * Convert the given argument to an instance of Date.\n *\n * If the argument is an instance of Date, the function returns its clone.\n *\n * If the argument is a number, it is treated as a timestamp.\n *\n * If the argument is none of the above, the function returns Invalid Date.\n *\n * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.\n *\n * @param {Date|Number} argument - the value to convert\n * @returns {Date} the parsed date in the local time zone\n * @throws {TypeError} 1 argument required\n *\n * @example\n * // Clone the date:\n * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))\n * //=> Tue Feb 11 2014 11:30:30\n *\n * @example\n * // Convert the timestamp to date:\n * const result = toDate(1392098430000)\n * //=> Tue Feb 11 2014 11:30:30\n */\nexport default function toDate(argument) {\n requiredArgs(1, arguments);\n var argStr = Object.prototype.toString.call(argument);\n\n // Clone the date\n if (argument instanceof Date || _typeof(argument) === 'object' && argStr === '[object Date]') {\n // Prevent the date to lose the milliseconds when passed to new Date() in IE10\n return new Date(argument.getTime());\n } else if (typeof argument === 'number' || argStr === '[object Number]') {\n return new Date(argument);\n } else {\n if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {\n // eslint-disable-next-line no-console\n console.warn(\"Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments\");\n // eslint-disable-next-line no-console\n console.warn(new Error().stack);\n }\n return new Date(NaN);\n }\n}","export default function addLeadingZeros(number, targetLength) {\n var sign = number < 0 ? '-' : '';\n var output = Math.abs(number).toString();\n while (output.length < targetLength) {\n output = '0' + output;\n }\n return sign + output;\n}","import toDate from \"../toDate/index.js\";\nimport addLeadingZeros from \"../_lib/addLeadingZeros/index.js\";\nimport requiredArgs from \"../_lib/requiredArgs/index.js\";\n/**\n * @name formatISO\n * @category Common Helpers\n * @summary Format the date according to the ISO 8601 standard (https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a003169814.htm).\n *\n * @description\n * Return the formatted date string in ISO 8601 format. Options may be passed to control the parts and notations of the date.\n *\n * @param {Date|Number} date - the original date\n * @param {Object} [options] - an object with options.\n * @param {'extended'|'basic'} [options.format='extended'] - if 'basic', hide delimiters between date and time values.\n * @param {'complete'|'date'|'time'} [options.representation='complete'] - format date, time with local time zone, or both.\n * @returns {String} the formatted date string (in local time zone)\n * @throws {TypeError} 1 argument required\n * @throws {RangeError} `date` must not be Invalid Date\n * @throws {RangeError} `options.format` must be 'extended' or 'basic'\n * @throws {RangeError} `options.representation` must be 'date', 'time' or 'complete'\n *\n * @example\n * // Represent 18 September 2019 in ISO 8601 format (local time zone is UTC):\n * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52))\n * //=> '2019-09-18T19:00:52Z'\n *\n * @example\n * // Represent 18 September 2019 in ISO 8601, short format (local time zone is UTC):\n * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { format: 'basic' })\n * //=> '20190918T190052'\n *\n * @example\n * // Represent 18 September 2019 in ISO 8601 format, date only:\n * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { representation: 'date' })\n * //=> '2019-09-18'\n *\n * @example\n * // Represent 18 September 2019 in ISO 8601 format, time only (local time zone is UTC):\n * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { representation: 'time' })\n * //=> '19:00:52Z'\n */\nexport default function formatISO(date, options) {\n var _options$format, _options$representati;\n requiredArgs(1, arguments);\n var originalDate = toDate(date);\n if (isNaN(originalDate.getTime())) {\n throw new RangeError('Invalid time value');\n }\n var format = String((_options$format = options === null || options === void 0 ? void 0 : options.format) !== null && _options$format !== void 0 ? _options$format : 'extended');\n var representation = String((_options$representati = options === null || options === void 0 ? void 0 : options.representation) !== null && _options$representati !== void 0 ? _options$representati : 'complete');\n if (format !== 'extended' && format !== 'basic') {\n throw new RangeError(\"format must be 'extended' or 'basic'\");\n }\n if (representation !== 'date' && representation !== 'time' && representation !== 'complete') {\n throw new RangeError(\"representation must be 'date', 'time', or 'complete'\");\n }\n var result = '';\n var tzOffset = '';\n var dateDelimiter = format === 'extended' ? '-' : '';\n var timeDelimiter = format === 'extended' ? ':' : '';\n\n // Representation is either 'date' or 'complete'\n if (representation !== 'time') {\n var day = addLeadingZeros(originalDate.getDate(), 2);\n var month = addLeadingZeros(originalDate.getMonth() + 1, 2);\n var year = addLeadingZeros(originalDate.getFullYear(), 4);\n\n // yyyyMMdd or yyyy-MM-dd.\n result = \"\".concat(year).concat(dateDelimiter).concat(month).concat(dateDelimiter).concat(day);\n }\n\n // Representation is either 'time' or 'complete'\n if (representation !== 'date') {\n // Add the timezone.\n var offset = originalDate.getTimezoneOffset();\n if (offset !== 0) {\n var absoluteOffset = Math.abs(offset);\n var hourOffset = addLeadingZeros(Math.floor(absoluteOffset / 60), 2);\n var minuteOffset = addLeadingZeros(absoluteOffset % 60, 2);\n // If less than 0, the sign is +, because it is ahead of time.\n var sign = offset < 0 ? '+' : '-';\n tzOffset = \"\".concat(sign).concat(hourOffset, \":\").concat(minuteOffset);\n } else {\n tzOffset = 'Z';\n }\n var hour = addLeadingZeros(originalDate.getHours(), 2);\n var minute = addLeadingZeros(originalDate.getMinutes(), 2);\n var second = addLeadingZeros(originalDate.getSeconds(), 2);\n\n // If there's also date, separate it with time with 'T'\n var separator = result === '' ? '' : 'T';\n\n // Creates a time string consisting of hour, minute, and second, separated by delimiters, if defined.\n var time = [hour, minute, second].join(timeDelimiter);\n\n // HHmmss or HH:mm:ss.\n result = \"\".concat(result).concat(separator).concat(time).concat(tzOffset);\n }\n return result;\n}","import classnames from 'classnames';\nimport { formatISO } from 'date-fns';\nimport { type ChangeEvent, useId, useRef } from 'react';\nimport { Icon, type IconicNames, type IconicTypes } from '@/atoms/Icons';\n\nimport { useValue } from '@/hooks/useValue.js';\nimport { useInternalStatus } from '@/hooks/useInternalStatus.js';\nimport { FormControl, type FormControlProps } from './FormControl.js';\n\ninterface DateFieldProps extends Omit<FormControlProps<Date | null>, 'max' | 'min'> {\n description?: string;\n /**\n * Open datepicker text\n */\n openDatepicker?: string;\n id?: string;\n icon?: IconicNames;\n iconType?: IconicTypes;\n errorMessage?: string;\n dataTestId?: string;\n /**\n * Minimum Date allowed\n */\n min?: Date | undefined;\n /**\n * Maximum Date allowed\n */\n max?: Date | undefined;\n}\n\nconst formatDate = (value: Date | number | undefined | null): string => {\n if (!value) {\n return '';\n }\n\n return formatISO(new Date(value), { representation: 'date' });\n};\n\nexport const DateField = (props: DateFieldProps) => {\n const internalId = useId();\n\n const {\n id = internalId,\n name = id,\n label,\n description,\n openDatepicker,\n validationStatus = 'default',\n icon = 'CalendarDefault',\n iconType,\n errorMessage,\n disabled = false,\n required = false,\n hideRequiredStar,\n dataTestId = 'DateField',\n value: initialValue,\n min: initialMin,\n max: initialMax,\n onChange,\n ...rest\n } = props;\n\n // NO LOGIC IS IMPLEMENTED YET HERE\n // THIS IS A VISUAL COMPONENT ONLY\n const ref = useRef<HTMLInputElement>(null);\n const internalStatus = useInternalStatus({\n isDisabled: disabled,\n validationStatus,\n });\n\n const { setValue, value } = useValue<string, Date | number | undefined | null>({\n name,\n formatter: formatDate as never,\n initialValue,\n onChange: (name, value) => onChange?.(name, new Date(value)),\n });\n\n const min = formatDate(initialMin);\n const max = formatDate(initialMax);\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n setValue(event.target.value);\n };\n\n const handleClickPicker = () => {\n ref.current?.showPicker();\n };\n\n return (\n <FormControl\n id={id}\n label={label}\n description={description}\n dataName=\"DateField\"\n dataTestId={dataTestId}\n disabled={disabled}\n required={required}\n hideRequiredStar={hideRequiredStar}\n validationStatus={validationStatus}\n errorMessage={errorMessage}\n >\n <div className=\"relative\">\n <input\n {...rest}\n type=\"date\"\n className={classnames(\n 'text-b3 rounded-pill date-field min-h-[50px] w-full border px-20 py-12 ps-[52px] font-normal outline-none',\n {\n 'border-lightGrey focus:border-black active:border-black':\n internalStatus === 'default',\n 'pe-[52px]': internalStatus === 'error' || internalStatus === 'success',\n 'bg-pearl text-grey': disabled,\n 'bg-white text-black': !disabled,\n 'border-red': !disabled && internalStatus === 'error',\n 'border-green': !disabled && internalStatus === 'success',\n },\n )}\n id={id}\n disabled={disabled}\n required={required}\n ref={ref}\n value={value}\n min={min}\n max={max}\n onChange={handleChange}\n />\n <div\n className={classnames(\n 'pointer-events-none absolute inset-0 flex items-center justify-between px-20 py-12',\n {\n 'text-grey': disabled,\n 'text-red': !disabled && internalStatus === 'error',\n 'text-green': !disabled && internalStatus === 'success',\n },\n )}\n >\n <button className=\"pointer-events-auto leading-none\" onClick={handleClickPicker}>\n <Icon name={icon} iconType={iconType} width=\"24px\" />\n <span className=\"sr-only\">\n {openDatepicker}\n {/* REPLACE THAT WITH SOMETHING LIKE \"OPEN DATEPICKER\" SOONER RATHER THAN LATER PLZ */}\n </span>\n </button>\n <span className=\"ms-auto flex gap-x-8\">\n {internalStatus === 'error' && <Icon name=\"CrossDefault\" width=\"24px\" />}\n {internalStatus === 'success' && <Icon name=\"CheckDefault\" width=\"24px\" />}\n </span>\n </div>\n </div>\n </FormControl>\n );\n};\n"],"names":["_typeof","o","requiredArgs","required","args","toDate","argument","argStr","addLeadingZeros","number","targetLength","sign","output","formatISO","date","options","_options$format","_options$representati","originalDate","format","representation","result","tzOffset","dateDelimiter","timeDelimiter","day","month","year","offset","absoluteOffset","hourOffset","minuteOffset","hour","minute","second","separator","time","formatDate","value","DateField","props","internalId","useId","id","name","label","description","openDatepicker","validationStatus","icon","iconType","errorMessage","disabled","hideRequiredStar","dataTestId","initialValue","initialMin","initialMax","onChange","rest","ref","useRef","internalStatus","useInternalStatus","setValue","useValue","min","max","handleChange","event","handleClickPicker","_a","jsx","FormControl","jsxs","classnames","Icon"],"mappings":";;;;;;;;AAAe,SAASA,EAAQC,GAAG;AACjC;AAEA,SAAOD,IAAwB,OAAO,UAArB,cAA2C,OAAO,OAAO,YAA1B,WAAqC,SAAUC,GAAG;AAChG,WAAO,OAAOA;AAAA,EACf,IAAG,SAAUA,GAAG;AACf,WAAOA,KAAmB,OAAO,UAArB,cAA+BA,EAAE,gBAAgB,UAAUA,MAAM,OAAO,YAAY,WAAW,OAA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QAAK,EAAA,WAAU,wBACb,UAAA;AAAA,gBAAAZ,MAAmB,WAAY,gBAAAU,EAAAI,GAAA,EAAK,MAAK,gBAAe,OAAM,QAAO;AAAA,gBACrEd,MAAmB,aAAa,gBAAAU,EAACI,KAAK,MAAK,gBAAe,OAAM,QAAO;AAAA,cAAA,GAC1E;AAAA,YAAA;AAAA,UAAA;AAAA,QACF;AAAA,MAAA,GACF;AAAA,IAAA;AAAA,EAAA;AAGN;","x_google_ignoreList":[0,1,2,3,4]}
|
|
1
|
+
{"version":3,"file":"DateField.js","sources":["../../../node_modules/@babel/runtime/helpers/esm/typeof.js","../../../node_modules/date-fns/esm/_lib/requiredArgs/index.js","../../../node_modules/date-fns/esm/toDate/index.js","../../../node_modules/date-fns/esm/differenceInMilliseconds/index.js","../../../node_modules/date-fns/esm/_lib/addLeadingZeros/index.js","../../../node_modules/date-fns/esm/formatISO/index.js","../../../lib/molecules/Forms/DateField.tsx"],"sourcesContent":["export default function _typeof(o) {\n \"@babel/helpers - typeof\";\n\n return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) {\n return typeof o;\n } : function (o) {\n return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o;\n }, _typeof(o);\n}","export default function requiredArgs(required, args) {\n if (args.length < required) {\n throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');\n }\n}","import _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport requiredArgs from \"../_lib/requiredArgs/index.js\";\n/**\n * @name toDate\n * @category Common Helpers\n * @summary Convert the given argument to an instance of Date.\n *\n * @description\n * Convert the given argument to an instance of Date.\n *\n * If the argument is an instance of Date, the function returns its clone.\n *\n * If the argument is a number, it is treated as a timestamp.\n *\n * If the argument is none of the above, the function returns Invalid Date.\n *\n * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.\n *\n * @param {Date|Number} argument - the value to convert\n * @returns {Date} the parsed date in the local time zone\n * @throws {TypeError} 1 argument required\n *\n * @example\n * // Clone the date:\n * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))\n * //=> Tue Feb 11 2014 11:30:30\n *\n * @example\n * // Convert the timestamp to date:\n * const result = toDate(1392098430000)\n * //=> Tue Feb 11 2014 11:30:30\n */\nexport default function toDate(argument) {\n requiredArgs(1, arguments);\n var argStr = Object.prototype.toString.call(argument);\n\n // Clone the date\n if (argument instanceof Date || _typeof(argument) === 'object' && argStr === '[object Date]') {\n // Prevent the date to lose the milliseconds when passed to new Date() in IE10\n return new Date(argument.getTime());\n } else if (typeof argument === 'number' || argStr === '[object Number]') {\n return new Date(argument);\n } else {\n if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {\n // eslint-disable-next-line no-console\n console.warn(\"Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments\");\n // eslint-disable-next-line no-console\n console.warn(new Error().stack);\n }\n return new Date(NaN);\n }\n}","import toDate from \"../toDate/index.js\";\nimport requiredArgs from \"../_lib/requiredArgs/index.js\";\n/**\n * @name differenceInMilliseconds\n * @category Millisecond Helpers\n * @summary Get the number of milliseconds between the given dates.\n *\n * @description\n * Get the number of milliseconds between the given dates.\n *\n * @param {Date|Number} dateLeft - the later date\n * @param {Date|Number} dateRight - the earlier date\n * @returns {Number} the number of milliseconds\n * @throws {TypeError} 2 arguments required\n *\n * @example\n * // How many milliseconds are between\n * // 2 July 2014 12:30:20.600 and 2 July 2014 12:30:21.700?\n * const result = differenceInMilliseconds(\n * new Date(2014, 6, 2, 12, 30, 21, 700),\n * new Date(2014, 6, 2, 12, 30, 20, 600)\n * )\n * //=> 1100\n */\nexport default function differenceInMilliseconds(dateLeft, dateRight) {\n requiredArgs(2, arguments);\n return toDate(dateLeft).getTime() - toDate(dateRight).getTime();\n}","export default function addLeadingZeros(number, targetLength) {\n var sign = number < 0 ? '-' : '';\n var output = Math.abs(number).toString();\n while (output.length < targetLength) {\n output = '0' + output;\n }\n return sign + output;\n}","import toDate from \"../toDate/index.js\";\nimport addLeadingZeros from \"../_lib/addLeadingZeros/index.js\";\nimport requiredArgs from \"../_lib/requiredArgs/index.js\";\n/**\n * @name formatISO\n * @category Common Helpers\n * @summary Format the date according to the ISO 8601 standard (https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a003169814.htm).\n *\n * @description\n * Return the formatted date string in ISO 8601 format. Options may be passed to control the parts and notations of the date.\n *\n * @param {Date|Number} date - the original date\n * @param {Object} [options] - an object with options.\n * @param {'extended'|'basic'} [options.format='extended'] - if 'basic', hide delimiters between date and time values.\n * @param {'complete'|'date'|'time'} [options.representation='complete'] - format date, time with local time zone, or both.\n * @returns {String} the formatted date string (in local time zone)\n * @throws {TypeError} 1 argument required\n * @throws {RangeError} `date` must not be Invalid Date\n * @throws {RangeError} `options.format` must be 'extended' or 'basic'\n * @throws {RangeError} `options.representation` must be 'date', 'time' or 'complete'\n *\n * @example\n * // Represent 18 September 2019 in ISO 8601 format (local time zone is UTC):\n * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52))\n * //=> '2019-09-18T19:00:52Z'\n *\n * @example\n * // Represent 18 September 2019 in ISO 8601, short format (local time zone is UTC):\n * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { format: 'basic' })\n * //=> '20190918T190052'\n *\n * @example\n * // Represent 18 September 2019 in ISO 8601 format, date only:\n * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { representation: 'date' })\n * //=> '2019-09-18'\n *\n * @example\n * // Represent 18 September 2019 in ISO 8601 format, time only (local time zone is UTC):\n * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { representation: 'time' })\n * //=> '19:00:52Z'\n */\nexport default function formatISO(date, options) {\n var _options$format, _options$representati;\n requiredArgs(1, arguments);\n var originalDate = toDate(date);\n if (isNaN(originalDate.getTime())) {\n throw new RangeError('Invalid time value');\n }\n var format = String((_options$format = options === null || options === void 0 ? void 0 : options.format) !== null && _options$format !== void 0 ? _options$format : 'extended');\n var representation = String((_options$representati = options === null || options === void 0 ? void 0 : options.representation) !== null && _options$representati !== void 0 ? _options$representati : 'complete');\n if (format !== 'extended' && format !== 'basic') {\n throw new RangeError(\"format must be 'extended' or 'basic'\");\n }\n if (representation !== 'date' && representation !== 'time' && representation !== 'complete') {\n throw new RangeError(\"representation must be 'date', 'time', or 'complete'\");\n }\n var result = '';\n var tzOffset = '';\n var dateDelimiter = format === 'extended' ? '-' : '';\n var timeDelimiter = format === 'extended' ? ':' : '';\n\n // Representation is either 'date' or 'complete'\n if (representation !== 'time') {\n var day = addLeadingZeros(originalDate.getDate(), 2);\n var month = addLeadingZeros(originalDate.getMonth() + 1, 2);\n var year = addLeadingZeros(originalDate.getFullYear(), 4);\n\n // yyyyMMdd or yyyy-MM-dd.\n result = \"\".concat(year).concat(dateDelimiter).concat(month).concat(dateDelimiter).concat(day);\n }\n\n // Representation is either 'time' or 'complete'\n if (representation !== 'date') {\n // Add the timezone.\n var offset = originalDate.getTimezoneOffset();\n if (offset !== 0) {\n var absoluteOffset = Math.abs(offset);\n var hourOffset = addLeadingZeros(Math.floor(absoluteOffset / 60), 2);\n var minuteOffset = addLeadingZeros(absoluteOffset % 60, 2);\n // If less than 0, the sign is +, because it is ahead of time.\n var sign = offset < 0 ? '+' : '-';\n tzOffset = \"\".concat(sign).concat(hourOffset, \":\").concat(minuteOffset);\n } else {\n tzOffset = 'Z';\n }\n var hour = addLeadingZeros(originalDate.getHours(), 2);\n var minute = addLeadingZeros(originalDate.getMinutes(), 2);\n var second = addLeadingZeros(originalDate.getSeconds(), 2);\n\n // If there's also date, separate it with time with 'T'\n var separator = result === '' ? '' : 'T';\n\n // Creates a time string consisting of hour, minute, and second, separated by delimiters, if defined.\n var time = [hour, minute, second].join(timeDelimiter);\n\n // HHmmss or HH:mm:ss.\n result = \"\".concat(result).concat(separator).concat(time).concat(tzOffset);\n }\n return result;\n}","import classnames from 'classnames';\nimport { differenceInMilliseconds, formatISO } from 'date-fns';\nimport { type ChangeEvent, useCallback, useEffect, useId, useRef, useState } from 'react';\nimport { Icon, type IconicNames, type IconicTypes } from '@/atoms/Icons';\n\nimport { useValue } from '@/hooks/useValue.js';\nimport { useInternalStatus } from '@/hooks/useInternalStatus.js';\nimport { FormControl, type FormControlProps } from './FormControl.js';\n\ninterface DateFieldProps extends Omit<FormControlProps<Date | null>, 'max' | 'min'> {\n description?: string;\n /**\n * Open datepicker text\n */\n openDatepicker?: string;\n id?: string;\n icon?: IconicNames;\n iconType?: IconicTypes;\n errorMessage?: string;\n dataTestId?: string;\n /**\n * Minimum Date allowed\n */\n min?: Date | undefined;\n /**\n * Maximum Date allowed\n */\n max?: Date | undefined;\n}\n\nconst formatDate = (value: Date | number | undefined | null): string => {\n if (!value) {\n return '';\n }\n\n return formatISO(new Date(value), { representation: 'date' });\n};\n\nconst validateDateRange = (date: string, min?: Date, max?: Date): boolean => {\n if (!date) {\n return true;\n }\n\n const normalizeDate = (d: Date) => new Date(d.getFullYear(), d.getMonth(), d.getDate());\n const inputDate = new Date(date);\n const normalizedInputDate = normalizeDate(inputDate);\n\n if (min && normalizedInputDate < normalizeDate(min)) {\n return false;\n }\n if (max && normalizedInputDate > normalizeDate(max)) {\n return false;\n }\n\n return true;\n};\n\nexport const DateField = (props: DateFieldProps) => {\n const internalId = useId();\n\n const {\n id = internalId,\n name = id,\n label,\n description,\n openDatepicker,\n validationStatus = 'default',\n icon = 'CalendarDefault',\n iconType,\n errorMessage,\n disabled = false,\n required = false,\n hideRequiredStar,\n dataTestId = 'DateField',\n value: initialValue,\n min: initialMin,\n max: initialMax,\n onChange,\n ...rest\n } = props;\n\n // NO LOGIC IS IMPLEMENTED YET HERE\n // THIS IS A VISUAL COMPONENT ONLY\n const ref = useRef<HTMLInputElement>(null);\n const [isFocused, setIsFocused] = useState<boolean>(false);\n\n const internalStatus = useInternalStatus({\n isDisabled: disabled,\n validationStatus,\n });\n\n const { setValue, value } = useValue<string, Date | number | undefined | null>({\n name,\n formatter: formatDate as never,\n initialValue,\n onChange: (name, value) => onChange?.(name, new Date(value)),\n });\n\n const min = formatDate(initialMin);\n const max = formatDate(initialMax);\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n setValue(event.target.value);\n };\n\n const handleClickPicker = () => {\n ref.current?.showPicker();\n };\n\n const handleOutOfRangeDate = useCallback(() => {\n const currentDate = new Date(value);\n\n if (initialMin && initialMax) {\n const distanceToMin = Math.abs(differenceInMilliseconds(currentDate, initialMin));\n const distanceToMax = Math.abs(differenceInMilliseconds(currentDate, initialMax));\n setValue(distanceToMin <= distanceToMax ? min : max);\n return;\n }\n\n if (initialMin) {\n setValue(min);\n return;\n }\n\n if (initialMax) {\n setValue(max);\n return;\n }\n }, [initialMax, initialMin, max, min, setValue, value]);\n\n useEffect(() => {\n const isValid = validateDateRange(value, initialMin, initialMax);\n if (!isValid && !isFocused) {\n handleOutOfRangeDate();\n }\n }, [handleOutOfRangeDate, initialMax, initialMin, isFocused, value]);\n\n return (\n <FormControl\n id={id}\n label={label}\n description={description}\n dataName=\"DateField\"\n dataTestId={dataTestId}\n disabled={disabled}\n required={required}\n hideRequiredStar={hideRequiredStar}\n validationStatus={validationStatus}\n errorMessage={errorMessage}\n >\n <div className=\"relative\">\n <input\n {...rest}\n type=\"date\"\n className={classnames(\n 'text-b3 rounded-pill date-field min-h-[50px] w-full border px-20 py-12 ps-[52px] font-normal outline-none',\n {\n 'border-lightGrey focus:border-black active:border-black':\n internalStatus === 'default',\n 'pe-[52px]': internalStatus === 'error' || internalStatus === 'success',\n 'bg-pearl text-grey': disabled,\n 'bg-white text-black': !disabled,\n 'border-red': !disabled && internalStatus === 'error',\n 'border-green': !disabled && internalStatus === 'success',\n },\n )}\n id={id}\n disabled={disabled}\n required={required}\n ref={ref}\n value={value}\n min={min}\n max={max}\n onChange={handleChange}\n onFocus={() => setIsFocused(true)}\n onBlur={() => setIsFocused(false)}\n />\n <div\n className={classnames(\n 'pointer-events-none absolute inset-0 flex items-center justify-between px-20 py-12',\n {\n 'text-grey': disabled,\n 'text-red': !disabled && internalStatus === 'error',\n 'text-green': !disabled && internalStatus === 'success',\n },\n )}\n >\n <button className=\"pointer-events-auto leading-none\" onClick={handleClickPicker}>\n <Icon name={icon} iconType={iconType} width=\"24px\" />\n <span className=\"sr-only\">\n {openDatepicker}\n {/* REPLACE THAT WITH SOMETHING LIKE \"OPEN DATEPICKER\" SOONER RATHER THAN LATER PLZ */}\n </span>\n </button>\n <span className=\"ms-auto flex gap-x-8\">\n {internalStatus === 'error' && <Icon name=\"CrossDefault\" width=\"24px\" />}\n {internalStatus === 'success' && <Icon name=\"CheckDefault\" width=\"24px\" />}\n </span>\n </div>\n </div>\n </FormControl>\n );\n};\n"],"names":["_typeof","o","requiredArgs","required","args","toDate","argument","argStr","differenceInMilliseconds","dateLeft","dateRight","addLeadingZeros","number","targetLength","sign","output","formatISO","date","options","_options$format","_options$representati","originalDate","format","representation","result","tzOffset","dateDelimiter","timeDelimiter","day","month","year","offset","absoluteOffset","hourOffset","minuteOffset","hour","minute","second","separator","time","formatDate","value","validateDateRange","min","max","normalizeDate","d","inputDate","normalizedInputDate","DateField","props","internalId","useId","id","name","label","description","openDatepicker","validationStatus","icon","iconType","errorMessage","disabled","hideRequiredStar","dataTestId","initialValue","initialMin","initialMax","onChange","rest","ref","useRef","isFocused","setIsFocused","useState","internalStatus","useInternalStatus","setValue","useValue","handleChange","event","handleClickPicker","_a","handleOutOfRangeDate","useCallback","currentDate","distanceToMin","distanceToMax","useEffect","jsx","FormControl","jsxs","classnames","Icon"],"mappings":";;;;;;;;AAAe,SAASA,EAAQC,GAAG;AACjC;AAEA,SAAOD,IAAwB,OAAO,UAArB,cAA2C,OAAO,OAAO,YAA1B,WAAqC,SAAUC,GAAG;AAChG,WAAO,OAAOA;AAAA,EAChB,IAAI,SAAUA,GAAG;AACf,WAAOA,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MlC,GAAM,UAAAC,GAAoB,OAAM,QAAO;AAAA,gBACnD,gBAAA6B,EAAC,QAAA,EAAK,WAAU,WACb,UAAAhC,EAAA,CAEH;AAAA,cAAA,GACF;AAAA,cACA,gBAAAkC,EAAC,QAAA,EAAK,WAAU,wBACb,UAAA;AAAA,gBAAAhB,MAAmB,WAAW,gBAAAc,EAACI,GAAA,EAAK,MAAK,gBAAe,OAAM,QAAO;AAAA,gBACrElB,MAAmB,aAAa,gBAAAc,EAACI,KAAK,MAAK,gBAAe,OAAM,OAAA,CAAO;AAAA,cAAA,EAAA,CAC1E;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACF,EAAA,CACF;AAAA,IAAA;AAAA,EAAA;AAGN;","x_google_ignoreList":[0,1,2,3,4,5]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Filter.js","sources":["../../../lib/molecules/Forms/Filter.tsx"],"sourcesContent":["import classnames from 'classnames';\nimport { type InputHTMLAttributes, useId } from 'react';\nimport './controls.css';\nimport { Icon } from '@/atoms/Icons';\nimport { useValue } from '@/hooks/useValue.js';\n\nexport interface FilterProps<Value = string>\n extends Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange'> {\n /**\n * The data-testid to apply to the button.\n * This is used for testing purposes.\n * */\n dataTestId?: string;\n /**\n * Is it attached to a dropdown?\n */\n hasDropdown?: boolean;\n\n onChange?: (name: string, value: Value | null) => void;\n}\n\nexport function Filter<Value = string>(props: FilterProps<Value>) {\n const internalId = useId();\n\n const {\n id = internalId,\n name = id,\n className,\n dataTestId,\n disabled,\n checked: initialChecked = false,\n value,\n tabIndex = 0,\n onChange,\n hasDropdown,\n children,\n ...rest\n } = props;\n\n const { value: checked, setValue } = useValue<boolean>({\n name,\n initialValue: initialChecked,\n onChange(name, checked) {\n onChange?.(name, checked ? ((value !== undefined ? value : checked) as Value) : null);\n },\n });\n\n return (\n <label className={classnames(className, 'relative')}>\n <input\n {...rest}\n name={name}\n data-testid={dataTestId}\n type=\"checkbox\"\n tabIndex={tabIndex}\n onChange={() => {\n !disabled && setValue(!checked);\n }}\n checked={checked}\n data-name=\"Filter\"\n disabled={disabled}\n value={value}\n />\n <span>\n <span className={classnames('text-b3 font-semibold')}>{children}</span>\n <Icon width={null} name=\"CheckDefault\" color=\"black\" />\n {hasDropdown && (\n <Icon name=\"ArrowDefaultDown\" className=\"ml-8\" width=\"24px\" color=\"black\" />\n )}\n </span>\n </label>\n );\n}\n"],"names":["Filter","props","internalId","useId","id","name","className","dataTestId","disabled","initialChecked","value","tabIndex","onChange","hasDropdown","children","rest","checked","setValue","useValue","classnames","jsx","Icon"],"mappings":";;;;;;;AAqBO,SAASA,EAAuBC,GAA2B;AAChE,QAAMC,IAAaC,
|
|
1
|
+
{"version":3,"file":"Filter.js","sources":["../../../lib/molecules/Forms/Filter.tsx"],"sourcesContent":["import classnames from 'classnames';\nimport { type InputHTMLAttributes, useId } from 'react';\nimport './controls.css';\nimport { Icon } from '@/atoms/Icons';\nimport { useValue } from '@/hooks/useValue.js';\n\nexport interface FilterProps<Value = string>\n extends Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange'> {\n /**\n * The data-testid to apply to the button.\n * This is used for testing purposes.\n * */\n dataTestId?: string;\n /**\n * Is it attached to a dropdown?\n */\n hasDropdown?: boolean;\n\n onChange?: (name: string, value: Value | null) => void;\n}\n\nexport function Filter<Value = string>(props: FilterProps<Value>) {\n const internalId = useId();\n\n const {\n id = internalId,\n name = id,\n className,\n dataTestId,\n disabled,\n checked: initialChecked = false,\n value,\n tabIndex = 0,\n onChange,\n hasDropdown,\n children,\n ...rest\n } = props;\n\n const { value: checked, setValue } = useValue<boolean>({\n name,\n initialValue: initialChecked,\n onChange(name, checked) {\n onChange?.(name, checked ? ((value !== undefined ? value : checked) as Value) : null);\n },\n });\n\n return (\n <label className={classnames(className, 'relative')}>\n <input\n {...rest}\n name={name}\n data-testid={dataTestId}\n type=\"checkbox\"\n tabIndex={tabIndex}\n onChange={() => {\n !disabled && setValue(!checked);\n }}\n checked={checked}\n data-name=\"Filter\"\n disabled={disabled}\n value={value}\n />\n <span>\n <span className={classnames('text-b3 font-semibold')}>{children}</span>\n <Icon width={null} name=\"CheckDefault\" color=\"black\" />\n {hasDropdown && (\n <Icon name=\"ArrowDefaultDown\" className=\"ml-8\" width=\"24px\" color=\"black\" />\n )}\n </span>\n </label>\n );\n}\n"],"names":["Filter","props","internalId","useId","id","name","className","dataTestId","disabled","initialChecked","value","tabIndex","onChange","hasDropdown","children","rest","checked","setValue","useValue","classnames","jsx","Icon"],"mappings":";;;;;;;AAqBO,SAASA,EAAuBC,GAA2B;AAChE,QAAMC,IAAaC,EAAA,GAEb;AAAA,IACJ,IAAAC,IAAKF;AAAA,IACL,MAAAG,IAAOD;AAAA,IACP,WAAAE;AAAA,IACA,YAAAC;AAAA,IACA,UAAAC;AAAA,IACA,SAASC,IAAiB;AAAA,IAC1B,OAAAC;AAAA,IACA,UAAAC,IAAW;AAAA,IACX,UAAAC;AAAA,IACA,aAAAC;AAAA,IACA,UAAAC;AAAA,IACA,GAAGC;AAAA,EAAA,IACDd,GAEE,EAAE,OAAOe,GAAS,UAAAC,EAAA,IAAaC,EAAkB;AAAA,IACrD,MAAAb;AAAA,IACA,cAAcI;AAAA,IACd,SAASJ,GAAMW,GAAS;AACtB,MAAAJ,KAAA,QAAAA,EAAWP,GAAMW,IAAYN,MAAU,SAAYA,IAAQM,IAAqB;AAAA,IAClF;AAAA,EAAA,CACD;AAED,2BACG,SAAA,EAAM,WAAWG,EAAWb,GAAW,UAAU,GAChD,UAAA;AAAA,IAAA,gBAAAc;AAAA,MAAC;AAAA,MAAA;AAAA,QACE,GAAGL;AAAA,QACJ,MAAAV;AAAA,QACA,eAAaE;AAAA,QACb,MAAK;AAAA,QACL,UAAAI;AAAA,QACA,UAAU,MAAM;AACd,WAACH,KAAYS,EAAS,CAACD,CAAO;AAAA,QAChC;AAAA,QACA,SAAAA;AAAA,QACA,aAAU;AAAA,QACV,UAAAR;AAAA,QACA,OAAAE;AAAA,MAAA;AAAA,IAAA;AAAA,sBAED,QAAA,EACC,UAAA;AAAA,MAAA,gBAAAU,EAAC,QAAA,EAAK,WAAWD,EAAW,uBAAuB,GAAI,UAAAL,GAAS;AAAA,wBAC/DO,GAAA,EAAK,OAAO,MAAM,MAAK,gBAAe,OAAM,SAAQ;AAAA,MACpDR,KACC,gBAAAO,EAACC,GAAA,EAAK,MAAK,oBAAmB,WAAU,QAAO,OAAM,QAAO,OAAM,QAAA,CAAQ;AAAA,IAAA,EAAA,CAE9E;AAAA,EAAA,GACF;AAEJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormControl.js","sources":["../../../lib/molecules/Forms/FormControl.tsx"],"sourcesContent":["import type { HTMLAttributes, InputHTMLAttributes, ReactNode } from 'react';\nimport { useInternalStatus, type ValidationStatus } from '@/hooks/useInternalStatus';\nimport { FormLabel, type FormLabelProps } from './FormLabel';\nimport { Icon } from '@/atoms/Icons';\nimport classnames from 'classnames';\n\nexport type FormControlProps<\n Value = unknown,\n Attributes extends HTMLAttributes<HTMLElement> = InputHTMLAttributes<HTMLInputElement>,\n> = {\n value?: Value;\n label?: ReactNode;\n validationStatus?: ValidationStatus;\n onChange?: (name: string, value: Value) => void;\n dataTestId?: string;\n dataName?: string;\n errorMessage?: string;\n} & Omit<Attributes & Partial<FormLabelProps>, 'onChange' | 'value'>;\n\nexport const FormControl = <Value = string,>({\n id,\n label,\n description,\n disabled,\n required,\n className,\n validationStatus = 'default',\n children,\n errorMessage,\n dataTestId,\n dataName,\n hideRequiredStar,\n layout,\n}: FormControlProps<Value>) => {\n const internalStatus = useInternalStatus({\n isDisabled: !!disabled,\n validationStatus,\n });\n\n const shouldDisplayErrorMessage = internalStatus === 'error' && errorMessage;\n\n return (\n <div\n className={classnames('flex flex-col gap-4', className)}\n data-name={dataName}\n data-testid={dataTestId}\n >\n {label && id && (\n <FormLabel\n description={description}\n id={id}\n layout={layout}\n required={required}\n hideRequiredStar={hideRequiredStar}\n >\n {label}\n </FormLabel>\n )}\n\n {children}\n\n {shouldDisplayErrorMessage && (\n <span className=\"text-red text-b4 flex items-start gap-x-4 px-20\">\n <Icon name=\"Error\" width=\"20px\" />\n {errorMessage}\n </span>\n )}\n </div>\n );\n};\n"],"names":["FormControl","id","label","description","disabled","required","className","validationStatus","children","errorMessage","dataTestId","dataName","hideRequiredStar","layout","shouldDisplayErrorMessage","useInternalStatus","jsxs","classnames","jsx","FormLabel","Icon"],"mappings":";;;;;;AAmBO,MAAMA,IAAc,CAAkB;AAAA,EAC3C,IAAAC;AAAA,EACA,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,kBAAAC,IAAmB;AAAA,EACnB,UAAAC;AAAA,EACA,cAAAC;AAAA,EACA,YAAAC;AAAA,EACA,UAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,QAAAC;AACF,MAA+B;
|
|
1
|
+
{"version":3,"file":"FormControl.js","sources":["../../../lib/molecules/Forms/FormControl.tsx"],"sourcesContent":["import type { HTMLAttributes, InputHTMLAttributes, ReactNode } from 'react';\nimport { useInternalStatus, type ValidationStatus } from '@/hooks/useInternalStatus';\nimport { FormLabel, type FormLabelProps } from './FormLabel';\nimport { Icon } from '@/atoms/Icons';\nimport classnames from 'classnames';\n\nexport type FormControlProps<\n Value = unknown,\n Attributes extends HTMLAttributes<HTMLElement> = InputHTMLAttributes<HTMLInputElement>,\n> = {\n value?: Value;\n label?: ReactNode;\n validationStatus?: ValidationStatus;\n onChange?: (name: string, value: Value) => void;\n dataTestId?: string;\n dataName?: string;\n errorMessage?: string;\n} & Omit<Attributes & Partial<FormLabelProps>, 'onChange' | 'value'>;\n\nexport const FormControl = <Value = string,>({\n id,\n label,\n description,\n disabled,\n required,\n className,\n validationStatus = 'default',\n children,\n errorMessage,\n dataTestId,\n dataName,\n hideRequiredStar,\n layout,\n}: FormControlProps<Value>) => {\n const internalStatus = useInternalStatus({\n isDisabled: !!disabled,\n validationStatus,\n });\n\n const shouldDisplayErrorMessage = internalStatus === 'error' && errorMessage;\n\n return (\n <div\n className={classnames('flex flex-col gap-4', className)}\n data-name={dataName}\n data-testid={dataTestId}\n >\n {label && id && (\n <FormLabel\n description={description}\n id={id}\n layout={layout}\n required={required}\n hideRequiredStar={hideRequiredStar}\n >\n {label}\n </FormLabel>\n )}\n\n {children}\n\n {shouldDisplayErrorMessage && (\n <span className=\"text-red text-b4 flex items-start gap-x-4 px-20\">\n <Icon name=\"Error\" width=\"20px\" />\n {errorMessage}\n </span>\n )}\n </div>\n );\n};\n"],"names":["FormControl","id","label","description","disabled","required","className","validationStatus","children","errorMessage","dataTestId","dataName","hideRequiredStar","layout","shouldDisplayErrorMessage","useInternalStatus","jsxs","classnames","jsx","FormLabel","Icon"],"mappings":";;;;;;AAmBO,MAAMA,IAAc,CAAkB;AAAA,EAC3C,IAAAC;AAAA,EACA,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,kBAAAC,IAAmB;AAAA,EACnB,UAAAC;AAAA,EACA,cAAAC;AAAA,EACA,YAAAC;AAAA,EACA,UAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,QAAAC;AACF,MAA+B;AAM7B,QAAMC,IALiBC,EAAkB;AAAA,IACvC,YAAY,CAAC,CAACX;AAAA,IACd,kBAAAG;AAAA,EAAA,CACD,MAEoD,WAAWE;AAEhE,SACE,gBAAAO;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWC,EAAW,uBAAuBX,CAAS;AAAA,MACtD,aAAWK;AAAA,MACX,eAAaD;AAAA,MAEZ,UAAA;AAAA,QAAAR,KAASD,KACR,gBAAAiB;AAAA,UAACC;AAAA,UAAA;AAAA,YACC,aAAAhB;AAAA,YACA,IAAAF;AAAA,YACA,QAAAY;AAAA,YACA,UAAAR;AAAA,YACA,kBAAAO;AAAA,YAEC,UAAAV;AAAA,UAAA;AAAA,QAAA;AAAA,QAIJM;AAAA,QAEAM,KACC,gBAAAE,EAAC,QAAA,EAAK,WAAU,mDACd,UAAA;AAAA,UAAA,gBAAAE,EAACE,GAAA,EAAK,MAAK,SAAQ,OAAM,QAAO;AAAA,UAC/BX;AAAA,QAAA,EAAA,CACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormLabel.js","sources":["../../../lib/molecules/Forms/FormLabel.tsx"],"sourcesContent":["import classnames from 'classnames';\nimport type { LabelHTMLAttributes } from 'react';\n\nexport interface FormLabelProps extends LabelHTMLAttributes<HTMLLabelElement> {\n description?: string;\n layout?: 'horizontal' | 'vertical';\n required?: boolean;\n hideRequiredStar?: boolean;\n}\n\nexport const FormLabel = ({\n id,\n description,\n layout = 'horizontal',\n required,\n className,\n children,\n hideRequiredStar = !required,\n ...rest\n}: FormLabelProps) => {\n return (\n <label\n {...rest}\n htmlFor={id}\n className={classnames(\n 'text-b3 font-semibold text-black flex',\n {\n 'flex-wrap items-center ps-20': layout === 'horizontal',\n 'flex-col items-start': layout === 'vertical',\n },\n className,\n )}\n data-name=\"InputLabel\"\n >\n {children}\n {required && !hideRequiredStar && <span>*</span>}\n {description && <span className=\"ms-12 text-b4 text-grey font-normal\">{description}</span>}\n </label>\n );\n};\n"],"names":["FormLabel","id","description","layout","required","className","children","hideRequiredStar","rest","jsxs","classnames","jsx"],"mappings":";;AAUO,MAAMA,IAAY,CAAC;AAAA,EACxB,IAAAC;AAAA,EACA,aAAAC;AAAA,EACA,QAAAC,IAAS;AAAA,EACT,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,kBAAAC,IAAmB,CAACH;AAAA,EACpB,GAAGI;AACL,MAEI,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACE,GAAGD;AAAA,IACJ,SAASP;AAAA,IACT,WAAWS;AAAA,MACT;AAAA,MACA;AAAA,QACE,gCAAgCP,MAAW;AAAA,QAC3C,wBAAwBA,MAAW;AAAA,
|
|
1
|
+
{"version":3,"file":"FormLabel.js","sources":["../../../lib/molecules/Forms/FormLabel.tsx"],"sourcesContent":["import classnames from 'classnames';\nimport type { LabelHTMLAttributes } from 'react';\n\nexport interface FormLabelProps extends LabelHTMLAttributes<HTMLLabelElement> {\n description?: string;\n layout?: 'horizontal' | 'vertical';\n required?: boolean;\n hideRequiredStar?: boolean;\n}\n\nexport const FormLabel = ({\n id,\n description,\n layout = 'horizontal',\n required,\n className,\n children,\n hideRequiredStar = !required,\n ...rest\n}: FormLabelProps) => {\n return (\n <label\n {...rest}\n htmlFor={id}\n className={classnames(\n 'text-b3 font-semibold text-black flex',\n {\n 'flex-wrap items-center ps-20': layout === 'horizontal',\n 'flex-col items-start': layout === 'vertical',\n },\n className,\n )}\n data-name=\"InputLabel\"\n >\n {children}\n {required && !hideRequiredStar && <span>*</span>}\n {description && <span className=\"ms-12 text-b4 text-grey font-normal\">{description}</span>}\n </label>\n );\n};\n"],"names":["FormLabel","id","description","layout","required","className","children","hideRequiredStar","rest","jsxs","classnames","jsx"],"mappings":";;AAUO,MAAMA,IAAY,CAAC;AAAA,EACxB,IAAAC;AAAA,EACA,aAAAC;AAAA,EACA,QAAAC,IAAS;AAAA,EACT,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,kBAAAC,IAAmB,CAACH;AAAA,EACpB,GAAGI;AACL,MAEI,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACE,GAAGD;AAAA,IACJ,SAASP;AAAA,IACT,WAAWS;AAAA,MACT;AAAA,MACA;AAAA,QACE,gCAAgCP,MAAW;AAAA,QAC3C,wBAAwBA,MAAW;AAAA,MAAA;AAAA,MAErCE;AAAA,IAAA;AAAA,IAEF,aAAU;AAAA,IAET,UAAA;AAAA,MAAAC;AAAA,MACAF,KAAY,CAACG,KAAoB,gBAAAI,EAAC,UAAK,UAAA,KAAC;AAAA,MACxCT,KAAe,gBAAAS,EAAC,QAAA,EAAK,WAAU,uCAAuC,UAAAT,EAAA,CAAY;AAAA,IAAA;AAAA,EAAA;AAAA;"}
|
|
@@ -116,7 +116,7 @@ export declare function useNumberField(props: NumberFieldProps): {
|
|
|
116
116
|
"aria-posinset"?: number | undefined;
|
|
117
117
|
"aria-pressed"?: boolean | "true" | "false" | "mixed" | undefined;
|
|
118
118
|
"aria-readonly"?: (boolean | "true" | "false") | undefined;
|
|
119
|
-
"aria-relevant"?: "text" | "additions" | "additions removals" | "additions text" | "
|
|
119
|
+
"aria-relevant"?: "all" | "text" | "additions" | "additions removals" | "additions text" | "removals" | "removals additions" | "removals text" | "text additions" | "text removals" | undefined;
|
|
120
120
|
"aria-required"?: (boolean | "true" | "false") | undefined;
|
|
121
121
|
"aria-roledescription"?: string | undefined;
|
|
122
122
|
"aria-rowcount"?: number | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberField.js","sources":["../../../lib/molecules/Forms/NumberField.tsx"],"sourcesContent":["import classnames from 'classnames';\n\nimport { type ChangeEvent, useId } from 'react';\n\nimport { useValue } from '@/hooks/useValue.js';\nimport { Button } from '../Buttons/Button';\nimport { FormControl, type FormControlProps } from './FormControl.js';\n\ninterface NumberFieldProps extends FormControlProps<number> {\n min?: number;\n max?: number;\n}\n\nconst INPUT_STYLE = { width: '28px', height: '28px' };\n\nexport function useNumberField(props: NumberFieldProps) {\n const internalId = useId();\n\n const {\n id = internalId,\n name = id,\n value: initialValue = 0,\n onChange,\n min = 0,\n max = 10,\n disabled = false,\n dataTestId = 'NumberField',\n ...rest\n } = props;\n\n const { value, setValue } = useValue<number, string | number | boolean>({\n name: name!,\n defaultValue: initialValue,\n formatter: Number,\n onChange,\n });\n\n const handleChange = (e: ChangeEvent<HTMLInputElement>) => {\n const newValue = Number(e.target.value);\n\n if (newValue >= min && newValue <= max) {\n setValue(Number(newValue));\n }\n };\n\n const increase = () => {\n if (value < max) {\n setValue(value + 1);\n }\n };\n\n const decrease = () => {\n if (value > min) {\n setValue(value - 1);\n }\n };\n\n return {\n ...rest,\n id,\n min,\n max,\n name,\n value,\n dataTestId,\n disabled,\n handleChange,\n increase,\n decrease,\n };\n}\n\nexport const NumberField = (props: NumberFieldProps) => {\n const {\n disabled,\n min,\n max,\n label,\n description,\n id,\n dataTestId,\n value,\n handleChange,\n increase,\n decrease,\n errorMessage,\n validationStatus,\n hideRequiredStar,\n required,\n ...rest\n } = useNumberField(props);\n\n return (\n <FormControl\n id={id}\n label={label}\n description={description}\n className={classnames('flex items-center justify-between', props.className)}\n dataName=\"NumberField\"\n dataTestId={dataTestId}\n errorMessage={errorMessage}\n validationStatus={validationStatus}\n disabled={disabled}\n required={required}\n hideRequiredStar={hideRequiredStar}\n layout=\"vertical\"\n >\n <div className=\"flex items-center gap-x-8\">\n <Button\n onClick={decrease}\n variant=\"circle\"\n disabled={value <= min || disabled}\n icon=\"MinusDefault\"\n aria-label=\"Decrease\"\n data-testid={`${dataTestId}-decrease`}\n />\n <input\n {...rest}\n className={classnames('text-b2 text-center font-normal outline-none', {\n 'bg-pearl text-grey': disabled,\n })}\n style={INPUT_STYLE}\n type=\"number\"\n id={id}\n onChange={handleChange}\n disabled={disabled}\n required={required}\n value={value}\n min={min}\n max={max}\n />\n <Button\n onClick={increase}\n variant=\"circle\"\n aria-label=\"Increase\"\n disabled={value >= max || disabled}\n icon=\"PlusDefault\"\n data-testid={`${dataTestId}-increase`}\n />\n </div>\n </FormControl>\n );\n};\n"],"names":["INPUT_STYLE","useNumberField","props","internalId","useId","id","name","initialValue","onChange","min","max","disabled","dataTestId","rest","value","setValue","useValue","e","newValue","NumberField","label","description","handleChange","increase","decrease","errorMessage","validationStatus","hideRequiredStar","required","jsx","FormControl","classnames","jsxs","Button"],"mappings":";;;;;;AAaA,MAAMA,IAAc,EAAE,OAAO,QAAQ,QAAQ,
|
|
1
|
+
{"version":3,"file":"NumberField.js","sources":["../../../lib/molecules/Forms/NumberField.tsx"],"sourcesContent":["import classnames from 'classnames';\n\nimport { type ChangeEvent, useId } from 'react';\n\nimport { useValue } from '@/hooks/useValue.js';\nimport { Button } from '../Buttons/Button';\nimport { FormControl, type FormControlProps } from './FormControl.js';\n\ninterface NumberFieldProps extends FormControlProps<number> {\n min?: number;\n max?: number;\n}\n\nconst INPUT_STYLE = { width: '28px', height: '28px' };\n\nexport function useNumberField(props: NumberFieldProps) {\n const internalId = useId();\n\n const {\n id = internalId,\n name = id,\n value: initialValue = 0,\n onChange,\n min = 0,\n max = 10,\n disabled = false,\n dataTestId = 'NumberField',\n ...rest\n } = props;\n\n const { value, setValue } = useValue<number, string | number | boolean>({\n name: name!,\n defaultValue: initialValue,\n formatter: Number,\n onChange,\n });\n\n const handleChange = (e: ChangeEvent<HTMLInputElement>) => {\n const newValue = Number(e.target.value);\n\n if (newValue >= min && newValue <= max) {\n setValue(Number(newValue));\n }\n };\n\n const increase = () => {\n if (value < max) {\n setValue(value + 1);\n }\n };\n\n const decrease = () => {\n if (value > min) {\n setValue(value - 1);\n }\n };\n\n return {\n ...rest,\n id,\n min,\n max,\n name,\n value,\n dataTestId,\n disabled,\n handleChange,\n increase,\n decrease,\n };\n}\n\nexport const NumberField = (props: NumberFieldProps) => {\n const {\n disabled,\n min,\n max,\n label,\n description,\n id,\n dataTestId,\n value,\n handleChange,\n increase,\n decrease,\n errorMessage,\n validationStatus,\n hideRequiredStar,\n required,\n ...rest\n } = useNumberField(props);\n\n return (\n <FormControl\n id={id}\n label={label}\n description={description}\n className={classnames('flex items-center justify-between', props.className)}\n dataName=\"NumberField\"\n dataTestId={dataTestId}\n errorMessage={errorMessage}\n validationStatus={validationStatus}\n disabled={disabled}\n required={required}\n hideRequiredStar={hideRequiredStar}\n layout=\"vertical\"\n >\n <div className=\"flex items-center gap-x-8\">\n <Button\n onClick={decrease}\n variant=\"circle\"\n disabled={value <= min || disabled}\n icon=\"MinusDefault\"\n aria-label=\"Decrease\"\n data-testid={`${dataTestId}-decrease`}\n />\n <input\n {...rest}\n className={classnames('text-b2 text-center font-normal outline-none', {\n 'bg-pearl text-grey': disabled,\n })}\n style={INPUT_STYLE}\n type=\"number\"\n id={id}\n onChange={handleChange}\n disabled={disabled}\n required={required}\n value={value}\n min={min}\n max={max}\n />\n <Button\n onClick={increase}\n variant=\"circle\"\n aria-label=\"Increase\"\n disabled={value >= max || disabled}\n icon=\"PlusDefault\"\n data-testid={`${dataTestId}-increase`}\n />\n </div>\n </FormControl>\n );\n};\n"],"names":["INPUT_STYLE","useNumberField","props","internalId","useId","id","name","initialValue","onChange","min","max","disabled","dataTestId","rest","value","setValue","useValue","e","newValue","NumberField","label","description","handleChange","increase","decrease","errorMessage","validationStatus","hideRequiredStar","required","jsx","FormControl","classnames","jsxs","Button"],"mappings":";;;;;;AAaA,MAAMA,IAAc,EAAE,OAAO,QAAQ,QAAQ,OAAA;AAEtC,SAASC,EAAeC,GAAyB;AACtD,QAAMC,IAAaC,EAAA,GAEb;AAAA,IACJ,IAAAC,IAAKF;AAAA,IACL,MAAAG,IAAOD;AAAA,IACP,OAAOE,IAAe;AAAA,IACtB,UAAAC;AAAA,IACA,KAAAC,IAAM;AAAA,IACN,KAAAC,IAAM;AAAA,IACN,UAAAC,IAAW;AAAA,IACX,YAAAC,IAAa;AAAA,IACb,GAAGC;AAAA,EAAA,IACDX,GAEE,EAAE,OAAAY,GAAO,UAAAC,EAAA,IAAaC,EAA4C;AAAA,IACtE,MAAAV;AAAA,IACA,cAAcC;AAAA,IACd,WAAW;AAAA,IACX,UAAAC;AAAA,EAAA,CACD;AAsBD,SAAO;AAAA,IACL,GAAGK;AAAA,IACH,IAAAR;AAAA,IACA,KAAAI;AAAA,IACA,KAAAC;AAAA,IACA,MAAAJ;AAAA,IACA,OAAAQ;AAAA,IACA,YAAAF;AAAA,IACA,UAAAD;AAAA,IACA,cA7BmB,CAACM,MAAqC;AACzD,YAAMC,I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AAA;AAAA,QAE5B,gBAAAiB;AAAA,UAAC;AAAA,UAAA;AAAA,YACE,GAAGhB;AAAA,YACJ,WAAWkB,EAAW,gDAAgD;AAAA,cACpE,sBAAsBpB;AAAA,YAAA,CACvB;AAAA,YACD,OAAOX;AAAA,YACP,MAAK;AAAA,YACL,IAAAK;AAAA,YACA,UAAUiB;AAAA,YACV,UAAAX;AAAA,YACA,UAAAiB;AAAA,YACA,OAAAd;AAAA,YACA,KAAAL;AAAA,YACA,KAAAC;AAAA,UAAA;AAAA,QAAA;AAAA,QAEF,gBAAAmB;AAAA,UAACI;AAAA,UAAA;AAAA,YACC,SAASV;AAAA,YACT,SAAQ;AAAA,YACR,cAAW;AAAA,YACX,UAAUT,KAASJ,KAAOC;AAAA,YAC1B,MAAK;AAAA,YACL,eAAa,GAAGC,CAAU;AAAA,UAAA;AAAA,QAAA;AAAA,MAC5B,EAAA,CACF;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Password.js","sources":["../../../../lib/molecules/Forms/Password/Password.tsx"],"sourcesContent":["import { useInternalStatus } from '@/hooks/useInternalStatus';\nimport classnames from 'classnames';\n\nimport { type HTMLInputTypeAttribute, useEffect, useId, useState } from 'react';\n\nimport { useValue } from '@/hooks/useValue';\nimport { FormControl, type FormControlProps } from '../FormControl';\nimport { Icon } from '@/atoms/Icons';\nimport { ValidationMessage } from './ValidationMessage';\n\nexport interface PasswordProps<Value> extends FormControlProps<Value> {\n validationMessages?: ValidationMessage[];\n withoutFieldValidation?: boolean;\n}\n\nexport function Password<Value = string>(props: PasswordProps<Value>) {\n const internalId = useId();\n\n const {\n id = internalId,\n name = id,\n label,\n value: initialValue,\n disabled = false,\n required = false,\n hideRequiredStar,\n validationStatus = 'default',\n errorMessage,\n validationMessages = [],\n withoutFieldValidation = false,\n className,\n onChange,\n dataTestId = 'Password',\n ...rest\n } = props;\n\n const internalStatus = useInternalStatus({\n isDisabled: disabled,\n validationStatus,\n });\n\n const { value, setValue } = useValue<Value>({\n name,\n initialValue,\n onChange,\n });\n const [type, setType] = useState<HTMLInputTypeAttribute>('password');\n\n useEffect(() => {\n if (disabled) {\n setType('password');\n } else {\n setType(type);\n }\n }, [type, disabled]);\n\n const toggleType = () => setType(type === 'password' ? 'text' : 'password');\n\n return (\n <FormControl\n className={className}\n id={id}\n label={label}\n dataName=\"Password\"\n dataTestId={dataTestId}\n disabled={disabled}\n required={required}\n hideRequiredStar={hideRequiredStar}\n validationStatus={withoutFieldValidation ? 'default' : validationStatus}\n errorMessage={errorMessage}\n >\n <div className=\"relative\">\n <input\n {...rest}\n id={id}\n name={name}\n type={type}\n value={value as any}\n disabled={disabled}\n required={required}\n onChange={(e) => setValue(e.target.value as Value)}\n className={classnames(\n 'text-b3 rounded-pill w-full border ps-20 py-[11px] font-normal outline-none',\n {\n 'border-lightGrey focus:border-black active:border-black pe-[52px]':\n (withoutFieldValidation || validationStatus === 'default') &&\n internalStatus !== 'disabled',\n 'bg-white text-black': internalStatus !== 'disabled',\n 'bg-pearl text-grey': internalStatus === 'disabled',\n 'pe-[84px]':\n !withoutFieldValidation &&\n (validationStatus === 'error' || validationStatus === 'success'),\n 'border-red': !withoutFieldValidation && validationStatus === 'error',\n 'border-green': !withoutFieldValidation && validationStatus === 'success',\n },\n )}\n aria-label={name}\n />\n\n <div\n className={classnames(\n 'pointer-events-none absolute inset-0 flex items-center justify-between px-20 py-12',\n )}\n >\n <span className=\"ms-auto flex gap-x-8\">\n {!withoutFieldValidation && validationStatus === 'error' && (\n <Icon name=\"CrossDefault\" color=\"red\" width=\"24px\" />\n )}\n\n {!withoutFieldValidation && validationStatus === 'success' && (\n <Icon name=\"CheckDefault\" color=\"green\" width=\"24px\" />\n )}\n\n {!disabled && (\n <button\n type=\"button\"\n className=\"pointer-events-auto size-24 inline-flex\"\n onClick={toggleType}\n >\n <Icon\n name={type === 'password' ? 'Invisible' : 'Visible'}\n width=\"24px\"\n type=\"svg\"\n />\n </button>\n )}\n </span>\n </div>\n </div>\n\n {validationMessages.length > 0 && (\n <div className=\"flex flex-col gap-[10px] mt-8\">\n {validationMessages.map(({ label, status }, index) => (\n <ValidationMessage label={label} status={status} key={index} />\n ))}\n </div>\n )}\n </FormControl>\n );\n}\n"],"names":["Password","props","internalId","useId","id","name","label","initialValue","disabled","required","hideRequiredStar","validationStatus","errorMessage","validationMessages","withoutFieldValidation","className","onChange","dataTestId","rest","internalStatus","useInternalStatus","value","setValue","useValue","type","setType","useState","useEffect","toggleType","jsxs","FormControl","jsx","e","classnames","Icon","status","index","ValidationMessage"],"mappings":";;;;;;;;;AAeO,SAASA,EAAyBC,GAA6B;AACpE,QAAMC,IAAaC,
|
|
1
|
+
{"version":3,"file":"Password.js","sources":["../../../../lib/molecules/Forms/Password/Password.tsx"],"sourcesContent":["import { useInternalStatus } from '@/hooks/useInternalStatus';\nimport classnames from 'classnames';\n\nimport { type HTMLInputTypeAttribute, useEffect, useId, useState } from 'react';\n\nimport { useValue } from '@/hooks/useValue';\nimport { FormControl, type FormControlProps } from '../FormControl';\nimport { Icon } from '@/atoms/Icons';\nimport { ValidationMessage } from './ValidationMessage';\n\nexport interface PasswordProps<Value> extends FormControlProps<Value> {\n validationMessages?: ValidationMessage[];\n withoutFieldValidation?: boolean;\n}\n\nexport function Password<Value = string>(props: PasswordProps<Value>) {\n const internalId = useId();\n\n const {\n id = internalId,\n name = id,\n label,\n value: initialValue,\n disabled = false,\n required = false,\n hideRequiredStar,\n validationStatus = 'default',\n errorMessage,\n validationMessages = [],\n withoutFieldValidation = false,\n className,\n onChange,\n dataTestId = 'Password',\n ...rest\n } = props;\n\n const internalStatus = useInternalStatus({\n isDisabled: disabled,\n validationStatus,\n });\n\n const { value, setValue } = useValue<Value>({\n name,\n initialValue,\n onChange,\n });\n const [type, setType] = useState<HTMLInputTypeAttribute>('password');\n\n useEffect(() => {\n if (disabled) {\n setType('password');\n } else {\n setType(type);\n }\n }, [type, disabled]);\n\n const toggleType = () => setType(type === 'password' ? 'text' : 'password');\n\n return (\n <FormControl\n className={className}\n id={id}\n label={label}\n dataName=\"Password\"\n dataTestId={dataTestId}\n disabled={disabled}\n required={required}\n hideRequiredStar={hideRequiredStar}\n validationStatus={withoutFieldValidation ? 'default' : validationStatus}\n errorMessage={errorMessage}\n >\n <div className=\"relative\">\n <input\n {...rest}\n id={id}\n name={name}\n type={type}\n value={value as any}\n disabled={disabled}\n required={required}\n onChange={(e) => setValue(e.target.value as Value)}\n className={classnames(\n 'text-b3 rounded-pill w-full border ps-20 py-[11px] font-normal outline-none',\n {\n 'border-lightGrey focus:border-black active:border-black pe-[52px]':\n (withoutFieldValidation || validationStatus === 'default') &&\n internalStatus !== 'disabled',\n 'bg-white text-black': internalStatus !== 'disabled',\n 'bg-pearl text-grey': internalStatus === 'disabled',\n 'pe-[84px]':\n !withoutFieldValidation &&\n (validationStatus === 'error' || validationStatus === 'success'),\n 'border-red': !withoutFieldValidation && validationStatus === 'error',\n 'border-green': !withoutFieldValidation && validationStatus === 'success',\n },\n )}\n aria-label={name}\n />\n\n <div\n className={classnames(\n 'pointer-events-none absolute inset-0 flex items-center justify-between px-20 py-12',\n )}\n >\n <span className=\"ms-auto flex gap-x-8\">\n {!withoutFieldValidation && validationStatus === 'error' && (\n <Icon name=\"CrossDefault\" color=\"red\" width=\"24px\" />\n )}\n\n {!withoutFieldValidation && validationStatus === 'success' && (\n <Icon name=\"CheckDefault\" color=\"green\" width=\"24px\" />\n )}\n\n {!disabled && (\n <button\n type=\"button\"\n className=\"pointer-events-auto size-24 inline-flex\"\n onClick={toggleType}\n >\n <Icon\n name={type === 'password' ? 'Invisible' : 'Visible'}\n width=\"24px\"\n type=\"svg\"\n />\n </button>\n )}\n </span>\n </div>\n </div>\n\n {validationMessages.length > 0 && (\n <div className=\"flex flex-col gap-[10px] mt-8\">\n {validationMessages.map(({ label, status }, index) => (\n <ValidationMessage label={label} status={status} key={index} />\n ))}\n </div>\n )}\n </FormControl>\n );\n}\n"],"names":["Password","props","internalId","useId","id","name","label","initialValue","disabled","required","hideRequiredStar","validationStatus","errorMessage","validationMessages","withoutFieldValidation","className","onChange","dataTestId","rest","internalStatus","useInternalStatus","value","setValue","useValue","type","setType","useState","useEffect","toggleType","jsxs","FormControl","jsx","e","classnames","Icon","status","index","ValidationMessage"],"mappings":";;;;;;;;;AAeO,SAASA,EAAyBC,GAA6B;AACpE,QAAMC,IAAaC,EAAA,GAEb;AAAA,IACJ,IAAAC,IAAKF;AAAA,IACL,MAAAG,IAAOD;AAAA,IACP,OAAAE;AAAA,IACA,OAAOC;AAAA,IACP,UAAAC,IAAW;AAAA,IACX,UAAAC,IAAW;AAAA,IACX,kBAAAC;AAAA,IACA,kBAAAC,IAAmB;AAAA,IACnB,cAAAC;AAAA,IACA,oBAAAC,IAAqB,CAAA;AAAA,IACrB,wBAAAC,IAAyB;AAAA,IACzB,WAAAC;AAAA,IACA,UAAAC;AAAA,IACA,YAAAC,IAAa;AAAA,IACb,GAAGC;AAAA,EAAA,IACDjB,GAEEkB,IAAiBC,EAAkB;AAAA,IACvC,YAAYZ;AAAA,IACZ,kBAAAG;AAAA,EAAA,CACD,GAEK,EAAE,OAAAU,GAAO,UAAAC,EAAA,IAAaC,EAAgB;AAAA,IAC1C,MAAAlB;AAAA,IACA,cAAAE;AAAA,IACA,UAAAS;AAAA,EAAA,CACD,GACK,CAACQ,GAAMC,CAAO,IAAIC,EAAiC,UAAU;AAEnE,EAAAC,EAAU,MAAM;AACd,IACEF,EADEjB,IACM,aAEAgB,CAFU;AAAA,EAItB,GAAG,CAACA,GAAMhB,CAAQ,CAAC;AAEnB,QAAMoB,IAAa,MAAMH,EAAQD,MAAS,aAAa,SAAS,UAAU;AAE1E,SACE,gBAAAK;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,WAAAf;AAAA,MACA,IAAAX;AAAA,MACA,OAAAE;AAAA,MACA,UAAS;AAAA,MACT,YAAAW;AAAA,MACA,UAAAT;AAAA,MACA,UAA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ACV,SAASH;AAAA,oBAET,UAAA,gBAAAG;AAAA,sBAACG;AAAA,sBAAA;AAAA,wBACC,MAAMV,MAAS,aAAa,cAAc;AAAA,wBAC1C,OAAM;AAAA,wBACN,MAAK;AAAA,sBAAA;AAAA,oBAAA;AAAA,kBACP;AAAA,gBAAA;AAAA,cACF,EAAA,CAEJ;AAAA,YAAA;AAAA,UAAA;AAAA,QACF,GACF;AAAA,QAECX,EAAmB,SAAS,KAC3B,gBAAAkB,EAAC,SAAI,WAAU,iCACZ,UAAAlB,EAAmB,IAAI,CAAC,EAAE,OAAAP,GAAO,QAAA6B,EAAA,GAAUC,MAC1C,gBAAAL,EAACM,GAAA,EAAkB,OAAO/B,GAAO,QAAA6B,KAAqBC,CAAO,CAC9D,EAAA,CACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValidationMessage.js","sources":["../../../../lib/molecules/Forms/Password/ValidationMessage.tsx"],"sourcesContent":["import classnames from 'classnames';\nimport { Icon } from '@/atoms/Icons';\nimport type { ValidationStatus } from '@/hooks/useInternalStatus';\n\nexport interface ValidationMessage {\n label: string;\n status: ValidationStatus;\n}\n\nconst ICON_PROPS = {\n default: {\n iconName: 'Edit',\n iconColor: 'middleGrey',\n },\n error: {\n iconName: 'Error',\n iconColor: 'red',\n },\n success: {\n iconName: 'CheckDefault',\n iconColor: 'green',\n },\n};\n\nexport function ValidationMessage({ label, status }: ValidationMessage) {\n const { iconName, iconColor } = ICON_PROPS[status];\n\n return (\n <div className=\"flex gap-[6px] px-20 items-center\">\n <Icon name={iconName} width=\"30px\" color={iconColor} />\n <span className={classnames('text-b3', `text-${iconColor}`)}>{label}</span>\n </div>\n );\n}\n"],"names":["ICON_PROPS","ValidationMessage","label","status","iconName","iconColor","jsxs","jsx","Icon","classnames"],"mappings":";;;;AASA,MAAMA,IAAa;AAAA,EACjB,SAAS;AAAA,IACP,UAAU;AAAA,IACV,WAAW;AAAA,
|
|
1
|
+
{"version":3,"file":"ValidationMessage.js","sources":["../../../../lib/molecules/Forms/Password/ValidationMessage.tsx"],"sourcesContent":["import classnames from 'classnames';\nimport { Icon } from '@/atoms/Icons';\nimport type { ValidationStatus } from '@/hooks/useInternalStatus';\n\nexport interface ValidationMessage {\n label: string;\n status: ValidationStatus;\n}\n\nconst ICON_PROPS = {\n default: {\n iconName: 'Edit',\n iconColor: 'middleGrey',\n },\n error: {\n iconName: 'Error',\n iconColor: 'red',\n },\n success: {\n iconName: 'CheckDefault',\n iconColor: 'green',\n },\n};\n\nexport function ValidationMessage({ label, status }: ValidationMessage) {\n const { iconName, iconColor } = ICON_PROPS[status];\n\n return (\n <div className=\"flex gap-[6px] px-20 items-center\">\n <Icon name={iconName} width=\"30px\" color={iconColor} />\n <span className={classnames('text-b3', `text-${iconColor}`)}>{label}</span>\n </div>\n );\n}\n"],"names":["ICON_PROPS","ValidationMessage","label","status","iconName","iconColor","jsxs","jsx","Icon","classnames"],"mappings":";;;;AASA,MAAMA,IAAa;AAAA,EACjB,SAAS;AAAA,IACP,UAAU;AAAA,IACV,WAAW;AAAA,EAAA;AAAA,EAEb,OAAO;AAAA,IACL,UAAU;AAAA,IACV,WAAW;AAAA,EAAA;AAAA,EAEb,SAAS;AAAA,IACP,UAAU;AAAA,IACV,WAAW;AAAA,EAAA;AAEf;AAEO,SAASC,EAAkB,EAAE,OAAAC,GAAO,QAAAC,KAA6B;AACtE,QAAM,EAAE,UAAAC,GAAU,WAAAC,MAAcL,EAAWG,CAAM;AAEjD,SACE,gBAAAG,EAAC,OAAA,EAAI,WAAU,qCACb,UAAA;AAAA,IAAA,gBAAAC,EAACC,KAAK,MAAMJ,GAAU,OAAM,QAAO,OAAOC,GAAW;AAAA,IACrD,gBAAAE,EAAC,UAAK,WAAWE,EAAW,WAAW,QAAQJ,CAAS,EAAE,GAAI,UAAAH,EAAA,CAAM;AAAA,EAAA,GACtE;AAEJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.js","sources":["../../../../lib/molecules/Forms/Radios/Radio.tsx"],"sourcesContent":["import classnames from 'classnames';\nimport { type InputHTMLAttributes, useId } from 'react';\nimport { useValue } from '@/hooks/useValue.js';\nimport '../controls.css';\n\nexport interface RadioProps<Value = string>\n extends Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange'> {\n /**\n * The data-testid to apply to the button.\n * This is used for testing purposes.\n * */\n dataTestId?: string;\n /**\n * The diameter of the radio button.\n * */\n size?: number;\n\n onChange?: (name: string, value: Value | null) => void;\n}\n\nexport function Radio<Value = string>(props: RadioProps<Value>) {\n const internalId = useId();\n\n const {\n id = internalId,\n name = id,\n className,\n dataTestId,\n disabled,\n checked: initialChecked = false,\n value,\n size = 24,\n tabIndex = 0,\n children,\n onChange,\n ...rest\n } = props;\n\n const { value: checked, setValue } = useValue<boolean>({\n name,\n initialValue: initialChecked,\n onChange(name, checked) {\n onChange?.(name, (value !== undefined ? value : checked) as Value);\n },\n });\n\n return (\n <label\n className={classnames(className, 'relative flex items-center gap-8', {\n 'text-grey': disabled,\n })}\n >\n <span className=\"relative\">\n <input\n {...rest}\n name={name}\n data-testid={dataTestId}\n type=\"radio\"\n tabIndex={tabIndex}\n onChange={() => {\n !disabled && setValue(!checked);\n }}\n defaultChecked={checked}\n data-name=\"Radio\"\n disabled={disabled}\n value={value}\n />\n\n <span style={{ height: size, width: size }}>\n <svg viewBox=\"0 0 16 16\" width={(size * 2) / 3} className=\"overflow-visible\">\n <circle cx=\"8\" cy=\"8\" r=\"8px\" style={{ fill: 'hsl(var(--color-saffron))' }} />\n </svg>\n </span>\n </span>\n\n {children}\n </label>\n );\n}\n"],"names":["Radio","props","internalId","useId","id","name","className","dataTestId","disabled","initialChecked","value","size","tabIndex","children","onChange","rest","checked","setValue","useValue","jsxs","classnames","jsx"],"mappings":";;;;;AAoBO,SAASA,EAAsBC,GAA0B;AAC9D,QAAMC,IAAaC,
|
|
1
|
+
{"version":3,"file":"Radio.js","sources":["../../../../lib/molecules/Forms/Radios/Radio.tsx"],"sourcesContent":["import classnames from 'classnames';\nimport { type InputHTMLAttributes, useId } from 'react';\nimport { useValue } from '@/hooks/useValue.js';\nimport '../controls.css';\n\nexport interface RadioProps<Value = string>\n extends Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange'> {\n /**\n * The data-testid to apply to the button.\n * This is used for testing purposes.\n * */\n dataTestId?: string;\n /**\n * The diameter of the radio button.\n * */\n size?: number;\n\n onChange?: (name: string, value: Value | null) => void;\n}\n\nexport function Radio<Value = string>(props: RadioProps<Value>) {\n const internalId = useId();\n\n const {\n id = internalId,\n name = id,\n className,\n dataTestId,\n disabled,\n checked: initialChecked = false,\n value,\n size = 24,\n tabIndex = 0,\n children,\n onChange,\n ...rest\n } = props;\n\n const { value: checked, setValue } = useValue<boolean>({\n name,\n initialValue: initialChecked,\n onChange(name, checked) {\n onChange?.(name, (value !== undefined ? value : checked) as Value);\n },\n });\n\n return (\n <label\n className={classnames(className, 'relative flex items-center gap-8', {\n 'text-grey': disabled,\n })}\n >\n <span className=\"relative\">\n <input\n {...rest}\n name={name}\n data-testid={dataTestId}\n type=\"radio\"\n tabIndex={tabIndex}\n onChange={() => {\n !disabled && setValue(!checked);\n }}\n defaultChecked={checked}\n data-name=\"Radio\"\n disabled={disabled}\n value={value}\n />\n\n <span style={{ height: size, width: size }}>\n <svg viewBox=\"0 0 16 16\" width={(size * 2) / 3} className=\"overflow-visible\">\n <circle cx=\"8\" cy=\"8\" r=\"8px\" style={{ fill: 'hsl(var(--color-saffron))' }} />\n </svg>\n </span>\n </span>\n\n {children}\n </label>\n );\n}\n"],"names":["Radio","props","internalId","useId","id","name","className","dataTestId","disabled","initialChecked","value","size","tabIndex","children","onChange","rest","checked","setValue","useValue","jsxs","classnames","jsx"],"mappings":";;;;;AAoBO,SAASA,EAAsBC,GAA0B;AAC9D,QAAMC,IAAaC,EAAA,GAEb;AAAA,IACJ,IAAAC,IAAKF;AA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