@godxjp/ui 19.6.0 → 20.1.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 +8 -2
- package/dist/app/theme-axes.d.ts +2 -0
- package/dist/app/theme-axes.js +45 -0
- package/dist/components/charts/chart-cartesian.d.ts +2 -1
- package/dist/components/charts/chart-cartesian.js +52 -3
- package/dist/components/charts/chart-category-axis.d.ts +55 -0
- package/dist/components/charts/chart-category-axis.js +93 -0
- package/dist/components/charts/chart-frame.d.ts +10 -1
- package/dist/components/charts/chart-frame.js +19 -3
- package/dist/components/charts/compact-bar-trend.d.ts +1 -1
- package/dist/components/charts/compact-bar-trend.js +2 -0
- package/dist/components/charts/pie-chart.d.ts +1 -1
- package/dist/components/charts/pie-chart.js +12 -1
- package/dist/components/charts/recharts-peer.d.ts +49 -0
- package/dist/components/charts/recharts-peer.js +45 -0
- package/dist/components/data-display/card.d.ts +14 -3
- package/dist/components/data-display/card.js +22 -4
- package/dist/components/data-display/code-block.js +6 -2
- package/dist/components/data-display/collapsible.d.ts +23 -4
- package/dist/components/data-display/collapsible.js +119 -4
- package/dist/components/data-display/data-table.d.ts +39 -4
- package/dist/components/data-display/data-table.js +802 -270
- package/dist/components/data-display/descriptions.d.ts +27 -6
- package/dist/components/data-display/descriptions.js +58 -17
- package/dist/components/data-display/index.d.ts +5 -1
- package/dist/components/data-display/index.js +4 -0
- package/dist/components/data-display/legend.d.ts +15 -0
- package/dist/components/data-display/legend.js +11 -0
- package/dist/components/data-display/list-row.d.ts +10 -1
- package/dist/components/data-display/list-row.js +8 -2
- package/dist/components/data-display/popover.d.ts +60 -7
- package/dist/components/data-display/popover.js +268 -39
- package/dist/components/data-display/progress.d.ts +50 -2
- package/dist/components/data-display/progress.js +57 -9
- package/dist/components/data-display/range-timeline.d.ts +38 -0
- package/dist/components/data-display/range-timeline.js +161 -0
- package/dist/components/data-display/scroll-area.js +13 -2
- package/dist/components/data-display/service-launcher-card.js +10 -10
- package/dist/components/data-display/table.d.ts +11 -3
- package/dist/components/data-display/table.js +48 -18
- package/dist/components/data-display/tree-list.js +4 -9
- package/dist/components/data-entry/calendar.d.ts +2 -2
- package/dist/components/data-entry/calendar.js +79 -33
- package/dist/components/data-entry/cascader.d.ts +1 -1
- package/dist/components/data-entry/cascader.js +188 -24
- package/dist/components/data-entry/checkbox.d.ts +19 -6
- package/dist/components/data-entry/checkbox.js +55 -16
- package/dist/components/data-entry/choice-option.d.ts +1 -1
- package/dist/components/data-entry/color-picker.d.ts +1 -1
- package/dist/components/data-entry/color-picker.js +17 -5
- package/dist/components/data-entry/control-appearance.d.ts +64 -0
- package/dist/components/data-entry/control-appearance.js +39 -0
- package/dist/components/data-entry/control-surface.d.ts +61 -0
- package/dist/components/data-entry/control-surface.js +39 -0
- package/dist/components/data-entry/date-picker.d.ts +1 -1
- package/dist/components/data-entry/date-picker.js +344 -113
- package/dist/components/data-entry/date-range-picker.d.ts +2 -2
- package/dist/components/data-entry/date-range-picker.js +278 -140
- package/dist/components/data-entry/field.js +0 -1
- package/dist/components/data-entry/form-field.d.ts +1 -1
- package/dist/components/data-entry/form-field.js +39 -4
- package/dist/components/data-entry/form.d.ts +4 -0
- package/dist/components/data-entry/form.js +5 -3
- package/dist/components/data-entry/index.d.ts +7 -3
- package/dist/components/data-entry/index.js +10 -1
- package/dist/components/data-entry/input-otp.d.ts +1 -1
- package/dist/components/data-entry/input.d.ts +12 -34
- package/dist/components/data-entry/input.js +92 -24
- package/dist/components/data-entry/label.d.ts +3 -2
- package/dist/components/data-entry/label.js +23 -10
- package/dist/components/data-entry/month-picker.d.ts +2 -2
- package/dist/components/data-entry/month-picker.js +47 -10
- package/dist/components/data-entry/month-range-picker.d.ts +2 -2
- package/dist/components/data-entry/month-range-picker.js +51 -11
- package/dist/components/data-entry/number-input.d.ts +7 -0
- package/dist/components/data-entry/number-input.js +147 -98
- package/dist/components/data-entry/password-input.d.ts +1 -1
- package/dist/components/data-entry/radio.d.ts +1 -1
- package/dist/components/data-entry/radio.js +61 -13
- package/dist/components/data-entry/search-input.d.ts +1 -1
- package/dist/components/data-entry/search-input.js +16 -2
- package/dist/components/data-entry/search-select.d.ts +2 -2
- package/dist/components/data-entry/search-select.js +209 -78
- package/dist/components/data-entry/select.d.ts +22 -4
- package/dist/components/data-entry/select.js +215 -163
- package/dist/components/data-entry/slider.d.ts +9 -1
- package/dist/components/data-entry/slider.js +87 -9
- package/dist/components/data-entry/switch.d.ts +3 -0
- package/dist/components/data-entry/switch.js +29 -3
- package/dist/components/data-entry/textarea.d.ts +14 -56
- package/dist/components/data-entry/textarea.js +80 -33
- package/dist/components/data-entry/time-picker.d.ts +2 -2
- package/dist/components/data-entry/time-picker.js +333 -109
- package/dist/components/data-entry/time-range-picker.d.ts +5 -0
- package/dist/components/data-entry/time-range-picker.js +89 -0
- package/dist/components/data-entry/transfer.d.ts +1 -1
- package/dist/components/data-entry/transfer.js +99 -31
- package/dist/components/data-entry/tree-select-strategy.d.ts +1 -1
- package/dist/components/data-entry/tree-select.d.ts +1 -1
- package/dist/components/data-entry/tree-select.js +197 -92
- package/dist/components/data-entry/tree-utils.d.ts +1 -1
- package/dist/components/data-entry/tree-utils.js +7 -14
- package/dist/components/data-entry/upload-files.d.ts +2 -0
- package/dist/components/data-entry/upload-files.js +31 -0
- package/dist/components/data-entry/upload-request.d.ts +4 -0
- package/dist/components/data-entry/upload-request.js +53 -0
- package/dist/components/data-entry/upload-types.d.ts +28 -0
- package/dist/components/data-entry/upload-types.js +2 -0
- package/dist/components/data-entry/upload.d.ts +2 -2
- package/dist/components/data-entry/upload.js +482 -117
- package/dist/components/feedback/dialog.d.ts +105 -38
- package/dist/components/feedback/dialog.js +268 -193
- package/dist/components/feedback/overlay-close-focus.d.ts +31 -0
- package/dist/components/feedback/overlay-close-focus.js +31 -0
- package/dist/components/feedback/overlay-header-tone.d.ts +1 -1
- package/dist/components/feedback/sheet.d.ts +53 -11
- package/dist/components/feedback/sheet.js +150 -81
- package/dist/components/feedback/tooltip.d.ts +51 -7
- package/dist/components/feedback/tooltip.js +107 -25
- package/dist/components/general/button.d.ts +1 -1
- package/dist/components/general/button.js +7 -3
- package/dist/components/general/index.d.ts +1 -0
- package/dist/components/general/index.js +2 -0
- package/dist/components/general/logo.d.ts +17 -0
- package/dist/components/general/logo.js +22 -16
- package/dist/components/general/typography.d.ts +3 -0
- package/dist/components/general/typography.js +15 -1
- package/dist/components/general/visually-hidden.d.ts +3 -0
- package/dist/components/general/visually-hidden.js +9 -0
- package/dist/components/layout/app-launcher.d.ts +34 -0
- package/dist/components/layout/app-launcher.js +228 -0
- package/dist/components/layout/app-shell.d.ts +3 -1
- package/dist/components/layout/app-shell.js +69 -12
- package/dist/components/layout/aspect-ratio.js +0 -1
- package/dist/components/layout/auth-divider.js +0 -1
- package/dist/components/layout/breadcrumb.d.ts +14 -2
- package/dist/components/layout/breadcrumb.js +46 -4
- package/dist/components/layout/flex.d.ts +1 -1
- package/dist/components/layout/flex.js +41 -3
- package/dist/components/layout/index.d.ts +3 -0
- package/dist/components/layout/index.js +5 -1
- package/dist/components/layout/nav-surface.d.ts +26 -0
- package/dist/components/layout/nav-surface.js +17 -0
- package/dist/components/layout/org-switcher.d.ts +5 -1
- package/dist/components/layout/org-switcher.js +25 -4
- package/dist/components/layout/page-container.d.ts +1 -1
- package/dist/components/layout/page-container.js +5 -3
- package/dist/components/layout/responsive-grid.d.ts +16 -2
- package/dist/components/layout/responsive-grid.js +29 -2
- package/dist/components/layout/separator.js +0 -1
- package/dist/components/layout/sidebar.js +4 -1
- package/dist/components/layout/split-pane.d.ts +14 -1
- package/dist/components/layout/split-pane.js +26 -13
- package/dist/components/layout/topbar-item.d.ts +3 -0
- package/dist/components/layout/topbar-item.js +19 -5
- package/dist/components/layout/topbar.d.ts +1 -1
- package/dist/components/layout/topbar.js +27 -6
- package/dist/components/navigation/app-setting-picker.js +21 -2
- package/dist/components/navigation/app-setting-toggle.d.ts +16 -0
- package/dist/components/navigation/app-setting-toggle.js +96 -0
- package/dist/components/navigation/dropdown-menu.d.ts +227 -18
- package/dist/components/navigation/dropdown-menu.js +402 -118
- package/dist/components/navigation/index.d.ts +2 -0
- package/dist/components/navigation/index.js +2 -0
- package/dist/components/navigation/pagination-utils.d.ts +2 -1
- package/dist/components/navigation/pagination.d.ts +2 -2
- package/dist/components/navigation/pagination.js +155 -83
- package/dist/components/navigation/steps.d.ts +2 -2
- package/dist/components/navigation/steps.js +29 -4
- package/dist/components/navigation/tabs.d.ts +29 -16
- package/dist/components/navigation/tabs.js +374 -144
- package/dist/components/ui/accordion.d.ts +50 -5
- package/dist/components/ui/accordion.js +239 -33
- package/dist/components/ui/aspect-ratio.d.ts +23 -2
- package/dist/components/ui/aspect-ratio.js +15 -13
- package/dist/components/ui/avatar.d.ts +29 -4
- package/dist/components/ui/avatar.js +111 -25
- package/dist/components/ui/hover-card.d.ts +42 -4
- package/dist/components/ui/hover-card.js +183 -27
- package/dist/components/ui/input-otp.d.ts +26 -28
- package/dist/components/ui/input-otp.js +50 -7
- package/dist/components/ui/label.js +0 -1
- package/dist/components/ui/password-input.d.ts +36 -2
- package/dist/components/ui/password-input.js +27 -7
- package/dist/components/ui/rating.d.ts +25 -0
- package/dist/components/ui/rating.js +67 -27
- package/dist/components/ui/segmented.d.ts +12 -3
- package/dist/components/ui/segmented.js +17 -2
- package/dist/components/ui/separator.d.ts +12 -2
- package/dist/components/ui/separator.js +30 -9
- package/dist/components/ui/tag-input.d.ts +45 -0
- package/dist/components/ui/tag-input.js +109 -27
- package/dist/components/ui/toggle-group.d.ts +50 -5
- package/dist/components/ui/toggle-group.js +79 -20
- package/dist/components/ui/toggle.d.ts +31 -5
- package/dist/components/ui/toggle.js +42 -3
- package/dist/form/form-context.d.ts +29 -0
- package/dist/form/form-context.js +44 -4
- package/dist/form/form-field-array.d.ts +22 -0
- package/dist/form/form-field-array.js +50 -0
- package/dist/form/form-field-control.d.ts +2 -1
- package/dist/form/form-field-control.js +116 -40
- package/dist/form/form-root.d.ts +2 -1
- package/dist/form/form-root.js +142 -23
- package/dist/form/index.d.ts +3 -1
- package/dist/form/index.js +12 -1
- package/dist/i18n/messages/en.json +64 -5
- package/dist/i18n/messages/ja.json +64 -5
- package/dist/i18n/messages/vi.json +64 -5
- package/dist/inertia/index.d.ts +20 -0
- package/dist/inertia/index.js +60 -1
- package/dist/lib/control-styles.d.ts +25 -3
- package/dist/lib/control-styles.js +9 -3
- package/dist/lib/datetime/picker-format.d.ts +8 -0
- package/dist/lib/datetime/picker-format.js +54 -0
- package/dist/lib/slot.d.ts +32 -0
- package/dist/lib/slot.js +22 -0
- package/dist/lib/variants.d.ts +22 -3
- package/dist/lib/variants.js +56 -1
- package/dist/props/components/app.prop.d.ts +25 -1
- package/dist/props/components/charts.prop.d.ts +21 -0
- package/dist/props/components/data-display.prop.d.ts +72 -4
- package/dist/props/components/data-entry.prop.d.ts +718 -46
- package/dist/props/components/form.prop.d.ts +142 -4
- package/dist/props/components/general.prop.d.ts +17 -1
- package/dist/props/components/index.d.ts +3 -3
- package/dist/props/components/layout.prop.d.ts +281 -11
- package/dist/props/components/navigation.prop.d.ts +114 -4
- package/dist/props/registry.d.ts +397 -11
- package/dist/props/registry.js +526 -11
- package/dist/props/vocabulary/content.prop.d.ts +1 -1
- package/dist/props/vocabulary/data.prop.d.ts +179 -1
- package/dist/props/vocabulary/index.d.ts +5 -5
- package/dist/props/vocabulary/interaction.prop.d.ts +68 -3
- package/dist/props/vocabulary/layout.prop.d.ts +57 -1
- package/dist/props/vocabulary/navigation.prop.d.ts +40 -0
- package/dist/props/vocabulary/shared.prop.d.ts +33 -0
- package/dist/styles/badge-layout.css +2 -1
- package/dist/styles/card-layout.css +26 -4
- package/dist/styles/chart-layout.css +15 -0
- package/dist/styles/control.css +657 -15
- package/dist/styles/core.css +5 -2
- package/dist/styles/data-display-layout.css +313 -6
- package/dist/styles/data-entry-layout.css +13 -0
- package/dist/styles/focus-ring.css +4 -0
- package/dist/styles/index.css +5 -2
- package/dist/styles/layout.css +327 -4
- package/dist/styles/navigation-layout.css +227 -0
- package/dist/styles/shell-layout.css +369 -13
- package/dist/styles/table-layout.css +95 -6
- package/dist/styles/text-layout.css +10 -4
- package/dist/tokens/base.css +2 -1
- package/dist/tokens/components/badge.css +1 -0
- package/dist/tokens/components/chart.css +6 -0
- package/dist/tokens/components/control.css +79 -2
- package/dist/tokens/components/data-display.css +20 -0
- package/dist/tokens/components/descriptions.css +11 -0
- package/dist/tokens/components/flex.css +8 -0
- package/dist/tokens/components/navigation.css +55 -0
- package/dist/tokens/components/shell.css +53 -3
- package/dist/tokens/components/table.css +14 -0
- package/dist/tokens/foundation.css +2 -0
- package/dist/tokens/semantic/layout.css +9 -0
- package/docs/COMPONENTS.md +9 -3
- package/docs/CONSUMER-RULES.md +13 -0
- package/docs/DESIGN-AUTHORITY.md +145 -83
- package/docs/DEVELOPMENT.md +4 -3
- package/docs/FORMS.md +151 -6
- package/docs/FRAME-COVERAGE-REPORT.md +32 -17
- package/docs/README.md +15 -15
- package/docs/STANDARDS-vocabulary-tokens.md +1 -1
- package/docs/TESTING.md +15 -6
- package/docs/WHAT-BELONGS-HERE.md +179 -0
- package/docs/charts/cjk-category-axis.tsx +81 -0
- package/docs/data-display/card/index.tsx +22 -0
- package/docs/data-display/data-table/examples/antd-parity.tsx +257 -0
- package/docs/data-display/data-table/index.tsx +23 -0
- package/docs/data-display/descriptions.tsx +41 -0
- package/docs/data-display/legend.tsx +145 -0
- package/docs/data-display/progress.tsx +32 -0
- package/docs/data-display/scroll-area.tsx +31 -25
- package/docs/data-display/table.tsx +104 -45
- package/docs/data-display/timeline.tsx +41 -0
- package/docs/data-entry/date-picker.tsx +85 -0
- package/docs/data-entry/date-range-picker.tsx +26 -0
- package/docs/data-entry/form-dynamic-fields.tsx +199 -0
- package/docs/data-entry/form.tsx +74 -4
- package/docs/data-entry/input-otp.tsx +24 -0
- package/docs/data-entry/input.tsx +46 -1
- package/docs/data-entry/month-range-picker.tsx +1 -1
- package/docs/data-entry/segmented.tsx +1 -1
- package/docs/data-entry/select.tsx +29 -2
- package/docs/data-entry/switch.tsx +41 -0
- package/docs/data-entry/textarea.tsx +38 -0
- package/docs/data-entry/time-picker.tsx +85 -1
- package/docs/data-entry/time-range-picker.tsx +55 -0
- package/docs/data-entry/transfer.tsx +17 -0
- package/docs/data-entry/upload.tsx +56 -12
- package/docs/feedback/sheet.tsx +1 -1
- package/docs/feedback/tooltip.tsx +1 -1
- package/docs/general/activity.tsx +2 -2
- package/docs/general/button/index.tsx +14 -1
- package/docs/general/typography.tsx +14 -1
- package/docs/layout/app-launcher.tsx +151 -0
- package/docs/layout/app-shell-arrangements.tsx +225 -0
- package/docs/layout/app-shell.tsx +11 -0
- package/docs/layout/aspect-ratio.tsx +1 -1
- package/docs/layout/flex.tsx +50 -0
- package/docs/layout/responsive-grid.tsx +21 -1
- package/docs/layout/topbar.tsx +5 -9
- package/docs/navigation/app-setting-picker.tsx +37 -1
- package/docs/navigation/app-setting-toggle.tsx +111 -0
- package/docs/navigation/breadcrumb.tsx +48 -0
- package/docs/navigation/dropdown-menu.tsx +21 -0
- package/docs/navigation/pagination.tsx +52 -0
- package/docs/navigation/steps.tsx +37 -0
- package/docs/navigation/tabs.tsx +97 -1
- package/docs/query/button-refetch.tsx +1 -0
- package/package.json +28 -8
- package/scripts/_agent-setup.mjs +182 -3
- package/scripts/consumer-rule.md +98 -0
- package/scripts/guinea-pig-skill.md +322 -0
- package/scripts/init-guinea-pig.mjs +84 -0
- package/scripts/postinstall.mjs +13 -2
- package/scripts/ui-audit.mjs +351 -37
- /package/dist/tokens/{antd.generated.css → derived.css} +0 -0
|
@@ -2,10 +2,22 @@
|
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import * as SwitchPrimitive from "@radix-ui/react-switch";
|
|
5
|
+
import { Loader2 } from "lucide-react";
|
|
5
6
|
import { cn } from "../../lib/utils.js";
|
|
6
7
|
import { useFieldIdentity } from "../../lib/field-a11y.js";
|
|
7
8
|
const Switch = React.forwardRef(
|
|
8
|
-
({
|
|
9
|
+
({
|
|
10
|
+
className,
|
|
11
|
+
size = "md",
|
|
12
|
+
name,
|
|
13
|
+
checked,
|
|
14
|
+
defaultChecked = false,
|
|
15
|
+
onCheckedChange,
|
|
16
|
+
loading = false,
|
|
17
|
+
checkedChildren,
|
|
18
|
+
unCheckedChildren,
|
|
19
|
+
...props
|
|
20
|
+
}, ref) => {
|
|
9
21
|
const identity = useFieldIdentity({
|
|
10
22
|
id: props.id,
|
|
11
23
|
name,
|
|
@@ -16,6 +28,7 @@ const Switch = React.forwardRef(
|
|
|
16
28
|
const isControlled = checked !== void 0;
|
|
17
29
|
const isChecked = isControlled ? checked : internalChecked;
|
|
18
30
|
const handleCheckedChange = (next) => {
|
|
31
|
+
if (loading) return;
|
|
19
32
|
if (!isControlled) {
|
|
20
33
|
setInternalChecked(next);
|
|
21
34
|
}
|
|
@@ -23,12 +36,15 @@ const Switch = React.forwardRef(
|
|
|
23
36
|
};
|
|
24
37
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
25
38
|
resolvedName ? /* @__PURE__ */ jsx("input", { type: "hidden", name: resolvedName, value: isChecked ? "1" : "0", readOnly: true }) : null,
|
|
26
|
-
/* @__PURE__ */
|
|
39
|
+
/* @__PURE__ */ jsxs(
|
|
27
40
|
SwitchPrimitive.Root,
|
|
28
41
|
{
|
|
29
42
|
ref,
|
|
30
43
|
"data-slot": "switch",
|
|
31
44
|
"data-size": size,
|
|
45
|
+
"data-loading": loading ? "true" : void 0,
|
|
46
|
+
"aria-busy": loading || void 0,
|
|
47
|
+
"aria-disabled": loading || void 0,
|
|
32
48
|
checked: isChecked,
|
|
33
49
|
onCheckedChange: handleCheckedChange,
|
|
34
50
|
className: cn(
|
|
@@ -42,7 +58,17 @@ const Switch = React.forwardRef(
|
|
|
42
58
|
),
|
|
43
59
|
...props,
|
|
44
60
|
"data-field": identity["data-field"] ?? props["data-field"],
|
|
45
|
-
children:
|
|
61
|
+
children: [
|
|
62
|
+
checkedChildren != null || unCheckedChildren != null ? /* @__PURE__ */ jsx("span", { "data-slot": "switch-content", className: "ui-switch-content", "aria-hidden": "true", children: isChecked ? checkedChildren : unCheckedChildren }) : null,
|
|
63
|
+
/* @__PURE__ */ jsx(SwitchPrimitive.Thumb, { "data-slot": "switch-thumb", className: "ui-switch-thumb", children: loading ? /* @__PURE__ */ jsx(
|
|
64
|
+
Loader2,
|
|
65
|
+
{
|
|
66
|
+
"data-slot": "switch-spinner",
|
|
67
|
+
className: "ui-switch-spinner",
|
|
68
|
+
"aria-hidden": "true"
|
|
69
|
+
}
|
|
70
|
+
) : null })
|
|
71
|
+
]
|
|
46
72
|
}
|
|
47
73
|
)
|
|
48
74
|
] });
|
|
@@ -1,63 +1,21 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
allowClear?: boolean;
|
|
5
|
-
/** Called after the field is cleared via the inline ✕. */
|
|
6
|
-
onClear?: () => void;
|
|
7
|
-
/**
|
|
8
|
-
* `ghost` strips the field's own border, background and focus ring, for a textarea embedded in a
|
|
9
|
-
* surface that already draws the box (a chat composer inside a Card). The surface then owns
|
|
10
|
-
* focus — give it `focus-within`.
|
|
11
|
-
*/
|
|
12
|
-
variant?: "default" | "ghost";
|
|
13
|
-
/**
|
|
14
|
-
* The floor is `minRows` (or `rows`, when that is the only one given) and never undercuts the
|
|
15
|
-
* `--control-height` tier; past `maxRows` the control stops growing and scrolls internally.
|
|
16
|
-
* Sizing is done in CSS by a hidden replica of the text, so it follows a paste, a programmatic
|
|
17
|
-
* value change, a font swap and a container resize — not just typing — and it never writes
|
|
18
|
-
* `style.height` or reads `scrollHeight`.
|
|
19
|
-
*/
|
|
20
|
-
autoGrow?: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Floor in text rows while `autoGrow` (theme default `--textarea-autogrow-min-height-rows`, 1).
|
|
23
|
-
* Ignored when `autoGrow` is false.
|
|
24
|
-
*/
|
|
25
|
-
minRows?: number;
|
|
26
|
-
/**
|
|
27
|
-
* Ceiling in text rows while `autoGrow` (theme default `--textarea-autogrow-max-height-rows`,
|
|
28
|
-
* 8); beyond it the control scrolls internally rather than pushing the page. Pass `0` for no
|
|
29
|
-
* ceiling — only correct inside an owning scroll container.
|
|
30
|
-
*/
|
|
31
|
-
maxRows?: number;
|
|
32
|
-
};
|
|
2
|
+
import type { ControlVariantProp } from "../../props/vocabulary/index.js";
|
|
3
|
+
export type { TextareaProp, TextareaProp as TextareaProps, } from "../../props/components/data-entry.prop.js";
|
|
33
4
|
export declare const Textarea: React.ForwardRefExoticComponent<React.TextareaHTMLAttributes<HTMLTextAreaElement> & {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
5
|
+
onValueChange?: (value: string) => void;
|
|
6
|
+
pad?: import("../../props/index.js").PadProp;
|
|
7
|
+
padRaw?: import("../../props/index.js").PadRawProp;
|
|
8
|
+
allowClear?: import("../../props/index.js").AllowClearProp;
|
|
37
9
|
onClear?: () => void;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
* focus — give it `focus-within`.
|
|
42
|
-
*/
|
|
43
|
-
variant?: "default" | "ghost";
|
|
44
|
-
/**
|
|
45
|
-
* The floor is `minRows` (or `rows`, when that is the only one given) and never undercuts the
|
|
46
|
-
* `--control-height` tier; past `maxRows` the control stops growing and scrolls internally.
|
|
47
|
-
* Sizing is done in CSS by a hidden replica of the text, so it follows a paste, a programmatic
|
|
48
|
-
* value change, a font swap and a container resize — not just typing — and it never writes
|
|
49
|
-
* `style.height` or reads `scrollHeight`.
|
|
50
|
-
*/
|
|
10
|
+
variant?: ControlVariantProp | "default" | "ghost";
|
|
11
|
+
status?: import("../../props/index.js").ControlStatusProp;
|
|
12
|
+
size?: "sm" | "md" | "lg";
|
|
51
13
|
autoGrow?: boolean;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
14
|
+
autoSize?: boolean | {
|
|
15
|
+
minRows?: number;
|
|
16
|
+
maxRows?: number;
|
|
17
|
+
};
|
|
56
18
|
minRows?: number;
|
|
57
|
-
/**
|
|
58
|
-
* Ceiling in text rows while `autoGrow` (theme default `--textarea-autogrow-max-height-rows`,
|
|
59
|
-
* 8); beyond it the control scrolls internally rather than pushing the page. Pass `0` for no
|
|
60
|
-
* ceiling — only correct inside an owning scroll container.
|
|
61
|
-
*/
|
|
62
19
|
maxRows?: number;
|
|
20
|
+
count?: import("../../props/components/data-entry.prop.js").ControlCountProp;
|
|
63
21
|
} & React.RefAttributes<HTMLTextAreaElement>>;
|
|
@@ -3,30 +3,54 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { X } from "lucide-react";
|
|
5
5
|
import { useTranslation } from "../../i18n/use-translation.js";
|
|
6
|
+
import { padStyle } from "../../lib/variants.js";
|
|
6
7
|
import { cn } from "../../lib/utils.js";
|
|
7
8
|
import { useFieldIdentity } from "../../lib/field-a11y.js";
|
|
8
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
controlMultilineClass,
|
|
11
|
+
controlMultilineFilledClass,
|
|
12
|
+
controlMultilineGhostClass
|
|
13
|
+
} from "../../lib/control-styles.js";
|
|
14
|
+
import { controlAppearanceAttributes, resolveControlCount } from "./control-appearance.js";
|
|
15
|
+
import { resolveAllowClear } from "./control-surface.js";
|
|
9
16
|
const UNBOUNDED_ROWS = "infinity";
|
|
10
17
|
const Textarea = React.forwardRef(
|
|
11
18
|
({
|
|
12
19
|
className,
|
|
13
|
-
|
|
20
|
+
pad,
|
|
21
|
+
padRaw,
|
|
22
|
+
allowClear,
|
|
14
23
|
onClear,
|
|
15
|
-
variant = "
|
|
24
|
+
variant = "outlined",
|
|
25
|
+
status,
|
|
26
|
+
size,
|
|
16
27
|
autoGrow = false,
|
|
28
|
+
autoSize,
|
|
17
29
|
minRows,
|
|
18
30
|
maxRows,
|
|
31
|
+
count,
|
|
19
32
|
rows,
|
|
20
33
|
style,
|
|
21
34
|
value,
|
|
22
35
|
defaultValue,
|
|
23
36
|
onChange,
|
|
37
|
+
onValueChange,
|
|
24
38
|
onCompositionStart,
|
|
25
39
|
onCompositionEnd,
|
|
26
40
|
...props
|
|
27
41
|
}, ref) => {
|
|
28
42
|
const { t } = useTranslation();
|
|
29
|
-
const
|
|
43
|
+
const resolvedVariant = variant === "default" ? "outlined" : variant === "ghost" ? "borderless" : variant;
|
|
44
|
+
const base = resolvedVariant === "borderless" ? controlMultilineGhostClass : resolvedVariant === "filled" ? controlMultilineFilledClass : controlMultilineClass;
|
|
45
|
+
const autoSizeEnabled = autoSize === true || typeof autoSize === "object";
|
|
46
|
+
const growing = autoGrow || autoSizeEnabled;
|
|
47
|
+
const floorRowsProp = minRows ?? (typeof autoSize === "object" ? autoSize.minRows : void 0);
|
|
48
|
+
const ceilRowsProp = maxRows ?? (typeof autoSize === "object" ? autoSize.maxRows : void 0);
|
|
49
|
+
const appearance = controlAppearanceAttributes({
|
|
50
|
+
status,
|
|
51
|
+
variant: resolvedVariant,
|
|
52
|
+
"aria-invalid": props["aria-invalid"]
|
|
53
|
+
});
|
|
30
54
|
const identity = useFieldIdentity({
|
|
31
55
|
id: props.id,
|
|
32
56
|
name: props.name,
|
|
@@ -41,11 +65,10 @@ const Textarea = React.forwardRef(
|
|
|
41
65
|
},
|
|
42
66
|
[ref]
|
|
43
67
|
);
|
|
44
|
-
const [
|
|
45
|
-
|
|
46
|
-
);
|
|
68
|
+
const [text, setText] = React.useState(() => String(value ?? defaultValue ?? ""));
|
|
69
|
+
const hasText = text.length > 0;
|
|
47
70
|
React.useEffect(() => {
|
|
48
|
-
if (value !== void 0)
|
|
71
|
+
if (value !== void 0) setText(String(value));
|
|
49
72
|
}, [value]);
|
|
50
73
|
const [mirror, setMirror] = React.useState(() => String(value ?? defaultValue ?? ""));
|
|
51
74
|
const composing = React.useRef(false);
|
|
@@ -55,21 +78,22 @@ const Textarea = React.forwardRef(
|
|
|
55
78
|
setMirror(el.value);
|
|
56
79
|
}, []);
|
|
57
80
|
React.useLayoutEffect(() => {
|
|
58
|
-
if (
|
|
81
|
+
if (growing) syncMirror();
|
|
59
82
|
});
|
|
60
83
|
React.useEffect(() => {
|
|
61
84
|
const form = innerRef.current?.form;
|
|
62
|
-
if (!
|
|
85
|
+
if (!growing || !form) return;
|
|
63
86
|
const onReset = () => {
|
|
64
87
|
queueMicrotask(syncMirror);
|
|
65
88
|
};
|
|
66
89
|
form.addEventListener("reset", onReset);
|
|
67
90
|
return () => form.removeEventListener("reset", onReset);
|
|
68
|
-
}, [
|
|
91
|
+
}, [growing, syncMirror]);
|
|
69
92
|
const handleChange = (event) => {
|
|
70
|
-
if (value === void 0)
|
|
71
|
-
if (
|
|
93
|
+
if (value === void 0) setText(event.target.value);
|
|
94
|
+
if (growing && !composing.current) setMirror(event.target.value);
|
|
72
95
|
onChange?.(event);
|
|
96
|
+
if (onChange !== onValueChange) onValueChange?.(event.target.value);
|
|
73
97
|
};
|
|
74
98
|
const handleCompositionStart = (event) => {
|
|
75
99
|
composing.current = true;
|
|
@@ -77,7 +101,7 @@ const Textarea = React.forwardRef(
|
|
|
77
101
|
};
|
|
78
102
|
const handleCompositionEnd = (event) => {
|
|
79
103
|
composing.current = false;
|
|
80
|
-
if (
|
|
104
|
+
if (growing) setMirror(event.currentTarget.value);
|
|
81
105
|
onCompositionEnd?.(event);
|
|
82
106
|
};
|
|
83
107
|
const clear = () => {
|
|
@@ -91,33 +115,46 @@ const Textarea = React.forwardRef(
|
|
|
91
115
|
el.dispatchEvent(new Event("input", { bubbles: true }));
|
|
92
116
|
el.focus();
|
|
93
117
|
}
|
|
94
|
-
|
|
95
|
-
if (
|
|
118
|
+
setText("");
|
|
119
|
+
if (growing) setMirror("");
|
|
96
120
|
onClear?.();
|
|
97
121
|
};
|
|
98
|
-
const floorRows =
|
|
99
|
-
const
|
|
122
|
+
const floorRows = floorRowsProp ?? (typeof rows === "number" ? rows : void 0);
|
|
123
|
+
const inset = padStyle(pad, padRaw);
|
|
124
|
+
const mirrorInset = inset ? {
|
|
125
|
+
"--textarea-padding-block-start": inset.paddingBlockStart ?? inset.padding ?? "var(--control-multiline-padding-block)",
|
|
126
|
+
"--textarea-padding-block-end": inset.paddingBlockEnd ?? inset.padding ?? "var(--control-multiline-padding-block)",
|
|
127
|
+
"--textarea-padding-inline-start": inset.paddingInlineStart ?? inset.padding ?? "var(--control-padding-x)",
|
|
128
|
+
"--textarea-padding-inline-end": inset.paddingInlineEnd ?? inset.padding ?? "var(--control-padding-x)",
|
|
129
|
+
"--textarea-autogrow-box-inset": `calc(var(--textarea-padding-block-start) + var(--textarea-padding-block-end) + ${resolvedVariant === "borderless" ? "0px" : "var(--control-border-width) * 2"})`
|
|
130
|
+
} : void 0;
|
|
131
|
+
const autoGrowVars = growing ? {
|
|
100
132
|
...floorRows === void 0 ? null : { "--textarea-autogrow-min-height-rows": floorRows },
|
|
101
|
-
...
|
|
102
|
-
"--textarea-autogrow-max-height-rows":
|
|
133
|
+
...ceilRowsProp === void 0 ? null : {
|
|
134
|
+
"--textarea-autogrow-max-height-rows": ceilRowsProp === 0 ? UNBOUNDED_ROWS : ceilRowsProp
|
|
103
135
|
}
|
|
104
136
|
} : void 0;
|
|
105
|
-
const
|
|
106
|
-
const
|
|
137
|
+
const clearControl = resolveAllowClear(allowClear, false, t("common.clear") ?? "Clear");
|
|
138
|
+
const showClear = clearControl.enabled && hasText && !props.disabled && !props.readOnly;
|
|
139
|
+
const counter = resolveControlCount(count, text);
|
|
140
|
+
const needsWrapper = clearControl.enabled || growing || counter !== null;
|
|
107
141
|
const field = /* @__PURE__ */ jsx(
|
|
108
142
|
"textarea",
|
|
109
143
|
{
|
|
110
144
|
ref: setRefs,
|
|
111
145
|
value,
|
|
112
146
|
defaultValue,
|
|
113
|
-
rows:
|
|
114
|
-
|
|
147
|
+
rows: growing ? 1 : rows,
|
|
148
|
+
"data-size": size,
|
|
149
|
+
onChange: handleChange,
|
|
115
150
|
onCompositionStart: handleCompositionStart,
|
|
116
151
|
onCompositionEnd: handleCompositionEnd,
|
|
117
|
-
style,
|
|
152
|
+
style: { ...style, ...padStyle(pad, padRaw) },
|
|
153
|
+
"data-pad-raw": padRaw === void 0 ? void 0 : "",
|
|
118
154
|
className: cn(base, showClear && "ui-input--trailing-affix", className),
|
|
119
155
|
...props,
|
|
120
|
-
...identity
|
|
156
|
+
...identity,
|
|
157
|
+
...appearance
|
|
121
158
|
}
|
|
122
159
|
);
|
|
123
160
|
if (!needsWrapper) return field;
|
|
@@ -125,13 +162,13 @@ const Textarea = React.forwardRef(
|
|
|
125
162
|
"span",
|
|
126
163
|
{
|
|
127
164
|
"data-slot": "textarea-affix-wrapper",
|
|
128
|
-
"data-autogrow-value":
|
|
129
|
-
style: autoGrowVars,
|
|
165
|
+
"data-autogrow-value": growing ? mirror : void 0,
|
|
166
|
+
style: { ...autoGrowVars, ...mirrorInset },
|
|
130
167
|
className: cn(
|
|
131
168
|
"relative w-full",
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
169
|
+
growing ? "grid" : "block",
|
|
170
|
+
growing && "ui-textarea-autogrow",
|
|
171
|
+
growing && resolvedVariant === "borderless" && "ui-textarea-autogrow--ghost"
|
|
135
172
|
),
|
|
136
173
|
children: [
|
|
137
174
|
field,
|
|
@@ -140,10 +177,20 @@ const Textarea = React.forwardRef(
|
|
|
140
177
|
{
|
|
141
178
|
type: "button",
|
|
142
179
|
tabIndex: -1,
|
|
143
|
-
"aria-label":
|
|
180
|
+
"aria-label": clearControl.label,
|
|
144
181
|
onClick: clear,
|
|
145
182
|
className: "ui-control-inline-affix-action ui-textarea-clear",
|
|
146
|
-
children: /* @__PURE__ */ jsx(X, { className: "ui-control-inline-affix-icon", "aria-hidden": "true" })
|
|
183
|
+
children: clearControl.clearIcon ?? /* @__PURE__ */ jsx(X, { className: "ui-control-inline-affix-icon", "aria-hidden": "true" })
|
|
184
|
+
}
|
|
185
|
+
) : null,
|
|
186
|
+
counter ? /* @__PURE__ */ jsx(
|
|
187
|
+
"span",
|
|
188
|
+
{
|
|
189
|
+
"data-slot": "textarea-count",
|
|
190
|
+
"data-exceeded": counter.exceeded ? "true" : void 0,
|
|
191
|
+
className: "ui-control-count ui-textarea-count",
|
|
192
|
+
"aria-hidden": "true",
|
|
193
|
+
children: counter.content
|
|
147
194
|
}
|
|
148
195
|
) : null
|
|
149
196
|
]
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { TimePickerProp } from "../../props/components/data-entry.prop.js";
|
|
3
|
-
export type { TimePickerProp, TimePickerProp as TimePickerProps, } from "../../props/components/data-entry.prop.js";
|
|
3
|
+
export type { TimePickerDisabledTimeProp, TimePickerProp, TimePickerProp as TimePickerProps, } from "../../props/components/data-entry.prop.js";
|
|
4
4
|
/**
|
|
5
5
|
* TimePicker — WAI-ARIA time combobox. The value lives on a real, typeable `HH:mm` `<input>` (24h
|
|
6
6
|
* canonical): form-submittable (give it a `name`), screen-reader friendly, and e2e-testable by
|
|
7
7
|
* filling the input.
|
|
8
8
|
*/
|
|
9
|
-
export declare function TimePicker({ value: controlledValue, defaultValue, onValueChange, placeholder, disabled, className, id, name, minuteStep, allowClear, ...ariaProps }: TimePickerProp): React.JSX.Element;
|
|
9
|
+
export declare function TimePicker({ value: controlledValue, defaultValue, onValueChange, placeholder, disabled, className, id, name, minuteStep, hourStep, changeOnScroll, secondStep, showSeconds: showSecondsProp, use12Hours, format, open: openProp, defaultOpen, onOpenChange, inputReadOnly, preserveInvalidOnBlur, placement, renderExtraFooter, size, status, variant, ref, disabledTime, hideDisabledOptions, showNow, needConfirm, allowClear, ...ariaProps }: TimePickerProp): React.JSX.Element;
|