@linyao.tw/ui 1.0.0 → 1.2.0
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/README.md +9 -1
- package/dist/components/date-time/calendar.js +8 -6
- package/dist/components/date-time/calendar.js.map +1 -1
- package/dist/components/date-time/date-field.js +10 -8
- package/dist/components/date-time/date-field.js.map +1 -1
- package/dist/components/date-time/date-picker.js +8 -6
- package/dist/components/date-time/date-picker.js.map +1 -1
- package/dist/components/date-time/date-range-picker.js +8 -6
- package/dist/components/date-time/date-range-picker.js.map +1 -1
- package/dist/components/date-time/index.js +1 -1
- package/dist/components/date-time/shared.d.ts +0 -1
- package/dist/components/date-time/shared.js +7 -9
- package/dist/components/date-time/shared.js.map +1 -1
- package/dist/components/date-time/time-field.js +8 -6
- package/dist/components/date-time/time-field.js.map +1 -1
- package/dist/components/feedback/alert.js +35 -34
- package/dist/components/feedback/alert.js.map +1 -1
- package/dist/components/feedback/banner.js +15 -14
- package/dist/components/feedback/banner.js.map +1 -1
- package/dist/components/feedback/empty-state.d.ts +2 -1
- package/dist/components/feedback/empty-state.js +31 -31
- package/dist/components/feedback/empty-state.js.map +1 -1
- package/dist/components/feedback/feedback.types.d.ts +0 -1
- package/dist/components/feedback/feedback.types.js +3 -5
- package/dist/components/feedback/feedback.types.js.map +1 -1
- package/dist/components/feedback/index.d.ts +8 -8
- package/dist/components/feedback/meter.js +21 -21
- package/dist/components/feedback/meter.js.map +1 -1
- package/dist/components/feedback/progress.js +21 -21
- package/dist/components/feedback/progress.js.map +1 -1
- package/dist/components/feedback/skeleton.js +11 -11
- package/dist/components/feedback/skeleton.js.map +1 -1
- package/dist/components/feedback/spinner.js +25 -25
- package/dist/components/feedback/spinner.js.map +1 -1
- package/dist/components/feedback/toast.js +23 -21
- package/dist/components/feedback/toast.js.map +1 -1
- package/dist/components/forms/{CodeField.d.ts → code-field.d.ts} +1 -1
- package/dist/components/forms/code-field.js +66 -0
- package/dist/components/forms/code-field.js.map +1 -0
- package/dist/components/forms/{FileUpload.d.ts → file-upload.d.ts} +1 -1
- package/dist/components/forms/{FileUpload.js → file-upload.js} +128 -111
- package/dist/components/forms/file-upload.js.map +1 -0
- package/dist/components/forms/index.d.ts +6 -6
- package/dist/components/forms/{Input.js → input.js} +4 -3
- package/dist/components/forms/input.js.map +1 -0
- package/dist/components/forms/internal.d.ts +0 -2
- package/dist/components/forms/internal.js +22 -25
- package/dist/components/forms/internal.js.map +1 -1
- package/dist/components/forms/number-field.js +74 -0
- package/dist/components/forms/number-field.js.map +1 -0
- package/dist/components/forms/otp-field.js +58 -0
- package/dist/components/forms/otp-field.js.map +1 -0
- package/dist/components/forms/{TextField.d.ts → text-field.d.ts} +5 -0
- package/dist/components/forms/text-field.js +201 -0
- package/dist/components/forms/text-field.js.map +1 -0
- package/dist/components/foundations/{Avatar.js → avatar.js} +13 -10
- package/dist/components/foundations/avatar.js.map +1 -0
- package/dist/components/foundations/{Badge.d.ts → badge.d.ts} +1 -1
- package/dist/components/foundations/{Badge.js → badge.js} +4 -3
- package/dist/components/foundations/badge.js.map +1 -0
- package/dist/components/foundations/{Button.js → button.js} +4 -3
- package/dist/components/foundations/button.js.map +1 -0
- package/dist/components/foundations/{Card.d.ts → card.d.ts} +9 -2
- package/dist/components/foundations/{Card.js → card.js} +6 -5
- package/dist/components/foundations/card.js.map +1 -0
- package/dist/components/foundations/{IconButton.d.ts → icon-button.d.ts} +2 -8
- package/dist/components/foundations/{IconButton.js → icon-button.js} +5 -4
- package/dist/components/foundations/icon-button.js.map +1 -0
- package/dist/components/foundations/index.d.ts +9 -9
- package/dist/components/foundations/{Link.d.ts → link.d.ts} +1 -1
- package/dist/components/foundations/link.js +47 -0
- package/dist/components/foundations/link.js.map +1 -0
- package/dist/components/foundations/{ListCell.d.ts → list-cell.d.ts} +1 -8
- package/dist/components/foundations/{ListCell.js → list-cell.js} +4 -3
- package/dist/components/foundations/list-cell.js.map +1 -0
- package/dist/components/foundations/{SectionHeading.d.ts → section-heading.d.ts} +5 -2
- package/dist/components/foundations/{SectionHeading.js → section-heading.js} +4 -3
- package/dist/components/foundations/section-heading.js.map +1 -0
- package/dist/components/foundations/{Separator.js → separator.js} +4 -3
- package/dist/components/foundations/separator.js.map +1 -0
- package/dist/components/navigation-data/breadcrumb-pagination.js +89 -81
- package/dist/components/navigation-data/breadcrumb-pagination.js.map +1 -1
- package/dist/components/navigation-data/command-palette.d.ts +26 -0
- package/dist/components/navigation-data/command-palette.js +101 -72
- package/dist/components/navigation-data/command-palette.js.map +1 -1
- package/dist/components/navigation-data/header-tab-bar.js +50 -46
- package/dist/components/navigation-data/header-tab-bar.js.map +1 -1
- package/dist/components/navigation-data/index.d.ts +7 -7
- package/dist/components/navigation-data/menubar-toolbar.js +2 -1
- package/dist/components/navigation-data/menubar-toolbar.js.map +1 -1
- package/dist/components/navigation-data/navigation-menu.js +2 -1
- package/dist/components/navigation-data/navigation-menu.js.map +1 -1
- package/dist/components/navigation-data/scroll-area.js +2 -1
- package/dist/components/navigation-data/scroll-area.js.map +1 -1
- package/dist/components/navigation-data/table-collection.d.ts +12 -3
- package/dist/components/navigation-data/table-collection.js +12 -9
- package/dist/components/navigation-data/table-collection.js.map +1 -1
- package/dist/components/overlays/dialog.d.ts +23 -3
- package/dist/components/overlays/dialog.js +138 -130
- package/dist/components/overlays/dialog.js.map +1 -1
- package/dist/components/overlays/disclosure.js +2 -1
- package/dist/components/overlays/disclosure.js.map +1 -1
- package/dist/components/overlays/drawer.d.ts +9 -2
- package/dist/components/overlays/drawer.js +158 -151
- package/dist/components/overlays/drawer.js.map +1 -1
- package/dist/components/overlays/floating.js +116 -113
- package/dist/components/overlays/floating.js.map +1 -1
- package/dist/components/overlays/index.d.ts +4 -4
- package/dist/components/selection/combobox.js +94 -93
- package/dist/components/selection/combobox.js.map +1 -1
- package/dist/components/selection/controls.d.ts +4 -1
- package/dist/components/selection/controls.js +141 -118
- package/dist/components/selection/controls.js.map +1 -1
- package/dist/components/selection/menu.js +121 -121
- package/dist/components/selection/menu.js.map +1 -1
- package/dist/components/selection/select.js +108 -107
- package/dist/components/selection/select.js.map +1 -1
- package/dist/fonts.css +13 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +39 -33
- package/dist/internal/accessible-name.d.ts +12 -0
- package/dist/internal/class-names.d.ts +12 -0
- package/dist/{components/selection/classnames.js → internal/class-names.js} +4 -3
- package/dist/internal/class-names.js.map +1 -0
- package/dist/internal/index.d.ts +3 -0
- package/dist/{components/foundations/shared.d.ts → internal/render.d.ts} +2 -1
- package/dist/intl/index.d.ts +3 -0
- package/dist/intl/linyao-provider.d.ts +38 -0
- package/dist/intl/linyao-provider.js +27 -0
- package/dist/intl/linyao-provider.js.map +1 -0
- package/dist/intl/messages.d.ts +48 -0
- package/dist/intl/messages.js +81 -0
- package/dist/intl/messages.js.map +1 -0
- package/dist/intl/provider.d.ts +18 -0
- package/dist/intl/provider.js +31 -0
- package/dist/intl/provider.js.map +1 -0
- package/dist/styles.css +1 -1
- package/package.json +6 -4
- package/dist/components/feedback/feedback.module.js +0 -42
- package/dist/components/feedback/feedback.module.js.map +0 -1
- package/dist/components/forms/CodeField.js +0 -63
- package/dist/components/forms/CodeField.js.map +0 -1
- package/dist/components/forms/FileUpload.js.map +0 -1
- package/dist/components/forms/Input.js.map +0 -1
- package/dist/components/forms/NumberField.js +0 -71
- package/dist/components/forms/NumberField.js.map +0 -1
- package/dist/components/forms/OTPField.js +0 -54
- package/dist/components/forms/OTPField.js.map +0 -1
- package/dist/components/forms/TextField.js +0 -199
- package/dist/components/forms/TextField.js.map +0 -1
- package/dist/components/foundations/Avatar.js.map +0 -1
- package/dist/components/foundations/Badge.js.map +0 -1
- package/dist/components/foundations/Button.js.map +0 -1
- package/dist/components/foundations/Card.js.map +0 -1
- package/dist/components/foundations/IconButton.js.map +0 -1
- package/dist/components/foundations/Link.js +0 -40
- package/dist/components/foundations/Link.js.map +0 -1
- package/dist/components/foundations/ListCell.js.map +0 -1
- package/dist/components/foundations/SectionHeading.js.map +0 -1
- package/dist/components/foundations/Separator.js.map +0 -1
- package/dist/components/foundations/shared.js +0 -8
- package/dist/components/foundations/shared.js.map +0 -1
- package/dist/components/navigation-data/utils.d.ts +0 -2
- package/dist/components/navigation-data/utils.js +0 -11
- package/dist/components/navigation-data/utils.js.map +0 -1
- package/dist/components/overlays/class-names.d.ts +0 -6
- package/dist/components/overlays/class-names.js +0 -11
- package/dist/components/overlays/class-names.js.map +0 -1
- package/dist/components/selection/classnames.d.ts +0 -4
- package/dist/components/selection/classnames.js.map +0 -1
- package/dist/components/selection/selection.module.js +0 -51
- package/dist/components/selection/selection.module.js.map +0 -1
- /package/dist/components/forms/{Input.d.ts → input.d.ts} +0 -0
- /package/dist/components/forms/{NumberField.d.ts → number-field.d.ts} +0 -0
- /package/dist/components/forms/{OTPField.d.ts → otp-field.d.ts} +0 -0
- /package/dist/components/foundations/{Avatar.d.ts → avatar.d.ts} +0 -0
- /package/dist/components/foundations/{Button.d.ts → button.d.ts} +0 -0
- /package/dist/components/foundations/{Separator.d.ts → separator.d.ts} +0 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import { cx as e, withStateClassName as t } from "../../internal/class-names.js";
|
|
4
|
+
import { useMessages as n } from "../../intl/provider.js";
|
|
5
|
+
import { FieldFrame as r } from "./internal.js";
|
|
6
|
+
import * as i from "react";
|
|
7
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
8
|
+
import { OTPField as o } from "@base-ui/react/otp-field";
|
|
9
|
+
//#region src/components/forms/code-field.tsx
|
|
10
|
+
function s(e, t, n) {
|
|
11
|
+
return Number.isFinite(e) ? Math.min(n, Math.max(t, Math.trunc(e))) : t;
|
|
12
|
+
}
|
|
13
|
+
var c = i.forwardRef(function({ label: i, description: c, error: l, invalid: u, disabled: d, readOnly: f, required: p, name: m, size: h = "md", className: g, style: _, requiredIndicator: v, validate: y, validationMode: b, validationDebounceTime: x, dirty: S, touched: C, actionsRef: w, inputClassName: T, inputStyle: E, getSlotLabel: D, length: O = 6, groupSize: k, groupClassName: A, groupStyle: j, placeholder: M, validationType: N = "numeric", ...P }, F) {
|
|
14
|
+
let I = n(), L = s(O, 2, 12), R = s(k ?? (L >= 9 ? 4 : 1), 1, L), z = R > 1, B = [], V = typeof M == "string" ? Array.from(M) : null;
|
|
15
|
+
for (let e = 0; e < L; e += R) B.push(Array.from({ length: Math.min(R, L - e) }, (t, n) => e + n));
|
|
16
|
+
let H = (n, r) => /* @__PURE__ */ a(o.Input, {
|
|
17
|
+
className: t(e("lyds-otp-field__input", "lyds-code-field__input", r && "lyds-code-field__group-input"), T),
|
|
18
|
+
style: E,
|
|
19
|
+
placeholder: typeof M == "function" ? M(n) : V?.[n],
|
|
20
|
+
"aria-label": n > 0 ? D?.(n) ?? I.codeSlotLabel(n + 1, L) : void 0
|
|
21
|
+
}, n);
|
|
22
|
+
return /* @__PURE__ */ a(r, {
|
|
23
|
+
label: i,
|
|
24
|
+
description: c,
|
|
25
|
+
error: l,
|
|
26
|
+
invalid: u,
|
|
27
|
+
disabled: d,
|
|
28
|
+
readOnly: f,
|
|
29
|
+
required: p,
|
|
30
|
+
name: m,
|
|
31
|
+
size: h,
|
|
32
|
+
className: g,
|
|
33
|
+
style: _,
|
|
34
|
+
requiredIndicator: v,
|
|
35
|
+
validate: y,
|
|
36
|
+
validationMode: b,
|
|
37
|
+
validationDebounceTime: x,
|
|
38
|
+
dirty: S,
|
|
39
|
+
touched: C,
|
|
40
|
+
actionsRef: w,
|
|
41
|
+
children: /* @__PURE__ */ a(o.Root, {
|
|
42
|
+
...P,
|
|
43
|
+
ref: F,
|
|
44
|
+
className: e("lyds-otp-field", "lyds-code-field"),
|
|
45
|
+
name: m,
|
|
46
|
+
disabled: d,
|
|
47
|
+
readOnly: f,
|
|
48
|
+
required: p,
|
|
49
|
+
length: L,
|
|
50
|
+
validationType: N,
|
|
51
|
+
"data-size": h,
|
|
52
|
+
"data-grouped": z || void 0,
|
|
53
|
+
"data-group-size": R,
|
|
54
|
+
children: B.map((t, n) => z ? /* @__PURE__ */ a("span", {
|
|
55
|
+
className: e("lyds-code-field__group", A),
|
|
56
|
+
style: j,
|
|
57
|
+
"data-group-index": n,
|
|
58
|
+
children: t.map((e) => H(e, !0))
|
|
59
|
+
}, t[0]) : H(t[0], !1))
|
|
60
|
+
})
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
//#endregion
|
|
64
|
+
export { c as CodeField };
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=code-field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-field.js","names":[],"sources":["../../../src/components/forms/code-field.tsx"],"sourcesContent":["import { cx, withStateClassName } from \"@/internal\";\nimport { useMessages } from \"@/intl\";\nimport { OTPField as BaseOTPField } from \"@base-ui/react/otp-field\";\nimport * as React from \"react\";\nimport \"./forms.css\";\nimport { FieldFrame } from \"./internal\";\nimport type { OTPFieldProps } from \"./otp-field\";\n\nexport interface CodeFieldProps extends Omit<OTPFieldProps, \"length\" | \"separator\" | \"separatorAfter\"> {\n\t/**\n\t * 驗證碼字元數。數值限制為 2 至 12。\n\t * @default 6\n\t */\n\tlength?: number;\n\t/**\n\t * 每個視覺群組顯示的字元數。長度為 9 至 12 時預設每四個字元一組;\n\t * 較短的驗證碼預設各自獨立。設為 1 可強制使用獨立輸入格。\n\t */\n\tgroupSize?: number;\n\tgroupClassName?: string;\n\tgroupStyle?: React.CSSProperties;\n\t/**\n\t * 空白輸入格的選用提示。字串會依序將每個字元分配至各輸入格;\n\t * 需要個別在地化或自訂時可使用函式。\n\t */\n\tplaceholder?: string | ((index: number) => string | undefined);\n}\n\nfunction constrainInteger(value: number, minimum: number, maximum: number): number {\n\tif (!Number.isFinite(value)) return minimum;\n\treturn Math.min(maximum, Math.max(minimum, Math.trunc(value)));\n}\n\n/** 以 Base UI OTP Field 實作的多格驗證碼控制項。 */\nexport const CodeField = React.forwardRef<HTMLDivElement, CodeFieldProps>(function CodeField(\n\t{\n\t\tlabel,\n\t\tdescription,\n\t\terror,\n\t\tinvalid,\n\t\tdisabled,\n\t\treadOnly,\n\t\trequired,\n\t\tname,\n\t\tsize = \"md\",\n\t\tclassName,\n\t\tstyle,\n\t\trequiredIndicator,\n\t\tvalidate,\n\t\tvalidationMode,\n\t\tvalidationDebounceTime,\n\t\tdirty,\n\t\ttouched,\n\t\tactionsRef,\n\t\tinputClassName,\n\t\tinputStyle,\n\t\tgetSlotLabel,\n\t\tlength: lengthProp = 6,\n\t\tgroupSize: groupSizeProp,\n\t\tgroupClassName,\n\t\tgroupStyle,\n\t\tplaceholder,\n\t\tvalidationType = \"numeric\",\n\t\t...otpProps\n\t},\n\tref\n) {\n\tconst messages = useMessages();\n\tconst length = constrainInteger(lengthProp, 2, 12);\n\tconst defaultGroupSize = length >= 9 ? 4 : 1;\n\tconst groupSize = constrainInteger(groupSizeProp ?? defaultGroupSize, 1, length);\n\tconst grouped = groupSize > 1;\n\tconst groups: number[][] = [];\n\tconst placeholderCharacters = typeof placeholder === \"string\" ? Array.from(placeholder) : null;\n\n\tfor (let start = 0; start < length; start += groupSize) {\n\t\tgroups.push(Array.from({ length: Math.min(groupSize, length - start) }, (_, offset) => start + offset));\n\t}\n\n\tconst renderSlot = (index: number, insideGroup: boolean) => (\n\t\t<BaseOTPField.Input\n\t\t\tkey={index}\n\t\t\tclassName={withStateClassName<BaseOTPField.Input.State>(cx(\"lyds-otp-field__input\", \"lyds-code-field__input\", insideGroup && \"lyds-code-field__group-input\"), inputClassName)}\n\t\t\tstyle={inputStyle}\n\t\t\tplaceholder={typeof placeholder === \"function\" ? placeholder(index) : placeholderCharacters?.[index]}\n\t\t\taria-label={index > 0 ? (getSlotLabel?.(index) ?? messages.codeSlotLabel(index + 1, length)) : undefined}\n\t\t/>\n\t);\n\n\treturn (\n\t\t<FieldFrame\n\t\t\tlabel={label}\n\t\t\tdescription={description}\n\t\t\terror={error}\n\t\t\tinvalid={invalid}\n\t\t\tdisabled={disabled}\n\t\t\treadOnly={readOnly}\n\t\t\trequired={required}\n\t\t\tname={name}\n\t\t\tsize={size}\n\t\t\tclassName={className}\n\t\t\tstyle={style}\n\t\t\trequiredIndicator={requiredIndicator}\n\t\t\tvalidate={validate}\n\t\t\tvalidationMode={validationMode}\n\t\t\tvalidationDebounceTime={validationDebounceTime}\n\t\t\tdirty={dirty}\n\t\t\ttouched={touched}\n\t\t\tactionsRef={actionsRef}\n\t\t>\n\t\t\t<BaseOTPField.Root\n\t\t\t\t{...otpProps}\n\t\t\t\tref={ref}\n\t\t\t\tclassName={cx(\"lyds-otp-field\", \"lyds-code-field\")}\n\t\t\t\tname={name}\n\t\t\t\tdisabled={disabled}\n\t\t\t\treadOnly={readOnly}\n\t\t\t\trequired={required}\n\t\t\t\tlength={length}\n\t\t\t\tvalidationType={validationType}\n\t\t\t\tdata-size={size}\n\t\t\t\tdata-grouped={grouped || undefined}\n\t\t\t\tdata-group-size={groupSize}\n\t\t\t>\n\t\t\t\t{groups.map((indices, groupIndex) =>\n\t\t\t\t\tgrouped ? (\n\t\t\t\t\t\t<span key={indices[0]} className={cx(\"lyds-code-field__group\", groupClassName)} style={groupStyle} data-group-index={groupIndex}>\n\t\t\t\t\t\t\t{indices.map(index => renderSlot(index, true))}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) : (\n\t\t\t\t\t\trenderSlot(indices[0] as number, false)\n\t\t\t\t\t)\n\t\t\t\t)}\n\t\t\t</BaseOTPField.Root>\n\t\t</FieldFrame>\n\t);\n});\n"],"mappings":";;;;;;;;;AA4BA,SAAS,EAAiB,GAAe,GAAiB,GAAyB;CAElF,OADK,OAAO,SAAS,CAAK,IACnB,KAAK,IAAI,GAAS,KAAK,IAAI,GAAS,KAAK,MAAM,CAAK,CAAC,CAAC,IADzB;AAErC;AAGA,IAAa,IAAY,EAAM,WAA2C,SACzE,EACC,UACA,gBACA,UACA,YACA,aACA,aACA,a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oBAAkB;IACnH,UAAA,EAAQ,KAAI,MAAS,EAAW,GAAO,EAAI,CAAC;GACxC,GAFK,EAAQ,EAEb,IAEN,EAAW,EAAQ,IAAc,EAAK,CAExC;EACkB,CAAA;CACR,CAAA;AAEd,CAAC"}
|
|
@@ -21,7 +21,7 @@ export interface DropZoneProps extends NativeFileInputProps, FieldAnatomyProps {
|
|
|
21
21
|
inputClassName?: string;
|
|
22
22
|
primaryLabel?: React.ReactNode;
|
|
23
23
|
secondaryLabel?: React.ReactNode;
|
|
24
|
-
browseLabel?:
|
|
24
|
+
browseLabel?: React.ReactNode;
|
|
25
25
|
invalidFileLabel?: React.ReactNode;
|
|
26
26
|
onChange?: React.ChangeEventHandler<HTMLInputElement>;
|
|
27
27
|
onFilesChange?: (files: readonly File[], details: DropZoneChangeDetails) => void;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
/* empty css */
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
3
|
+
import { cx as e } from "../../internal/class-names.js";
|
|
4
|
+
import { useMessages as t } from "../../intl/provider.js";
|
|
5
|
+
import { FieldFrame as n } from "./internal.js";
|
|
4
6
|
import * as r from "react";
|
|
5
7
|
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
6
8
|
import { Input as o } from "@base-ui/react/input";
|
|
7
9
|
import { FileIcon as s } from "@phosphor-icons/react/dist/csr/File";
|
|
8
10
|
import { PlusIcon as c } from "@phosphor-icons/react/dist/csr/Plus";
|
|
9
|
-
//#region src/components/forms/
|
|
11
|
+
//#region src/components/forms/file-upload.tsx
|
|
10
12
|
function l({ file: e }) {
|
|
11
13
|
let [t, n] = r.useState(null);
|
|
12
14
|
return r.useEffect(() => {
|
|
@@ -41,27 +43,28 @@ function u(e, t) {
|
|
|
41
43
|
return t ? t.startsWith(".") ? n.endsWith(t) : t.endsWith("/*") ? r.startsWith(t.slice(0, -1)) : r === t : !1;
|
|
42
44
|
});
|
|
43
45
|
}
|
|
44
|
-
function d({ accept:
|
|
46
|
+
function d({ accept: n, files: r, invalidFileLabel: o, summaryId: c }) {
|
|
47
|
+
let d = t();
|
|
45
48
|
return /* @__PURE__ */ a("div", {
|
|
46
|
-
className:
|
|
49
|
+
className: e("lyds-file-selection", r.length === 0 && "lyds-sr-only"),
|
|
47
50
|
children: [/* @__PURE__ */ i("p", {
|
|
48
|
-
id:
|
|
51
|
+
id: c,
|
|
49
52
|
className: "lyds-file-selection__summary",
|
|
50
53
|
role: "status",
|
|
51
54
|
"aria-live": "polite",
|
|
52
55
|
"aria-atomic": "true",
|
|
53
|
-
children:
|
|
54
|
-
}),
|
|
56
|
+
children: r.length > 0 ? d.fileSelectionSummary(r.length) : null
|
|
57
|
+
}), r.length > 0 ? /* @__PURE__ */ i("ul", {
|
|
55
58
|
className: "lyds-file-selection__list",
|
|
56
|
-
"aria-label":
|
|
57
|
-
children:
|
|
58
|
-
let
|
|
59
|
+
"aria-label": d.fileSelectionLabel,
|
|
60
|
+
children: r.map((e, t) => {
|
|
61
|
+
let r = u(e, n);
|
|
59
62
|
return /* @__PURE__ */ a("li", {
|
|
60
63
|
className: "lyds-file-selection__item",
|
|
61
|
-
"data-invalid":
|
|
64
|
+
"data-invalid": r ? void 0 : "",
|
|
62
65
|
children: [/* @__PURE__ */ i("span", {
|
|
63
66
|
className: "lyds-file-selection__visual",
|
|
64
|
-
children:
|
|
67
|
+
children: e.type.startsWith("image/") ? /* @__PURE__ */ i(l, { file: e }) : /* @__PURE__ */ i(s, {
|
|
65
68
|
"aria-hidden": "true",
|
|
66
69
|
weight: "regular"
|
|
67
70
|
})
|
|
@@ -69,14 +72,14 @@ function d({ accept: e, files: n, invalidFileLabel: r, summaryId: o }) {
|
|
|
69
72
|
className: "lyds-file-selection__details",
|
|
70
73
|
children: [/* @__PURE__ */ i("span", {
|
|
71
74
|
className: "lyds-file-selection__name",
|
|
72
|
-
title:
|
|
73
|
-
children:
|
|
74
|
-
}),
|
|
75
|
+
title: e.name,
|
|
76
|
+
children: e.name
|
|
77
|
+
}), r ? null : /* @__PURE__ */ i("span", {
|
|
75
78
|
className: "lyds-file-selection__status",
|
|
76
|
-
children:
|
|
79
|
+
children: o
|
|
77
80
|
})]
|
|
78
81
|
})]
|
|
79
|
-
}, `${
|
|
82
|
+
}, `${e.name}-${e.size}-${e.lastModified}-${t}`);
|
|
80
83
|
})
|
|
81
84
|
}) : null]
|
|
82
85
|
});
|
|
@@ -93,16 +96,40 @@ function ee(e, t, n) {
|
|
|
93
96
|
n
|
|
94
97
|
]);
|
|
95
98
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
99
|
+
function te(e, t) {
|
|
100
|
+
return (n) => {
|
|
101
|
+
t?.(n), e && n.preventDefault();
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function ne({ children: t, className: n, disabled: r, htmlFor: o, id: s, readOnly: c, size: l, startIcon: u }) {
|
|
105
|
+
return /* @__PURE__ */ a("label", {
|
|
106
|
+
className: e("lyds-button", n),
|
|
107
|
+
"data-disabled": r || void 0,
|
|
108
|
+
"data-readonly": c || void 0,
|
|
109
|
+
"data-size": l,
|
|
110
|
+
"data-variant": "secondary",
|
|
111
|
+
htmlFor: o,
|
|
112
|
+
children: [u == null ? null : /* @__PURE__ */ i("span", {
|
|
113
|
+
className: "lyds-button__icon",
|
|
114
|
+
"aria-hidden": "true",
|
|
115
|
+
children: u
|
|
116
|
+
}), /* @__PURE__ */ i("span", {
|
|
117
|
+
className: "lyds-button__label",
|
|
118
|
+
id: s,
|
|
119
|
+
children: t
|
|
120
|
+
})]
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
var f = r.forwardRef(function({ label: s, description: c, error: l, invalid: u, disabled: f, readOnly: p, required: m, name: h, size: g = "md", className: _, style: v, requiredIndicator: y, validate: b, validationMode: x, validationDebounceTime: S, dirty: C, touched: w, actionsRef: T, inputClassName: E, inputStyle: D, triggerLabel: O, invalidFileLabel: k, onChange: A, onFilesChange: j, id: re, ...M }, N) {
|
|
124
|
+
let P = t(), F = te(p, M.onClick), I = r.useId(), L = re ?? I, R = `${L}-label`, z = `${L}-description`, B = `${L}-error`, V = `${L}-trigger-label`, H = `${L}-selection-summary`, U = r.useRef(null), [W, G] = r.useState([]);
|
|
125
|
+
ee(U, M.form, G), r.useImperativeHandle(N, () => U.current);
|
|
126
|
+
let K = (e) => {
|
|
100
127
|
if (!(f || p) && (A?.(e), !e.defaultPrevented)) {
|
|
101
128
|
let t = Array.from(e.currentTarget.files ?? []);
|
|
102
|
-
|
|
129
|
+
G(t), j?.(t, e);
|
|
103
130
|
}
|
|
104
131
|
};
|
|
105
|
-
return /* @__PURE__ */ i(
|
|
132
|
+
return /* @__PURE__ */ i(n, {
|
|
106
133
|
label: s,
|
|
107
134
|
description: c,
|
|
108
135
|
error: l,
|
|
@@ -115,9 +142,9 @@ var f = r.forwardRef(function({ label: s, description: c, error: l, invalid: u,
|
|
|
115
142
|
className: _,
|
|
116
143
|
style: v,
|
|
117
144
|
requiredIndicator: y,
|
|
118
|
-
labelId:
|
|
119
|
-
descriptionId:
|
|
120
|
-
errorId:
|
|
145
|
+
labelId: R,
|
|
146
|
+
descriptionId: z,
|
|
147
|
+
errorId: B,
|
|
121
148
|
validate: b,
|
|
122
149
|
validationMode: x,
|
|
123
150
|
validationDebounceTime: S,
|
|
@@ -129,105 +156,100 @@ var f = r.forwardRef(function({ label: s, description: c, error: l, invalid: u,
|
|
|
129
156
|
"data-size": g,
|
|
130
157
|
children: [
|
|
131
158
|
/* @__PURE__ */ i(o, {
|
|
132
|
-
...
|
|
133
|
-
ref:
|
|
134
|
-
id:
|
|
159
|
+
...M,
|
|
160
|
+
ref: U,
|
|
161
|
+
id: L,
|
|
135
162
|
type: "file",
|
|
136
|
-
className:
|
|
163
|
+
className: e("lyds-file-upload__input", E),
|
|
137
164
|
style: D,
|
|
138
|
-
disabled: f
|
|
165
|
+
disabled: f,
|
|
139
166
|
readOnly: p,
|
|
167
|
+
"aria-disabled": p || void 0,
|
|
168
|
+
onClick: F,
|
|
140
169
|
required: m,
|
|
141
170
|
"aria-invalid": u || void 0,
|
|
142
|
-
"aria-labelledby": s == null ?
|
|
143
|
-
"aria-describedby":
|
|
144
|
-
|
|
145
|
-
U.length > 0 ? V : null,
|
|
146
|
-
z
|
|
147
|
-
].filter(Boolean).join(" "),
|
|
148
|
-
tabIndex: -1,
|
|
149
|
-
onChange: G
|
|
171
|
+
"aria-labelledby": s == null ? V : `${R} ${V}`,
|
|
172
|
+
"aria-describedby": e(c != null && z, W.length > 0 && H, l != null && B) || void 0,
|
|
173
|
+
onChange: K
|
|
150
174
|
}),
|
|
151
|
-
/* @__PURE__ */ i(
|
|
175
|
+
/* @__PURE__ */ i(ne, {
|
|
152
176
|
className: "lyds-file-upload__trigger",
|
|
153
|
-
disabled: f
|
|
177
|
+
disabled: !!f,
|
|
178
|
+
htmlFor: L,
|
|
179
|
+
id: V,
|
|
180
|
+
readOnly: !!p,
|
|
154
181
|
size: g,
|
|
155
|
-
|
|
156
|
-
onClick: () => H.current?.click(),
|
|
157
|
-
children: /* @__PURE__ */ i("span", {
|
|
158
|
-
id: B,
|
|
159
|
-
children: O
|
|
160
|
-
})
|
|
182
|
+
children: O ?? P.fileUploadTrigger
|
|
161
183
|
}),
|
|
162
184
|
/* @__PURE__ */ i(d, {
|
|
163
|
-
accept:
|
|
164
|
-
files:
|
|
165
|
-
invalidFileLabel: k,
|
|
166
|
-
summaryId:
|
|
185
|
+
accept: M.accept,
|
|
186
|
+
files: W,
|
|
187
|
+
invalidFileLabel: k ?? P.fileUploadInvalidFile,
|
|
188
|
+
summaryId: H
|
|
167
189
|
})
|
|
168
190
|
]
|
|
169
191
|
})
|
|
170
192
|
});
|
|
171
|
-
}), p = r.forwardRef(function({ label: s, description: l, error: u, invalid: f, disabled: p, readOnly: m, required: h, name: g, size: _ = "md", className: v, style: y, requiredIndicator: b, validate: x, validationMode: S, validationDebounceTime: C, dirty: w, touched: T, actionsRef: E, inputClassName: D, primaryLabel: O
|
|
172
|
-
let V = r.useId(),
|
|
173
|
-
ee(
|
|
174
|
-
let
|
|
175
|
-
if (p || m || (
|
|
193
|
+
}), p = r.forwardRef(function({ label: s, description: l, error: u, invalid: f, disabled: p, readOnly: m, required: h, name: g, size: _ = "md", className: v, style: y, requiredIndicator: b, validate: x, validationMode: S, validationDebounceTime: C, dirty: w, touched: T, actionsRef: E, inputClassName: D, primaryLabel: O, secondaryLabel: k, browseLabel: A, invalidFileLabel: j, onChange: re, onFilesChange: M, onDragEnter: N, onDragOver: P, onDragLeave: F, onDrop: I, id: L, ...R }, z) {
|
|
194
|
+
let B = t(), V = te(m, R.onClick), H = r.useId(), U = L ?? H, W = `${U}-label`, G = `${U}-description`, K = `${U}-error`, q = `${U}-trigger-label`, J = `${U}-selection-summary`, Y = r.useRef(null), [ie, X] = r.useState(!1), [ae, Z] = r.useState([]), Q = r.useRef(0), $ = r.useRef(null);
|
|
195
|
+
ee(Y, R.form, Z), r.useImperativeHandle(z, () => Y.current);
|
|
196
|
+
let oe = (e) => {
|
|
197
|
+
if (p || m || (re?.(e), e.defaultPrevented)) return;
|
|
176
198
|
let t = $.current;
|
|
177
199
|
if (t != null) {
|
|
178
|
-
t.handled = !0, Z(t.files),
|
|
200
|
+
t.handled = !0, Z(t.files), M?.(t.files, {
|
|
179
201
|
source: "drop",
|
|
180
202
|
event: t.event
|
|
181
203
|
});
|
|
182
204
|
return;
|
|
183
205
|
}
|
|
184
206
|
let n = Array.from(e.currentTarget.files ?? []);
|
|
185
|
-
Z(n),
|
|
207
|
+
Z(n), M?.(n, {
|
|
186
208
|
source: "input",
|
|
187
209
|
event: e
|
|
188
210
|
});
|
|
189
|
-
},
|
|
211
|
+
}, se = (e) => {
|
|
190
212
|
if (p || m) {
|
|
191
|
-
|
|
213
|
+
N?.(e);
|
|
192
214
|
return;
|
|
193
215
|
}
|
|
194
|
-
e.preventDefault(),
|
|
195
|
-
},
|
|
216
|
+
e.preventDefault(), N?.(e), Q.current += 1, X(!0);
|
|
217
|
+
}, ce = (e) => {
|
|
196
218
|
if (p || m) {
|
|
197
|
-
|
|
219
|
+
P?.(e);
|
|
198
220
|
return;
|
|
199
221
|
}
|
|
200
|
-
e.preventDefault(), e.dataTransfer.dropEffect = "copy",
|
|
201
|
-
},
|
|
202
|
-
|
|
203
|
-
},
|
|
222
|
+
e.preventDefault(), e.dataTransfer.dropEffect = "copy", P?.(e);
|
|
223
|
+
}, le = (e) => {
|
|
224
|
+
F?.(e), !(p || m) && (Q.current = Math.max(0, Q.current - 1), Q.current === 0 && X(!1));
|
|
225
|
+
}, ue = (e) => {
|
|
204
226
|
if (p || m) {
|
|
205
|
-
|
|
227
|
+
I?.(e);
|
|
206
228
|
return;
|
|
207
229
|
}
|
|
208
|
-
e.preventDefault(),
|
|
230
|
+
e.preventDefault(), I?.(e), Q.current = 0, X(!1);
|
|
209
231
|
let t = Array.from(e.dataTransfer.files ?? []);
|
|
210
|
-
if (
|
|
232
|
+
if (Y.current != null) {
|
|
211
233
|
try {
|
|
212
|
-
|
|
234
|
+
Y.current.files = e.dataTransfer.files;
|
|
213
235
|
} catch {}
|
|
214
236
|
let n = {
|
|
215
237
|
event: e,
|
|
216
238
|
files: t,
|
|
217
239
|
handled: !1
|
|
218
240
|
};
|
|
219
|
-
$.current = n,
|
|
241
|
+
$.current = n, Y.current.dispatchEvent(new Event("change", { bubbles: !0 })), $.current = null, n.handled || (Z(t), M?.(t, {
|
|
220
242
|
source: "drop",
|
|
221
243
|
event: e
|
|
222
244
|
}));
|
|
223
245
|
return;
|
|
224
246
|
}
|
|
225
|
-
Z(t),
|
|
247
|
+
Z(t), M?.(t, {
|
|
226
248
|
source: "drop",
|
|
227
249
|
event: e
|
|
228
250
|
});
|
|
229
251
|
};
|
|
230
|
-
return /* @__PURE__ */ a(
|
|
252
|
+
return /* @__PURE__ */ a(n, {
|
|
231
253
|
label: s,
|
|
232
254
|
description: l,
|
|
233
255
|
error: u,
|
|
@@ -240,9 +262,9 @@ var f = r.forwardRef(function({ label: s, description: c, error: l, invalid: u,
|
|
|
240
262
|
className: v,
|
|
241
263
|
style: y,
|
|
242
264
|
requiredIndicator: b,
|
|
243
|
-
labelId:
|
|
244
|
-
descriptionId:
|
|
245
|
-
errorId:
|
|
265
|
+
labelId: W,
|
|
266
|
+
descriptionId: G,
|
|
267
|
+
errorId: K,
|
|
246
268
|
validate: x,
|
|
247
269
|
validationMode: S,
|
|
248
270
|
validationDebounceTime: C,
|
|
@@ -250,64 +272,59 @@ var f = r.forwardRef(function({ label: s, description: c, error: l, invalid: u,
|
|
|
250
272
|
touched: T,
|
|
251
273
|
actionsRef: E,
|
|
252
274
|
children: [/* @__PURE__ */ i(o, {
|
|
253
|
-
...
|
|
254
|
-
ref:
|
|
255
|
-
id:
|
|
275
|
+
...R,
|
|
276
|
+
ref: Y,
|
|
277
|
+
id: U,
|
|
256
278
|
type: "file",
|
|
257
|
-
className:
|
|
258
|
-
disabled: p
|
|
279
|
+
className: e("lyds-drop-zone__input", D),
|
|
280
|
+
disabled: p,
|
|
259
281
|
readOnly: m,
|
|
282
|
+
"aria-disabled": m || void 0,
|
|
283
|
+
onClick: V,
|
|
260
284
|
required: h,
|
|
261
285
|
"aria-invalid": f || void 0,
|
|
262
|
-
"aria-labelledby": s == null ?
|
|
263
|
-
"aria-describedby":
|
|
264
|
-
|
|
265
|
-
X.length > 0 ? q : null,
|
|
266
|
-
G
|
|
267
|
-
].filter(Boolean).join(" "),
|
|
268
|
-
tabIndex: -1,
|
|
269
|
-
onChange: ne
|
|
286
|
+
"aria-labelledby": s == null ? q : `${W} ${q}`,
|
|
287
|
+
"aria-describedby": e(l != null && G, ae.length > 0 && J, u != null && K) || void 0,
|
|
288
|
+
onChange: oe
|
|
270
289
|
}), /* @__PURE__ */ a("div", {
|
|
271
290
|
className: "lyds-drop-zone",
|
|
272
291
|
"data-size": _,
|
|
273
|
-
"data-dragging":
|
|
292
|
+
"data-dragging": ie || void 0,
|
|
274
293
|
"data-disabled": p || void 0,
|
|
275
294
|
"data-readonly": m || void 0,
|
|
276
|
-
onDragEnter:
|
|
277
|
-
onDragOver:
|
|
278
|
-
onDragLeave:
|
|
279
|
-
onDrop:
|
|
295
|
+
onDragEnter: se,
|
|
296
|
+
onDragOver: ce,
|
|
297
|
+
onDragLeave: le,
|
|
298
|
+
onDrop: ue,
|
|
280
299
|
children: [
|
|
281
300
|
/* @__PURE__ */ a("span", {
|
|
282
301
|
className: "lyds-drop-zone__copy",
|
|
283
302
|
children: [/* @__PURE__ */ i("span", {
|
|
284
303
|
className: "lyds-drop-zone__primary",
|
|
285
|
-
children: O
|
|
304
|
+
children: O ?? B.dropZonePrimary
|
|
286
305
|
}), /* @__PURE__ */ i("span", {
|
|
287
306
|
className: "lyds-drop-zone__secondary",
|
|
288
|
-
children: k
|
|
307
|
+
children: k ?? B.dropZoneSecondary
|
|
289
308
|
})]
|
|
290
309
|
}),
|
|
291
|
-
/* @__PURE__ */ i(
|
|
310
|
+
/* @__PURE__ */ i(ne, {
|
|
292
311
|
className: "lyds-drop-zone__button",
|
|
293
|
-
disabled: p
|
|
312
|
+
disabled: !!p,
|
|
313
|
+
htmlFor: U,
|
|
314
|
+
id: q,
|
|
315
|
+
readOnly: !!m,
|
|
294
316
|
size: _,
|
|
295
317
|
startIcon: /* @__PURE__ */ i(c, {
|
|
296
318
|
"aria-hidden": "true",
|
|
297
319
|
weight: "bold"
|
|
298
320
|
}),
|
|
299
|
-
|
|
300
|
-
onClick: () => J.current?.click(),
|
|
301
|
-
children: /* @__PURE__ */ i("span", {
|
|
302
|
-
id: K,
|
|
303
|
-
children: A
|
|
304
|
-
})
|
|
321
|
+
children: A ?? B.dropZoneBrowse
|
|
305
322
|
}),
|
|
306
323
|
/* @__PURE__ */ i(d, {
|
|
307
|
-
accept:
|
|
308
|
-
files:
|
|
309
|
-
invalidFileLabel: j,
|
|
310
|
-
summaryId:
|
|
324
|
+
accept: R.accept,
|
|
325
|
+
files: ae,
|
|
326
|
+
invalidFileLabel: j ?? B.fileUploadInvalidFile,
|
|
327
|
+
summaryId: J
|
|
311
328
|
})
|
|
312
329
|
]
|
|
313
330
|
})]
|
|
@@ -316,4 +333,4 @@ var f = r.forwardRef(function({ label: s, description: c, error: l, invalid: u,
|
|
|
316
333
|
//#endregion
|
|
317
334
|
export { p as DropZone, f as FileUpload };
|
|
318
335
|
|
|
319
|
-
//# sourceMappingURL=
|
|
336
|
+
//# sourceMappingURL=file-upload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-upload.js","names":[],"sources":["../../../src/components/forms/file-upload.tsx"],"sourcesContent":["import { cx } from \"@/internal\";\nimport { useMessages } from \"@/intl\";\nimport { Input as BaseInput } from \"@base-ui/react/input\";\nimport { FileIcon } from \"@phosphor-icons/react/dist/csr/File\";\nimport { PlusIcon } from \"@phosphor-icons/react/dist/csr/Plus\";\nimport * as React from \"react\";\nimport \"./forms.css\";\nimport { FieldFrame, type FieldAnatomyProps } from \"./internal\";\ntype NativeFileInputProps = Omit<\n\tReact.InputHTMLAttributes<HTMLInputElement>,\n\t\"children\" | \"className\" | \"defaultValue\" | \"disabled\" | \"name\" | \"onChange\" | \"readOnly\" | \"required\" | \"size\" | \"style\" | \"type\" | \"value\"\n>;\n\nfunction FileImagePreview({ file }: { file: File }) {\n\tconst [preview, setPreview] = React.useState<{ file: File; url: string } | null>(null);\n\n\tReact.useEffect(() => {\n\t\tif (typeof URL.createObjectURL !== \"function\" || typeof URL.revokeObjectURL !== \"function\") return;\n\n\t\tconst previewUrl = URL.createObjectURL(file);\n\t\tlet disposed = false;\n\t\tqueueMicrotask(() => {\n\t\t\tif (!disposed) {\n\t\t\t\tsetPreview({ file, url: previewUrl });\n\t\t\t}\n\t\t});\n\n\t\treturn () => {\n\t\t\tdisposed = true;\n\t\t\tURL.revokeObjectURL(previewUrl);\n\t\t};\n\t}, [file]);\n\n\tif (preview?.file !== file) return <FileIcon aria-hidden=\"true\" weight=\"regular\" />;\n\treturn <img className=\"lyds-file-selection__thumbnail\" src={preview.url} alt=\"\" width={48} height={48} loading=\"lazy\" decoding=\"async\" />;\n}\n\nfunction isFileAccepted(file: File, accept: string | undefined): boolean {\n\tif (!accept?.trim()) return true;\n\n\tconst fileName = file.name.toLocaleLowerCase();\n\tconst mimeType = file.type.toLocaleLowerCase();\n\treturn accept.split(\",\").some(rawRule => {\n\t\tconst rule = rawRule.trim().toLocaleLowerCase();\n\t\tif (!rule) return false;\n\t\tif (rule.startsWith(\".\")) return fileName.endsWith(rule);\n\t\tif (rule.endsWith(\"/*\")) return mimeType.startsWith(rule.slice(0, -1));\n\t\treturn mimeType === rule;\n\t});\n}\n\ninterface FileSelectionPreviewProps {\n\taccept: string | undefined;\n\tfiles: readonly File[];\n\tinvalidFileLabel: React.ReactNode;\n\tsummaryId: string;\n}\n\nfunction FileSelectionPreview({ accept, files, invalidFileLabel, summaryId }: FileSelectionPreviewProps) {\n\tconst messages = useMessages();\n\n\treturn (\n\t\t<div className={cx(\"lyds-file-selection\", files.length === 0 && \"lyds-sr-only\")}>\n\t\t\t<p id={summaryId} className=\"lyds-file-selection__summary\" role=\"status\" aria-live=\"polite\" aria-atomic=\"true\">\n\t\t\t\t{files.length > 0 ? messages.fileSelectionSummary(files.length) : null}\n\t\t\t</p>\n\t\t\t{files.length > 0 ? (\n\t\t\t\t<ul className=\"lyds-file-selection__list\" aria-label={messages.fileSelectionLabel}>\n\t\t\t\t\t{files.map((file, index) => {\n\t\t\t\t\t\tconst accepted = isFileAccepted(file, accept);\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<li className=\"lyds-file-selection__item\" data-invalid={accepted ? undefined : \"\"} key={`${file.name}-${file.size}-${file.lastModified}-${index}`}>\n\t\t\t\t\t\t\t\t<span className=\"lyds-file-selection__visual\">{file.type.startsWith(\"image/\") ? <FileImagePreview file={file} /> : <FileIcon aria-hidden=\"true\" weight=\"regular\" />}</span>\n\t\t\t\t\t\t\t\t<span className=\"lyds-file-selection__details\">\n\t\t\t\t\t\t\t\t\t<span className=\"lyds-file-selection__name\" title={file.name}>\n\t\t\t\t\t\t\t\t\t\t{file.name}\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t{accepted ? null : <span className=\"lyds-file-selection__status\">{invalidFileLabel}</span>}\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t);\n\t\t\t\t\t})}\n\t\t\t\t</ul>\n\t\t\t) : null}\n\t\t</div>\n\t);\n}\n\nfunction useClearFileSelectionOnFormReset(inputRef: React.RefObject<HTMLInputElement | null>, formId: string | undefined, setSelectedFiles: React.Dispatch<React.SetStateAction<readonly File[]>>) {\n\tReact.useEffect(() => {\n\t\tconst form = inputRef.current?.form;\n\t\tif (form == null) return;\n\n\t\tconst handleReset = () => setSelectedFiles([]);\n\t\tform.addEventListener(\"reset\", handleReset);\n\t\treturn () => form.removeEventListener(\"reset\", handleReset);\n\t}, [formId, inputRef, setSelectedFiles]);\n}\n\n/**\n * HTML has no read-only file input. Disabling one would drop whatever the user already picked from\n * the submission, so a read-only field stays enabled and simply refuses to open the picker.\n */\nfunction useBlockedPicker(readOnly: boolean | undefined, onClick: React.MouseEventHandler<HTMLInputElement> | undefined) {\n\treturn (event: React.MouseEvent<HTMLInputElement>) => {\n\t\tonClick?.(event);\n\t\tif (readOnly) event.preventDefault();\n\t};\n}\n\ninterface FileTriggerProps {\n\tchildren: React.ReactNode;\n\tclassName: string;\n\tdisabled: boolean;\n\thtmlFor: string;\n\tid: string;\n\treadOnly: boolean;\n\tsize: FieldAnatomyProps[\"size\"];\n\tstartIcon?: React.ReactNode;\n}\n\n/**\n * The visible affordance is a label bound to the real file input, so the input keeps the single\n * tab stop, the accessible name and native picker activation. Rendering a button beside the input\n * instead would leave the description, error and validity on an element the keyboard cannot reach.\n */\nfunction FileTrigger({ children, className, disabled, htmlFor, id, readOnly, size, startIcon }: FileTriggerProps) {\n\treturn (\n\t\t<label className={cx(\"lyds-button\", className)} data-disabled={disabled || undefined} data-readonly={readOnly || undefined} data-size={size} data-variant=\"secondary\" htmlFor={htmlFor}>\n\t\t\t{startIcon != null ? (\n\t\t\t\t<span className=\"lyds-button__icon\" aria-hidden=\"true\">\n\t\t\t\t\t{startIcon}\n\t\t\t\t</span>\n\t\t\t) : null}\n\t\t\t<span className=\"lyds-button__label\" id={id}>\n\t\t\t\t{children}\n\t\t\t</span>\n\t\t</label>\n\t);\n}\n\nexport interface FileUploadProps extends NativeFileInputProps, FieldAnatomyProps {\n\tinputClassName?: string;\n\tinputStyle?: React.CSSProperties;\n\ttriggerLabel?: React.ReactNode;\n\tinvalidFileLabel?: React.ReactNode;\n\tonChange?: React.ChangeEventHandler<HTMLInputElement>;\n\tonFilesChange?: (files: readonly File[], event: React.ChangeEvent<HTMLInputElement>) => void;\n}\n\nexport const FileUpload = React.forwardRef<HTMLInputElement, FileUploadProps>(function FileUpload(\n\t{\n\t\tlabel,\n\t\tdescription,\n\t\terror,\n\t\tinvalid,\n\t\tdisabled,\n\t\treadOnly,\n\t\trequired,\n\t\tname,\n\t\tsize = \"md\",\n\t\tclassName,\n\t\tstyle,\n\t\trequiredIndicator,\n\t\tvalidate,\n\t\tvalidationMode,\n\t\tvalidationDebounceTime,\n\t\tdirty,\n\t\ttouched,\n\t\tactionsRef,\n\t\tinputClassName,\n\t\tinputStyle,\n\t\ttriggerLabel,\n\t\tinvalidFileLabel,\n\t\tonChange,\n\t\tonFilesChange,\n\t\tid: idProp,\n\t\t...inputProps\n\t},\n\tforwardedRef\n) {\n\tconst messages = useMessages();\n\tconst blockPickerWhenReadOnly = useBlockedPicker(readOnly, inputProps.onClick);\n\tconst generatedId = React.useId();\n\tconst id = idProp ?? generatedId;\n\tconst labelId = `${id}-label`;\n\tconst descriptionId = `${id}-description`;\n\tconst errorId = `${id}-error`;\n\tconst triggerId = `${id}-trigger-label`;\n\tconst selectionSummaryId = `${id}-selection-summary`;\n\tconst inputRef = React.useRef<HTMLInputElement>(null);\n\tconst [selectedFiles, setSelectedFiles] = React.useState<readonly File[]>([]);\n\tuseClearFileSelectionOnFormReset(inputRef, inputProps.form, setSelectedFiles);\n\tReact.useImperativeHandle(forwardedRef, () => inputRef.current as HTMLInputElement);\n\n\tconst handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n\t\tif (disabled || readOnly) return;\n\t\tonChange?.(event);\n\t\tif (!event.defaultPrevented) {\n\t\t\tconst files = Array.from(event.currentTarget.files ?? []);\n\t\t\tsetSelectedFiles(files);\n\t\t\tonFilesChange?.(files, event);\n\t\t}\n\t};\n\n\treturn (\n\t\t<FieldFrame\n\t\t\tlabel={label}\n\t\t\tdescription={description}\n\t\t\terror={error}\n\t\t\tinvalid={invalid}\n\t\t\tdisabled={disabled}\n\t\t\treadOnly={readOnly}\n\t\t\trequired={required}\n\t\t\tname={name}\n\t\t\tsize={size}\n\t\t\tclassName={className}\n\t\t\tstyle={style}\n\t\t\trequiredIndicator={requiredIndicator}\n\t\t\tlabelId={labelId}\n\t\t\tdescriptionId={descriptionId}\n\t\t\terrorId={errorId}\n\t\t\tvalidate={validate}\n\t\t\tvalidationMode={validationMode}\n\t\t\tvalidationDebounceTime={validationDebounceTime}\n\t\t\tdirty={dirty}\n\t\t\ttouched={touched}\n\t\t\tactionsRef={actionsRef}\n\t\t>\n\t\t\t<div className=\"lyds-file-upload\" data-size={size}>\n\t\t\t\t<BaseInput\n\t\t\t\t\t{...inputProps}\n\t\t\t\t\tref={inputRef}\n\t\t\t\t\tid={id}\n\t\t\t\t\ttype=\"file\"\n\t\t\t\t\tclassName={cx(\"lyds-file-upload__input\", inputClassName)}\n\t\t\t\t\tstyle={inputStyle}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\treadOnly={readOnly}\n\t\t\t\t\taria-disabled={readOnly || undefined}\n\t\t\t\t\tonClick={blockPickerWhenReadOnly}\n\t\t\t\t\trequired={required}\n\t\t\t\t\taria-invalid={invalid || undefined}\n\t\t\t\t\taria-labelledby={label != null ? `${labelId} ${triggerId}` : triggerId}\n\t\t\t\t\taria-describedby={cx(description != null && descriptionId, selectedFiles.length > 0 && selectionSummaryId, error != null && errorId) || undefined}\n\t\t\t\t\tonChange={handleChange}\n\t\t\t\t/>\n\t\t\t\t<FileTrigger className=\"lyds-file-upload__trigger\" disabled={Boolean(disabled)} htmlFor={id} id={triggerId} readOnly={Boolean(readOnly)} size={size}>\n\t\t\t\t\t{triggerLabel ?? messages.fileUploadTrigger}\n\t\t\t\t</FileTrigger>\n\t\t\t\t<FileSelectionPreview accept={inputProps.accept} files={selectedFiles} invalidFileLabel={invalidFileLabel ?? messages.fileUploadInvalidFile} summaryId={selectionSummaryId} />\n\t\t\t</div>\n\t\t</FieldFrame>\n\t);\n});\n\nexport type DropZoneChangeDetails = { source: \"input\"; event: React.ChangeEvent<HTMLInputElement> } | { source: \"drop\"; event: React.DragEvent<HTMLDivElement> };\n\nexport interface DropZoneProps extends NativeFileInputProps, FieldAnatomyProps {\n\tinputClassName?: string;\n\tprimaryLabel?: React.ReactNode;\n\tsecondaryLabel?: React.ReactNode;\n\tbrowseLabel?: React.ReactNode;\n\tinvalidFileLabel?: React.ReactNode;\n\tonChange?: React.ChangeEventHandler<HTMLInputElement>;\n\tonFilesChange?: (files: readonly File[], details: DropZoneChangeDetails) => void;\n\tonDragEnter?: React.DragEventHandler<HTMLDivElement>;\n\tonDragOver?: React.DragEventHandler<HTMLDivElement>;\n\tonDragLeave?: React.DragEventHandler<HTMLDivElement>;\n\tonDrop?: React.DragEventHandler<HTMLDivElement>;\n}\n\nexport const DropZone = React.forwardRef<HTMLInputElement, DropZoneProps>(function DropZone(\n\t{\n\t\tlabel,\n\t\tdescription,\n\t\terror,\n\t\tinvalid,\n\t\tdisabled,\n\t\treadOnly,\n\t\trequired,\n\t\tname,\n\t\tsize = \"md\",\n\t\tclassName,\n\t\tstyle,\n\t\trequiredIndicator,\n\t\tvalidate,\n\t\tvalidationMode,\n\t\tvalidationDebounceTime,\n\t\tdirty,\n\t\ttouched,\n\t\tactionsRef,\n\t\tinputClassName,\n\t\tprimaryLabel,\n\t\tsecondaryLabel,\n\t\tbrowseLabel,\n\t\tinvalidFileLabel,\n\t\tonChange,\n\t\tonFilesChange,\n\t\tonDragEnter,\n\t\tonDragOver,\n\t\tonDragLeave,\n\t\tonDrop,\n\t\tid: idProp,\n\t\t...inputProps\n\t},\n\tforwardedRef\n) {\n\tconst messages = useMessages();\n\tconst blockPickerWhenReadOnly = useBlockedPicker(readOnly, inputProps.onClick);\n\tconst generatedId = React.useId();\n\tconst id = idProp ?? generatedId;\n\tconst labelId = `${id}-label`;\n\tconst descriptionId = `${id}-description`;\n\tconst errorId = `${id}-error`;\n\tconst triggerId = `${id}-trigger-label`;\n\tconst selectionSummaryId = `${id}-selection-summary`;\n\tconst inputRef = React.useRef<HTMLInputElement>(null);\n\tconst [dragging, setDragging] = React.useState(false);\n\tconst [selectedFiles, setSelectedFiles] = React.useState<readonly File[]>([]);\n\tconst dragDepth = React.useRef(0);\n\tconst pendingDrop = React.useRef<{ event: React.DragEvent<HTMLDivElement>; files: readonly File[]; handled: boolean } | null>(null);\n\tuseClearFileSelectionOnFormReset(inputRef, inputProps.form, setSelectedFiles);\n\n\tReact.useImperativeHandle(forwardedRef, () => inputRef.current as HTMLInputElement);\n\n\tconst handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n\t\tif (disabled || readOnly) return;\n\t\tonChange?.(event);\n\t\tif (event.defaultPrevented) return;\n\n\t\tconst drop = pendingDrop.current;\n\t\tif (drop != null) {\n\t\t\tdrop.handled = true;\n\t\t\tsetSelectedFiles(drop.files);\n\t\t\tonFilesChange?.(drop.files, { source: \"drop\", event: drop.event });\n\t\t\treturn;\n\t\t}\n\n\t\tconst files = Array.from(event.currentTarget.files ?? []);\n\t\tsetSelectedFiles(files);\n\t\tonFilesChange?.(files, { source: \"input\", event });\n\t};\n\n\tconst handleDragEnter = (event: React.DragEvent<HTMLDivElement>) => {\n\t\tif (disabled || readOnly) {\n\t\t\tonDragEnter?.(event);\n\t\t\treturn;\n\t\t}\n\t\tevent.preventDefault();\n\t\tonDragEnter?.(event);\n\t\tdragDepth.current += 1;\n\t\tsetDragging(true);\n\t};\n\n\tconst handleDragOver = (event: React.DragEvent<HTMLDivElement>) => {\n\t\tif (disabled || readOnly) {\n\t\t\tonDragOver?.(event);\n\t\t\treturn;\n\t\t}\n\t\tevent.preventDefault();\n\t\tevent.dataTransfer.dropEffect = \"copy\";\n\t\tonDragOver?.(event);\n\t};\n\n\tconst handleDragLeave = (event: React.DragEvent<HTMLDivElement>) => {\n\t\tonDragLeave?.(event);\n\t\tif (disabled || readOnly) return;\n\t\tdragDepth.current = Math.max(0, dragDepth.current - 1);\n\t\tif (dragDepth.current === 0) setDragging(false);\n\t};\n\n\tconst handleDrop = (event: React.DragEvent<HTMLDivElement>) => {\n\t\tif (disabled || readOnly) {\n\t\t\tonDrop?.(event);\n\t\t\treturn;\n\t\t}\n\t\tevent.preventDefault();\n\t\tonDrop?.(event);\n\t\tdragDepth.current = 0;\n\t\tsetDragging(false);\n\t\tconst files = Array.from(event.dataTransfer.files ?? []);\n\t\tif (inputRef.current != null) {\n\t\t\ttry {\n\t\t\t\tinputRef.current.files = event.dataTransfer.files;\n\t\t\t} catch {\n\t\t\t\t// 部分瀏覽器會提供唯讀的 FileList。回呼仍是檔案狀態的主要來源,\n\t\t\t\t// 觸發 change 事件則可同步更新原生驗證狀態。\n\t\t\t}\n\n\t\t\tconst drop = { event, files, handled: false };\n\t\t\tpendingDrop.current = drop;\n\t\t\tinputRef.current.dispatchEvent(new Event(\"change\", { bubbles: true }));\n\t\t\tpendingDrop.current = null;\n\t\t\tif (!drop.handled) {\n\t\t\t\tsetSelectedFiles(files);\n\t\t\t\tonFilesChange?.(files, { source: \"drop\", event });\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tsetSelectedFiles(files);\n\t\tonFilesChange?.(files, { source: \"drop\", event });\n\t};\n\n\treturn (\n\t\t<FieldFrame\n\t\t\tlabel={label}\n\t\t\tdescription={description}\n\t\t\terror={error}\n\t\t\tinvalid={invalid}\n\t\t\tdisabled={disabled}\n\t\t\treadOnly={readOnly}\n\t\t\trequired={required}\n\t\t\tname={name}\n\t\t\tsize={size}\n\t\t\tclassName={className}\n\t\t\tstyle={style}\n\t\t\trequiredIndicator={requiredIndicator}\n\t\t\tlabelId={labelId}\n\t\t\tdescriptionId={descriptionId}\n\t\t\terrorId={errorId}\n\t\t\tvalidate={validate}\n\t\t\tvalidationMode={validationMode}\n\t\t\tvalidationDebounceTime={validationDebounceTime}\n\t\t\tdirty={dirty}\n\t\t\ttouched={touched}\n\t\t\tactionsRef={actionsRef}\n\t\t>\n\t\t\t<BaseInput\n\t\t\t\t{...inputProps}\n\t\t\t\tref={inputRef}\n\t\t\t\tid={id}\n\t\t\t\ttype=\"file\"\n\t\t\t\tclassName={cx(\"lyds-drop-zone__input\", inputClassName)}\n\t\t\t\tdisabled={disabled}\n\t\t\t\treadOnly={readOnly}\n\t\t\t\taria-disabled={readOnly || undefined}\n\t\t\t\tonClick={blockPickerWhenReadOnly}\n\t\t\t\trequired={required}\n\t\t\t\taria-invalid={invalid || undefined}\n\t\t\t\taria-labelledby={label != null ? `${labelId} ${triggerId}` : triggerId}\n\t\t\t\taria-describedby={cx(description != null && descriptionId, selectedFiles.length > 0 && selectionSummaryId, error != null && errorId) || undefined}\n\t\t\t\tonChange={handleInputChange}\n\t\t\t/>\n\t\t\t<div\n\t\t\t\tclassName=\"lyds-drop-zone\"\n\t\t\t\tdata-size={size}\n\t\t\t\tdata-dragging={dragging || undefined}\n\t\t\t\tdata-disabled={disabled || undefined}\n\t\t\t\tdata-readonly={readOnly || undefined}\n\t\t\t\tonDragEnter={handleDragEnter}\n\t\t\t\tonDragOver={handleDragOver}\n\t\t\t\tonDragLeave={handleDragLeave}\n\t\t\t\tonDrop={handleDrop}\n\t\t\t>\n\t\t\t\t<span className=\"lyds-drop-zone__copy\">\n\t\t\t\t\t<span className=\"lyds-drop-zone__primary\">{primaryLabel ?? messages.dropZonePrimary}</span>\n\t\t\t\t\t<span className=\"lyds-drop-zone__secondary\">{secondaryLabel ?? messages.dropZoneSecondary}</span>\n\t\t\t\t</span>\n\t\t\t\t<FileTrigger\n\t\t\t\t\tclassName=\"lyds-drop-zone__button\"\n\t\t\t\t\tdisabled={Boolean(disabled)}\n\t\t\t\t\thtmlFor={id}\n\t\t\t\t\tid={triggerId}\n\t\t\t\t\treadOnly={Boolean(readOnly)}\n\t\t\t\t\tsize={size}\n\t\t\t\t\tstartIcon={<PlusIcon aria-hidden=\"true\" weight=\"bold\" />}\n\t\t\t\t>\n\t\t\t\t\t{browseLabel ?? messages.dropZoneBrowse}\n\t\t\t\t</FileTrigger>\n\t\t\t\t<FileSelectionPreview accept={inputProps.accept} files={selectedFiles} invalidFileLabel={invalidFileLabel ?? messages.fileUploadInvalidFile} summaryId={selectionSummaryId} />\n\t\t\t</div>\n\t\t</FieldFrame>\n\t);\n});\n"],"mappings":";;;;;;;;;;;AAaA,SAAS,EAAiB,EAAE,WAAwB;CACnD,IAAM,CAAC,GAAS,KAAc,EAAM,SAA6C,IAAI;CAoBrF,OAlBA,EAAM,gBAAgB;EACrB,IAAI,OAAO,IAAI,mBAAoB,cAAc,OAAO,IAAI,mBAAoB,YAAY;EAE5F,IAAM,IAAa,IAAI,gBAAgB,CAAI,GACvC,IAAW;EAOf,OANA,qBAAqB;GACpB,AAAK,KACJ,EAAW;IAAE;IAAM,KAAK;GAAW,CAAC;EAEtC,CAAC,SAEY;GAEZ,AADA,IAAW,IACX,IAAI,gBAAgB,CAAU;EAC/B;CACD,GAAG,CAAC,CAAI,CAAC,GAEL,GAAS,SAAS,IACf,kBAAC,OAAD;EAAK,WAAU;EAAiC,KAAK,EAAQ;EAAK,KAAI;EAAG,OAAO;EAAI,QAAQ;EAAI,SAAQ;EAAO,UAAS;CAAS,CAAA,IADrG,kBAAC,GAAD;EAAU,e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export { CodeField, type CodeFieldProps } from './
|
|
2
|
-
export { DropZone, FileUpload, type DropZoneChangeDetails, type DropZoneProps, type FileUploadProps } from './
|
|
3
|
-
export { Input, type InputProps } from './
|
|
1
|
+
export { CodeField, type CodeFieldProps } from './code-field.js';
|
|
2
|
+
export { DropZone, FileUpload, type DropZoneChangeDetails, type DropZoneProps, type FileUploadProps } from './file-upload.js';
|
|
3
|
+
export { Input, type InputProps } from './input.js';
|
|
4
4
|
export type { FieldAnatomyProps, FieldSize, FieldValidationProps } from './internal.js';
|
|
5
|
-
export { NumberField, type NumberFieldProps } from './
|
|
6
|
-
export { OTPField, type OTPFieldProps } from './
|
|
7
|
-
export { PasswordField, PhoneField, SearchField, TextField, TextView, Textarea, type PasswordFieldProps, type PhoneFieldCountrySelectorState, type PhoneFieldProps, type SearchFieldProps, type TextFieldProps, type TextViewProps, type TextareaProps } from './
|
|
5
|
+
export { NumberField, type NumberFieldProps } from './number-field.js';
|
|
6
|
+
export { OTPField, type OTPFieldProps } from './otp-field.js';
|
|
7
|
+
export { PasswordField, PhoneField, SearchField, TextField, TextView, Textarea, type PasswordFieldProps, type PhoneFieldCountrySelectorState, type PhoneFieldProps, type SearchFieldProps, type TextFieldProps, type TextViewProps, type TextareaProps } from './text-field.js';
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
/* empty css */
|
|
2
|
-
import { withStateClassName as e } from "
|
|
3
|
+
import { withStateClassName as e } from "../../internal/class-names.js";
|
|
3
4
|
import * as t from "react";
|
|
4
5
|
import { jsx as n } from "react/jsx-runtime";
|
|
5
6
|
import { Field as r } from "@base-ui/react/field";
|
|
6
7
|
import { Input as i } from "@base-ui/react/input";
|
|
7
|
-
//#region src/components/forms/
|
|
8
|
+
//#region src/components/forms/input.tsx
|
|
8
9
|
var a = t.forwardRef(function({ size: t = "md", inputSize: a, invalid: o, className: s, disabled: c, readOnly: l, required: u, name: d, "aria-invalid": f, ...p }, m) {
|
|
9
10
|
return /* @__PURE__ */ n(r.Root, {
|
|
10
11
|
className: "lyds-input-root",
|
|
@@ -30,4 +31,4 @@ var a = t.forwardRef(function({ size: t = "md", inputSize: a, invalid: o, classN
|
|
|
30
31
|
//#endregion
|
|
31
32
|
export { a as Input };
|
|
32
33
|
|
|
33
|
-
//# sourceMappingURL=
|
|
34
|
+
//# sourceMappingURL=input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.js","names":[],"sources":["../../../src/components/forms/input.tsx"],"sourcesContent":["import { withStateClassName } from \"@/internal\";\nimport { Field as BaseField } from \"@base-ui/react/field\";\nimport { Input as BaseInput } from \"@base-ui/react/input\";\nimport * as React from \"react\";\nimport \"./forms.css\";\nimport { type FieldSize } from \"./internal\";\nexport interface InputProps extends Omit<BaseInput.Props, \"size\"> {\n\t/** Linyao Design System 的控制項尺寸。原生 HTML `size` 屬性請使用 `inputSize`。 */\n\tsize?: FieldSize;\n\tinputSize?: number;\n\tinvalid?: boolean;\n}\n\n/**\n * 使用 Linyao Design System 樣式與 Base UI 值變更資訊的基礎文字輸入元件。\n * 需要可見標籤、說明或錯誤訊息時,請使用 TextField。\n */\nexport const Input = React.forwardRef<HTMLInputElement, InputProps>(function Input(\n\t{ size = \"md\", inputSize, invalid, className, disabled, readOnly, required, name, \"aria-invalid\": ariaInvalid, ...props },\n\tref\n) {\n\treturn (\n\t\t<BaseField.Root className=\"lyds-input-root\" name={name} disabled={disabled} invalid={invalid} data-size={size} data-readonly={readOnly || undefined} data-required={required || undefined}>\n\t\t\t<BaseInput\n\t\t\t\t{...props}\n\t\t\t\tref={ref}\n\t\t\t\tclassName={withStateClassName<BaseInput.State>(\"lyds-input\", className)}\n\t\t\t\tdisabled={disabled}\n\t\t\t\treadOnly={readOnly}\n\t\t\t\trequired={required}\n\t\t\t\tsize={inputSize}\n\t\t\t\taria-invalid={invalid ? true : ariaInvalid}\n\t\t\t\tdata-size={size}\n\t\t\t/>\n\t\t</BaseField.Root>\n\t);\n});\n"],"mappings":";;;;;;;;AAiBA,IAAa,IAAQ,EAAM,WAAyC,SACnE,EAAE,UAAO,MAAM,cAAW,YAAS,cAAW,aAAU,aAAU,aAAU,SAAM,gBAAgB,GAAa,GAAG,KAClH,GACC;CACD,OACC,kBAAC,EAAU,MAAX;EAAgB,WAAU;EAAwB;EAAgB;EAAmB;EAAS,aAAW;EAAM,iBAAe,KAAY,KAAA;EAAW,iBAAe,KAAY,KAAA;EAC/K,UAAA,kBAAC,GAAD;GACC,GAAI;GACC;GACL,WAAW,EAAoC,cAAc,CAAS;GAC5D;GACA;GACA;GACV,MAAM;GACN,gBAAc,IAAU,KAAO;GAC/B,aAAW;EACX,CAAA;CACc,CAAA;AAElB,CAAC"}
|
|
@@ -27,7 +27,5 @@ interface FieldFrameProps extends FieldAnatomyProps {
|
|
|
27
27
|
descriptionId?: string | undefined;
|
|
28
28
|
errorId?: string | undefined;
|
|
29
29
|
}
|
|
30
|
-
export declare function cx(...classes: Array<string | false | null | undefined>): string;
|
|
31
|
-
export declare function withStateClassName<State>(baseClassName: string, className: string | ((state: State) => string | undefined) | undefined): string | ((state: State) => string);
|
|
32
30
|
export declare function FieldFrame({ children, label, description, error, invalid, disabled, readOnly, required, name, size, className, style, requiredIndicator, labelId, descriptionId, errorId, validate, validationMode, validationDebounceTime, dirty, touched, actionsRef }: FieldFrameProps): React.JSX.Element;
|
|
33
31
|
export {};
|