@lt-three/love3 0.0.0 → 0.1.1
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 +85 -1
- package/dist/native/analytics/animation.d.ts +4 -0
- package/dist/native/analytics/animation.js +6 -0
- package/dist/native/analytics/chart.types.d.ts +25 -0
- package/dist/native/analytics/chart.types.js +0 -0
- package/dist/native/analytics/line-chart.d.ts +4 -0
- package/dist/native/analytics/line-chart.ios.d.ts +4 -0
- package/dist/native/analytics/line-chart.ios.js +24 -0
- package/dist/native/analytics/line-chart.js +33 -0
- package/dist/native/analytics/metric-card.d.ts +10 -0
- package/dist/native/analytics/metric-card.js +29 -0
- package/dist/native/analytics/multi-line-chart.d.ts +18 -0
- package/dist/native/analytics/multi-line-chart.js +216 -0
- package/dist/native/analytics/pie-chart.d.ts +15 -0
- package/dist/native/analytics/pie-chart.ios.d.ts +4 -0
- package/dist/native/analytics/pie-chart.ios.js +24 -0
- package/dist/native/analytics/pie-chart.js +92 -0
- package/dist/native/analytics/single-number.d.ts +19 -0
- package/dist/native/analytics/single-number.js +101 -0
- package/dist/native/atom/avatar.d.ts +21 -0
- package/dist/native/atom/avatar.js +46 -0
- package/dist/native/atom/badge.d.ts +28 -0
- package/dist/native/atom/badge.js +51 -0
- package/dist/native/atom/button.d.ts +46 -0
- package/dist/native/atom/button.js +109 -0
- package/dist/native/atom/checkbox.d.ts +21 -0
- package/dist/native/atom/checkbox.js +47 -0
- package/dist/native/atom/colored-value.d.ts +12 -0
- package/dist/native/atom/colored-value.js +24 -0
- package/dist/native/atom/image.d.ts +21 -0
- package/dist/native/atom/image.js +72 -0
- package/dist/native/atom/label.d.ts +18 -0
- package/dist/native/atom/label.js +33 -0
- package/dist/native/atom/link.d.ts +18 -0
- package/dist/native/atom/link.js +25 -0
- package/dist/native/atom/readout.d.ts +22 -0
- package/dist/native/atom/readout.js +39 -0
- package/dist/native/atom/search-input.d.ts +12 -0
- package/dist/native/atom/search-input.js +36 -0
- package/dist/native/atom/select.d.ts +54 -0
- package/dist/native/atom/select.js +200 -0
- package/dist/native/atom/separator.d.ts +12 -0
- package/dist/native/atom/separator.js +16 -0
- package/dist/native/atom/skeleton.d.ts +12 -0
- package/dist/native/atom/skeleton.js +39 -0
- package/dist/native/atom/slider.d.ts +32 -0
- package/dist/native/atom/slider.js +75 -0
- package/dist/native/atom/spinner.d.ts +15 -0
- package/dist/native/atom/spinner.js +25 -0
- package/dist/native/atom/switch.d.ts +18 -0
- package/dist/native/atom/switch.js +52 -0
- package/dist/native/atom/symbol.d.ts +16 -0
- package/dist/native/atom/symbol.js +38 -0
- package/dist/native/atom/symbol.types.d.ts +25 -0
- package/dist/native/atom/symbol.types.js +49 -0
- package/dist/native/atom/text-field.d.ts +49 -0
- package/dist/native/atom/text-field.js +56 -0
- package/dist/native/atom/text.d.ts +2 -0
- package/dist/native/atom/text.js +3 -0
- package/dist/native/atom/theme-toggle.d.ts +21 -0
- package/dist/native/atom/theme-toggle.js +36 -0
- package/dist/native/atom/timezone-select.d.ts +16 -0
- package/dist/native/atom/timezone-select.js +28 -0
- package/dist/native/atom/typography.d.ts +13 -0
- package/dist/native/atom/typography.js +28 -0
- package/dist/native/base/button.d.ts +61 -0
- package/dist/native/base/button.js +92 -0
- package/dist/native/base/form.d.ts +72 -0
- package/dist/native/base/form.js +113 -0
- package/dist/native/base/glass-card.d.ts +15 -0
- package/dist/native/base/glass-card.js +38 -0
- package/dist/native/base/input.d.ts +29 -0
- package/dist/native/base/input.js +27 -0
- package/dist/native/base/sheet.d.ts +71 -0
- package/dist/native/base/sheet.js +187 -0
- package/dist/native/base/text.d.ts +14 -0
- package/dist/native/base/text.js +53 -0
- package/dist/native/form/checkbox.d.ts +13 -0
- package/dist/native/form/checkbox.js +55 -0
- package/dist/native/form/date-picker.d.ts +23 -0
- package/dist/native/form/date-picker.js +119 -0
- package/dist/native/form/form.d.ts +22 -0
- package/dist/native/form/form.js +44 -0
- package/dist/native/form/radio-group.d.ts +23 -0
- package/dist/native/form/radio-group.js +88 -0
- package/dist/native/form/select.d.ts +13 -0
- package/dist/native/form/select.js +45 -0
- package/dist/native/form/slider.d.ts +14 -0
- package/dist/native/form/slider.js +42 -0
- package/dist/native/form/switch.d.ts +9 -0
- package/dist/native/form/switch.js +59 -0
- package/dist/native/form/text-area.d.ts +11 -0
- package/dist/native/form/text-area.js +50 -0
- package/dist/native/form/text-input.d.ts +18 -0
- package/dist/native/form/text-input.js +90 -0
- package/dist/native/index.d.ts +1 -0
- package/dist/native/index.js +0 -0
- package/dist/native/layout/accordion.d.ts +25 -0
- package/dist/native/layout/accordion.js +54 -0
- package/dist/native/layout/card.d.ts +47 -0
- package/dist/native/layout/card.js +57 -0
- package/dist/native/layout/description.d.ts +16 -0
- package/dist/native/layout/description.js +32 -0
- package/dist/native/layout/error.d.ts +21 -0
- package/dist/native/layout/error.js +44 -0
- package/dist/native/layout/information.d.ts +25 -0
- package/dist/native/layout/information.js +35 -0
- package/dist/native/layout/locked.d.ts +38 -0
- package/dist/native/layout/locked.js +94 -0
- package/dist/native/layout/modal.d.ts +25 -0
- package/dist/native/layout/modal.js +93 -0
- package/dist/native/layout/not-found.d.ts +17 -0
- package/dist/native/layout/not-found.js +30 -0
- package/dist/native/layout/page-frame.d.ts +23 -0
- package/dist/native/layout/page-frame.js +46 -0
- package/dist/native/layout/panel.d.ts +18 -0
- package/dist/native/layout/panel.js +23 -0
- package/dist/native/layout/reorderable-list.d.ts +42 -0
- package/dist/native/layout/reorderable-list.js +52 -0
- package/dist/native/layout/sheet.d.ts +30 -0
- package/dist/native/layout/sheet.js +46 -0
- package/dist/native/layout/simple-dialog.d.ts +16 -0
- package/dist/native/layout/simple-dialog.js +20 -0
- package/dist/native/layout/simple-table.d.ts +50 -0
- package/dist/native/layout/simple-table.js +75 -0
- package/dist/native/layout/tab-bar.d.ts +33 -0
- package/dist/native/layout/tab-bar.js +48 -0
- package/dist/native/layout/tabs.d.ts +28 -0
- package/dist/native/layout/tabs.js +54 -0
- package/dist/native/layout/tuning-panel.d.ts +24 -0
- package/dist/native/layout/tuning-panel.js +246 -0
- package/dist/native/lib/autocomplete.d.ts +7 -0
- package/dist/native/lib/autocomplete.js +34 -0
- package/dist/native/lib/breakpoints.d.ts +14 -0
- package/dist/native/lib/breakpoints.js +17 -0
- package/dist/native/lib/chart-palette.d.ts +8 -0
- package/dist/native/lib/chart-palette.js +20 -0
- package/dist/native/lib/confirm.d.ts +48 -0
- package/dist/native/lib/confirm.js +69 -0
- package/dist/native/lib/control.d.ts +24 -0
- package/dist/native/lib/control.js +0 -0
- package/dist/native/lib/external-store.d.ts +16 -0
- package/dist/native/lib/external-store.js +30 -0
- package/dist/native/lib/keyboard.d.ts +15 -0
- package/dist/native/lib/keyboard.js +24 -0
- package/dist/native/lib/labels.d.ts +15 -0
- package/dist/native/lib/labels.js +17 -0
- package/dist/native/lib/loading.d.ts +10 -0
- package/dist/native/lib/loading.js +15 -0
- package/dist/native/lib/network.d.ts +11 -0
- package/dist/native/lib/network.js +20 -0
- package/dist/native/lib/scheme.d.ts +18 -0
- package/dist/native/lib/scheme.js +22 -0
- package/dist/native/lib/snackbar.d.ts +45 -0
- package/dist/native/lib/snackbar.js +59 -0
- package/dist/native/lib/theme.d.ts +34 -0
- package/dist/native/lib/theme.js +53 -0
- package/dist/native/lib/timezone.d.ts +26 -0
- package/dist/native/lib/timezone.js +95 -0
- package/dist/native/lib/token-color.d.ts +5 -0
- package/dist/native/lib/token-color.js +13 -0
- package/dist/native/lib/token-color.web.d.ts +4 -0
- package/dist/native/lib/token-color.web.js +7 -0
- package/dist/native/lib/tuning-context.d.ts +9 -0
- package/dist/native/lib/tuning-context.js +7 -0
- package/dist/native/lib/tuning.d.ts +24 -0
- package/dist/native/lib/tuning.js +42 -0
- package/dist/native/lib/typography.d.ts +10 -0
- package/dist/native/lib/typography.js +11 -0
- package/dist/native/lib/utils.d.ts +11 -0
- package/dist/native/lib/utils.js +21 -0
- package/dist/native/once/confirm.d.ts +7 -0
- package/dist/native/once/confirm.js +60 -0
- package/dist/native/once/error-boundary.d.ts +28 -0
- package/dist/native/once/error-boundary.js +55 -0
- package/dist/native/once/loading-lock.d.ts +8 -0
- package/dist/native/once/loading-lock.js +28 -0
- package/dist/native/once/offline-banner.d.ts +15 -0
- package/dist/native/once/offline-banner.js +35 -0
- package/dist/native/once/snackbar.d.ts +17 -0
- package/dist/native/once/snackbar.js +106 -0
- package/dist/native/styles.css +46 -0
- package/dist/shared/analytics.d.ts +71 -0
- package/dist/shared/analytics.js +0 -0
- package/dist/shared/button.d.ts +7 -0
- package/dist/shared/button.js +23 -0
- package/dist/shared/form.d.ts +45 -0
- package/dist/shared/form.js +46 -0
- package/dist/shared/index.d.ts +3 -0
- package/dist/shared/index.js +3 -0
- package/dist/tokens/contrast-pairs.d.ts +30 -0
- package/dist/tokens/contrast-pairs.js +404 -0
- package/dist/tokens/index.d.ts +6 -0
- package/dist/tokens/index.js +10 -0
- package/dist/tokens/styles.gen.css +250 -0
- package/dist/tokens/tokens.gen.d.ts +141 -0
- package/dist/tokens/tokens.gen.js +206 -0
- package/dist/tuning/catalog.d.ts +27 -0
- package/dist/tuning/catalog.gen.d.ts +4 -0
- package/dist/tuning/catalog.gen.js +397 -0
- package/dist/tuning/catalog.js +128 -0
- package/dist/tuning/color.d.ts +20 -0
- package/dist/tuning/color.js +80 -0
- package/dist/tuning/css.d.ts +35 -0
- package/dist/tuning/css.js +147 -0
- package/dist/tuning/index.d.ts +8 -0
- package/dist/tuning/index.js +9 -0
- package/dist/tuning/model.d.ts +33 -0
- package/dist/tuning/model.js +154 -0
- package/dist/tuning/native.d.ts +35 -0
- package/dist/tuning/native.js +80 -0
- package/dist/tuning/schema.d.ts +69 -0
- package/dist/tuning/schema.js +247 -0
- package/dist/tuning/types.d.ts +75 -0
- package/dist/tuning/types.js +39 -0
- package/dist/web/analytics/line-chart.d.ts +20 -0
- package/dist/web/analytics/line-chart.js +28 -0
- package/dist/web/analytics/metric-card.d.ts +18 -0
- package/dist/web/analytics/metric-card.js +40 -0
- package/dist/web/analytics/multi-line-chart.d.ts +39 -0
- package/dist/web/analytics/multi-line-chart.js +345 -0
- package/dist/web/atom/avatar.d.ts +11 -0
- package/dist/web/atom/avatar.js +24 -0
- package/dist/web/atom/badge.d.ts +2 -0
- package/dist/web/atom/badge.js +3 -0
- package/dist/web/atom/button.d.ts +23 -0
- package/dist/web/atom/button.js +35 -0
- package/dist/web/atom/checkbox.d.ts +19 -0
- package/dist/web/atom/checkbox.js +33 -0
- package/dist/web/atom/colored-value.d.ts +13 -0
- package/dist/web/atom/colored-value.js +24 -0
- package/dist/web/atom/help.d.ts +10 -0
- package/dist/web/atom/help.js +18 -0
- package/dist/web/atom/label.d.ts +2 -0
- package/dist/web/atom/label.js +3 -0
- package/dist/web/atom/segmented-control.d.ts +39 -0
- package/dist/web/atom/segmented-control.js +42 -0
- package/dist/web/atom/select.d.ts +43 -0
- package/dist/web/atom/select.js +93 -0
- package/dist/web/atom/separator.d.ts +2 -0
- package/dist/web/atom/separator.js +3 -0
- package/dist/web/atom/skeleton.d.ts +2 -0
- package/dist/web/atom/skeleton.js +3 -0
- package/dist/web/atom/slider.d.ts +33 -0
- package/dist/web/atom/slider.js +70 -0
- package/dist/web/atom/spinner.d.ts +8 -0
- package/dist/web/atom/spinner.js +14 -0
- package/dist/web/atom/switch.d.ts +11 -0
- package/dist/web/atom/switch.js +10 -0
- package/dist/web/atom/text-area.d.ts +23 -0
- package/dist/web/atom/text-area.js +27 -0
- package/dist/web/atom/text-field.d.ts +18 -0
- package/dist/web/atom/text-field.js +22 -0
- package/dist/web/atom/toggle-chip.d.ts +22 -0
- package/dist/web/atom/toggle-chip.js +28 -0
- package/dist/web/atom/tooltip.d.ts +23 -0
- package/dist/web/atom/tooltip.js +26 -0
- package/dist/web/atom/typography.d.ts +6 -0
- package/dist/web/atom/typography.js +23 -0
- package/dist/web/base/accordion.d.ts +9 -0
- package/dist/web/base/accordion.js +44 -0
- package/dist/web/base/alert.d.ts +11 -0
- package/dist/web/base/alert.js +37 -0
- package/dist/web/base/avatar.d.ts +8 -0
- package/dist/web/base/avatar.js +29 -0
- package/dist/web/base/badge.d.ts +12 -0
- package/dist/web/base/badge.js +26 -0
- package/dist/web/base/breadcrumb.d.ts +16 -0
- package/dist/web/base/breadcrumb.js +72 -0
- package/dist/web/base/button.d.ts +12 -0
- package/dist/web/base/button.js +47 -0
- package/dist/web/base/card.d.ts +19 -0
- package/dist/web/base/card.js +74 -0
- package/dist/web/base/checkbox.d.ts +6 -0
- package/dist/web/base/checkbox.js +21 -0
- package/dist/web/base/dialog.d.ts +20 -0
- package/dist/web/base/dialog.js +92 -0
- package/dist/web/base/dropdown-menu.d.ts +29 -0
- package/dist/web/base/dropdown-menu.js +125 -0
- package/dist/web/base/field.d.ts +27 -0
- package/dist/web/base/field.js +118 -0
- package/dist/web/base/form.d.ts +38 -0
- package/dist/web/base/form.js +110 -0
- package/dist/web/base/input.d.ts +9 -0
- package/dist/web/base/input.js +23 -0
- package/dist/web/base/label.d.ts +6 -0
- package/dist/web/base/label.js +15 -0
- package/dist/web/base/pagination.d.ts +34 -0
- package/dist/web/base/pagination.js +90 -0
- package/dist/web/base/popover.d.ts +11 -0
- package/dist/web/base/popover.js +37 -0
- package/dist/web/base/radio-group.d.ts +7 -0
- package/dist/web/base/radio-group.js +27 -0
- package/dist/web/base/scroll-area.d.ts +10 -0
- package/dist/web/base/scroll-area.js +41 -0
- package/dist/web/base/select.d.ts +17 -0
- package/dist/web/base/select.js +96 -0
- package/dist/web/base/separator.d.ts +6 -0
- package/dist/web/base/separator.js +17 -0
- package/dist/web/base/sheet.d.ts +19 -0
- package/dist/web/base/sheet.js +88 -0
- package/dist/web/base/skeleton.d.ts +5 -0
- package/dist/web/base/skeleton.js +14 -0
- package/dist/web/base/slider.d.ts +9 -0
- package/dist/web/base/slider.js +39 -0
- package/dist/web/base/sonner.d.ts +9 -0
- package/dist/web/base/sonner.js +25 -0
- package/dist/web/base/spinner.d.ts +5 -0
- package/dist/web/base/spinner.js +17 -0
- package/dist/web/base/switch.d.ts +6 -0
- package/dist/web/base/switch.js +19 -0
- package/dist/web/base/table.d.ts +14 -0
- package/dist/web/base/table.js +68 -0
- package/dist/web/base/tabs.d.ts +9 -0
- package/dist/web/base/tabs.js +36 -0
- package/dist/web/base/textarea.d.ts +9 -0
- package/dist/web/base/textarea.js +23 -0
- package/dist/web/base/tooltip.d.ts +9 -0
- package/dist/web/base/tooltip.js +36 -0
- package/dist/web/form/checkbox.d.ts +35 -0
- package/dist/web/form/checkbox.js +91 -0
- package/dist/web/form/radio-group.d.ts +24 -0
- package/dist/web/form/radio-group.js +75 -0
- package/dist/web/form/select.d.ts +16 -0
- package/dist/web/form/select.js +44 -0
- package/dist/web/form/slider.d.ts +19 -0
- package/dist/web/form/slider.js +51 -0
- package/dist/web/form/switch.d.ts +11 -0
- package/dist/web/form/switch.js +50 -0
- package/dist/web/form/text-area.d.ts +10 -0
- package/dist/web/form/text-area.js +31 -0
- package/dist/web/form/text-input.d.ts +10 -0
- package/dist/web/form/text-input.js +42 -0
- package/dist/web/index.d.ts +1 -0
- package/dist/web/index.js +0 -0
- package/dist/web/layout/accordion.d.ts +26 -0
- package/dist/web/layout/accordion.js +29 -0
- package/dist/web/layout/alert-modal.d.ts +41 -0
- package/dist/web/layout/alert-modal.js +71 -0
- package/dist/web/layout/card.d.ts +17 -0
- package/dist/web/layout/card.js +35 -0
- package/dist/web/layout/description.d.ts +12 -0
- package/dist/web/layout/description.js +20 -0
- package/dist/web/layout/information.d.ts +36 -0
- package/dist/web/layout/information.js +53 -0
- package/dist/web/layout/modal.d.ts +16 -0
- package/dist/web/layout/modal.js +37 -0
- package/dist/web/layout/page-frame.d.ts +37 -0
- package/dist/web/layout/page-frame.js +79 -0
- package/dist/web/layout/scroll-area.d.ts +10 -0
- package/dist/web/layout/scroll-area.js +13 -0
- package/dist/web/layout/sheet.d.ts +32 -0
- package/dist/web/layout/sheet.js +68 -0
- package/dist/web/layout/simple-dialog.d.ts +11 -0
- package/dist/web/layout/simple-dialog.js +24 -0
- package/dist/web/layout/simple-table.d.ts +49 -0
- package/dist/web/layout/simple-table.js +58 -0
- package/dist/web/layout/tabs.d.ts +26 -0
- package/dist/web/layout/tabs.js +42 -0
- package/dist/web/layout/titled-modal.d.ts +32 -0
- package/dist/web/layout/titled-modal.js +58 -0
- package/dist/web/lib/css-vars.d.ts +14 -0
- package/dist/web/lib/css-vars.js +18 -0
- package/dist/web/lib/dialog.d.ts +13 -0
- package/dist/web/lib/dialog.js +0 -0
- package/dist/web/lib/form.d.ts +2 -0
- package/dist/web/lib/form.js +3 -0
- package/dist/web/lib/labels.d.ts +27 -0
- package/dist/web/lib/labels.js +29 -0
- package/dist/web/lib/modal-open-focus.d.ts +17 -0
- package/dist/web/lib/modal-open-focus.js +44 -0
- package/dist/web/lib/restore-focus.d.ts +12 -0
- package/dist/web/lib/restore-focus.js +32 -0
- package/dist/web/lib/utils.d.ts +4 -0
- package/dist/web/lib/utils.js +10 -0
- package/dist/web/styles.css +162 -0
- package/package.json +203 -4
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { BaseInputProps } from "../../shared/form.js";
|
|
2
|
+
import { Checkbox as Checkbox$1 } from "../base/checkbox.js";
|
|
3
|
+
import "../lib/form.js";
|
|
4
|
+
import React, { ComponentProps } from "react";
|
|
5
|
+
//#region src/web/form/checkbox.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* The name of the checkbox. One of the following is required (so a checkbox never has no name).
|
|
8
|
+
* - `checkboxLabel`: text shown on the right (clicking it toggles)
|
|
9
|
+
* - `label`: the field label shown above (for a standalone checkbox with no text on the right; the label becomes the name)
|
|
10
|
+
* - `aria-label` / `aria-labelledby`: when there is no visible label (selecting a table row, etc.)
|
|
11
|
+
*/
|
|
12
|
+
type CheckboxNameProps = {
|
|
13
|
+
checkboxLabel: React.ReactNode;
|
|
14
|
+
} | {
|
|
15
|
+
checkboxLabel?: undefined;
|
|
16
|
+
label: React.ReactNode;
|
|
17
|
+
} | {
|
|
18
|
+
checkboxLabel?: undefined;
|
|
19
|
+
"aria-label": string;
|
|
20
|
+
} | {
|
|
21
|
+
checkboxLabel?: undefined;
|
|
22
|
+
"aria-labelledby": string;
|
|
23
|
+
};
|
|
24
|
+
export type CheckboxProps = BaseInputProps<boolean> & Omit<ComponentProps<typeof Checkbox$1>, "checked" | "onCheckedChange" | "value" | "onChange"> & {
|
|
25
|
+
/** Vertical alignment of the checkbox and the label */
|
|
26
|
+
align?: "center" | "start";
|
|
27
|
+
} & CheckboxNameProps;
|
|
28
|
+
/**
|
|
29
|
+
* A Checkbox that supports both form and controlled use.
|
|
30
|
+
* - Passing `value` / `onValueChange` selects controlled mode (it uses `atom/checkbox` inside)
|
|
31
|
+
* - When omitted, it takes the value from the field context
|
|
32
|
+
*/
|
|
33
|
+
export declare function Checkbox(props: CheckboxProps): React.JSX.Element;
|
|
34
|
+
//#endregion
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { useFieldValue } from "../../shared/form.js";
|
|
2
|
+
import { cn } from "../lib/utils.js";
|
|
3
|
+
import { Checkbox as Checkbox$1 } from "../base/checkbox.js";
|
|
4
|
+
import { Label } from "../base/label.js";
|
|
5
|
+
import { FormControl, FormDescription, FormItem, FormLabel, FormMessage } from "../base/form.js";
|
|
6
|
+
import { useId } from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
|
|
9
|
+
//#region src/web/form/checkbox.tsx
|
|
10
|
+
/**
|
|
11
|
+
* A Checkbox that supports both form and controlled use.
|
|
12
|
+
* - Passing `value` / `onValueChange` selects controlled mode (it uses `atom/checkbox` inside)
|
|
13
|
+
* - When omitted, it takes the value from the field context
|
|
14
|
+
*/
|
|
15
|
+
function Checkbox(props) {
|
|
16
|
+
if (props.value !== void 0 && props.onValueChange !== void 0) return /* @__PURE__ */ jsx(ControlledCheckbox, {
|
|
17
|
+
...props,
|
|
18
|
+
value: props.value,
|
|
19
|
+
onValueChange: props.onValueChange
|
|
20
|
+
});
|
|
21
|
+
return /* @__PURE__ */ jsx(FieldCheckbox, { ...props });
|
|
22
|
+
}
|
|
23
|
+
function ControlledCheckbox({ label, required, helpText, description, className, checkboxLabel, align = "center", wrapperClassName, disabled, value, onValueChange, ...rest }) {
|
|
24
|
+
return /* @__PURE__ */ jsx(Layout, {
|
|
25
|
+
label,
|
|
26
|
+
required,
|
|
27
|
+
helpText,
|
|
28
|
+
description,
|
|
29
|
+
className,
|
|
30
|
+
checkboxLabel,
|
|
31
|
+
align,
|
|
32
|
+
wrapperClassName,
|
|
33
|
+
disabled,
|
|
34
|
+
checked: value,
|
|
35
|
+
onCheckedChange: onValueChange,
|
|
36
|
+
rest
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function FieldCheckbox({ label, required, helpText, description, debounce, className, checkboxLabel, align = "center", wrapperClassName, disabled, ...rest }) {
|
|
40
|
+
const [value, setValue] = useFieldValue({ debounce });
|
|
41
|
+
return /* @__PURE__ */ jsx(Layout, {
|
|
42
|
+
label,
|
|
43
|
+
required,
|
|
44
|
+
helpText,
|
|
45
|
+
description,
|
|
46
|
+
className,
|
|
47
|
+
checkboxLabel,
|
|
48
|
+
align,
|
|
49
|
+
wrapperClassName,
|
|
50
|
+
disabled,
|
|
51
|
+
checked: value ?? false,
|
|
52
|
+
onCheckedChange: setValue,
|
|
53
|
+
rest
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function Layout({ label, required, helpText, description, className, checkboxLabel, align, wrapperClassName, disabled, checked, onCheckedChange, rest }) {
|
|
57
|
+
const id = useId();
|
|
58
|
+
return /* @__PURE__ */ jsxs(FormItem, {
|
|
59
|
+
className: wrapperClassName,
|
|
60
|
+
children: [
|
|
61
|
+
label && /* @__PURE__ */ jsx(FormLabel, {
|
|
62
|
+
required,
|
|
63
|
+
helpText,
|
|
64
|
+
children: label
|
|
65
|
+
}),
|
|
66
|
+
/* @__PURE__ */ jsx("div", {
|
|
67
|
+
className: cn("flex gap-3", align === "start" ? "items-start" : "items-center"),
|
|
68
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
69
|
+
className: "inline-flex items-center gap-1.5",
|
|
70
|
+
children: [/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(Checkbox$1, {
|
|
71
|
+
...checkboxLabel === void 0 ? {} : { id },
|
|
72
|
+
checked,
|
|
73
|
+
onCheckedChange: (next) => onCheckedChange(next === true),
|
|
74
|
+
disabled,
|
|
75
|
+
className,
|
|
76
|
+
...rest
|
|
77
|
+
}) }), checkboxLabel === void 0 ? null : /* @__PURE__ */ jsx(Label, {
|
|
78
|
+
htmlFor: id,
|
|
79
|
+
className: "cursor-pointer",
|
|
80
|
+
children: checkboxLabel
|
|
81
|
+
})]
|
|
82
|
+
})
|
|
83
|
+
}),
|
|
84
|
+
description && /* @__PURE__ */ jsx(FormDescription, { children: description }),
|
|
85
|
+
/* @__PURE__ */ jsx(FormMessage, {})
|
|
86
|
+
]
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
//#endregion
|
|
91
|
+
export { Checkbox };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { FieldInputProps } from "../../shared/form.js";
|
|
2
|
+
import "../lib/form.js";
|
|
3
|
+
import React from "react";
|
|
4
|
+
//#region src/web/form/radio-group.d.ts
|
|
5
|
+
type Option = {
|
|
6
|
+
value: string;
|
|
7
|
+
label: string;
|
|
8
|
+
content?: React.ReactNode;
|
|
9
|
+
};
|
|
10
|
+
export type RadioGroupProps = FieldInputProps & {
|
|
11
|
+
options: Option[];
|
|
12
|
+
} & ({
|
|
13
|
+
type: "list";
|
|
14
|
+
full?: never;
|
|
15
|
+
} | {
|
|
16
|
+
type: "box";
|
|
17
|
+
full?: boolean;
|
|
18
|
+
} | {
|
|
19
|
+
type?: never;
|
|
20
|
+
full?: boolean;
|
|
21
|
+
});
|
|
22
|
+
export declare function RadioGroup({ label, description, required, helpText, ...rest }: RadioGroupProps): React.JSX.Element;
|
|
23
|
+
//#endregion
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { useFieldValue } from "../../shared/form.js";
|
|
2
|
+
import { cn } from "../lib/utils.js";
|
|
3
|
+
import { Label } from "../base/label.js";
|
|
4
|
+
import { FormControl, FormDescription, FormItem, FormLabel, FormMessage, useFormField } from "../base/form.js";
|
|
5
|
+
import { RadioGroup as RadioGroup$1, RadioGroupItem } from "../base/radio-group.js";
|
|
6
|
+
import { useId } from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
|
|
9
|
+
//#region src/web/form/radio-group.tsx
|
|
10
|
+
function RadioGroup({ label, description, required, helpText, ...rest }) {
|
|
11
|
+
return /* @__PURE__ */ jsxs(FormItem, { children: [
|
|
12
|
+
label && /* @__PURE__ */ jsx(FormLabel, {
|
|
13
|
+
required,
|
|
14
|
+
helpText,
|
|
15
|
+
children: label
|
|
16
|
+
}),
|
|
17
|
+
/* @__PURE__ */ jsx(RadioGroupBody, {
|
|
18
|
+
hasLabel: Boolean(label),
|
|
19
|
+
...rest
|
|
20
|
+
}),
|
|
21
|
+
description && /* @__PURE__ */ jsx(FormDescription, { children: description }),
|
|
22
|
+
/* @__PURE__ */ jsx(FormMessage, {})
|
|
23
|
+
] });
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The container of the options. It is drawn inside FormItem (the same context as the label), so it can read the label's id.
|
|
27
|
+
* The group itself holds `formItemId` (the target of the label's `htmlFor`) and takes its name from the label through `aria-labelledby`.
|
|
28
|
+
* The input of each option passes its own id to FormControl (one field has several controls, so reusing formItemId would duplicate it).
|
|
29
|
+
*/
|
|
30
|
+
function RadioGroupBody({ hasLabel, options, disabled, debounce, className, full, type = "list" }) {
|
|
31
|
+
const [value, setValue] = useFieldValue({ debounce });
|
|
32
|
+
const { formItemId, formLabelId } = useFormField();
|
|
33
|
+
return /* @__PURE__ */ jsx(RadioGroup$1, {
|
|
34
|
+
id: formItemId,
|
|
35
|
+
"aria-labelledby": hasLabel ? formLabelId : void 0,
|
|
36
|
+
onValueChange: (next) => setValue(next),
|
|
37
|
+
value,
|
|
38
|
+
className: cn(type === "box" && "flex flex-wrap gap-2", className),
|
|
39
|
+
disabled,
|
|
40
|
+
children: options.map((option) => /* @__PURE__ */ jsx(RadioOption, {
|
|
41
|
+
option,
|
|
42
|
+
type,
|
|
43
|
+
full
|
|
44
|
+
}, option.value))
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function RadioOption({ option, type, full }) {
|
|
48
|
+
const id = useId();
|
|
49
|
+
return /* @__PURE__ */ jsxs(Label, {
|
|
50
|
+
className: cn("cursor-pointer hover:bg-accent/50 grid grid-cols-[min-content_1fr] p-1 gap-y-0 rounded-control px-3", type === "box" && "border py-0 px-3 h-fit", option.content && "pb-3", full && "grow"),
|
|
51
|
+
children: [
|
|
52
|
+
/* @__PURE__ */ jsx("div", {
|
|
53
|
+
className: cn("h-9 flex items-center"),
|
|
54
|
+
children: /* @__PURE__ */ jsx(FormControl, {
|
|
55
|
+
id,
|
|
56
|
+
children: /* @__PURE__ */ jsx(RadioGroupItem, {
|
|
57
|
+
className: cn("cursor-pointer"),
|
|
58
|
+
value: option.value
|
|
59
|
+
})
|
|
60
|
+
})
|
|
61
|
+
}),
|
|
62
|
+
/* @__PURE__ */ jsx("p", {
|
|
63
|
+
className: cn("text-sm leading-none font-medium"),
|
|
64
|
+
children: option.label
|
|
65
|
+
}),
|
|
66
|
+
/* @__PURE__ */ jsx("div", {
|
|
67
|
+
className: cn("flex gap-2", type === "box" && "col-span-full flex-col", type === "list" && "col-start-2"),
|
|
68
|
+
children: option.content
|
|
69
|
+
})
|
|
70
|
+
]
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
75
|
+
export { RadioGroup };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FieldInputProps } from "../../shared/form.js";
|
|
2
|
+
import "../lib/form.js";
|
|
3
|
+
//#region src/web/form/select.d.ts
|
|
4
|
+
export type SelectOption = {
|
|
5
|
+
value: string;
|
|
6
|
+
label: string;
|
|
7
|
+
};
|
|
8
|
+
export type SelectOptionGroup = {
|
|
9
|
+
label: string;
|
|
10
|
+
options: SelectOption[];
|
|
11
|
+
};
|
|
12
|
+
export type SelectProps = FieldInputProps & {
|
|
13
|
+
options: (SelectOption | SelectOptionGroup)[];
|
|
14
|
+
};
|
|
15
|
+
export declare function Select({ label, description, placeholder, disabled, debounce, required, helpText, options, className, wrapperClassName }: SelectProps): import("react").JSX.Element;
|
|
16
|
+
//#endregion
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useFieldValue } from "../../shared/form.js";
|
|
2
|
+
import { cn } from "../lib/utils.js";
|
|
3
|
+
import { FormControl, FormDescription, FormItem, FormLabel, FormMessage } from "../base/form.js";
|
|
4
|
+
import { Select as Select$1, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue } from "../base/select.js";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
//#region src/web/form/select.tsx
|
|
8
|
+
const emptyValue = ":EMPTY:";
|
|
9
|
+
function isOptionGroup(option) {
|
|
10
|
+
return "options" in option;
|
|
11
|
+
}
|
|
12
|
+
function renderOption(option) {
|
|
13
|
+
return /* @__PURE__ */ jsx(SelectItem, {
|
|
14
|
+
value: option.value ? option.value : emptyValue,
|
|
15
|
+
children: option.label
|
|
16
|
+
}, option.value);
|
|
17
|
+
}
|
|
18
|
+
function Select({ label, description, placeholder, disabled, debounce, required, helpText, options, className, wrapperClassName }) {
|
|
19
|
+
const [value, setValue] = useFieldValue({ debounce });
|
|
20
|
+
return /* @__PURE__ */ jsxs(FormItem, {
|
|
21
|
+
className: wrapperClassName,
|
|
22
|
+
children: [
|
|
23
|
+
label && /* @__PURE__ */ jsx(FormLabel, {
|
|
24
|
+
required,
|
|
25
|
+
helpText,
|
|
26
|
+
children: label
|
|
27
|
+
}),
|
|
28
|
+
/* @__PURE__ */ jsxs(Select$1, {
|
|
29
|
+
value,
|
|
30
|
+
onValueChange: (next) => setValue(emptyValue === next ? "" : next),
|
|
31
|
+
disabled,
|
|
32
|
+
children: [/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(SelectTrigger, {
|
|
33
|
+
className: cn("w-full cursor-pointer", className),
|
|
34
|
+
children: /* @__PURE__ */ jsx(SelectValue, { placeholder: placeholder ?? "選択してください" })
|
|
35
|
+
}) }), /* @__PURE__ */ jsx(SelectContent, { children: options.map((option) => isOptionGroup(option) ? /* @__PURE__ */ jsxs(SelectGroup, { children: [/* @__PURE__ */ jsx(SelectLabel, { children: option.label }), option.options.map(renderOption)] }, option.label) : renderOption(option)) })]
|
|
36
|
+
}),
|
|
37
|
+
description && /* @__PURE__ */ jsx(FormDescription, { children: description }),
|
|
38
|
+
/* @__PURE__ */ jsx(FormMessage, {})
|
|
39
|
+
]
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
export { Select };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FieldInputProps } from "../../shared/form.js";
|
|
2
|
+
import "../lib/form.js";
|
|
3
|
+
import React from "react";
|
|
4
|
+
//#region src/web/form/slider.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* The field type for Slider allows both a single value (`number`) and a range (`number[]`) (which one is decided by the field's value).
|
|
7
|
+
*/
|
|
8
|
+
export type SliderProps = FieldInputProps & {
|
|
9
|
+
min?: number;
|
|
10
|
+
max: number;
|
|
11
|
+
step?: number;
|
|
12
|
+
formattedValue?: React.ReactNode;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The Slider with TanStack Form integration. The value comes from the field context.
|
|
16
|
+
* If you need a controlled one, use `atom/slider`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function Slider(props: SliderProps): React.JSX.Element;
|
|
19
|
+
//#endregion
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useFieldValue } from "../../shared/form.js";
|
|
2
|
+
import { FormControl, FormDescription, FormItem, FormMessage } from "../base/form.js";
|
|
3
|
+
import { Slider as Slider$1 } from "../atom/slider.js";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/web/form/slider.tsx
|
|
7
|
+
/**
|
|
8
|
+
* The Slider with TanStack Form integration. The value comes from the field context.
|
|
9
|
+
* If you need a controlled one, use `atom/slider`.
|
|
10
|
+
*/
|
|
11
|
+
function Slider(props) {
|
|
12
|
+
const { label, required, description, helpText, min, max, step, debounce, disabled, className, wrapperClassName, formattedValue } = props;
|
|
13
|
+
const [value, setValue] = useFieldValue({ debounce });
|
|
14
|
+
return /* @__PURE__ */ jsxs(FormItem, {
|
|
15
|
+
className: wrapperClassName,
|
|
16
|
+
children: [
|
|
17
|
+
/* @__PURE__ */ jsx(FormControl, { children: Array.isArray(value) ? /* @__PURE__ */ jsx(Slider$1, {
|
|
18
|
+
value,
|
|
19
|
+
onValueChange: (next) => setValue(next),
|
|
20
|
+
label,
|
|
21
|
+
required,
|
|
22
|
+
helpText,
|
|
23
|
+
min,
|
|
24
|
+
max,
|
|
25
|
+
step,
|
|
26
|
+
disabled,
|
|
27
|
+
className,
|
|
28
|
+
formattedValue,
|
|
29
|
+
wrapperClassName: "contents"
|
|
30
|
+
}) : /* @__PURE__ */ jsx(Slider$1, {
|
|
31
|
+
value: typeof value === "number" ? value : 0,
|
|
32
|
+
onValueChange: (next) => setValue(next),
|
|
33
|
+
label,
|
|
34
|
+
required,
|
|
35
|
+
helpText,
|
|
36
|
+
min,
|
|
37
|
+
max,
|
|
38
|
+
step,
|
|
39
|
+
disabled,
|
|
40
|
+
className,
|
|
41
|
+
formattedValue,
|
|
42
|
+
wrapperClassName: "contents"
|
|
43
|
+
}) }),
|
|
44
|
+
description && /* @__PURE__ */ jsx(FormDescription, { children: description }),
|
|
45
|
+
/* @__PURE__ */ jsx(FormMessage, {})
|
|
46
|
+
]
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
export { Slider };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseInputProps } from "../../shared/form.js";
|
|
2
|
+
import "../lib/form.js";
|
|
3
|
+
//#region src/web/form/switch.d.ts
|
|
4
|
+
export type SwitchProps = BaseInputProps<boolean>;
|
|
5
|
+
/**
|
|
6
|
+
* A Switch that supports both form and controlled use.
|
|
7
|
+
* - Passing `value` / `onValueChange` selects controlled mode (it does not read the field context, so it works outside a field)
|
|
8
|
+
* - When omitted, it takes the value from the field context
|
|
9
|
+
*/
|
|
10
|
+
export declare function Switch(props: SwitchProps): import("react").JSX.Element;
|
|
11
|
+
//#endregion
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useFieldValue } from "../../shared/form.js";
|
|
2
|
+
import { cn } from "../lib/utils.js";
|
|
3
|
+
import { FormControl, FormDescription, FormItem, FormLabel, FormMessage } from "../base/form.js";
|
|
4
|
+
import { Switch as Switch$1 } from "../base/switch.js";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
//#region src/web/form/switch.tsx
|
|
8
|
+
/**
|
|
9
|
+
* A Switch that supports both form and controlled use.
|
|
10
|
+
* - Passing `value` / `onValueChange` selects controlled mode (it does not read the field context, so it works outside a field)
|
|
11
|
+
* - When omitted, it takes the value from the field context
|
|
12
|
+
*/
|
|
13
|
+
function Switch(props) {
|
|
14
|
+
if (props.value !== void 0 && props.onValueChange !== void 0) return /* @__PURE__ */ jsx(Layout, {
|
|
15
|
+
...props,
|
|
16
|
+
checked: props.value,
|
|
17
|
+
onCheckedChange: props.onValueChange
|
|
18
|
+
});
|
|
19
|
+
return /* @__PURE__ */ jsx(FieldSwitch, { ...props });
|
|
20
|
+
}
|
|
21
|
+
function FieldSwitch(props) {
|
|
22
|
+
const [value, setValue] = useFieldValue({ debounce: props.debounce });
|
|
23
|
+
return /* @__PURE__ */ jsx(Layout, {
|
|
24
|
+
...props,
|
|
25
|
+
checked: value ?? false,
|
|
26
|
+
onCheckedChange: setValue
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function Layout({ label, required, description, disabled, helpText, className, checked, onCheckedChange }) {
|
|
30
|
+
return /* @__PURE__ */ jsxs(FormItem, { children: [
|
|
31
|
+
/* @__PURE__ */ jsxs("div", {
|
|
32
|
+
className: cn("h-9 flex items-center justify-between"),
|
|
33
|
+
children: [label && /* @__PURE__ */ jsx(FormLabel, {
|
|
34
|
+
required,
|
|
35
|
+
helpText,
|
|
36
|
+
children: label
|
|
37
|
+
}), /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(Switch$1, {
|
|
38
|
+
className: cn("h-fit cursor-pointer", className),
|
|
39
|
+
checked,
|
|
40
|
+
onCheckedChange,
|
|
41
|
+
disabled
|
|
42
|
+
}) })]
|
|
43
|
+
}),
|
|
44
|
+
description && /* @__PURE__ */ jsx(FormDescription, { children: description }),
|
|
45
|
+
/* @__PURE__ */ jsx(FormMessage, {})
|
|
46
|
+
] });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
export { Switch };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FieldInputProps } from "../../shared/form.js";
|
|
2
|
+
import { Textarea as Textarea$1 } from "../base/textarea.js";
|
|
3
|
+
import "../lib/form.js";
|
|
4
|
+
import { ComponentProps } from "react";
|
|
5
|
+
//#region src/web/form/text-area.d.ts
|
|
6
|
+
export type TextareaProps = FieldInputProps & Omit<ComponentProps<typeof Textarea$1>, "name" | "className" | "value" | "defaultValue" | "onChange"> & {
|
|
7
|
+
fullHeight?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare function Textarea(props: TextareaProps): import("react").JSX.Element;
|
|
10
|
+
//#endregion
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useFieldValue } from "../../shared/form.js";
|
|
2
|
+
import { cn } from "../lib/utils.js";
|
|
3
|
+
import { FormControl, FormDescription, FormItem, FormLabel, FormMessage } from "../base/form.js";
|
|
4
|
+
import { Textarea as Textarea$1 } from "../base/textarea.js";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
//#region src/web/form/text-area.tsx
|
|
8
|
+
function Textarea(props) {
|
|
9
|
+
const { label, required, description, debounce, className, fullHeight, ...remain } = props;
|
|
10
|
+
const [value, setValue] = useFieldValue({ debounce });
|
|
11
|
+
return /* @__PURE__ */ jsxs(FormItem, {
|
|
12
|
+
className: cn(fullHeight && "h-full"),
|
|
13
|
+
children: [
|
|
14
|
+
label && /* @__PURE__ */ jsx(FormLabel, {
|
|
15
|
+
required,
|
|
16
|
+
children: label
|
|
17
|
+
}),
|
|
18
|
+
/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(Textarea$1, {
|
|
19
|
+
value: value ?? "",
|
|
20
|
+
onChange: (e) => setValue(e.currentTarget.value),
|
|
21
|
+
className: cn("min-h-[200px] text-sm", className),
|
|
22
|
+
...remain
|
|
23
|
+
}) }),
|
|
24
|
+
description && /* @__PURE__ */ jsx(FormDescription, { children: description }),
|
|
25
|
+
/* @__PURE__ */ jsx(FormMessage, {})
|
|
26
|
+
]
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { Textarea };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FieldInputProps } from "../../shared/form.js";
|
|
2
|
+
import "../lib/form.js";
|
|
3
|
+
//#region src/web/form/text-input.d.ts
|
|
4
|
+
export type TextInputProps = {
|
|
5
|
+
type?: "text" | "email" | "password" | "tel" | "url" | "number";
|
|
6
|
+
/** Hint for the browser's autofill (`email`, `current-password`, `one-time-code` and so on; a value of the HTML `autocomplete` attribute). */
|
|
7
|
+
autoComplete?: string;
|
|
8
|
+
} & FieldInputProps;
|
|
9
|
+
export declare function TextInput({ label, required, description, debounce, className, wrapperClassName, type, helpText, ...remain }: TextInputProps): import("react").JSX.Element;
|
|
10
|
+
//#endregion
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useFieldValue } from "../../shared/form.js";
|
|
2
|
+
import { cn } from "../lib/utils.js";
|
|
3
|
+
import { FormControl, FormDescription, FormItem, FormLabel, FormMessage } from "../base/form.js";
|
|
4
|
+
import { Input } from "../base/input.js";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
//#region src/web/form/text-input.tsx
|
|
8
|
+
function TextInput({ label, required, description, debounce, className, wrapperClassName, type, helpText, ...remain }) {
|
|
9
|
+
const [value, setValue] = useFieldValue({ debounce });
|
|
10
|
+
return /* @__PURE__ */ jsxs(FormItem, {
|
|
11
|
+
className: wrapperClassName,
|
|
12
|
+
children: [
|
|
13
|
+
label && /* @__PURE__ */ jsx(FormLabel, {
|
|
14
|
+
required,
|
|
15
|
+
helpText,
|
|
16
|
+
children: label
|
|
17
|
+
}),
|
|
18
|
+
/* @__PURE__ */ jsx(FormControl, { children: type === "number" ? /* @__PURE__ */ jsx(Input, {
|
|
19
|
+
type,
|
|
20
|
+
value: value ?? "",
|
|
21
|
+
onChange: (e) => {
|
|
22
|
+
const next = e.currentTarget.valueAsNumber;
|
|
23
|
+
if (Number.isNaN(next)) setValue(null);
|
|
24
|
+
else setValue(next);
|
|
25
|
+
},
|
|
26
|
+
className: cn("text-sm", className),
|
|
27
|
+
...remain
|
|
28
|
+
}) : /* @__PURE__ */ jsx(Input, {
|
|
29
|
+
value: value ?? "",
|
|
30
|
+
type,
|
|
31
|
+
onChange: (e) => setValue(e.currentTarget.value),
|
|
32
|
+
className: cn("text-sm", className),
|
|
33
|
+
...remain
|
|
34
|
+
}) }),
|
|
35
|
+
description && /* @__PURE__ */ jsx(FormDescription, { children: description }),
|
|
36
|
+
/* @__PURE__ */ jsx(FormMessage, {})
|
|
37
|
+
]
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { TextInput };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
File without changes
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Accordion as Accordion$1 } from "../base/accordion.js";
|
|
2
|
+
import { ComponentProps, ReactNode } from "react";
|
|
3
|
+
//#region src/web/layout/accordion.d.ts
|
|
4
|
+
export type AccordionEntry = {
|
|
5
|
+
/** A stable ID used for the Radix item's value. */
|
|
6
|
+
value: string;
|
|
7
|
+
trigger: ReactNode;
|
|
8
|
+
content: ReactNode;
|
|
9
|
+
};
|
|
10
|
+
type RootProps = ComponentProps<typeof Accordion$1>;
|
|
11
|
+
/** A distributive Omit, to keep Radix's single / multiple discriminated union. */
|
|
12
|
+
type DistributedOmit<T, K extends keyof never> = T extends unknown ? Omit<T, K> : never;
|
|
13
|
+
export type AccordionProps = DistributedOmit<RootProps, "children"> & {
|
|
14
|
+
items: AccordionEntry[];
|
|
15
|
+
/** Extra class attached to the outside of each item. */
|
|
16
|
+
itemClassName?: string;
|
|
17
|
+
triggerClassName?: string;
|
|
18
|
+
contentClassName?: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* A data-driven Accordion wrapping the shadcn primitives.
|
|
22
|
+
* Callers do not have to assemble Item / Trigger / Content themselves.
|
|
23
|
+
*/
|
|
24
|
+
export declare function Accordion({ items, itemClassName, triggerClassName, contentClassName, className, ...rest }: AccordionProps): import("react").JSX.Element;
|
|
25
|
+
//#endregion
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { cn } from "../lib/utils.js";
|
|
2
|
+
import { Accordion as Accordion$1, AccordionContent, AccordionItem, AccordionTrigger } from "../base/accordion.js";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/web/layout/accordion.tsx
|
|
6
|
+
/**
|
|
7
|
+
* A data-driven Accordion wrapping the shadcn primitives.
|
|
8
|
+
* Callers do not have to assemble Item / Trigger / Content themselves.
|
|
9
|
+
*/
|
|
10
|
+
function Accordion({ items, itemClassName, triggerClassName, contentClassName, className, ...rest }) {
|
|
11
|
+
return /* @__PURE__ */ jsx(Accordion$1, {
|
|
12
|
+
className,
|
|
13
|
+
...rest,
|
|
14
|
+
children: items.map((item) => /* @__PURE__ */ jsxs(AccordionItem, {
|
|
15
|
+
value: item.value,
|
|
16
|
+
className: cn(itemClassName),
|
|
17
|
+
children: [/* @__PURE__ */ jsx(AccordionTrigger, {
|
|
18
|
+
className: cn(triggerClassName),
|
|
19
|
+
children: item.trigger
|
|
20
|
+
}), /* @__PURE__ */ jsx(AccordionContent, {
|
|
21
|
+
className: cn(contentClassName),
|
|
22
|
+
children: item.content
|
|
23
|
+
})]
|
|
24
|
+
}, item.value))
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { Accordion };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as React$1 from "react";
|
|
2
|
+
//#region src/web/layout/alert-modal.d.ts
|
|
3
|
+
export type AlertModalTone = "default" | "danger";
|
|
4
|
+
export type AlertModalAction = {
|
|
5
|
+
label: string;
|
|
6
|
+
onClick: () => void;
|
|
7
|
+
/**
|
|
8
|
+
* When omitted: "the last action is the primary action (indigo fill; for danger, the destructive-solid fill), and the others are border only (outline)".
|
|
9
|
+
*/
|
|
10
|
+
emphasis?: "primary" | "secondary";
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
"data-testid"?: string;
|
|
13
|
+
};
|
|
14
|
+
type AlertModalProps = {
|
|
15
|
+
open: boolean;
|
|
16
|
+
onOpenChange: (open: boolean) => void;
|
|
17
|
+
/** `danger` is a confirmation of an action that cannot be undone. A state-error icon is added to the left of the heading, and the primary action gets the destructive-solid fill (the heading text colour stays normal). */
|
|
18
|
+
tone?: AlertModalTone;
|
|
19
|
+
title: React$1.ReactNode;
|
|
20
|
+
description?: React$1.ReactNode;
|
|
21
|
+
/** Laid out right-aligned, in order from the left. Usually [cancel, primary action]. */
|
|
22
|
+
actions: AlertModalAction[];
|
|
23
|
+
/** When false, a scrim click or Esc does not close it (to make the user choose one of the actions). */
|
|
24
|
+
dismissible?: boolean;
|
|
25
|
+
"data-testid"?: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* A small modal for confirmation (it has no ×).
|
|
29
|
+
*
|
|
30
|
+
* Overlay surface, p-5, width 400 (fitted to the viewport). A heading (16/24 semibold) and body text (13/20, muted), with right-aligned actions (gap-2, the default Button size).
|
|
31
|
+
* With `danger`, a small state-error icon is added to the left of the heading and the primary action gets the destructive-solid fill.
|
|
32
|
+
* No border and no ring (it floats on the shadow alone, like `DialogContent`). The caller holds the open state (controlled only).
|
|
33
|
+
*
|
|
34
|
+
* While shown it carries `data-modal-open`, so floating persistent UI can be hidden with CSS.
|
|
35
|
+
*
|
|
36
|
+
* The initial focus on open goes to the first action only when it was opened by keyboard, and otherwise to the modal body
|
|
37
|
+
* (so that no ring appears on the first button when opened with the mouse; `useModalOpenAutoFocus`).
|
|
38
|
+
*/
|
|
39
|
+
export declare function AlertModal({ open, onOpenChange, tone, title, description, actions, dismissible, "data-testid": testId }: AlertModalProps): React$1.JSX.Element;
|
|
40
|
+
//#endregion
|
|
41
|
+
export {};
|