@jcsoftdev/ui 0.2.3 → 0.3.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/CHANGELOG.md +288 -7
- package/README.md +2 -1
- package/bin/ui-theme.mjs +1151 -25
- package/dist/ai/attachment/attachment.js +1 -1
- package/dist/ai/chat-list/group.js +3 -1
- package/dist/ai/conversation/conversation.js +1 -1
- package/dist/ai/internal/use-copy.d.ts +1 -5
- package/dist/ai/internal/use-copy.js +1 -32
- package/dist/ai/markdown/parse.js +59 -17
- package/dist/ai/source/source.js +1 -1
- package/dist/atoms/avatar/avatar.d.ts +13 -3
- package/dist/atoms/avatar/avatar.js +40 -2
- package/dist/atoms/avatar/index.d.ts +1 -1
- package/dist/atoms/avatar/index.js +3 -1
- package/dist/atoms/button/button.d.ts +4 -1
- package/dist/atoms/button/button.js +4 -2
- package/dist/atoms/checkbox/checkbox.d.ts +8 -3
- package/dist/atoms/checkbox/checkbox.js +23 -2
- package/dist/atoms/chip/chip.d.ts +9 -3
- package/dist/atoms/chip/chip.js +26 -4
- package/dist/atoms/chip/index.d.ts +1 -1
- package/dist/atoms/chip/index.js +4 -1
- package/dist/atoms/status-dot/index.d.ts +1 -1
- package/dist/atoms/status-dot/status-dot.d.ts +4 -2
- package/dist/atoms/status-dot/status-dot.js +5 -1
- package/dist/charts/bar-chart/bar-race-chart.js +1 -0
- package/dist/charts/beeswarm-chart/beeswarm-chart.js +1 -1
- package/dist/charts/chord-chart/chord-chart.js +13 -5
- package/dist/charts/core/cartesian/cartesian-chart.d.ts +1 -1
- package/dist/charts/core/cartesian/cartesian-chart.js +48 -11
- package/dist/charts/core/cartesian/layout.d.ts +6 -1
- package/dist/charts/core/cartesian/layout.js +14 -5
- package/dist/charts/core/cartesian/marks.d.ts +2 -2
- package/dist/charts/core/cartesian/marks.js +1 -1
- package/dist/charts/core/cartesian/types.d.ts +28 -2
- package/dist/charts/core/category-explorer.d.ts +2 -2
- package/dist/charts/core/category-explorer.js +8 -4
- package/dist/charts/core/chart-dock.d.ts +26 -0
- package/dist/charts/core/chart-dock.js +45 -0
- package/dist/charts/core/chart-frame.d.ts +9 -2
- package/dist/charts/core/chart-frame.js +105 -25
- package/dist/charts/core/distribution/explorer.d.ts +5 -2
- package/dist/charts/core/distribution/explorer.js +12 -5
- package/dist/charts/core/distribution/xy-points.js +1 -1
- package/dist/charts/core/index.d.ts +3 -0
- package/dist/charts/core/index.js +3 -0
- package/dist/charts/core/leave-grace.d.ts +11 -0
- package/dist/charts/core/leave-grace.js +26 -0
- package/dist/charts/core/nearest.d.ts +14 -0
- package/dist/charts/core/nearest.js +22 -0
- package/dist/charts/core/plot-overlay.js +9 -3
- package/dist/charts/core/pointer.test-utils.d.ts +38 -0
- package/dist/charts/core/pointer.test-utils.js +123 -0
- package/dist/charts/core/tooltip.d.ts +25 -2
- package/dist/charts/core/tooltip.js +115 -40
- package/dist/charts/core/touch-select.d.ts +20 -0
- package/dist/charts/core/touch-select.js +184 -0
- package/dist/charts/core/types.d.ts +8 -4
- package/dist/charts/core/types.js +5 -0
- package/dist/charts/core/use-index-navigation.d.ts +17 -6
- package/dist/charts/core/use-index-navigation.js +47 -10
- package/dist/charts/donut-chart/donut-chart.d.ts +5 -1
- package/dist/charts/donut-chart/donut-chart.js +40 -1
- package/dist/charts/donut-chart/slice-labels.d.ts +20 -0
- package/dist/charts/donut-chart/slice-labels.js +20 -0
- package/dist/charts/dumbbell-chart/dumbbell-chart.js +6 -3
- package/dist/charts/fill-gauge-chart/fill-gauge-chart.js +1 -0
- package/dist/charts/funnel-chart/funnel-chart.js +2 -1
- package/dist/charts/gauge-chart/gauge-chart.js +2 -1
- package/dist/charts/heatmap-chart/heatmap-chart.d.ts +4 -1
- package/dist/charts/heatmap-chart/heatmap-chart.js +3 -1
- package/dist/charts/heatmap-chart/heatmap-grid.d.ts +4 -1
- package/dist/charts/heatmap-chart/heatmap-grid.js +3 -1
- package/dist/charts/hex-tile-map/hex-tile-map.js +124 -115
- package/dist/charts/hierarchy-morph/hierarchy-morph.js +2 -1
- package/dist/charts/icicle-chart/icicle-chart.js +7 -9
- package/dist/charts/lollipop-chart/lollipop-chart.js +6 -3
- package/dist/charts/maps/geo/map-viewport.js +1 -1
- package/dist/charts/polar-area-chart/polar-area-chart.js +42 -12
- package/dist/charts/progress-units/progress-units.js +1 -0
- package/dist/charts/radar-chart/radar-chart.js +1 -1
- package/dist/charts/radial-bar-chart/radial-bar-chart.js +2 -1
- package/dist/charts/range-area-chart/range-area-chart.js +3 -2
- package/dist/charts/sankey-chart/sankey-chart.js +12 -4
- package/dist/charts/tree-chart/tree-chart.js +1 -0
- package/dist/charts/treemap-chart/treemap-chart.js +2 -7
- package/dist/charts/waterfall-chart/waterfall-chart.js +6 -3
- package/dist/containers/action-bar/action-bar.d.ts +11 -2
- package/dist/containers/action-bar/action-bar.js +4 -1
- package/dist/containers/card/card.d.ts +21 -3
- package/dist/containers/card/card.js +20 -5
- package/dist/containers/grid/grid.d.ts +15 -0
- package/dist/containers/grid/grid.js +24 -0
- package/dist/containers/grid/index.d.ts +1 -0
- package/dist/containers/grid/index.js +4 -0
- package/dist/containers/index.d.ts +3 -0
- package/dist/containers/index.js +3 -0
- package/dist/containers/kpi/kpi.d.ts +13 -2
- package/dist/containers/kpi/kpi.js +86 -24
- package/dist/containers/kpi-group/index.d.ts +1 -1
- package/dist/containers/kpi-group/index.js +3 -1
- package/dist/containers/kpi-group/kpi-group.d.ts +9 -1
- package/dist/containers/kpi-group/kpi-group.js +11 -1
- package/dist/containers/page/index.d.ts +1 -0
- package/dist/containers/page/index.js +4 -0
- package/dist/containers/page/page.d.ts +7 -0
- package/dist/containers/page/page.js +14 -0
- package/dist/containers/page-header/page-header.d.ts +8 -3
- package/dist/containers/page-header/page-header.js +35 -8
- package/dist/containers/responsive-list/responsive-list.d.ts +1 -1
- package/dist/containers/responsive-list/responsive-list.js +6 -3
- package/dist/containers/stack/index.d.ts +1 -0
- package/dist/containers/stack/index.js +6 -0
- package/dist/containers/stack/stack.d.ts +15 -0
- package/dist/containers/stack/stack.js +43 -0
- package/dist/forms/copy-field/copy-field.d.ts +17 -0
- package/dist/forms/copy-field/copy-field.js +72 -0
- package/dist/forms/copy-field/index.d.ts +1 -0
- package/dist/forms/copy-field/index.js +4 -0
- package/dist/forms/emoji-picker/emoji-picker.js +1 -1
- package/dist/forms/form/form.d.ts +15 -0
- package/dist/forms/form/form.js +29 -0
- package/dist/forms/form/index.d.ts +1 -0
- package/dist/forms/form/index.js +10 -0
- package/dist/forms/index.d.ts +2 -0
- package/dist/forms/index.js +2 -0
- package/dist/forms/input/index.d.ts +1 -1
- package/dist/forms/input/index.js +3 -2
- package/dist/forms/input/input.d.ts +6 -2
- package/dist/forms/input/input.js +9 -3
- package/dist/glass/crystal-map.d.ts +70 -0
- package/dist/glass/crystal-map.js +88 -0
- package/dist/glass/displacement-map.d.ts +117 -0
- package/dist/glass/displacement-map.js +201 -0
- package/dist/glass/index.d.ts +8 -0
- package/dist/glass/index.js +63 -0
- package/dist/glass/lens-crystal.d.ts +29 -0
- package/dist/glass/lens-crystal.js +161 -0
- package/dist/glass/lens-dispersion.d.ts +11 -0
- package/dist/glass/lens-dispersion.js +19 -0
- package/dist/glass/liquid-glass.d.ts +41 -0
- package/dist/glass/liquid-glass.js +256 -0
- package/dist/glass/liquid-motion.d.ts +53 -0
- package/dist/glass/liquid-motion.js +302 -0
- package/dist/glass/liquid-options.d.ts +162 -0
- package/dist/glass/liquid-options.js +179 -0
- package/dist/glass/refraction.d.ts +100 -0
- package/dist/glass/refraction.js +714 -0
- package/dist/glass/specular-map.d.ts +26 -0
- package/dist/glass/specular-map.js +75 -0
- package/dist/glass/spring.d.ts +79 -0
- package/dist/glass/spring.js +58 -0
- package/dist/glass/support.d.ts +13 -0
- package/dist/glass/support.js +14 -0
- package/dist/glass/use-glass-refraction.d.ts +8 -0
- package/dist/glass/use-glass-refraction.js +16 -0
- package/dist/i18n/strings.d.ts +24 -0
- package/dist/i18n/strings.js +18 -2
- package/dist/icons/index.d.ts +2 -0
- package/dist/icons/index.js +4 -0
- package/dist/icons/key.d.ts +2 -0
- package/dist/icons/key.js +12 -0
- package/dist/icons/webhook.d.ts +2 -0
- package/dist/icons/webhook.js +12 -0
- package/dist/liquid/index.d.ts +3 -0
- package/dist/liquid/index.js +29 -0
- package/dist/navigation/breadcrumbs/breadcrumbs.d.ts +29 -0
- package/dist/navigation/breadcrumbs/breadcrumbs.js +70 -0
- package/dist/navigation/breadcrumbs/index.d.ts +1 -0
- package/dist/navigation/breadcrumbs/index.js +6 -0
- package/dist/navigation/index.d.ts +1 -0
- package/dist/navigation/index.js +1 -0
- package/dist/navigation/segmented/index.d.ts +1 -1
- package/dist/navigation/segmented/model.d.ts +5 -0
- package/dist/navigation/segmented/model.js +6 -0
- package/dist/navigation/segmented/segmented.d.ts +17 -3
- package/dist/navigation/segmented/segmented.js +20 -4
- package/dist/overlays/context-menu/context-menu.d.ts +9 -1
- package/dist/overlays/context-menu/context-menu.js +4 -1
- package/dist/overlays/dialog/dialog.d.ts +9 -1
- package/dist/overlays/dialog/dialog.js +3 -0
- package/dist/overlays/drawer/drawer.d.ts +9 -1
- package/dist/overlays/drawer/drawer.js +3 -0
- package/dist/overlays/dropdown-menu/dropdown-menu.d.ts +9 -1
- package/dist/overlays/dropdown-menu/dropdown-menu.js +3 -1
- package/dist/overlays/hover-card/hover-card.d.ts +10 -1
- package/dist/overlays/hover-card/hover-card.js +4 -1
- package/dist/overlays/popover/popover.d.ts +9 -1
- package/dist/overlays/popover/popover.js +3 -0
- package/dist/palette/command-palette/command-palette.d.ts +12 -2
- package/dist/palette/command-palette/command-palette.js +5 -0
- package/dist/primitives/command/command.d.ts +3 -2
- package/dist/primitives/command/command.js +2 -0
- package/dist/primitives/menu/menu.js +1 -1
- package/dist/primitives/popper/popper.js +5 -0
- package/dist/rich-text/rich-text-editor.js +94 -8
- package/dist/rich-text/sanitize.js +70 -20
- package/dist/shell/app-shell/app-shell.d.ts +17 -0
- package/dist/shell/app-shell/app-shell.js +44 -4
- package/dist/shell/bottom-nav/bottom-nav.d.ts +34 -0
- package/dist/shell/bottom-nav/bottom-nav.js +124 -0
- package/dist/shell/bottom-nav/index.d.ts +2 -0
- package/dist/shell/bottom-nav/index.js +9 -0
- package/dist/shell/bottom-nav/split.d.ts +11 -0
- package/dist/shell/bottom-nav/split.js +10 -0
- package/dist/shell/sidebar/sidebar.d.ts +16 -2
- package/dist/shell/sidebar/sidebar.js +46 -4
- package/dist/shell/topbar/topbar.d.ts +20 -9
- package/dist/shell/topbar/topbar.js +16 -9
- package/dist/states/empty-state/empty-state.d.ts +3 -1
- package/dist/states/empty-state/empty-state.js +9 -1
- package/dist/states/error-state/error-state.d.ts +3 -1
- package/dist/states/error-state/error-state.js +2 -0
- package/dist/states/index.d.ts +1 -0
- package/dist/states/index.js +1 -0
- package/dist/states/live-status-bar/index.d.ts +1 -0
- package/dist/states/live-status-bar/index.js +6 -0
- package/dist/states/live-status-bar/live-status-bar.d.ts +17 -0
- package/dist/states/live-status-bar/live-status-bar.js +49 -0
- package/dist/states/offline-banner/offline-banner.d.ts +3 -1
- package/dist/states/offline-banner/offline-banner.js +8 -4
- package/dist/utils/class-groups.js +17 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/material.d.ts +13 -0
- package/dist/utils/material.js +6 -0
- package/dist/utils/tone.d.ts +8 -0
- package/dist/utils/tone.js +17 -0
- package/dist/utils/use-copy.d.ts +5 -0
- package/dist/utils/use-copy.js +35 -0
- package/icons/svg/key.svg +5 -0
- package/icons/svg/webhook.svg +5 -0
- package/package.json +31 -21
- package/scripts/build-theme.d.mts +22 -0
- package/scripts/build-theme.mjs +236 -4
- package/src/ai/attachment/attachment.tsx +1 -1
- package/src/ai/chat-list/group.ts +3 -1
- package/src/ai/conversation/conversation.tsx +1 -1
- package/src/ai/internal/use-copy.ts +1 -38
- package/src/ai/markdown/parse.ts +74 -17
- package/src/ai/source/source.tsx +1 -1
- package/src/atoms/avatar/avatar.tsx +57 -4
- package/src/atoms/avatar/index.ts +8 -1
- package/src/atoms/button/button.tsx +8 -3
- package/src/atoms/checkbox/checkbox.tsx +30 -3
- package/src/atoms/chip/chip.tsx +37 -5
- package/src/atoms/chip/index.ts +7 -1
- package/src/atoms/status-dot/index.ts +1 -0
- package/src/atoms/status-dot/status-dot.tsx +15 -3
- package/src/charts/README.md +21 -0
- package/src/charts/bar-chart/bar-race-chart.tsx +1 -0
- package/src/charts/beeswarm-chart/beeswarm-chart.tsx +1 -1
- package/src/charts/chord-chart/chord-chart.tsx +13 -5
- package/src/charts/core/cartesian/cartesian-chart.tsx +55 -10
- package/src/charts/core/cartesian/layout.ts +29 -10
- package/src/charts/core/cartesian/marks.tsx +3 -3
- package/src/charts/core/cartesian/types.ts +30 -2
- package/src/charts/core/category-explorer.tsx +12 -6
- package/src/charts/core/chart-dock.tsx +68 -0
- package/src/charts/core/chart-frame.tsx +116 -27
- package/src/charts/core/distribution/explorer.tsx +17 -7
- package/src/charts/core/distribution/xy-points.tsx +1 -1
- package/src/charts/core/index.ts +3 -0
- package/src/charts/core/leave-grace.ts +35 -0
- package/src/charts/core/nearest.ts +38 -0
- package/src/charts/core/plot-overlay.tsx +9 -3
- package/src/charts/core/pointer.test-utils.ts +146 -0
- package/src/charts/core/tooltip.tsx +129 -15
- package/src/charts/core/touch-select.ts +250 -0
- package/src/charts/core/types.ts +13 -4
- package/src/charts/core/use-index-navigation.ts +70 -11
- package/src/charts/donut-chart/donut-chart.tsx +53 -3
- package/src/charts/donut-chart/slice-labels.ts +39 -0
- package/src/charts/dumbbell-chart/dumbbell-chart.tsx +8 -3
- package/src/charts/fill-gauge-chart/fill-gauge-chart.tsx +1 -0
- package/src/charts/funnel-chart/funnel-chart.tsx +2 -1
- package/src/charts/gauge-chart/gauge-chart.tsx +2 -1
- package/src/charts/heatmap-chart/heatmap-chart.tsx +5 -0
- package/src/charts/heatmap-chart/heatmap-grid.tsx +5 -1
- package/src/charts/hex-tile-map/hex-tile-map.tsx +6 -1
- package/src/charts/hierarchy-morph/hierarchy-morph.tsx +2 -1
- package/src/charts/icicle-chart/icicle-chart.tsx +8 -9
- package/src/charts/lollipop-chart/lollipop-chart.tsx +8 -3
- package/src/charts/maps/geo/map-viewport.tsx +1 -1
- package/src/charts/polar-area-chart/polar-area-chart.tsx +37 -12
- package/src/charts/progress-units/progress-units.tsx +1 -0
- package/src/charts/radar-chart/radar-chart.tsx +1 -1
- package/src/charts/radial-bar-chart/radial-bar-chart.tsx +2 -1
- package/src/charts/range-area-chart/range-area-chart.tsx +3 -2
- package/src/charts/sankey-chart/sankey-chart.tsx +12 -4
- package/src/charts/tree-chart/tree-chart.tsx +1 -0
- package/src/charts/treemap-chart/treemap-chart.tsx +2 -7
- package/src/charts/waterfall-chart/waterfall-chart.tsx +8 -3
- package/src/containers/action-bar/action-bar.tsx +13 -2
- package/src/containers/card/card.tsx +43 -4
- package/src/containers/grid/grid.tsx +37 -0
- package/src/containers/grid/index.ts +1 -0
- package/src/containers/index.ts +3 -0
- package/src/containers/kpi/kpi.tsx +116 -22
- package/src/containers/kpi-group/index.ts +7 -1
- package/src/containers/kpi-group/kpi-group.tsx +26 -1
- package/src/containers/page/index.ts +1 -0
- package/src/containers/page/page.tsx +17 -0
- package/src/containers/page-header/page-header.tsx +38 -8
- package/src/containers/responsive-list/responsive-list.tsx +7 -4
- package/src/containers/stack/index.ts +7 -0
- package/src/containers/stack/stack.tsx +55 -0
- package/src/forms/copy-field/copy-field.tsx +88 -0
- package/src/forms/copy-field/index.ts +1 -0
- package/src/forms/emoji-picker/emoji-picker.tsx +1 -1
- package/src/forms/form/form.tsx +46 -0
- package/src/forms/form/index.ts +8 -0
- package/src/forms/index.ts +2 -0
- package/src/forms/input/index.ts +1 -1
- package/src/forms/input/input.tsx +14 -3
- package/src/glass/crystal-map.ts +150 -0
- package/src/glass/displacement-map.ts +317 -0
- package/src/glass/index.ts +43 -0
- package/src/glass/lens-crystal.ts +226 -0
- package/src/glass/lens-dispersion.ts +34 -0
- package/src/glass/liquid-glass.tsx +371 -0
- package/src/glass/liquid-motion.ts +395 -0
- package/src/glass/liquid-options.ts +306 -0
- package/src/glass/refraction.ts +1010 -0
- package/src/glass/specular-map.ts +95 -0
- package/src/glass/spring.ts +98 -0
- package/src/glass/support.ts +27 -0
- package/src/glass/use-glass-refraction.ts +21 -0
- package/src/i18n/strings.ts +24 -0
- package/src/icons/index.ts +2 -0
- package/src/icons/key.tsx +13 -0
- package/src/icons/webhook.tsx +13 -0
- package/src/liquid/index.ts +24 -0
- package/src/navigation/breadcrumbs/breadcrumbs.tsx +103 -0
- package/src/navigation/breadcrumbs/index.ts +8 -0
- package/src/navigation/index.ts +1 -0
- package/src/navigation/segmented/index.ts +1 -0
- package/src/navigation/segmented/model.ts +11 -0
- package/src/navigation/segmented/segmented.tsx +45 -6
- package/src/overlays/context-menu/context-menu.tsx +11 -1
- package/src/overlays/dialog/dialog.tsx +10 -0
- package/src/overlays/drawer/drawer.tsx +10 -0
- package/src/overlays/dropdown-menu/dropdown-menu.tsx +10 -1
- package/src/overlays/hover-card/hover-card.tsx +12 -1
- package/src/overlays/popover/popover.tsx +10 -0
- package/src/palette/command-palette/command-palette.tsx +15 -1
- package/src/primitives/command/command.tsx +4 -0
- package/src/primitives/menu/menu.tsx +1 -1
- package/src/primitives/popper/popper.tsx +10 -0
- package/src/rich-text/rich-text-editor.tsx +116 -13
- package/src/rich-text/sanitize.ts +94 -23
- package/src/shell/app-shell/app-shell.tsx +60 -4
- package/src/shell/bottom-nav/bottom-nav.tsx +187 -0
- package/src/shell/bottom-nav/index.ts +8 -0
- package/src/shell/bottom-nav/split.ts +20 -0
- package/src/shell/sidebar/sidebar.tsx +51 -5
- package/src/shell/topbar/topbar.tsx +81 -58
- package/src/states/empty-state/empty-state.tsx +11 -1
- package/src/states/error-state/error-state.tsx +4 -0
- package/src/states/index.ts +1 -0
- package/src/states/live-status-bar/index.ts +6 -0
- package/src/states/live-status-bar/live-status-bar.tsx +62 -0
- package/src/states/offline-banner/offline-banner.tsx +13 -5
- package/src/utils/class-groups.ts +17 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/material.ts +16 -0
- package/src/utils/tone.ts +29 -0
- package/src/utils/use-copy.ts +38 -0
- package/styles/Theme.kt +64 -3
- package/styles/base.css +51 -0
- package/styles/tailwind.css +833 -0
- package/styles/theme.css +546 -4
- package/styles/tokens.css +788 -15
- package/tokens/default.json +918 -29
- package/scripts/build-theme.d.ts +0 -18
|
@@ -1,10 +1,45 @@
|
|
|
1
1
|
import type { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
2
|
import type { ClassNames } from "../../utils/class-names.js";
|
|
3
3
|
import { cn } from "../../utils/cn.js";
|
|
4
|
+
import { customToneStyle, isCustomTone } from "../../utils/tone.js";
|
|
4
5
|
|
|
5
6
|
export type KpiVariant = "default" | "danger";
|
|
6
7
|
|
|
7
|
-
export type
|
|
8
|
+
export type KpiBuiltinTone = "neutral" | "accent" | "success" | "warning" | "danger" | "info";
|
|
9
|
+
|
|
10
|
+
/** A built-in tone, or the name of a tone declared in `tonePalettes`. */
|
|
11
|
+
export type KpiTone = KpiBuiltinTone | (string & {});
|
|
12
|
+
|
|
13
|
+
const valueToneClasses: Record<KpiBuiltinTone, string> = {
|
|
14
|
+
neutral: "text-ink",
|
|
15
|
+
accent: "text-accent-ink",
|
|
16
|
+
success: "text-success",
|
|
17
|
+
warning: "text-warning",
|
|
18
|
+
danger: "text-danger",
|
|
19
|
+
info: "text-info",
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const dotToneClasses: Record<KpiBuiltinTone, string> = {
|
|
23
|
+
neutral: "bg-ink-3",
|
|
24
|
+
accent: "bg-accent",
|
|
25
|
+
success: "bg-success",
|
|
26
|
+
warning: "bg-warning",
|
|
27
|
+
danger: "bg-danger",
|
|
28
|
+
info: "bg-info",
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const builtinTones = new Set<string>(Object.keys(valueToneClasses));
|
|
32
|
+
|
|
33
|
+
export type KpiPart =
|
|
34
|
+
| "root"
|
|
35
|
+
| "header"
|
|
36
|
+
| "label"
|
|
37
|
+
| "dot"
|
|
38
|
+
| "icon"
|
|
39
|
+
| "value"
|
|
40
|
+
| "suffix"
|
|
41
|
+
| "trend"
|
|
42
|
+
| "description";
|
|
8
43
|
|
|
9
44
|
export interface KpiProps extends Omit<ComponentPropsWithoutRef<"div">, "children"> {
|
|
10
45
|
/** Short label describing the metric. */
|
|
@@ -16,6 +51,14 @@ export interface KpiProps extends Omit<ComponentPropsWithoutRef<"div">, "childre
|
|
|
16
51
|
/** Optional subtext. */
|
|
17
52
|
description?: ReactNode;
|
|
18
53
|
variant?: KpiVariant;
|
|
54
|
+
/** Colours the value and the label dot. Wins over `variant`. */
|
|
55
|
+
tone?: KpiTone;
|
|
56
|
+
/** Leading dot on the label, in the tone's colour. */
|
|
57
|
+
dot?: boolean;
|
|
58
|
+
/** Icon at the end of the label row. */
|
|
59
|
+
icon?: ReactNode;
|
|
60
|
+
/** Change indicator next to the value, e.g. a `TrendChip`. */
|
|
61
|
+
trend?: ReactNode;
|
|
19
62
|
/** Per-part classes merged with `cn`; consumer classes win. `className` still targets the root and is merged last. */
|
|
20
63
|
classNames?: ClassNames<KpiPart>;
|
|
21
64
|
}
|
|
@@ -26,41 +69,92 @@ export function Kpi({
|
|
|
26
69
|
suffix,
|
|
27
70
|
description,
|
|
28
71
|
variant = "default",
|
|
72
|
+
tone: toneProp,
|
|
73
|
+
dot,
|
|
74
|
+
icon,
|
|
75
|
+
trend,
|
|
29
76
|
className,
|
|
30
77
|
classNames,
|
|
78
|
+
style,
|
|
31
79
|
...props
|
|
32
80
|
}: KpiProps) {
|
|
81
|
+
const tone: KpiTone = toneProp ?? (variant === "danger" ? "danger" : "neutral");
|
|
82
|
+
const custom = isCustomTone(tone, builtinTones);
|
|
83
|
+
const valueTone = custom
|
|
84
|
+
? "text-(--tone-c-ink)"
|
|
85
|
+
: (valueToneClasses[tone as KpiBuiltinTone] ?? valueToneClasses.neutral);
|
|
86
|
+
const dotTone = custom
|
|
87
|
+
? "bg-(--tone-c)"
|
|
88
|
+
: (dotToneClasses[tone as KpiBuiltinTone] ?? dotToneClasses.neutral);
|
|
89
|
+
const labelNode = (
|
|
90
|
+
<span
|
|
91
|
+
className={cn(
|
|
92
|
+
"break-words font-semibold text-fs-120 text-ink-2",
|
|
93
|
+
dot && "inline-flex items-center gap-1.5",
|
|
94
|
+
classNames?.label,
|
|
95
|
+
)}
|
|
96
|
+
>
|
|
97
|
+
{dot ? (
|
|
98
|
+
<span
|
|
99
|
+
aria-hidden="true"
|
|
100
|
+
className={cn("size-1.5 shrink-0 rounded-pill", dotTone, classNames?.dot)}
|
|
101
|
+
/>
|
|
102
|
+
) : null}
|
|
103
|
+
{label}
|
|
104
|
+
</span>
|
|
105
|
+
);
|
|
106
|
+
const valueNode = (
|
|
107
|
+
<span
|
|
108
|
+
className={cn(
|
|
109
|
+
"break-words text-kpi-number tabular-nums @max-[9rem]/kpi:text-fs-220",
|
|
110
|
+
valueTone,
|
|
111
|
+
classNames?.value,
|
|
112
|
+
)}
|
|
113
|
+
>
|
|
114
|
+
{value}
|
|
115
|
+
{suffix ? (
|
|
116
|
+
<small
|
|
117
|
+
className={cn(
|
|
118
|
+
"ml-1 font-semibold text-fs-140 text-ink-3 tracking-normal",
|
|
119
|
+
classNames?.suffix,
|
|
120
|
+
)}
|
|
121
|
+
>
|
|
122
|
+
{suffix}
|
|
123
|
+
</small>
|
|
124
|
+
) : null}
|
|
125
|
+
</span>
|
|
126
|
+
);
|
|
33
127
|
return (
|
|
34
128
|
<div
|
|
35
129
|
{...props}
|
|
130
|
+
style={customToneStyle(tone, builtinTones, style)}
|
|
36
131
|
className={cn(
|
|
37
132
|
"@container/kpi flex min-w-0 flex-col gap-0.5 bg-surface px-4.5 py-3.5",
|
|
38
133
|
classNames?.root,
|
|
39
134
|
className,
|
|
40
135
|
)}
|
|
41
136
|
>
|
|
42
|
-
|
|
43
|
-
{
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
variant === "danger" ? "text-danger" : "text-ink",
|
|
49
|
-
classNames?.value,
|
|
50
|
-
)}
|
|
51
|
-
>
|
|
52
|
-
{value}
|
|
53
|
-
{suffix ? (
|
|
54
|
-
<small
|
|
55
|
-
className={cn(
|
|
56
|
-
"ml-1 font-semibold text-fs-140 text-ink-3 tracking-normal",
|
|
57
|
-
classNames?.suffix,
|
|
58
|
-
)}
|
|
137
|
+
{icon ? (
|
|
138
|
+
<div className={cn("flex items-center justify-between gap-2", classNames?.header)}>
|
|
139
|
+
{labelNode}
|
|
140
|
+
<span
|
|
141
|
+
aria-hidden="true"
|
|
142
|
+
className={cn("shrink-0 text-ink-3 [&_svg]:size-4", classNames?.icon)}
|
|
59
143
|
>
|
|
60
|
-
{
|
|
61
|
-
</
|
|
62
|
-
|
|
63
|
-
|
|
144
|
+
{icon}
|
|
145
|
+
</span>
|
|
146
|
+
</div>
|
|
147
|
+
) : (
|
|
148
|
+
labelNode
|
|
149
|
+
)}
|
|
150
|
+
{trend ? (
|
|
151
|
+
<div className="flex flex-wrap items-baseline gap-x-2 gap-y-1">
|
|
152
|
+
{valueNode}
|
|
153
|
+
<span className={cn("shrink-0", classNames?.trend)}>{trend}</span>
|
|
154
|
+
</div>
|
|
155
|
+
) : (
|
|
156
|
+
valueNode
|
|
157
|
+
)}
|
|
64
158
|
{description ? (
|
|
65
159
|
<span className={cn("break-words text-fs-120 text-ink-3", classNames?.description)}>
|
|
66
160
|
{description}
|
|
@@ -19,10 +19,19 @@ export interface KpiGroupItem {
|
|
|
19
19
|
description?: ReactNode;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
export type KpiGroupLayout = "divided" | "auto-fit";
|
|
23
|
+
|
|
22
24
|
export type KpiGroupPart = "root" | "list" | "item" | "label" | "value" | "trend" | "description";
|
|
23
25
|
|
|
24
26
|
export interface KpiGroupProps extends Omit<ComponentPropsWithoutRef<"dl">, "children"> {
|
|
25
27
|
items: KpiGroupItem[];
|
|
28
|
+
/**
|
|
29
|
+
* `divided` (default): one card, 1, 2 or 4 columns by container width. `auto-fit`: separate
|
|
30
|
+
* cards in as many columns as fit `minItemWidth`.
|
|
31
|
+
*/
|
|
32
|
+
layout?: KpiGroupLayout;
|
|
33
|
+
/** Minimum tile width in px for `layout="auto-fit"`. */
|
|
34
|
+
minItemWidth?: number;
|
|
26
35
|
/** Animate numeric values counting up. */
|
|
27
36
|
animate?: boolean;
|
|
28
37
|
/** Per-part classes merged with `cn`; consumer classes win. `className` still targets the root wrapper and is merged last. */
|
|
@@ -35,17 +44,32 @@ export interface KpiGroupProps extends Omit<ComponentPropsWithoutRef<"dl">, "chi
|
|
|
35
44
|
*/
|
|
36
45
|
export function KpiGroup({
|
|
37
46
|
items,
|
|
47
|
+
layout = "divided",
|
|
48
|
+
minItemWidth = 150,
|
|
38
49
|
animate = true,
|
|
39
50
|
className,
|
|
40
51
|
classNames,
|
|
52
|
+
style,
|
|
41
53
|
...props
|
|
42
54
|
}: KpiGroupProps) {
|
|
55
|
+
const autoFit = layout === "auto-fit";
|
|
43
56
|
return (
|
|
44
57
|
<div className={cn("@container/kpi-group min-w-0", classNames?.root, className)}>
|
|
45
58
|
<dl
|
|
46
59
|
{...props}
|
|
60
|
+
style={
|
|
61
|
+
autoFit
|
|
62
|
+
? {
|
|
63
|
+
gridTemplateColumns: `repeat(auto-fit, minmax(min(100%, ${minItemWidth}px), 1fr))`,
|
|
64
|
+
...style,
|
|
65
|
+
}
|
|
66
|
+
: style
|
|
67
|
+
}
|
|
47
68
|
className={cn(
|
|
48
|
-
"m-0 grid
|
|
69
|
+
"m-0 grid",
|
|
70
|
+
autoFit
|
|
71
|
+
? "gap-density"
|
|
72
|
+
: "grid-cols-1 gap-px overflow-hidden rounded-card border-card bg-divider shadow-card @sm/kpi-group:grid-cols-2 @3xl/kpi-group:grid-cols-4",
|
|
49
73
|
classNames?.list,
|
|
50
74
|
)}
|
|
51
75
|
>
|
|
@@ -54,6 +78,7 @@ export function KpiGroup({
|
|
|
54
78
|
key={item.id}
|
|
55
79
|
className={cn(
|
|
56
80
|
"surface-card flex min-w-0 flex-col gap-density-sm p-card",
|
|
81
|
+
autoFit && "rounded-card border-card shadow-card",
|
|
57
82
|
classNames?.item,
|
|
58
83
|
)}
|
|
59
84
|
>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Page, type PageProps } from "./page.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef } from "react";
|
|
2
|
+
import { cn } from "../../utils/cn.js";
|
|
3
|
+
|
|
4
|
+
export type PageProps = ComponentPropsWithoutRef<"div">;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Vertical flow of page sections. It is the `page` container, so `Cols` and `SettingsLayout`
|
|
8
|
+
* inside it react to the page width instead of the viewport.
|
|
9
|
+
*/
|
|
10
|
+
export function Page({ className, ...props }: PageProps) {
|
|
11
|
+
return (
|
|
12
|
+
<div
|
|
13
|
+
className={cn("@container/page flex w-full min-w-0 flex-col gap-6", className)}
|
|
14
|
+
{...props}
|
|
15
|
+
/>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
@@ -1,26 +1,50 @@
|
|
|
1
|
-
import type { ComponentPropsWithoutRef } from "react";
|
|
1
|
+
import type { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
2
|
import { cn } from "../../utils/cn.js";
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export interface PageHeaderProps extends ComponentPropsWithoutRef<"header"> {
|
|
5
|
+
/** Trail shown on its own row above the title, usually a `Breadcrumbs`. */
|
|
6
|
+
breadcrumbs?: ReactNode;
|
|
7
|
+
/** Tighter, centred header with a smaller title and a body-size lede. */
|
|
8
|
+
compact?: boolean;
|
|
9
|
+
}
|
|
5
10
|
|
|
6
11
|
/**
|
|
7
12
|
* Page header. No required parts: compose an eyebrow / title / lede block in
|
|
8
13
|
* a plain `<div>` and, when the view has buttons, `PageHeaderActions` as the
|
|
9
14
|
* second child. Actions wrap under the title when the container is too narrow.
|
|
10
15
|
*/
|
|
11
|
-
export function PageHeader({
|
|
16
|
+
export function PageHeader({
|
|
17
|
+
breadcrumbs,
|
|
18
|
+
className,
|
|
19
|
+
compact,
|
|
20
|
+
children,
|
|
21
|
+
...props
|
|
22
|
+
}: PageHeaderProps) {
|
|
12
23
|
return (
|
|
13
24
|
<header
|
|
14
|
-
|
|
25
|
+
data-compact={compact ? "" : undefined}
|
|
26
|
+
className={cn(
|
|
27
|
+
"flex flex-wrap items-end justify-between gap-x-6 gap-y-3.5",
|
|
28
|
+
compact && "flex-col items-center justify-center gap-y-2 text-center",
|
|
29
|
+
className,
|
|
30
|
+
)}
|
|
15
31
|
{...props}
|
|
16
|
-
|
|
32
|
+
>
|
|
33
|
+
{breadcrumbs ? <div className="basis-full">{breadcrumbs}</div> : null}
|
|
34
|
+
{children}
|
|
35
|
+
</header>
|
|
17
36
|
);
|
|
18
37
|
}
|
|
19
38
|
|
|
20
39
|
export type PageHeaderEyebrowProps = ComponentPropsWithoutRef<"div">;
|
|
21
40
|
|
|
22
41
|
export function PageHeaderEyebrow({ className, ...props }: PageHeaderEyebrowProps) {
|
|
23
|
-
return
|
|
42
|
+
return (
|
|
43
|
+
<div
|
|
44
|
+
className={cn("mb-1 font-semibold text-fs-120 text-ink-3 in-data-compact:mb-0.5", className)}
|
|
45
|
+
{...props}
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
24
48
|
}
|
|
25
49
|
|
|
26
50
|
export type PageHeaderTitleProps = ComponentPropsWithoutRef<"h1">;
|
|
@@ -29,7 +53,10 @@ export type PageHeaderTitleProps = ComponentPropsWithoutRef<"h1">;
|
|
|
29
53
|
export function PageHeaderTitle({ className, ...props }: PageHeaderTitleProps) {
|
|
30
54
|
return (
|
|
31
55
|
<h1
|
|
32
|
-
className={cn(
|
|
56
|
+
className={cn(
|
|
57
|
+
"m-0 break-words text-page-title [text-wrap:balance] in-data-compact:text-fs-220",
|
|
58
|
+
className,
|
|
59
|
+
)}
|
|
33
60
|
{...props}
|
|
34
61
|
/>
|
|
35
62
|
);
|
|
@@ -40,7 +67,10 @@ export type PageHeaderLedeProps = ComponentPropsWithoutRef<"p">;
|
|
|
40
67
|
export function PageHeaderLede({ className, ...props }: PageHeaderLedeProps) {
|
|
41
68
|
return (
|
|
42
69
|
<p
|
|
43
|
-
className={cn(
|
|
70
|
+
className={cn(
|
|
71
|
+
"mt-1.25 max-w-[68ch] break-words text-lede text-ink-2 in-data-compact:mt-0.5 in-data-compact:text-body",
|
|
72
|
+
className,
|
|
73
|
+
)}
|
|
44
74
|
{...props}
|
|
45
75
|
/>
|
|
46
76
|
);
|
|
@@ -50,7 +50,7 @@ export interface ResponsiveListProps<T> {
|
|
|
50
50
|
classNames?: ClassNames<ResponsiveListPart>;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
/** A table
|
|
53
|
+
/** A table once its own container is 42rem wide and a stack of cards below that, from one column definition. */
|
|
54
54
|
export function ResponsiveList<T>({
|
|
55
55
|
caption,
|
|
56
56
|
items,
|
|
@@ -67,10 +67,10 @@ export function ResponsiveList<T>({
|
|
|
67
67
|
const details = columns.filter((column) => column !== primary);
|
|
68
68
|
|
|
69
69
|
return (
|
|
70
|
-
<div className={cn("min-w-0", classNames?.root, className)}>
|
|
70
|
+
<div className={cn("@container/responsive-list min-w-0", classNames?.root, className)}>
|
|
71
71
|
<div
|
|
72
72
|
className={cn(
|
|
73
|
-
"hidden rounded-card border-card shadow-card surface-card
|
|
73
|
+
"hidden rounded-card border-card shadow-card surface-card @min-[42rem]/responsive-list:block",
|
|
74
74
|
classNames?.tableWrapper,
|
|
75
75
|
)}
|
|
76
76
|
>
|
|
@@ -116,7 +116,10 @@ export function ResponsiveList<T>({
|
|
|
116
116
|
</div>
|
|
117
117
|
<ul
|
|
118
118
|
aria-label={caption}
|
|
119
|
-
className={cn(
|
|
119
|
+
className={cn(
|
|
120
|
+
"m-0 flex list-none flex-col gap-density p-0 @min-[42rem]/responsive-list:hidden",
|
|
121
|
+
classNames?.cards,
|
|
122
|
+
)}
|
|
120
123
|
>
|
|
121
124
|
{items.map((item) => (
|
|
122
125
|
<li
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef } from "react";
|
|
2
|
+
import { cn } from "../../utils/cn.js";
|
|
3
|
+
|
|
4
|
+
export type StackDirection = "column" | "row";
|
|
5
|
+
export type StackGap = "none" | "xs" | "sm" | "md" | "lg" | "xl";
|
|
6
|
+
export type StackAlign = "start" | "center" | "end" | "stretch" | "baseline";
|
|
7
|
+
|
|
8
|
+
export const stackGapClasses: Record<StackGap, string> = {
|
|
9
|
+
none: "gap-0",
|
|
10
|
+
xs: "gap-1",
|
|
11
|
+
sm: "gap-2",
|
|
12
|
+
md: "gap-4",
|
|
13
|
+
lg: "gap-6",
|
|
14
|
+
xl: "gap-8",
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const alignClasses: Record<StackAlign, string> = {
|
|
18
|
+
start: "items-start",
|
|
19
|
+
center: "items-center",
|
|
20
|
+
end: "items-end",
|
|
21
|
+
stretch: "items-stretch",
|
|
22
|
+
baseline: "items-baseline",
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export interface StackProps extends ComponentPropsWithoutRef<"div"> {
|
|
26
|
+
/** `column` stacks children vertically, `row` lays them out inline and wraps. Defaults to `column`. */
|
|
27
|
+
direction?: StackDirection;
|
|
28
|
+
/** Space between children. Defaults to `md`. */
|
|
29
|
+
gap?: StackGap;
|
|
30
|
+
/** Cross-axis alignment. Defaults to `stretch` for a column and `center` for a row. */
|
|
31
|
+
align?: StackAlign;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** One-axis flex layout with token gaps. A row wraps instead of overflowing. */
|
|
35
|
+
export function Stack({
|
|
36
|
+
direction = "column",
|
|
37
|
+
gap = "md",
|
|
38
|
+
align,
|
|
39
|
+
className,
|
|
40
|
+
...props
|
|
41
|
+
}: StackProps) {
|
|
42
|
+
const row = direction === "row";
|
|
43
|
+
return (
|
|
44
|
+
<div
|
|
45
|
+
className={cn(
|
|
46
|
+
"flex min-w-0",
|
|
47
|
+
row ? "flex-row flex-wrap" : "flex-col",
|
|
48
|
+
alignClasses[align ?? (row ? "center" : "stretch")],
|
|
49
|
+
stackGapClasses[gap],
|
|
50
|
+
className,
|
|
51
|
+
)}
|
|
52
|
+
{...props}
|
|
53
|
+
/>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { type ComponentPropsWithoutRef, type ReactNode, useId } from "react";
|
|
4
|
+
import { useUiStrings } from "../../i18n/index.js";
|
|
5
|
+
import { Check, Copy } from "../../icons/index.js";
|
|
6
|
+
import type { ClassNames } from "../../utils/class-names.js";
|
|
7
|
+
import { cn } from "../../utils/cn.js";
|
|
8
|
+
import { useCopy } from "../../utils/use-copy.js";
|
|
9
|
+
|
|
10
|
+
export type CopyFieldPart = "root" | "label" | "box" | "value" | "button";
|
|
11
|
+
|
|
12
|
+
export interface CopyFieldProps
|
|
13
|
+
extends Omit<ComponentPropsWithoutRef<"div">, "children" | "onCopy"> {
|
|
14
|
+
label: ReactNode;
|
|
15
|
+
/** Text shown in monospace and written to the clipboard. */
|
|
16
|
+
value: string;
|
|
17
|
+
/** Called after the value was copied. */
|
|
18
|
+
onCopy?: (value: string) => void;
|
|
19
|
+
/** Accessible name of the button; defaults to the UI string `copy`. */
|
|
20
|
+
copyLabel?: string;
|
|
21
|
+
/** Announced and shown on the button after copying; defaults to the UI string `copied`. */
|
|
22
|
+
copiedLabel?: string;
|
|
23
|
+
/** Per-part classes merged with `cn`; consumer classes win. `className` still targets the root and is merged last. */
|
|
24
|
+
classNames?: ClassNames<CopyFieldPart>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function CopyField({
|
|
28
|
+
label,
|
|
29
|
+
value,
|
|
30
|
+
onCopy,
|
|
31
|
+
copyLabel,
|
|
32
|
+
copiedLabel,
|
|
33
|
+
className,
|
|
34
|
+
classNames,
|
|
35
|
+
...props
|
|
36
|
+
}: CopyFieldProps) {
|
|
37
|
+
const strings = useUiStrings();
|
|
38
|
+
const id = useId();
|
|
39
|
+
const { copied, copy } = useCopy(1500);
|
|
40
|
+
const buttonLabel = copied ? (copiedLabel ?? strings.copied) : (copyLabel ?? strings.copy);
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<div {...props} className={cn("flex min-w-0 flex-col gap-1.5", classNames?.root, className)}>
|
|
44
|
+
<label htmlFor={id} className={cn("font-semibold text-ink-2 text-meta", classNames?.label)}>
|
|
45
|
+
{label}
|
|
46
|
+
</label>
|
|
47
|
+
<div
|
|
48
|
+
className={cn(
|
|
49
|
+
"flex min-w-0 items-center gap-2 rounded-input border-control bg-surface-control pr-1 pl-3",
|
|
50
|
+
classNames?.box,
|
|
51
|
+
)}
|
|
52
|
+
>
|
|
53
|
+
<input
|
|
54
|
+
id={id}
|
|
55
|
+
readOnly
|
|
56
|
+
value={value}
|
|
57
|
+
onFocus={(event) => event.currentTarget.select()}
|
|
58
|
+
className={cn(
|
|
59
|
+
"h-input min-w-0 flex-1 truncate bg-transparent font-mono text-control text-ink focus:outline-none",
|
|
60
|
+
classNames?.value,
|
|
61
|
+
)}
|
|
62
|
+
/>
|
|
63
|
+
<button
|
|
64
|
+
type="button"
|
|
65
|
+
onClick={() => {
|
|
66
|
+
void copy(value);
|
|
67
|
+
onCopy?.(value);
|
|
68
|
+
}}
|
|
69
|
+
className={cn(
|
|
70
|
+
"inline-flex h-control-sm shrink-0 cursor-pointer items-center gap-1.5 rounded-button px-2.5 font-semibold text-ink-2 text-meta hover:bg-surface-2 hover:text-ink focus-visible:focus-ring in-data-[density=touch]:h-11",
|
|
71
|
+
copied && "text-success",
|
|
72
|
+
classNames?.button,
|
|
73
|
+
)}
|
|
74
|
+
>
|
|
75
|
+
{copied ? (
|
|
76
|
+
<Check aria-hidden="true" className="size-4" />
|
|
77
|
+
) : (
|
|
78
|
+
<Copy aria-hidden="true" className="size-4" />
|
|
79
|
+
)}
|
|
80
|
+
<span>{buttonLabel}</span>
|
|
81
|
+
</button>
|
|
82
|
+
</div>
|
|
83
|
+
<span role="status" className="sr-only">
|
|
84
|
+
{copied ? (copiedLabel ?? strings.copied) : null}
|
|
85
|
+
</span>
|
|
86
|
+
</div>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CopyField, type CopyFieldPart, type CopyFieldProps } from "./copy-field.js";
|
|
@@ -79,7 +79,7 @@ export function EmojiPicker({
|
|
|
79
79
|
return (
|
|
80
80
|
<div
|
|
81
81
|
className={cn(
|
|
82
|
-
"@container/emoji flex w-full max-w-xs min-w-0 flex-col gap-density-sm rounded-popover border-card
|
|
82
|
+
"@container/emoji flex w-full max-w-xs min-w-0 flex-col gap-density-sm rounded-popover border-card surface-overlay p-card text-ink",
|
|
83
83
|
classNames?.root,
|
|
84
84
|
className,
|
|
85
85
|
)}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
+
import { cn } from "../../utils/cn.js";
|
|
3
|
+
|
|
4
|
+
export type FormProps = ComponentPropsWithoutRef<"form">;
|
|
5
|
+
|
|
6
|
+
/** Vertical form layout; every `<form>` attribute and handler passes through. */
|
|
7
|
+
export function Form({ className, ...props }: FormProps) {
|
|
8
|
+
return <form className={cn("flex min-w-0 flex-col gap-4", className)} {...props} />;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface FormMessageProps extends Omit<ComponentPropsWithoutRef<"p">, "role" | "children"> {
|
|
12
|
+
/** Message text; `null`, `undefined` and an empty string render nothing. */
|
|
13
|
+
message: ReactNode | null | undefined;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function hasMessage(message: ReactNode): boolean {
|
|
17
|
+
return message !== null && message !== undefined && message !== false && message !== "";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type FormErrorProps = FormMessageProps;
|
|
21
|
+
|
|
22
|
+
/** Submit-level error. `role="alert"`, so assistive tech announces it as soon as it appears. */
|
|
23
|
+
export function FormError({ message, className, ...props }: FormErrorProps) {
|
|
24
|
+
if (!hasMessage(message)) return null;
|
|
25
|
+
return (
|
|
26
|
+
<p role="alert" className={cn("m-0 font-semibold text-danger text-meta", className)} {...props}>
|
|
27
|
+
{message}
|
|
28
|
+
</p>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type FormStatusProps = FormMessageProps;
|
|
33
|
+
|
|
34
|
+
/** Submit-level confirmation. `role="status"`, a polite live region that does not interrupt. */
|
|
35
|
+
export function FormStatus({ message, className, ...props }: FormStatusProps) {
|
|
36
|
+
if (!hasMessage(message)) return null;
|
|
37
|
+
return (
|
|
38
|
+
<p
|
|
39
|
+
role="status"
|
|
40
|
+
className={cn("m-0 font-semibold text-meta text-success", className)}
|
|
41
|
+
{...props}
|
|
42
|
+
>
|
|
43
|
+
{message}
|
|
44
|
+
</p>
|
|
45
|
+
);
|
|
46
|
+
}
|
package/src/forms/index.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export * from "./accent-picker/index.js";
|
|
2
2
|
export * from "./checkbox-button-group/index.js";
|
|
3
|
+
export * from "./copy-field/index.js";
|
|
3
4
|
export * from "./dropzone/index.js";
|
|
4
5
|
export * from "./emoji-picker/index.js";
|
|
5
6
|
export * from "./emoji-reaction-button/index.js";
|
|
6
7
|
export * from "./field/index.js";
|
|
8
|
+
export * from "./form/index.js";
|
|
7
9
|
export * from "./form-grid/index.js";
|
|
8
10
|
export * from "./inline-select/index.js";
|
|
9
11
|
export * from "./input/index.js";
|
package/src/forms/input/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Input, type InputProps } from "./input.js";
|
|
1
|
+
export { Input, type InputProps, type InputSize, inputSizeClasses } from "./input.js";
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import type { ComponentPropsWithoutRef } from "react";
|
|
2
2
|
import { cn } from "../../utils/cn.js";
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export type InputSize = "md" | "lg";
|
|
5
5
|
|
|
6
|
-
export
|
|
6
|
+
export const inputSizeClasses: Readonly<Record<InputSize, string>> = {
|
|
7
|
+
md: "h-input px-3",
|
|
8
|
+
lg: "h-control-lg px-4 text-fs-140",
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export interface InputProps extends Omit<ComponentPropsWithoutRef<"input">, "size"> {
|
|
12
|
+
/** `lg` is the thumb-friendly height of the large `Button`. */
|
|
13
|
+
size?: InputSize;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function Input({ size = "md", className, ...props }: InputProps) {
|
|
7
17
|
return (
|
|
8
18
|
<input
|
|
9
19
|
className={cn(
|
|
10
|
-
"
|
|
20
|
+
"w-full min-w-0 rounded-input border-control bg-surface-control text-control text-ink placeholder:text-ink-3 focus:border-transparent focus:outline-2 focus:outline-accent-ink focus:-outline-offset-1 aria-[invalid=true]:border-danger",
|
|
21
|
+
inputSizeClasses[size],
|
|
11
22
|
className,
|
|
12
23
|
)}
|
|
13
24
|
{...props}
|