@k8ordo/ui 3.0.0 → 4.0.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 +73 -182
- package/dist/{integrations/_shared → catalog}/icon-map.d.mts +4 -2
- package/dist/catalog/icon-map.mjs +212 -0
- package/dist/catalog/icon-names.d.mts +1 -0
- package/dist/{integrations/_shared → catalog}/icon-names.mjs +3 -1
- package/dist/catalog/index.d.mts +1289 -0
- package/dist/catalog/index.mjs +419 -0
- package/dist/catalog/render.css +34 -0
- package/dist/catalog/render.d.mts +72 -0
- package/dist/catalog/render.mjs +631 -0
- package/dist/catalog/render.module.mjs +11 -0
- package/dist/{integrations/_shared → catalog}/schemas.d.mts +120 -132
- package/dist/{integrations/_shared → catalog}/schemas.mjs +189 -131
- package/dist/catalog/to-tree.d.mts +4 -0
- package/dist/catalog/to-tree.mjs +17 -0
- package/dist/components/_internal/checked-values.d.mts +1 -0
- package/dist/components/_internal/checked-values.mjs +5 -0
- package/dist/components/_internal/field-message.css +25 -0
- package/dist/components/_internal/field-message.d.mts +10 -0
- package/dist/components/_internal/field-message.mjs +22 -0
- package/dist/components/_internal/field-message.module.mjs +9 -0
- package/dist/components/_internal/focus-ring.css +1 -1
- package/dist/components/_internal/high-contrast.css +1 -0
- package/dist/components/{observers/in-view → _internal}/in-view.mjs +1 -1
- package/dist/components/{observers/resize → _internal}/resize.mjs +1 -1
- package/dist/components/ai/_internal/attachment-preview.mjs +1 -1
- package/dist/components/ai/_internal/collapsible.mjs +1 -1
- package/dist/components/ai/attachment/attachment.d.mts +1 -1
- package/dist/components/ai/attachment/index.d.mts +1 -1
- package/dist/components/ai/conversation/conversation.mjs +4 -4
- package/dist/components/ai/index.d.mts +2 -2
- package/dist/components/ai/message/index.d.mts +2 -2
- package/dist/components/ai/message/message.d.mts +2 -2
- package/dist/components/ai/message/message.mjs +9 -9
- package/dist/components/ai/prompt-input/prompt-input.mjs +4 -4
- package/dist/components/ai/source/index.d.mts +2 -2
- package/dist/components/ai/source/source.d.mts +2 -2
- package/dist/components/ai/source/source.mjs +1 -1
- package/dist/components/ai/tool-invocation/approval-bar.mjs +11 -22
- package/dist/components/ai/tool-invocation/tool-invocation.d.mts +2 -2
- package/dist/components/buttons/button/button.css +1 -1
- package/dist/components/buttons/button/button.d.mts +34 -37
- package/dist/components/buttons/button/button.mjs +37 -24
- package/dist/components/buttons/button/button.module.mjs +0 -1
- package/dist/components/buttons/button/index.d.mts +2 -2
- package/dist/components/buttons/copy-button/copy-button.mjs +4 -4
- package/dist/components/buttons/icon-button/icon-button.css +3 -3
- package/dist/components/buttons/icon-button/icon-button.d.mts +37 -43
- package/dist/components/buttons/icon-button/icon-button.mjs +73 -63
- package/dist/components/buttons/icon-button/icon-button.module.mjs +2 -2
- package/dist/components/buttons/icon-button/index.d.mts +2 -2
- package/dist/components/buttons/toolbar/toolbar.css +5 -1
- package/dist/components/buttons/toolbar/toolbar.mjs +1 -1
- package/dist/components/data-display/accordion/accordion-button.d.mts +4 -1
- package/dist/components/data-display/accordion/accordion-button.mjs +4 -4
- package/dist/components/data-display/accordion/index.d.mts +3 -3
- package/dist/components/data-display/card/card-action.d.mts +6 -0
- package/dist/components/data-display/card/card-action.mjs +21 -0
- package/dist/components/data-display/card/card.css +24 -0
- package/dist/components/data-display/card/card.d.mts +26 -3
- package/dist/components/data-display/card/card.mjs +46 -6
- package/dist/components/data-display/card/card.module.mjs +4 -1
- package/dist/components/data-display/card/index.d.mts +2 -2
- package/dist/components/data-display/carousel/carousel.mjs +2 -2
- package/dist/components/data-display/code/code.css +4 -0
- package/dist/components/data-display/code-block/code-block.mjs +1 -1
- package/dist/components/data-display/data-table/data-table.css +0 -3
- package/dist/components/data-display/data-table/data-table.mjs +25 -26
- package/dist/components/data-display/tree/tree.d.mts +1 -1
- package/dist/components/data-display/tree/tree.mjs +6 -5
- package/dist/components/feedback/alert/alert.d.mts +2 -7
- package/dist/components/feedback/alert/alert.mjs +11 -11
- package/dist/components/feedback/alert/index.d.mts +2 -2
- package/dist/components/feedback/callout/callout.mjs +2 -2
- package/dist/components/feedback/progress/progress.mjs +1 -1
- package/dist/components/feedback/toast/context.d.mts +4 -5
- package/dist/components/feedback/toast/index.d.mts +2 -2
- package/dist/components/feedback/toast/provider.d.mts +7 -2
- package/dist/components/feedback/toast/provider.mjs +7 -2
- package/dist/components/feedback/toast/toast.d.mts +2 -3
- package/dist/components/form/autocomplete/autocomplete.d.mts +2 -2
- package/dist/components/form/autocomplete/autocomplete.mjs +12 -9
- package/dist/components/form/calendar/calendar.mjs +3 -5
- package/dist/components/form/checkbox/checkbox.d.mts +3 -1
- package/dist/components/form/checkbox/checkbox.mjs +44 -45
- package/dist/components/form/checkbox-card/checkbox-card.d.mts +3 -2
- package/dist/components/form/checkbox-card/checkbox-card.mjs +13 -6
- package/dist/components/form/checkbox-group/checkbox-group.d.mts +15 -20
- package/dist/components/form/checkbox-group/checkbox-group.mjs +18 -26
- package/dist/components/form/checkbox-group/index.d.mts +2 -34
- package/dist/components/form/checkbox-group/index.mjs +1 -8
- package/dist/components/form/color-picker/color-picker.css +3 -5
- package/dist/components/form/color-picker/color-picker.d.mts +0 -1
- package/dist/components/form/color-picker/color-picker.mjs +4 -4
- package/dist/components/form/combobox/combobox.d.mts +0 -1
- package/dist/components/form/combobox/combobox.mjs +9 -8
- package/dist/components/form/date-picker/date-picker.css +0 -5
- package/dist/components/form/date-picker/date-picker.mjs +21 -22
- package/dist/components/form/file-field/file-field.d.mts +6 -3
- package/dist/components/form/file-field/file-field.mjs +41 -18
- package/dist/components/form/file-field/index.d.mts +4 -1
- package/dist/components/form/form/form.mjs +0 -1
- package/dist/components/form/form-control/form-control.css +0 -15
- package/dist/components/form/form-control/form-control.d.mts +3 -4
- package/dist/components/form/form-control/form-control.mjs +44 -46
- package/dist/components/form/form-control/form-control.module.mjs +0 -3
- package/dist/components/form/number-field/number-field.d.mts +2 -2
- package/dist/components/form/number-field/number-field.mjs +13 -52
- package/dist/components/form/password-input/password-input.mjs +1 -1
- package/dist/components/form/radio/radio.mjs +4 -2
- package/dist/components/form/radio-card/radio-card.mjs +9 -2
- package/dist/components/form/range-slider/range-slider.d.mts +4 -2
- package/dist/components/form/range-slider/range-slider.mjs +2 -4
- package/dist/components/form/select/select.css +6 -4
- package/dist/components/form/select/select.d.mts +5 -0
- package/dist/components/form/select/select.mjs +10 -7
- package/dist/components/form/slider/slider.d.mts +2 -2
- package/dist/components/form/slider/slider.mjs +3 -6
- package/dist/components/form/switch/switch.d.mts +3 -0
- package/dist/components/form/switch/switch.mjs +43 -31
- package/dist/components/form/text-field/index.d.mts +2 -2
- package/dist/components/form/text-field/text-field.css +4 -0
- package/dist/components/form/text-field/text-field.d.mts +1 -1
- package/dist/components/form/textarea/textarea.d.mts +0 -1
- package/dist/components/form/textarea/textarea.mjs +1 -1
- package/dist/components/icons/base.d.mts +0 -1
- package/dist/components/icons/base.mjs +1 -2
- package/dist/components/icons/clipboard-check.d.mts +3 -0
- package/dist/components/icons/clipboard-check.mjs +18 -0
- package/dist/components/icons/git-pull-request.d.mts +3 -0
- package/dist/components/icons/git-pull-request.mjs +20 -0
- package/dist/components/icons/index.d.mts +9 -7
- package/dist/components/icons/index.mjs +30 -28
- package/dist/components/index.d.mts +58 -66
- package/dist/components/index.mjs +13 -19
- package/dist/components/layout/resizable-panels/resizable-panels.mjs +3 -3
- package/dist/components/navigation/anchor/anchor.css +3 -3
- package/dist/components/navigation/anchor/anchor.mjs +20 -7
- package/dist/components/navigation/anchor/anchor.module.mjs +1 -1
- package/dist/components/navigation/breadcrumb/breadcrumb.d.mts +6 -4
- package/dist/components/navigation/breadcrumb/breadcrumb.mjs +3 -2
- package/dist/components/navigation/pagination/pagination.d.mts +2 -2
- package/dist/components/navigation/pagination/pagination.mjs +2 -2
- package/dist/components/navigation/side-nav/side-nav.mjs +1 -1
- package/dist/components/navigation/stepper/stepper.mjs +3 -3
- package/dist/components/navigation/tabs/index.d.mts +10 -5
- package/dist/components/navigation/tabs/tabs.d.mts +11 -6
- package/dist/components/navigation/tabs/tabs.mjs +24 -27
- package/dist/components/overlays/_internal/modal-header.css +38 -0
- package/dist/components/overlays/_internal/modal-header.d.mts +7 -0
- package/dist/components/overlays/_internal/modal-header.mjs +32 -0
- package/dist/components/overlays/_internal/modal-header.module.mjs +10 -0
- package/dist/components/overlays/command-palette/command-palette.d.mts +2 -2
- package/dist/components/overlays/command-palette/command-palette.mjs +9 -8
- package/dist/components/overlays/context-menu/context-menu.mjs +3 -3
- package/dist/components/overlays/context-menu/index.d.mts +27 -2
- package/dist/components/overlays/dialog/dialog.css +3 -21
- package/dist/components/overlays/dialog/dialog.d.mts +20 -9
- package/dist/components/overlays/dialog/dialog.mjs +35 -73
- package/dist/components/overlays/dialog/dialog.module.mjs +1 -3
- package/dist/components/overlays/dialog/index.d.mts +2 -15
- package/dist/components/overlays/dialog/index.mjs +1 -8
- package/dist/components/overlays/drawer/drawer.css +4 -26
- package/dist/components/overlays/drawer/drawer.d.mts +7 -2
- package/dist/components/overlays/drawer/drawer.mjs +24 -37
- package/dist/components/overlays/drawer/drawer.module.mjs +2 -6
- package/dist/components/overlays/dropdown-menu/dropdown-menu.d.mts +35 -5
- package/dist/components/overlays/dropdown-menu/dropdown-menu.mjs +29 -11
- package/dist/components/overlays/dropdown-menu/hooks.d.mts +1 -1
- package/dist/components/overlays/dropdown-menu/hooks.mjs +1 -1
- package/dist/components/overlays/dropdown-menu/index.d.mts +34 -4
- package/dist/components/overlays/dropdown-menu/shared.css +1 -0
- package/dist/components/overlays/dropdown-menu/sub-menu.mjs +4 -4
- package/dist/components/overlays/list-box/hooks.mjs +2 -2
- package/dist/components/overlays/list-box/index.d.mts +2 -25
- package/dist/components/overlays/list-box/index.mjs +1 -9
- package/dist/components/overlays/list-box/list-box.d.mts +11 -16
- package/dist/components/overlays/list-box/list-box.mjs +23 -16
- package/dist/components/overlays/modal/modal.d.mts +8 -7
- package/dist/components/overlays/modal/modal.mjs +23 -32
- package/dist/components/overlays/popover/anchor-positioning.d.mts +3 -16
- package/dist/components/overlays/popover/anchor-positioning.mjs +14 -6
- package/dist/components/overlays/popover/hooks.d.mts +0 -2
- package/dist/components/overlays/popover/hooks.mjs +0 -2
- package/dist/components/overlays/popover/index.d.mts +19 -2
- package/dist/components/overlays/popover/index.mjs +7 -2
- package/dist/components/overlays/popover/popover.css +6 -0
- package/dist/components/overlays/popover/popover.d.mts +15 -2
- package/dist/components/overlays/popover/popover.mjs +28 -13
- package/dist/components/overlays/popover/popover.module.mjs +2 -1
- package/dist/components/overlays/tooltip/bridge.css +1 -1
- package/dist/components/overlays/tooltip/tooltip.mjs +5 -5
- package/dist/helpers/index.mjs +1 -1
- package/dist/i18n/en.mjs +1 -2
- package/dist/i18n/index.d.mts +3 -4
- package/dist/i18n/index.mjs +1 -2
- package/dist/i18n/ja.mjs +1 -2
- package/dist/i18n/messages.d.mts +2 -4
- package/dist/i18n/usage.d.mts +2 -1
- package/dist/i18n/usage.mjs +3 -3
- package/dist/index.d.mts +30 -36
- package/dist/index.mjs +4 -10
- package/dist/internal/iso-date.mjs +1 -1
- package/dist/styles/index.css +79 -225
- package/dist/styles/tailwind.css +1 -1
- package/dist/styles/tokens.css +281 -0
- package/dist/styles/tokens.d.mts +1 -1
- package/dist/styles/tokens.mjs +1 -1
- package/dist/types/index.d.mts +2 -2
- package/dist/types/variables.d.mts +4 -2
- package/docs/GUIDE.md +141 -66
- package/docs/llms.txt +38 -11
- package/docs/props.generated.json +752 -481
- package/docs/references/ai-chat.md +87 -39
- package/docs/references/color.md +15 -15
- package/docs/references/components.md +568 -499
- package/docs/references/generative-ui.md +373 -185
- package/docs/references/interaction-design.md +6 -5
- package/docs/references/spatial-design.md +8 -8
- package/docs/references/types.md +22 -25
- package/package.json +37 -70
- package/dist/components/form/date-field/date-field.css +0 -31
- package/dist/components/form/date-field/date-field.d.mts +0 -7
- package/dist/components/form/date-field/date-field.mjs +0 -19
- package/dist/components/form/date-field/date-field.module.mjs +0 -4
- package/dist/components/form/date-field/index.d.mts +0 -2
- package/dist/components/form/date-field/index.mjs +0 -1
- package/dist/components/observers/in-view/index.d.mts +0 -2
- package/dist/components/observers/in-view/index.mjs +0 -1
- package/dist/components/observers/resize/index.d.mts +0 -2
- package/dist/components/observers/resize/index.mjs +0 -1
- package/dist/components/overlays/_internal/modal-dialog-context.d.mts +0 -11
- package/dist/components/overlays/_internal/modal-dialog-context.mjs +0 -12
- package/dist/components/providers/index.d.mts +0 -3
- package/dist/components/providers/index.mjs +0 -3
- package/dist/components/providers/portal-root.d.mts +0 -8
- package/dist/components/providers/portal-root.mjs +0 -11
- package/dist/components/providers/ui-provider.d.mts +0 -2
- package/dist/components/providers/ui-provider.mjs +0 -6
- package/dist/integrations/_shared/icon-map.mjs +0 -208
- package/dist/integrations/_shared/icon-names.d.mts +0 -1
- package/dist/integrations/_shared/openui-defs.d.mts +0 -15
- package/dist/integrations/_shared/openui-defs.mjs +0 -230
- package/dist/integrations/_shared/renderers.css +0 -50
- package/dist/integrations/_shared/renderers.d.mts +0 -88
- package/dist/integrations/_shared/renderers.mjs +0 -880
- package/dist/integrations/_shared/renderers.module.mjs +0 -13
- package/dist/integrations/ai-sdk/index.d.mts +0 -3
- package/dist/integrations/ai-sdk/index.mjs +0 -1
- package/dist/integrations/ai-sdk/map-parts.d.mts +0 -44
- package/dist/integrations/ai-sdk/map-parts.mjs +0 -56
- package/dist/integrations/json-render/catalog.d.mts +0 -1359
- package/dist/integrations/json-render/catalog.mjs +0 -373
- package/dist/integrations/json-render/registry.d.mts +0 -26
- package/dist/integrations/json-render/registry.mjs +0 -192
- package/dist/integrations/openui/form-views.d.mts +0 -24
- package/dist/integrations/openui/form-views.mjs +0 -89
- package/dist/integrations/openui/library.d.mts +0 -202
- package/dist/integrations/openui/library.mjs +0 -83
- package/dist/integrations/openui/prompt.d.mts +0 -2
- package/dist/integrations/openui/prompt.mjs +0 -18
- /package/dist/components/{observers → _internal}/fragment-instance.d.mts +0 -0
- /package/dist/components/{observers/in-view → _internal}/in-view.d.mts +0 -0
- /package/dist/components/{observers/resize → _internal}/resize.d.mts +0 -0
|
@@ -1,38 +1,30 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { checkedValuesAround } from "../../_internal/checked-values.mjs";
|
|
3
|
+
import { Checkbox } from "../checkbox/checkbox.mjs";
|
|
2
4
|
import checkbox_group_module_default from "./checkbox-group.module.mjs";
|
|
3
5
|
import { clsx } from "clsx";
|
|
4
|
-
import {
|
|
6
|
+
import { createElement } from "react";
|
|
5
7
|
import { jsx } from "react/jsx-runtime";
|
|
6
8
|
// src/components/form/checkbox-group/checkbox-group.tsx
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
value,
|
|
12
|
-
defaultValue: defaultValue ?? [],
|
|
13
|
-
disabled,
|
|
14
|
-
name,
|
|
15
|
-
notifyChange: (event) => {
|
|
16
|
-
const inputs = event.currentTarget.closest("fieldset")?.querySelectorAll(`input[type="checkbox"][name="${CSS.escape(name)}"]`) ?? [];
|
|
17
|
-
onChange?.([...inputs].filter((input) => input.checked).map((input) => input.value));
|
|
18
|
-
}
|
|
19
|
-
}), [
|
|
20
|
-
value,
|
|
21
|
-
defaultValue,
|
|
22
|
-
disabled,
|
|
23
|
-
name,
|
|
24
|
-
onChange
|
|
25
|
-
]);
|
|
9
|
+
const CheckboxGroup = ({ "aria-labelledby": labelledbyId, defaultValue, disabled = false, invalid = false, name, onChange, options, ref, required: _required, value, ...rest }) => {
|
|
10
|
+
const handleChange = (_checked, event) => {
|
|
11
|
+
onChange?.(checkedValuesAround(event.currentTarget));
|
|
12
|
+
};
|
|
26
13
|
return /* @__PURE__ */ jsx("fieldset", {
|
|
27
14
|
...rest,
|
|
28
|
-
"aria-invalid": invalid,
|
|
29
15
|
"aria-labelledby": labelledbyId,
|
|
30
16
|
className: clsx(checkbox_group_module_default.root, disabled && checkbox_group_module_default.disabled),
|
|
31
17
|
ref,
|
|
32
|
-
children: /* @__PURE__ */
|
|
33
|
-
value:
|
|
34
|
-
|
|
35
|
-
|
|
18
|
+
children: options.map((option) => /* @__PURE__ */ createElement(Checkbox, {
|
|
19
|
+
...value === void 0 ? { defaultChecked: defaultValue?.includes(option.value) } : { checked: value.includes(option.value) },
|
|
20
|
+
disabled,
|
|
21
|
+
invalid,
|
|
22
|
+
key: option.value,
|
|
23
|
+
label: option.label,
|
|
24
|
+
name,
|
|
25
|
+
onChange: handleChange,
|
|
26
|
+
value: option.value
|
|
27
|
+
}))
|
|
36
28
|
});
|
|
37
29
|
};
|
|
38
|
-
export {
|
|
30
|
+
export { CheckboxGroup };
|
|
@@ -1,34 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
'aria-labelledby': string;
|
|
4
|
-
invalid?: boolean;
|
|
5
|
-
name: string;
|
|
6
|
-
ref?: import("react").Ref<HTMLFieldSetElement>;
|
|
7
|
-
} & Omit<import("react").FieldsetHTMLAttributes<HTMLFieldSetElement>, "aria-labelledby" | "className" | "defaultValue" | "name" | "onChange" | "role" | "style"> & {
|
|
8
|
-
children?: import("react").ReactNode | undefined;
|
|
9
|
-
} & ({
|
|
10
|
-
value: string[];
|
|
11
|
-
onChange: (value: string[]) => void;
|
|
12
|
-
defaultValue?: never;
|
|
13
|
-
} | {
|
|
14
|
-
defaultValue?: string[];
|
|
15
|
-
value?: never;
|
|
16
|
-
onChange?: (value: string[]) => void;
|
|
17
|
-
})>;
|
|
18
|
-
readonly Item: import("react").FC<{
|
|
19
|
-
indeterminate?: boolean;
|
|
20
|
-
invalid?: boolean;
|
|
21
|
-
itemValue?: string;
|
|
22
|
-
label: string;
|
|
23
|
-
labelHidden?: boolean;
|
|
24
|
-
ref?: import("react").Ref<HTMLInputElement>;
|
|
25
|
-
} & Omit<import("react").InputHTMLAttributes<HTMLInputElement>, "checked" | "children" | "className" | "defaultChecked" | "onChange" | "style" | "type" | "value"> & ({
|
|
26
|
-
checked: boolean;
|
|
27
|
-
onChange: (checked: boolean, event: import("react").ChangeEvent<HTMLInputElement>) => void;
|
|
28
|
-
defaultChecked?: never;
|
|
29
|
-
} | {
|
|
30
|
-
defaultChecked?: boolean;
|
|
31
|
-
checked?: never;
|
|
32
|
-
onChange?: (checked: boolean, event: import("react").ChangeEvent<HTMLInputElement>) => void;
|
|
33
|
-
})>;
|
|
34
|
-
};
|
|
1
|
+
import { CheckboxGroup } from "./checkbox-group.mjs";
|
|
2
|
+
export { CheckboxGroup };
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { Checkbox } from "../checkbox/checkbox.mjs";
|
|
3
|
-
// src/components/form/checkbox-group/index.ts
|
|
4
|
-
const CheckboxGroup = {
|
|
5
|
-
Root,
|
|
6
|
-
Item: Checkbox
|
|
7
|
-
};
|
|
8
|
-
export { CheckboxGroup };
|
|
1
|
+
export { CheckboxGroup } from "./checkbox-group.mjs";
|
|
@@ -58,8 +58,10 @@
|
|
|
58
58
|
outline-style: none;
|
|
59
59
|
|
|
60
60
|
@media (forced-colors: active) {
|
|
61
|
+
border-color: var(--color-system-canvas-text);
|
|
62
|
+
outline: 2px solid var(--color-system-canvas-text);
|
|
61
63
|
outline-offset: 2px;
|
|
62
|
-
|
|
64
|
+
box-shadow: none;
|
|
63
65
|
}
|
|
64
66
|
}
|
|
65
67
|
|
|
@@ -119,10 +121,6 @@
|
|
|
119
121
|
border-radius: var(--radius-full);
|
|
120
122
|
forced-color-adjust: none;
|
|
121
123
|
inline-size: 100%;
|
|
122
|
-
|
|
123
|
-
@media (forced-colors: active) {
|
|
124
|
-
outline-color: var(--color-system-canvas-text);
|
|
125
|
-
}
|
|
126
124
|
}
|
|
127
125
|
|
|
128
126
|
.SyHfiq_track:where(:dir(rtl), [dir="rtl"], [dir="rtl"] *) {
|
|
@@ -8,7 +8,6 @@ export type ColorPickerSwatch = Readonly<{
|
|
|
8
8
|
type BaseProps = {
|
|
9
9
|
invalid?: boolean;
|
|
10
10
|
swatches?: readonly ColorPickerSwatch[];
|
|
11
|
-
type?: string;
|
|
12
11
|
ref?: Ref<HTMLInputElement>;
|
|
13
12
|
} & Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'className' | 'style' | 'value' | 'onChange' | 'defaultValue' | 'children'>;
|
|
14
13
|
type ControlledProps = {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { getMessages } from "../../../i18n/current.mjs";
|
|
3
2
|
import { mergeRefs } from "../../../helpers/merge-refs.mjs";
|
|
4
|
-
import
|
|
5
|
-
import high_contrast_module_default from "../../_internal/high-contrast.module.mjs";
|
|
3
|
+
import { getMessages } from "../../../i18n/current.mjs";
|
|
6
4
|
import { commitInputValue } from "../../../internal/commit-input-value.mjs";
|
|
7
5
|
import { hexToHsl, hslToHex, parseHex } from "../../../internal/hex-color.mjs";
|
|
8
6
|
import { rangeInputClass } from "../slider/range-input-class.mjs";
|
|
7
|
+
import focus_ring_module_default from "../../_internal/focus-ring.module.mjs";
|
|
8
|
+
import high_contrast_module_default from "../../_internal/high-contrast.module.mjs";
|
|
9
9
|
import color_picker_module_default from "./color-picker.module.mjs";
|
|
10
10
|
import { clsx } from "clsx";
|
|
11
11
|
import { useEffect, useEffectEvent, useId, useMemo, useRef, useState } from "react";
|
|
@@ -54,7 +54,7 @@ const Channel = ({ label, value, max, unit, stops, disabled, onChange }) => {
|
|
|
54
54
|
})]
|
|
55
55
|
})] });
|
|
56
56
|
};
|
|
57
|
-
const ColorPicker = ({ invalid = false, swatches,
|
|
57
|
+
const ColorPicker = ({ invalid = false, swatches, value, defaultValue, onChange, disabled = false, readOnly = false, onBlur, onKeyDown, ref, ...rest }) => {
|
|
58
58
|
const messages = getMessages();
|
|
59
59
|
const isControlled = value !== void 0;
|
|
60
60
|
const inputRef = useRef(null);
|
|
@@ -12,7 +12,6 @@ type BaseProps = {
|
|
|
12
12
|
options?: readonly Option[];
|
|
13
13
|
/** 打った文字で候補を探す。打ち直すと前の問い合わせは `signal` で打ち切る。 */
|
|
14
14
|
search?: ComboboxSearch;
|
|
15
|
-
type?: string;
|
|
16
15
|
ref?: Ref<HTMLInputElement>;
|
|
17
16
|
} & Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'role' | 'className' | 'style' | 'value' | 'onChange' | 'defaultValue' | 'children' | 'autoComplete' | 'aria-autocomplete' | 'aria-controls' | 'aria-expanded' | 'aria-activedescendant'>;
|
|
18
17
|
type ControlledProps = {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { getMessages } from "../../../i18n/current.mjs";
|
|
3
|
-
import sr_only_module_default from "../../_internal/sr-only.module.mjs";
|
|
4
2
|
import { mergeRefs } from "../../../helpers/merge-refs.mjs";
|
|
5
|
-
import focus_ring_module_default from "../../_internal/focus-ring.module.mjs";
|
|
6
3
|
import { useControllableState } from "../../../hooks/controllable-state/index.mjs";
|
|
7
4
|
import { useWritingMode } from "../../../hooks/writing-mode/index.mjs";
|
|
8
|
-
import {
|
|
5
|
+
import { getLocale, getMessages } from "../../../i18n/current.mjs";
|
|
9
6
|
import { FormValue } from "../../_internal/form-value.mjs";
|
|
7
|
+
import { ChevronIcon } from "../../icons/chevron.mjs";
|
|
8
|
+
import focus_ring_module_default from "../../_internal/focus-ring.module.mjs";
|
|
9
|
+
import sr_only_module_default from "../../_internal/sr-only.module.mjs";
|
|
10
10
|
import combobox_module_default from "./combobox.module.mjs";
|
|
11
11
|
import { clsx } from "clsx";
|
|
12
12
|
import { useCallback, useId, useMemo, useRef, useState, useTransition } from "react";
|
|
@@ -14,9 +14,10 @@ import { useFormStatus } from "react-dom";
|
|
|
14
14
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
15
|
// src/components/form/combobox/combobox.tsx
|
|
16
16
|
const NO_OPTIONS = [];
|
|
17
|
-
const matches = (option, text) => option.label.toLocaleLowerCase().includes(text.trim().toLocaleLowerCase());
|
|
18
|
-
const Combobox = ({ invalid = false, options: optionsProp, search,
|
|
17
|
+
const matches = (option, text, locale) => option.label.toLocaleLowerCase(locale).includes(text.trim().toLocaleLowerCase(locale));
|
|
18
|
+
const Combobox = ({ invalid = false, options: optionsProp, search, value, defaultValue, onChange, name, id, disabled = false, readOnly = false, required = false, placeholder, onBlur, onKeyDown, ref, ...rest }) => {
|
|
19
19
|
const messages = getMessages();
|
|
20
|
+
const locale = getLocale();
|
|
20
21
|
const options = optionsProp ?? NO_OPTIONS;
|
|
21
22
|
const baseId = useId();
|
|
22
23
|
const listboxId = `${baseId}-listbox`;
|
|
@@ -39,7 +40,7 @@ const Combobox = ({ invalid = false, options: optionsProp, search, type: _type,
|
|
|
39
40
|
const { pending } = useFormStatus();
|
|
40
41
|
const locked = readOnly || pending;
|
|
41
42
|
const expanded = isOpen && !locked;
|
|
42
|
-
const candidates = search === void 0 ? text === null ? options : options.filter((option) => matches(option, text)) : text === null || text.trim() === "" ? options : found ?? NO_OPTIONS;
|
|
43
|
+
const candidates = search === void 0 ? text === null ? options : options.filter((option) => matches(option, text, locale)) : text === null || text.trim() === "" ? options : found ?? NO_OPTIONS;
|
|
43
44
|
const active = activeIndex === void 0 || candidates.length === 0 ? void 0 : Math.min(activeIndex, candidates.length - 1);
|
|
44
45
|
const currentLabel = current === "" ? "" : [
|
|
45
46
|
...options,
|
|
@@ -180,7 +181,7 @@ const Combobox = ({ invalid = false, options: optionsProp, search, type: _type,
|
|
|
180
181
|
disabled,
|
|
181
182
|
id,
|
|
182
183
|
onBlur: (event) => {
|
|
183
|
-
if (text
|
|
184
|
+
if (text?.trim() === "") {
|
|
184
185
|
setCurrent("");
|
|
185
186
|
setPicked(null);
|
|
186
187
|
}
|
|
@@ -78,12 +78,7 @@
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
.VmF9ya_dialog {
|
|
81
|
-
border-radius: var(--radius-xl);
|
|
82
|
-
border-width: 1px;
|
|
83
|
-
border-color: var(--color-border-subtle);
|
|
84
|
-
background-color: var(--color-bg-raised);
|
|
85
81
|
padding: calc(var(--spacing) * 3);
|
|
86
|
-
box-shadow: var(--shadow-md);
|
|
87
82
|
}
|
|
88
83
|
}
|
|
89
84
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { getMessages } from "../../../i18n/current.mjs";
|
|
3
2
|
import { mergeRefs } from "../../../helpers/merge-refs.mjs";
|
|
4
|
-
import
|
|
5
|
-
import { Popover } from "../../overlays/popover/index.mjs";
|
|
6
|
-
import { Calendar } from "../calendar/calendar.mjs";
|
|
3
|
+
import { getMessages } from "../../../i18n/current.mjs";
|
|
7
4
|
import { commitInputValue } from "../../../internal/commit-input-value.mjs";
|
|
8
5
|
import { CalendarIcon } from "../../icons/calendar.mjs";
|
|
6
|
+
import { Popover } from "../../overlays/popover/index.mjs";
|
|
7
|
+
import { Calendar } from "../calendar/calendar.mjs";
|
|
8
|
+
import focus_ring_module_default from "../../_internal/focus-ring.module.mjs";
|
|
9
9
|
import date_picker_module_default from "./date-picker.module.mjs";
|
|
10
10
|
import { clsx } from "clsx";
|
|
11
11
|
import { useMemo, useRef, useState } from "react";
|
|
@@ -45,7 +45,6 @@ const DatePicker = ({ invalid = false, value, defaultValue, onChange, disabled =
|
|
|
45
45
|
setIsOpen(next);
|
|
46
46
|
},
|
|
47
47
|
placement: "bottom-end",
|
|
48
|
-
role: "dialog",
|
|
49
48
|
children: [/* @__PURE__ */ jsx(Popover.Trigger, { renderItem: (props) => /* @__PURE__ */ jsx("button", {
|
|
50
49
|
...props,
|
|
51
50
|
"aria-label": messages.datePickerOpen,
|
|
@@ -53,23 +52,23 @@ const DatePicker = ({ invalid = false, value, defaultValue, onChange, disabled =
|
|
|
53
52
|
disabled: locked,
|
|
54
53
|
type: "button",
|
|
55
54
|
children: /* @__PURE__ */ jsx(CalendarIcon, { size: "sm" })
|
|
56
|
-
}) }), /* @__PURE__ */ jsx(Popover.Content, {
|
|
57
|
-
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
})
|
|
72
|
-
})
|
|
55
|
+
}) }), /* @__PURE__ */ jsx(Popover.Content, {
|
|
56
|
+
label: messages.datePickerDialog,
|
|
57
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
58
|
+
className: date_picker_module_default.dialog,
|
|
59
|
+
children: isOpen ? /* @__PURE__ */ jsx(Calendar, {
|
|
60
|
+
defaultValue: openedWith,
|
|
61
|
+
max: asDate(max),
|
|
62
|
+
min: asDate(min),
|
|
63
|
+
onChange: (next) => {
|
|
64
|
+
const input = inputRef.current;
|
|
65
|
+
if (input !== null) commitInputValue(input, next);
|
|
66
|
+
onChange?.(next);
|
|
67
|
+
setIsOpen(false);
|
|
68
|
+
}
|
|
69
|
+
}) : null
|
|
70
|
+
})
|
|
71
|
+
})]
|
|
73
72
|
})]
|
|
74
73
|
});
|
|
75
74
|
};
|
|
@@ -2,17 +2,20 @@ import { ChangeEvent, FC, InputHTMLAttributes, PropsWithChildren, ReactElement,
|
|
|
2
2
|
type RootProps = PropsWithChildren<{
|
|
3
3
|
invalid?: boolean;
|
|
4
4
|
maxFiles?: number;
|
|
5
|
-
defaultValue?: File[]
|
|
5
|
+
defaultValue?: File[];
|
|
6
6
|
onChange?: (files: FileList | null, event?: ChangeEvent<HTMLInputElement>) => void;
|
|
7
7
|
webkitDirectory?: boolean;
|
|
8
8
|
ref?: Ref<HTMLInputElement>;
|
|
9
9
|
} & Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'className' | 'style' | 'onChange' | 'defaultValue' | 'value' | 'children'>>;
|
|
10
|
-
export declare const Root: ({ children, disabled, invalid, required, multiple, accept, maxFiles, defaultValue, onChange, webkitDirectory, ref, ...rest }: RootProps) => import("react").JSX.Element;
|
|
10
|
+
export declare const Root: ({ children, disabled, invalid, required, multiple, accept, maxFiles, defaultValue, onChange, webkitDirectory, ref, onFocus, ...rest }: RootProps) => import("react").JSX.Element;
|
|
11
11
|
export declare const Trigger: FC<{
|
|
12
12
|
renderItem: (props: {
|
|
13
|
+
id: string;
|
|
14
|
+
'aria-labelledby': string | undefined;
|
|
15
|
+
'aria-describedby': string | undefined;
|
|
16
|
+
ref: (node: HTMLElement | null) => void;
|
|
13
17
|
onClick: () => void;
|
|
14
18
|
disabled: boolean;
|
|
15
|
-
invalid: boolean;
|
|
16
19
|
}) => ReactElement;
|
|
17
20
|
}>;
|
|
18
21
|
export declare const Dropzone: FC<{
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { getMessages } from "../../../i18n/current.mjs";
|
|
3
|
-
import sr_only_module_default from "../../_internal/sr-only.module.mjs";
|
|
4
|
-
import { mergeRefs } from "../../../helpers/merge-refs.mjs";
|
|
5
|
-
import { Button } from "../../buttons/button/button.mjs";
|
|
6
|
-
import { createSafeContext } from "../../../helpers/create-safe-context.mjs";
|
|
7
|
-
import { IconButton } from "../../buttons/icon-button/icon-button.mjs";
|
|
8
|
-
import { XIcon } from "../../icons/x.mjs";
|
|
9
3
|
import { acceptsFile } from "../../../internal/accepts-file.mjs";
|
|
10
4
|
import { carriesFiles } from "../../../internal/carries-files.mjs";
|
|
11
5
|
import { droppedFiles } from "../../../internal/dropped-files.mjs";
|
|
6
|
+
import { Button } from "../../buttons/button/button.mjs";
|
|
7
|
+
import { IconButton } from "../../buttons/icon-button/icon-button.mjs";
|
|
8
|
+
import { XIcon } from "../../icons/x.mjs";
|
|
9
|
+
import { createSafeContext } from "../../../helpers/create-safe-context.mjs";
|
|
10
|
+
import { mergeRefs } from "../../../helpers/merge-refs.mjs";
|
|
11
|
+
import sr_only_module_default from "../../_internal/sr-only.module.mjs";
|
|
12
12
|
import file_field_module_default from "./file-field.module.mjs";
|
|
13
13
|
import { clsx } from "clsx";
|
|
14
14
|
import { useCallback, useEffect, useEffectEvent, useId, useMemo, useRef, useState } from "react";
|
|
@@ -31,13 +31,14 @@ const announce = (input, files) => {
|
|
|
31
31
|
input.files = toFileList(files);
|
|
32
32
|
input.dispatchEvent(new Event("input", { bubbles: true }));
|
|
33
33
|
};
|
|
34
|
-
const Root = ({ children, disabled = false, invalid = false, required = false, multiple = false, accept, maxFiles, defaultValue, onChange, webkitDirectory = false, ref, ...rest }) => {
|
|
34
|
+
const Root = ({ children, disabled = false, invalid = false, required = false, multiple = false, accept, maxFiles, defaultValue, onChange, webkitDirectory = false, ref, onFocus, ...rest }) => {
|
|
35
35
|
const generatedId = useId();
|
|
36
36
|
const inputRef = useRef(null);
|
|
37
|
+
const triggerRef = useRef(null);
|
|
37
38
|
const mergedRef = useMemo(() => mergeRefs(inputRef, ref), [ref]);
|
|
38
39
|
const { pending } = useFormStatus();
|
|
39
40
|
const disabledResolved = disabled || pending;
|
|
40
|
-
const defaultFiles =
|
|
41
|
+
const defaultFiles = defaultValue ?? [];
|
|
41
42
|
const [acceptedFiles, setAcceptedFiles] = useState(() => toAccepted(defaultFiles));
|
|
42
43
|
const writeDefaults = useEffectEvent(() => {
|
|
43
44
|
if (inputRef.current !== null) inputRef.current.files = toFileList(defaultFiles);
|
|
@@ -97,9 +98,17 @@ const Root = ({ children, disabled = false, invalid = false, required = false, m
|
|
|
97
98
|
const openFilePicker = useCallback(() => {
|
|
98
99
|
inputRef.current?.click();
|
|
99
100
|
}, []);
|
|
101
|
+
const setTrigger = useCallback((node) => {
|
|
102
|
+
triggerRef.current = node;
|
|
103
|
+
}, []);
|
|
104
|
+
const labelledBy = rest["aria-labelledby"];
|
|
105
|
+
const describedBy = rest["aria-describedby"];
|
|
100
106
|
const contextValue = useMemo(() => ({
|
|
101
107
|
disabled: disabledResolved,
|
|
102
108
|
invalid,
|
|
109
|
+
labelledBy,
|
|
110
|
+
describedBy,
|
|
111
|
+
setTrigger,
|
|
103
112
|
acceptedFiles,
|
|
104
113
|
onFileDelete,
|
|
105
114
|
onFilesDrop,
|
|
@@ -107,6 +116,9 @@ const Root = ({ children, disabled = false, invalid = false, required = false, m
|
|
|
107
116
|
}), [
|
|
108
117
|
disabledResolved,
|
|
109
118
|
invalid,
|
|
119
|
+
labelledBy,
|
|
120
|
+
describedBy,
|
|
121
|
+
setTrigger,
|
|
110
122
|
acceptedFiles,
|
|
111
123
|
onFileDelete,
|
|
112
124
|
onFilesDrop,
|
|
@@ -119,31 +131,43 @@ const Root = ({ children, disabled = false, invalid = false, required = false, m
|
|
|
119
131
|
children: [/* @__PURE__ */ jsx("input", {
|
|
120
132
|
...rest,
|
|
121
133
|
accept,
|
|
134
|
+
"aria-hidden": true,
|
|
122
135
|
"aria-invalid": invalid,
|
|
123
136
|
className: sr_only_module_default.srOnly,
|
|
124
137
|
disabled: disabledResolved,
|
|
125
138
|
id: rest.id ?? generatedId,
|
|
126
139
|
multiple,
|
|
127
140
|
onChange: onFilesChange,
|
|
141
|
+
onFocus: (event) => {
|
|
142
|
+
onFocus?.(event);
|
|
143
|
+
triggerRef.current?.focus();
|
|
144
|
+
},
|
|
128
145
|
ref: mergedRef,
|
|
129
146
|
required,
|
|
147
|
+
tabIndex: -1,
|
|
130
148
|
type: "file",
|
|
131
149
|
webkitdirectory: webkitDirectory ? "true" : void 0
|
|
132
150
|
}), children]
|
|
133
151
|
})
|
|
134
152
|
});
|
|
135
153
|
};
|
|
136
|
-
const
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
154
|
+
const useTriggerWiring = () => {
|
|
155
|
+
const id = useId();
|
|
156
|
+
const { labelledBy, describedBy, setTrigger, openFilePicker, disabled } = useFileFieldContext();
|
|
157
|
+
return {
|
|
158
|
+
id,
|
|
159
|
+
"aria-labelledby": labelledBy === void 0 ? void 0 : `${labelledBy} ${id}`,
|
|
160
|
+
"aria-describedby": describedBy,
|
|
161
|
+
ref: setTrigger,
|
|
162
|
+
onClick: openFilePicker,
|
|
163
|
+
disabled
|
|
164
|
+
};
|
|
143
165
|
};
|
|
166
|
+
const Trigger = ({ renderItem }) => renderItem(useTriggerWiring());
|
|
144
167
|
const Dropzone = ({ children }) => {
|
|
145
168
|
const messages = getMessages();
|
|
146
|
-
const
|
|
169
|
+
const wiring = useTriggerWiring();
|
|
170
|
+
const { disabled, invalid, onFilesDrop } = useFileFieldContext();
|
|
147
171
|
const [depth, setDepth] = useState(0);
|
|
148
172
|
const isDragging = depth > 0 && !disabled;
|
|
149
173
|
return /* @__PURE__ */ jsx("div", {
|
|
@@ -173,8 +197,7 @@ const Dropzone = ({ children }) => {
|
|
|
173
197
|
className: file_field_module_default.hint,
|
|
174
198
|
children: messages.fileFieldDrop
|
|
175
199
|
}), /* @__PURE__ */ jsx(Button, {
|
|
176
|
-
|
|
177
|
-
onClick: openFilePicker,
|
|
200
|
+
...wiring,
|
|
178
201
|
size: "sm",
|
|
179
202
|
variant: "outline",
|
|
180
203
|
children: messages.fileFieldTrigger
|
|
@@ -3,9 +3,12 @@ export declare const FileField: {
|
|
|
3
3
|
readonly Root: typeof Root;
|
|
4
4
|
readonly Trigger: import("react").FC<{
|
|
5
5
|
renderItem: (props: {
|
|
6
|
+
id: string;
|
|
7
|
+
'aria-labelledby': string | undefined;
|
|
8
|
+
'aria-describedby': string | undefined;
|
|
9
|
+
ref: (node: HTMLElement | null) => void;
|
|
6
10
|
onClick: () => void;
|
|
7
11
|
disabled: boolean;
|
|
8
|
-
invalid: boolean;
|
|
9
12
|
}) => import("react").ReactElement;
|
|
10
13
|
}>;
|
|
11
14
|
readonly Dropzone: import("react").FC<{
|
|
@@ -23,21 +23,6 @@
|
|
|
23
23
|
font-weight: var(--font-weight-medium);
|
|
24
24
|
color: var(--color-fg-error);
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
._8KGDqG_message {
|
|
28
|
-
margin-top: calc(var(--spacing) * 1);
|
|
29
|
-
padding-left: calc(var(--spacing) * .5);
|
|
30
|
-
font-size: var(--font-size-sm);
|
|
31
|
-
line-height: var(--line-height-sm);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
._8KGDqG_error {
|
|
35
|
-
color: var(--color-fg-error);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
._8KGDqG_help {
|
|
39
|
-
color: var(--color-fg-mute);
|
|
40
|
-
}
|
|
41
26
|
}
|
|
42
27
|
|
|
43
28
|
@layer utilities;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { FC, HTMLAttributes, ReactElement, Ref } from "react";
|
|
2
2
|
type FormControlProps = {
|
|
3
3
|
disabled?: boolean;
|
|
4
|
-
invalid?: boolean;
|
|
5
4
|
required?: boolean;
|
|
6
5
|
label: string;
|
|
7
|
-
labelAs?: 'label' | '
|
|
6
|
+
labelAs?: 'label' | 'group';
|
|
8
7
|
helpText?: string;
|
|
9
8
|
errorText?: string | undefined;
|
|
10
9
|
renderInput: (props: {
|
|
@@ -15,7 +14,7 @@ type FormControlProps = {
|
|
|
15
14
|
invalid: boolean;
|
|
16
15
|
required: boolean;
|
|
17
16
|
}) => ReactElement;
|
|
18
|
-
ref?: Ref<
|
|
19
|
-
} & Omit<HTMLAttributes<
|
|
17
|
+
ref?: Ref<HTMLDivElement>;
|
|
18
|
+
} & Omit<HTMLAttributes<HTMLDivElement>, 'className' | 'style' | 'children'>;
|
|
20
19
|
export declare const FormControl: FC<FormControlProps>;
|
|
21
20
|
export {};
|
|
@@ -1,61 +1,59 @@
|
|
|
1
|
-
"use client";
|
|
2
1
|
import { getMessages } from "../../../i18n/current.mjs";
|
|
2
|
+
import { hasErrorText } from "../../_internal/field-message.mjs";
|
|
3
|
+
import field_message_module_default from "../../_internal/field-message.module.mjs";
|
|
3
4
|
import form_control_module_default from "./form-control.module.mjs";
|
|
4
5
|
import { clsx } from "clsx";
|
|
5
6
|
import { useId } from "react";
|
|
6
|
-
import {
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
// src/components/form/form-control/form-control.tsx
|
|
8
|
-
const FormControl = ({ disabled = false,
|
|
9
|
+
const FormControl = ({ disabled = false, required = false, label, labelAs = "label", helpText, errorText, renderInput, ref, ...rest }) => {
|
|
9
10
|
const messages = getMessages();
|
|
10
11
|
const id = useId();
|
|
11
|
-
const
|
|
12
|
+
const invalid = hasErrorText(errorText);
|
|
12
13
|
const hasHelpText = helpText !== void 0 && helpText !== "";
|
|
13
|
-
const describedbyId = invalid
|
|
14
|
+
const describedbyId = invalid ? `${id}-feedback` : hasHelpText ? `${id}-helptext` : void 0;
|
|
14
15
|
const labelId = `${id}-label`;
|
|
15
|
-
|
|
16
|
-
className: form_control_module_default.required,
|
|
17
|
-
children: messages.required
|
|
18
|
-
})] });
|
|
19
|
-
const content = /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
20
|
-
labelAs === "label" ? /* @__PURE__ */ jsx("label", {
|
|
21
|
-
className: form_control_module_default.label,
|
|
22
|
-
htmlFor: id,
|
|
23
|
-
id: labelId,
|
|
24
|
-
children: labelContent
|
|
25
|
-
}) : /* @__PURE__ */ jsx("legend", {
|
|
26
|
-
className: form_control_module_default.label,
|
|
27
|
-
id: labelId,
|
|
28
|
-
children: labelContent
|
|
29
|
-
}),
|
|
30
|
-
renderInput({
|
|
31
|
-
id,
|
|
32
|
-
"aria-describedby": describedbyId,
|
|
33
|
-
"aria-labelledby": labelId,
|
|
34
|
-
disabled,
|
|
35
|
-
invalid,
|
|
36
|
-
required
|
|
37
|
-
}),
|
|
38
|
-
invalid && hasErrorText ? /* @__PURE__ */ jsx("p", {
|
|
39
|
-
"aria-live": "polite",
|
|
40
|
-
className: clsx(form_control_module_default.message, form_control_module_default.error),
|
|
41
|
-
id: `${id}-feedback`,
|
|
42
|
-
children: errorText
|
|
43
|
-
}) : hasHelpText ? /* @__PURE__ */ jsx("p", {
|
|
44
|
-
className: clsx(form_control_module_default.message, form_control_module_default.help),
|
|
45
|
-
id: `${id}-helptext`,
|
|
46
|
-
children: helpText
|
|
47
|
-
}) : null
|
|
48
|
-
] });
|
|
49
|
-
return labelAs === "legend" ? /* @__PURE__ */ jsx("fieldset", {
|
|
16
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
50
17
|
...rest,
|
|
51
18
|
className: form_control_module_default.root,
|
|
52
19
|
ref,
|
|
53
|
-
children:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
20
|
+
children: [
|
|
21
|
+
labelAs === "label" ? /* @__PURE__ */ jsxs("label", {
|
|
22
|
+
className: form_control_module_default.label,
|
|
23
|
+
htmlFor: id,
|
|
24
|
+
id: labelId,
|
|
25
|
+
children: [label, required && /* @__PURE__ */ jsx("span", {
|
|
26
|
+
"aria-hidden": true,
|
|
27
|
+
className: form_control_module_default.required,
|
|
28
|
+
children: messages.required
|
|
29
|
+
})]
|
|
30
|
+
}) : /* @__PURE__ */ jsxs("span", {
|
|
31
|
+
className: form_control_module_default.label,
|
|
32
|
+
id: labelId,
|
|
33
|
+
children: [label, required && /* @__PURE__ */ jsx("span", {
|
|
34
|
+
className: form_control_module_default.required,
|
|
35
|
+
children: messages.required
|
|
36
|
+
})]
|
|
37
|
+
}),
|
|
38
|
+
renderInput({
|
|
39
|
+
id,
|
|
40
|
+
"aria-describedby": describedbyId,
|
|
41
|
+
"aria-labelledby": labelId,
|
|
42
|
+
disabled,
|
|
43
|
+
invalid,
|
|
44
|
+
required
|
|
45
|
+
}),
|
|
46
|
+
invalid ? /* @__PURE__ */ jsx("p", {
|
|
47
|
+
"aria-live": "polite",
|
|
48
|
+
className: clsx(field_message_module_default.message, field_message_module_default.error),
|
|
49
|
+
id: `${id}-feedback`,
|
|
50
|
+
children: errorText
|
|
51
|
+
}) : hasHelpText ? /* @__PURE__ */ jsx("p", {
|
|
52
|
+
className: clsx(field_message_module_default.message, field_message_module_default.help),
|
|
53
|
+
id: `${id}-helptext`,
|
|
54
|
+
children: helpText
|
|
55
|
+
}) : null
|
|
56
|
+
]
|
|
59
57
|
});
|
|
60
58
|
};
|
|
61
59
|
export { FormControl };
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import './form-control.css';
|
|
2
2
|
// src/components/form/form-control/form-control.module.css
|
|
3
3
|
var form_control_module_default = {
|
|
4
|
-
"error": "_8KGDqG_error",
|
|
5
|
-
"help": "_8KGDqG_help",
|
|
6
4
|
"label": "_8KGDqG_label",
|
|
7
|
-
"message": "_8KGDqG_message",
|
|
8
5
|
"required": "_8KGDqG_required",
|
|
9
6
|
"root": "_8KGDqG_root"
|
|
10
7
|
};
|
|
@@ -6,8 +6,8 @@ type BaseProps = {
|
|
|
6
6
|
ref?: Ref<HTMLInputElement>;
|
|
7
7
|
} & Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'role' | 'className' | 'style' | 'value' | 'onChange' | 'defaultValue' | 'children' | 'step' | 'min' | 'max'> & {
|
|
8
8
|
step?: number | 'any';
|
|
9
|
-
min?: number
|
|
10
|
-
max?: number
|
|
9
|
+
min?: number;
|
|
10
|
+
max?: number;
|
|
11
11
|
};
|
|
12
12
|
type ControlledProps = {
|
|
13
13
|
value: number | null;
|