@techsio/ui-kit 0.57.0 → 0.58.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 +128 -133
- package/dist/atoms/action-icon.js +9 -8
- package/dist/atoms/button.js +78 -18
- package/dist/atoms/checkbox.js +77 -17
- package/dist/atoms/hotkeys.js +26 -7
- package/dist/atoms/icon.js +5 -5
- package/dist/atoms/image.js +107 -2
- package/dist/atoms/input.js +57 -9
- package/dist/atoms/label.js +13 -4
- package/dist/atoms/link-button.js +14 -12
- package/dist/atoms/link.js +18 -4
- package/dist/atoms/numeric-input.js +293 -76
- package/dist/atoms/rating.js +306 -73
- package/dist/atoms/skeleton.js +18 -14
- package/dist/atoms/status-text.js +31 -18
- package/dist/atoms/textarea.js +59 -12
- package/dist/atoms/tooltip.js +64 -43
- package/dist/hotkeys.js +1 -0
- package/dist/internal/choice-control.js +173 -0
- package/dist/internal/combobox-query-sync.js +11 -0
- package/dist/internal/date-picker-coordinator.js +56 -40
- package/dist/internal/date-picker-dom.js +44 -0
- package/dist/internal/date-picker-input.js +30 -0
- package/dist/internal/described-by.js +23 -18
- package/dist/internal/form-control-lifecycle.js +122 -0
- package/dist/internal/molecules/command.context.js +1 -0
- package/dist/internal/molecules/drawer.context.js +1 -0
- package/dist/internal/molecules/vertical-navigation.context.js +1 -0
- package/dist/internal/molecules/vertical-navigation.styles.js +9 -2
- package/dist/internal/numeric-input-editing.js +87 -0
- package/dist/internal/organisms/sidebar.context.js +1 -0
- package/dist/internal/organisms/sidebar.focus.js +1 -0
- package/dist/internal/overlay-portal.js +72 -0
- package/dist/internal/reduced-motion.js +1 -0
- package/dist/internal/use-effective-disabled.js +8 -0
- package/dist/molecules/accordion.js +44 -30
- package/dist/molecules/availability-status.js +1 -0
- package/dist/molecules/breadcrumb.js +11 -11
- package/dist/molecules/carousel.js +279 -97
- package/dist/molecules/cascade-select.js +327 -81
- package/dist/molecules/chart.js +276 -38
- package/dist/molecules/color-select.js +181 -62
- package/dist/molecules/combobox.js +535 -182
- package/dist/molecules/command.js +2 -1
- package/dist/molecules/date-picker.js +571 -119
- package/dist/molecules/dialog.js +81 -47
- package/dist/molecules/drawer.js +54 -5
- package/dist/molecules/file-upload.js +373 -37
- package/dist/molecules/form-checkbox.js +65 -22
- package/dist/molecules/form-error-summary.js +29 -5
- package/dist/molecules/form-input.js +26 -30
- package/dist/molecules/form-numeric-input.js +11 -9
- package/dist/molecules/form-textarea.js +26 -23
- package/dist/molecules/menu.js +170 -47
- package/dist/molecules/pagination.js +100 -28
- package/dist/molecules/phone-input.js +172 -37
- package/dist/molecules/popover.js +53 -26
- package/dist/molecules/price-block.js +1 -0
- package/dist/molecules/product-card.js +23 -18
- package/dist/molecules/quantity-field.js +4 -2
- package/dist/molecules/radio-card.js +102 -30
- package/dist/molecules/radio-group.js +108 -31
- package/dist/molecules/search-form.js +116 -13
- package/dist/molecules/select.js +226 -81
- package/dist/molecules/slider.js +141 -30
- package/dist/molecules/steps.js +181 -50
- package/dist/molecules/switch.js +85 -20
- package/dist/molecules/tabs.js +227 -31
- package/dist/molecules/toast.js +146 -51
- package/dist/molecules/totals-summary.js +2 -1
- package/dist/molecules/tour.js +9 -5
- package/dist/molecules/tree-view.js +255 -109
- package/dist/molecules/vertical-navigation.js +8 -4
- package/dist/organisms/data-table.fields.js +25 -5
- package/dist/organisms/data-table.helpers.js +6 -2
- package/dist/organisms/data-table.js +580 -151
- package/dist/organisms/footer.js +18 -11
- package/dist/organisms/gallery.js +61 -24
- package/dist/organisms/header.js +106 -32
- package/dist/organisms/line-item.js +1 -0
- package/dist/organisms/sidebar.js +1 -0
- package/dist/organisms/table.js +22 -7
- package/dist/src/atoms/action-icon.d.ts +10 -10
- package/dist/src/atoms/action-icon.d.ts.map +1 -1
- package/dist/src/atoms/badge.d.ts +3 -3
- package/dist/src/atoms/badge.d.ts.map +1 -1
- package/dist/src/atoms/button.d.ts +35 -24
- package/dist/src/atoms/button.d.ts.map +1 -1
- package/dist/src/atoms/checkbox.d.ts +6 -5
- package/dist/src/atoms/checkbox.d.ts.map +1 -1
- package/dist/src/atoms/hotkeys.d.ts +3 -2
- package/dist/src/atoms/hotkeys.d.ts.map +1 -1
- package/dist/src/atoms/icon.d.ts +18 -17
- package/dist/src/atoms/icon.d.ts.map +1 -1
- package/dist/src/atoms/image.d.ts +14 -6
- package/dist/src/atoms/image.d.ts.map +1 -1
- package/dist/src/atoms/input.d.ts +23 -14
- package/dist/src/atoms/input.d.ts.map +1 -1
- package/dist/src/atoms/label.d.ts +4 -4
- package/dist/src/atoms/label.d.ts.map +1 -1
- package/dist/src/atoms/link-button.d.ts +54 -31
- package/dist/src/atoms/link-button.d.ts.map +1 -1
- package/dist/src/atoms/link.d.ts +30 -9
- package/dist/src/atoms/link.d.ts.map +1 -1
- package/dist/src/atoms/numeric-input.d.ts +23 -19
- package/dist/src/atoms/numeric-input.d.ts.map +1 -1
- package/dist/src/atoms/rating.d.ts +54 -26
- package/dist/src/atoms/rating.d.ts.map +1 -1
- package/dist/src/atoms/skeleton.d.ts +9 -9
- package/dist/src/atoms/skeleton.d.ts.map +1 -1
- package/dist/src/atoms/status-text.d.ts +21 -13
- package/dist/src/atoms/status-text.d.ts.map +1 -1
- package/dist/src/atoms/textarea.d.ts +22 -20
- package/dist/src/atoms/textarea.d.ts.map +1 -1
- package/dist/src/atoms/tooltip.d.ts +5 -5
- package/dist/src/atoms/tooltip.d.ts.map +1 -1
- package/dist/src/hotkeys.d.ts +1 -1
- package/dist/src/hotkeys.d.ts.map +1 -1
- package/dist/src/internal/choice-control.d.ts +18 -0
- package/dist/src/internal/choice-control.d.ts.map +1 -0
- package/dist/src/internal/combobox-query-sync.d.ts +4 -0
- package/dist/src/internal/combobox-query-sync.d.ts.map +1 -0
- package/dist/src/internal/date-picker-coordinator.d.ts +7 -1
- package/dist/src/internal/date-picker-coordinator.d.ts.map +1 -1
- package/dist/src/internal/date-picker-dom.d.ts +10 -0
- package/dist/src/internal/date-picker-dom.d.ts.map +1 -0
- package/dist/src/internal/date-picker-input.d.ts +7 -0
- package/dist/src/internal/date-picker-input.d.ts.map +1 -0
- package/dist/src/internal/described-by.d.ts +7 -1
- package/dist/src/internal/described-by.d.ts.map +1 -1
- package/dist/src/internal/form-control-lifecycle.d.ts +22 -0
- package/dist/src/internal/form-control-lifecycle.d.ts.map +1 -0
- package/dist/src/internal/molecules/vertical-navigation.context.d.ts +1 -1
- package/dist/src/internal/molecules/vertical-navigation.context.d.ts.map +1 -1
- package/dist/src/internal/molecules/vertical-navigation.styles.d.ts +21 -0
- package/dist/src/internal/molecules/vertical-navigation.styles.d.ts.map +1 -1
- package/dist/src/internal/numeric-input-editing.d.ts +13 -0
- package/dist/src/internal/numeric-input-editing.d.ts.map +1 -0
- package/dist/src/internal/overlay-portal.d.ts +18 -0
- package/dist/src/internal/overlay-portal.d.ts.map +1 -0
- package/dist/src/internal/use-effective-disabled.d.ts +4 -0
- package/dist/src/internal/use-effective-disabled.d.ts.map +1 -0
- package/dist/src/molecules/accordion.d.ts +25 -19
- package/dist/src/molecules/accordion.d.ts.map +1 -1
- package/dist/src/molecules/availability-status.d.ts +4 -1
- package/dist/src/molecules/availability-status.d.ts.map +1 -1
- package/dist/src/molecules/breadcrumb.d.ts +2 -2
- package/dist/src/molecules/breadcrumb.d.ts.map +1 -1
- package/dist/src/molecules/carousel.d.ts +51 -52
- package/dist/src/molecules/carousel.d.ts.map +1 -1
- package/dist/src/molecules/cascade-select.d.ts +23 -8
- package/dist/src/molecules/cascade-select.d.ts.map +1 -1
- package/dist/src/molecules/chart.d.ts +7 -1
- package/dist/src/molecules/chart.d.ts.map +1 -1
- package/dist/src/molecules/color-select.d.ts +19 -3
- package/dist/src/molecules/color-select.d.ts.map +1 -1
- package/dist/src/molecules/combobox.d.ts +23 -5
- package/dist/src/molecules/combobox.d.ts.map +1 -1
- package/dist/src/molecules/command.d.ts +1 -1
- package/dist/src/molecules/date-picker.d.ts +7 -3
- package/dist/src/molecules/date-picker.d.ts.map +1 -1
- package/dist/src/molecules/dialog.d.ts +7 -3
- package/dist/src/molecules/dialog.d.ts.map +1 -1
- package/dist/src/molecules/drawer.d.ts +4 -4
- package/dist/src/molecules/drawer.d.ts.map +1 -1
- package/dist/src/molecules/file-upload.d.ts +11 -6
- package/dist/src/molecules/file-upload.d.ts.map +1 -1
- package/dist/src/molecules/form-checkbox.d.ts +7 -2
- package/dist/src/molecules/form-checkbox.d.ts.map +1 -1
- package/dist/src/molecules/form-error-summary.d.ts +4 -3
- package/dist/src/molecules/form-error-summary.d.ts.map +1 -1
- package/dist/src/molecules/form-input.d.ts +5 -6
- package/dist/src/molecules/form-input.d.ts.map +1 -1
- package/dist/src/molecules/form-numeric-input.d.ts +5 -5
- package/dist/src/molecules/form-numeric-input.d.ts.map +1 -1
- package/dist/src/molecules/form-textarea.d.ts +5 -6
- package/dist/src/molecules/form-textarea.d.ts.map +1 -1
- package/dist/src/molecules/menu.d.ts +17 -3
- package/dist/src/molecules/menu.d.ts.map +1 -1
- package/dist/src/molecules/pagination.d.ts +1 -1
- package/dist/src/molecules/pagination.d.ts.map +1 -1
- package/dist/src/molecules/phone-input.d.ts +4 -1
- package/dist/src/molecules/phone-input.d.ts.map +1 -1
- package/dist/src/molecules/popover.d.ts +7 -1
- package/dist/src/molecules/popover.d.ts.map +1 -1
- package/dist/src/molecules/price-block.d.ts +1 -1
- package/dist/src/molecules/price-block.d.ts.map +1 -1
- package/dist/src/molecules/product-card.d.ts +20 -25
- package/dist/src/molecules/product-card.d.ts.map +1 -1
- package/dist/src/molecules/quantity-field.d.ts +1 -1
- package/dist/src/molecules/quantity-field.d.ts.map +1 -1
- package/dist/src/molecules/radio-card.d.ts +10 -3
- package/dist/src/molecules/radio-card.d.ts.map +1 -1
- package/dist/src/molecules/radio-group.d.ts +15 -6
- package/dist/src/molecules/radio-group.d.ts.map +1 -1
- package/dist/src/molecules/search-form.d.ts +37 -12
- package/dist/src/molecules/search-form.d.ts.map +1 -1
- package/dist/src/molecules/select.d.ts +34 -29
- package/dist/src/molecules/select.d.ts.map +1 -1
- package/dist/src/molecules/slider.d.ts +23 -2
- package/dist/src/molecules/slider.d.ts.map +1 -1
- package/dist/src/molecules/steps.d.ts +30 -10
- package/dist/src/molecules/steps.d.ts.map +1 -1
- package/dist/src/molecules/switch.d.ts +54 -33
- package/dist/src/molecules/switch.d.ts.map +1 -1
- package/dist/src/molecules/tabs.d.ts +11 -11
- package/dist/src/molecules/tabs.d.ts.map +1 -1
- package/dist/src/molecules/toast.d.ts +25 -13
- package/dist/src/molecules/toast.d.ts.map +1 -1
- package/dist/src/molecules/totals-summary.d.ts +1 -1
- package/dist/src/molecules/totals-summary.d.ts.map +1 -1
- package/dist/src/molecules/tour.d.ts +1 -1
- package/dist/src/molecules/tour.d.ts.map +1 -1
- package/dist/src/molecules/tree-view.d.ts +16 -20
- package/dist/src/molecules/tree-view.d.ts.map +1 -1
- package/dist/src/molecules/vertical-navigation.d.ts +2 -2
- package/dist/src/molecules/vertical-navigation.d.ts.map +1 -1
- package/dist/src/organisms/data-table.d.ts +24 -3
- package/dist/src/organisms/data-table.d.ts.map +1 -1
- package/dist/src/organisms/data-table.fields.d.ts +4 -1
- package/dist/src/organisms/data-table.fields.d.ts.map +1 -1
- package/dist/src/organisms/data-table.helpers.d.ts +5 -12
- package/dist/src/organisms/data-table.helpers.d.ts.map +1 -1
- package/dist/src/organisms/footer.d.ts +5 -5
- package/dist/src/organisms/footer.d.ts.map +1 -1
- package/dist/src/organisms/gallery.d.ts +11 -9
- package/dist/src/organisms/gallery.d.ts.map +1 -1
- package/dist/src/organisms/header.d.ts +24 -22
- package/dist/src/organisms/header.d.ts.map +1 -1
- package/dist/src/organisms/table.d.ts +14 -14
- package/dist/src/organisms/table.d.ts.map +1 -1
- package/dist/src/templates/accordion.d.ts +8 -6
- package/dist/src/templates/accordion.d.ts.map +1 -1
- package/dist/src/templates/breadcrumb.d.ts +1 -1
- package/dist/src/templates/breadcrumb.d.ts.map +1 -1
- package/dist/src/templates/carousel.d.ts +3 -3
- package/dist/src/templates/carousel.d.ts.map +1 -1
- package/dist/src/templates/facet-filter-panel.d.ts +9 -3
- package/dist/src/templates/facet-filter-panel.d.ts.map +1 -1
- package/dist/src/templates/gallery.d.ts +2 -2
- package/dist/src/templates/gallery.d.ts.map +1 -1
- package/dist/src/templates/numeric-input.d.ts +1 -1
- package/dist/src/templates/numeric-input.d.ts.map +1 -1
- package/dist/src/templates/popover.d.ts +4 -2
- package/dist/src/templates/popover.d.ts.map +1 -1
- package/dist/src/templates/product-card.d.ts +12 -4
- package/dist/src/templates/product-card.d.ts.map +1 -1
- package/dist/src/templates/search-suggestions.d.ts +1 -1
- package/dist/src/templates/select.d.ts +7 -2
- package/dist/src/templates/select.d.ts.map +1 -1
- package/dist/src/templates/tabs.d.ts +8 -7
- package/dist/src/templates/tabs.d.ts.map +1 -1
- package/dist/src/theme/theme-config.d.ts +9 -16
- package/dist/src/theme/theme-config.d.ts.map +1 -1
- package/dist/src/theme/theme-provider.d.ts +16 -21
- package/dist/src/theme/theme-provider.d.ts.map +1 -1
- package/dist/src/theme/theme-toggle.d.ts.map +1 -1
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/templates/accordion.js +3 -1
- package/dist/templates/breadcrumb.js +11 -4
- package/dist/templates/carousel.js +3 -6
- package/dist/templates/facet-filter-panel.js +121 -52
- package/dist/templates/gallery.js +6 -2
- package/dist/templates/numeric-input.js +6 -1
- package/dist/templates/popover.js +6 -1
- package/dist/templates/product-card.js +52 -26
- package/dist/templates/select.js +6 -1
- package/dist/templates/tabs.js +4 -2
- package/dist/theme/theme-config.js +8 -16
- package/dist/theme/theme-provider.js +89 -63
- package/dist/theme/theme-toggle.js +17 -9
- package/dist/utils.js +11 -1
- package/package.json +9 -5
- package/src/tokens/_base.css +4 -3
- package/src/tokens/_business-atoms.css +103 -0
- package/src/tokens/_foundation-overrides.css +251 -0
- package/src/tokens/_reset.css +10 -10
- package/src/tokens/_scheme-scopes.css +4144 -0
- package/src/tokens/_semantic.css +1 -23
- package/src/tokens/_tokens-base.css +36 -32
- package/src/tokens/_typography.css +2 -1
- package/src/tokens/components/_form-control.css +149 -6
- package/src/tokens/components/_popup-surface.css +15 -29
- package/src/tokens/components/atoms/_action-icon.css +49 -0
- package/src/tokens/components/atoms/_button.css +67 -0
- package/src/tokens/components/atoms/_checkbox.css +47 -4
- package/src/tokens/components/atoms/_hotkeys.css +2 -0
- package/src/tokens/components/atoms/_icon.css +60 -7
- package/src/tokens/components/atoms/_image.css +18 -0
- package/src/tokens/components/atoms/_input.css +20 -0
- package/src/tokens/components/atoms/_label.css +3 -7
- package/src/tokens/components/atoms/_link.css +47 -5
- package/src/tokens/components/atoms/_numeric-input.css +111 -2
- package/src/tokens/components/atoms/_rating.css +55 -6
- package/src/tokens/components/atoms/_skeleton.css +12 -2
- package/src/tokens/components/atoms/_status-text.css +35 -5
- package/src/tokens/components/atoms/_textarea.css +32 -3
- package/src/tokens/components/atoms/_tooltip.css +25 -0
- package/src/tokens/components/molecules/_accordion.css +46 -5
- package/src/tokens/components/molecules/_breadcrumb.css +15 -4
- package/src/tokens/components/molecules/_carousel.css +67 -0
- package/src/tokens/components/molecules/_cascade-select.css +104 -0
- package/src/tokens/components/molecules/_chart.css +12 -14
- package/src/tokens/components/molecules/_color-select.css +21 -0
- package/src/tokens/components/molecules/_combobox.css +81 -0
- package/src/tokens/components/molecules/_command.css +1 -0
- package/src/tokens/components/molecules/_date-picker.css +66 -10
- package/src/tokens/components/molecules/_dialog.css +36 -4
- package/src/tokens/components/molecules/_drawer.css +39 -3
- package/src/tokens/components/molecules/_file-upload.css +16 -1
- package/src/tokens/components/molecules/_menu.css +17 -0
- package/src/tokens/components/molecules/_pagination.css +19 -0
- package/src/tokens/components/molecules/_phone-input.css +20 -5
- package/src/tokens/components/molecules/_popover.css +34 -0
- package/src/tokens/components/molecules/_product-card.css +49 -0
- package/src/tokens/components/molecules/_radio-card.css +35 -0
- package/src/tokens/components/molecules/_radio-group.css +8 -0
- package/src/tokens/components/molecules/_select.css +33 -0
- package/src/tokens/components/molecules/_slider.css +5 -0
- package/src/tokens/components/molecules/_steps.css +52 -0
- package/src/tokens/components/molecules/_switch.css +59 -10
- package/src/tokens/components/molecules/_tabs.css +61 -3
- package/src/tokens/components/molecules/_toast.css +60 -0
- package/src/tokens/components/molecules/_totals-summary.css +22 -22
- package/src/tokens/components/molecules/_tour.css +16 -1
- package/src/tokens/components/molecules/_tree-view.css +27 -3
- package/src/tokens/components/molecules/_vertical-navigation.css +21 -3
- package/src/tokens/components/organisms/_data-table.css +97 -0
- package/src/tokens/components/organisms/_footer.css +9 -0
- package/src/tokens/components/organisms/_gallery.css +11 -0
- package/src/tokens/components/organisms/_header.css +22 -0
- package/src/tokens/components/organisms/_sidebar.css +1 -1
- package/src/tokens/components/organisms/_table.css +31 -0
- package/src/tokens/components/templates/_facet-filter-panel.css +11 -1
- package/src/tokens/figma/akros/variables.css +6 -6
- package/src/tokens/figma/brand-overrides.css +162 -57
- package/src/tokens/figma/business/variables.css +6 -6
- package/src/tokens/figma/cyber/variables.css +115 -38
- package/src/tokens/figma/cyber-dark/variables.css +115 -38
- package/src/tokens/figma/dark/variables.css +4 -4
- package/src/tokens/figma/light/variables.css +43 -40
- package/src/tokens/figma/{neo → n1}/variables.css +114 -114
- package/src/tokens/figma/variables.css +639 -240
- package/src/tokens/theme.css +24 -4
- package/src/tokens/_colors.css +0 -5
- package/src/tokens/figma/neo-dark/variables.css +0 -457
package/dist/molecules/tabs.js
CHANGED
|
@@ -1,45 +1,48 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx } from "react/jsx-runtime";
|
|
2
3
|
import { mergeProps, normalizeProps, useMachine } from "@zag-js/react";
|
|
3
|
-
import { createContext, useContext, useEffect, useId, useState } from "react";
|
|
4
|
+
import { createContext, useContext, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
4
5
|
import { Button } from "../atoms/button.js";
|
|
5
6
|
import { tv } from "../utils.js";
|
|
6
7
|
import * as __rspack_external__zag_js_tabs_b98983a9 from "@zag-js/tabs";
|
|
7
8
|
const tabsVariants = tv({
|
|
8
9
|
slots: {
|
|
9
10
|
root: [
|
|
10
|
-
"flex w-full",
|
|
11
|
+
"flex w-full min-w-0 max-w-full",
|
|
11
12
|
"data-[orientation=horizontal]:flex-col",
|
|
12
13
|
"data-[orientation=vertical]:flex-row",
|
|
13
14
|
"bg-tabs-bg",
|
|
14
15
|
"rounded-tabs"
|
|
15
16
|
],
|
|
16
17
|
list: [
|
|
17
|
-
"relative flex",
|
|
18
|
+
"relative flex min-w-0 max-w-full",
|
|
18
19
|
"bg-tabs-list-bg",
|
|
19
|
-
"data-[orientation=horizontal]:flex-row",
|
|
20
|
-
"data-[orientation=vertical]:flex-col"
|
|
20
|
+
"data-[orientation=horizontal]:flex-row data-[orientation=horizontal]:overflow-x-auto",
|
|
21
|
+
"data-[orientation=vertical]:w-max data-[orientation=vertical]:shrink-0 data-[orientation=vertical]:flex-col"
|
|
21
22
|
],
|
|
22
23
|
trigger: [
|
|
23
|
-
"relative flex items-center justify-center",
|
|
24
|
-
"text-tabs-trigger-fg-base",
|
|
24
|
+
"relative flex shrink-0 items-center justify-center",
|
|
25
|
+
"font-tabs-trigger text-tabs-trigger-fg-base data-selected:font-tabs-trigger-selected",
|
|
26
|
+
"tabs-trigger-press",
|
|
25
27
|
"rounded-tabs-trigger",
|
|
26
28
|
"cursor-pointer",
|
|
27
|
-
"hover:bg-tabs-trigger-bg-hover",
|
|
29
|
+
"not-data-disabled:hover:bg-tabs-trigger-bg-hover",
|
|
28
30
|
"focus-visible:outline-(style:--default-ring-style) focus-visible:outline-(length:--default-ring-width)",
|
|
29
31
|
"focus-visible:outline-tabs-ring",
|
|
30
|
-
"
|
|
32
|
+
"tabs-trigger-focus",
|
|
31
33
|
"data-[selected]:text-tabs-trigger-fg-selected",
|
|
32
34
|
"data-[disabled]:cursor-not-allowed data-[disabled]:text-tabs-trigger-fg-disabled",
|
|
33
35
|
"transition-colors duration-200 motion-reduce:transition-none"
|
|
34
36
|
],
|
|
35
37
|
indicator: [
|
|
36
|
-
"absolute rounded-tabs-indicator bg-tabs-indicator-bg",
|
|
37
|
-
"
|
|
38
|
+
"tabs-indicator-position absolute rounded-tabs-indicator bg-tabs-indicator-bg",
|
|
39
|
+
"duration-200 motion-reduce:transition-none",
|
|
40
|
+
"data-[orientation=vertical]:h-(--tabs-indicator-height) data-[orientation=horizontal]:w-(--tabs-indicator-width)",
|
|
38
41
|
"data-[orientation=horizontal]:h-tabs-indicator-height data-[orientation=vertical]:w-tabs-indicator",
|
|
39
|
-
"data-[orientation=vertical]
|
|
42
|
+
"data-[orientation=vertical]:-start-tabs-rail-offset data-[orientation=horizontal]:bottom-0"
|
|
40
43
|
],
|
|
41
44
|
content: [
|
|
42
|
-
"text-tabs-content-fg",
|
|
45
|
+
"wrap-anywhere min-w-0 max-w-full text-tabs-content-fg data-[orientation=vertical]:flex-1",
|
|
43
46
|
"focus-visible:outline-(style:--default-ring-style) focus-visible:outline-(length:--default-ring-width)",
|
|
44
47
|
"focus-visible:outline-tabs-ring",
|
|
45
48
|
"focus-visible:outline-offset-(length:--default-ring-offset)"
|
|
@@ -48,12 +51,12 @@ const tabsVariants = tv({
|
|
|
48
51
|
variants: {
|
|
49
52
|
variant: {
|
|
50
53
|
default: {
|
|
51
|
-
|
|
54
|
+
trigger: "tabs-trigger-selected",
|
|
52
55
|
indicator: "hidden"
|
|
53
56
|
},
|
|
54
57
|
line: {
|
|
55
|
-
list: "border-b-(length:--border-width-tabs) border-tabs-border-base",
|
|
56
|
-
indicator: "
|
|
58
|
+
list: "data-[orientation=horizontal]:border-b-(length:--border-width-tabs) data-[orientation=vertical]:border-s-(length:--border-width-tabs) border-tabs-border-base",
|
|
59
|
+
indicator: ""
|
|
57
60
|
},
|
|
58
61
|
solid: {
|
|
59
62
|
trigger: "data-[selected]:bg-tabs-trigger-bg-selected data-[selected]:text-tabs-trigger-fg-solid-selected",
|
|
@@ -93,10 +96,10 @@ const tabsVariants = tv({
|
|
|
93
96
|
list: "justify-start"
|
|
94
97
|
},
|
|
95
98
|
center: {
|
|
96
|
-
list: "
|
|
99
|
+
list: "tabs-list-center"
|
|
97
100
|
},
|
|
98
101
|
end: {
|
|
99
|
-
list: "
|
|
102
|
+
list: "tabs-list-end"
|
|
100
103
|
}
|
|
101
104
|
}
|
|
102
105
|
},
|
|
@@ -113,9 +116,58 @@ function useTabsContext() {
|
|
|
113
116
|
if (!context) throw new Error("Tabs components must be used within Tabs");
|
|
114
117
|
return context;
|
|
115
118
|
}
|
|
119
|
+
function enabledNeighbor(enabled, previous, value) {
|
|
120
|
+
const index = previous.indexOf(value ?? "");
|
|
121
|
+
const neighbors = [
|
|
122
|
+
...previous.slice(Math.max(0, index + 1)),
|
|
123
|
+
...previous.slice(0, Math.max(0, index)).reverse()
|
|
124
|
+
];
|
|
125
|
+
return neighbors.map((candidate)=>enabled.find((trigger)=>trigger.dataset.value === candidate)).find(Boolean) ?? enabled[0];
|
|
126
|
+
}
|
|
127
|
+
function restoreOwnedTabFocus(root, previous, target) {
|
|
128
|
+
if (!previous) return false;
|
|
129
|
+
const unavailable = !previous.isConnected || previous.matches(":disabled") || Boolean(previous.closest('[data-part="content"][hidden]'));
|
|
130
|
+
if (!unavailable) return false;
|
|
131
|
+
const active = root.ownerDocument.activeElement;
|
|
132
|
+
if (active === root.ownerDocument.body || root.contains(active)) target?.focus();
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
function tabEntry(root, enabled, focusedValue, target) {
|
|
136
|
+
const focused = enabled.find((trigger)=>trigger.dataset.value === focusedValue);
|
|
137
|
+
const ownsTriggerFocus = enabled.includes(root.ownerDocument.activeElement);
|
|
138
|
+
return ownsTriggerFocus ? focused ?? target : target ?? focused;
|
|
139
|
+
}
|
|
140
|
+
function reconcileTabSelection(api, selected, target, controlled, request) {
|
|
141
|
+
if (selected) {
|
|
142
|
+
request.current = null;
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (!target) {
|
|
146
|
+
if (!controlled && api.value) api.clearValue();
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const next = target.dataset.value;
|
|
150
|
+
if (null == next) return;
|
|
151
|
+
const key = `${api.value ?? ""}:${next}`;
|
|
152
|
+
if (request.current === key) return;
|
|
153
|
+
request.current = key;
|
|
154
|
+
api.setValue(next);
|
|
155
|
+
}
|
|
156
|
+
function reconcileTabFocus(root, triggers, enabled, previous, api, target, lastFocused, setFocused) {
|
|
157
|
+
const focused = enabled.find((trigger)=>trigger.dataset.value === api.focusedValue);
|
|
158
|
+
const replacement = focused ?? enabledNeighbor(enabled, previous, api.focusedValue) ?? target;
|
|
159
|
+
if (!focused && replacement) setFocused(replacement.dataset.value ?? null);
|
|
160
|
+
const entryTarget = tabEntry(root, enabled, api.focusedValue, target);
|
|
161
|
+
for (const trigger of triggers)trigger.tabIndex = trigger === entryTarget ? 0 : -1;
|
|
162
|
+
if (restoreOwnedTabFocus(root, lastFocused.current, replacement)) lastFocused.current = null;
|
|
163
|
+
}
|
|
116
164
|
function Tabs({ id, defaultValue, value, orientation = "horizontal", dir = "ltr", activationMode = "automatic", loopFocus = true, onValueChange, variant, size, fitted, justify, children, ref, className, ...props }) {
|
|
117
165
|
const generatedId = useId();
|
|
118
166
|
const uniqueId = id || generatedId;
|
|
167
|
+
const rootElement = useRef(null);
|
|
168
|
+
const previousValues = useRef([]);
|
|
169
|
+
const lastFocused = useRef(null);
|
|
170
|
+
const recoveryRequest = useRef(null);
|
|
119
171
|
const service = useMachine(__rspack_external__zag_js_tabs_b98983a9.machine, {
|
|
120
172
|
id: uniqueId,
|
|
121
173
|
value,
|
|
@@ -125,7 +177,7 @@ function Tabs({ id, defaultValue, value, orientation = "horizontal", dir = "ltr"
|
|
|
125
177
|
activationMode,
|
|
126
178
|
loopFocus,
|
|
127
179
|
onValueChange: ({ value: nextValue })=>{
|
|
128
|
-
onValueChange?.(nextValue);
|
|
180
|
+
if (null != nextValue) onValueChange?.(nextValue);
|
|
129
181
|
}
|
|
130
182
|
});
|
|
131
183
|
const api = __rspack_external__zag_js_tabs_b98983a9.connect(service, normalizeProps);
|
|
@@ -136,6 +188,33 @@ function Tabs({ id, defaultValue, value, orientation = "horizontal", dir = "ltr"
|
|
|
136
188
|
justify
|
|
137
189
|
});
|
|
138
190
|
const [contentValues, setContentValues] = useState(()=>new Set());
|
|
191
|
+
useEffect(()=>{
|
|
192
|
+
const root = rootElement.current;
|
|
193
|
+
if (!root) return;
|
|
194
|
+
const reconcile = ()=>{
|
|
195
|
+
const triggers = Array.from(root.querySelectorAll('[data-scope="tabs"][data-part="trigger"]')).filter((trigger)=>trigger.closest('[data-scope="tabs"][data-part="root"]') === root);
|
|
196
|
+
const enabled = triggers.filter((trigger)=>!trigger.disabled);
|
|
197
|
+
const values = triggers.map((trigger)=>trigger.dataset.value ?? "");
|
|
198
|
+
const selected = enabled.find((trigger)=>trigger.dataset.value === api.value);
|
|
199
|
+
const fallback = enabledNeighbor(enabled, previousValues.current, api.value);
|
|
200
|
+
const target = selected ?? fallback;
|
|
201
|
+
reconcileTabSelection(api, selected, target, void 0 !== value, recoveryRequest);
|
|
202
|
+
reconcileTabFocus(root, triggers, enabled, previousValues.current, api, target, lastFocused, (next)=>service.context.set("focusedValue", next));
|
|
203
|
+
if (selected || null == api.value) previousValues.current = values;
|
|
204
|
+
};
|
|
205
|
+
reconcile();
|
|
206
|
+
const observer = new MutationObserver(reconcile);
|
|
207
|
+
observer.observe(root, {
|
|
208
|
+
childList: true,
|
|
209
|
+
subtree: true,
|
|
210
|
+
attributes: true,
|
|
211
|
+
attributeFilter: [
|
|
212
|
+
"disabled",
|
|
213
|
+
"hidden"
|
|
214
|
+
]
|
|
215
|
+
});
|
|
216
|
+
return ()=>observer.disconnect();
|
|
217
|
+
});
|
|
139
218
|
return /*#__PURE__*/ jsx(TabsContext.Provider, {
|
|
140
219
|
value: {
|
|
141
220
|
api,
|
|
@@ -151,9 +230,20 @@ function Tabs({ id, defaultValue, value, orientation = "horizontal", dir = "ltr"
|
|
|
151
230
|
className: styles.root({
|
|
152
231
|
className
|
|
153
232
|
}),
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
233
|
+
...mergeProps(props, api.getRootProps()),
|
|
234
|
+
onBlurCapture: (event)=>{
|
|
235
|
+
props.onBlurCapture?.(event);
|
|
236
|
+
if (event.relatedTarget && !event.currentTarget.contains(event.relatedTarget)) lastFocused.current = null;
|
|
237
|
+
},
|
|
238
|
+
onFocusCapture: (event)=>{
|
|
239
|
+
props.onFocusCapture?.(event);
|
|
240
|
+
lastFocused.current = event.target;
|
|
241
|
+
},
|
|
242
|
+
ref: (node)=>{
|
|
243
|
+
rootElement.current = node;
|
|
244
|
+
if ("function" == typeof ref) return ref(node);
|
|
245
|
+
if (ref) ref.current = node;
|
|
246
|
+
},
|
|
157
247
|
children: children
|
|
158
248
|
})
|
|
159
249
|
});
|
|
@@ -165,25 +255,46 @@ Tabs.List = function({ children, ref, className, ...props }) {
|
|
|
165
255
|
className
|
|
166
256
|
}),
|
|
167
257
|
ref: ref,
|
|
168
|
-
...api.getListProps(),
|
|
169
|
-
|
|
258
|
+
...mergeProps(api.getListProps(), props),
|
|
259
|
+
role: "tablist",
|
|
170
260
|
children: children
|
|
171
261
|
});
|
|
172
262
|
};
|
|
173
263
|
Tabs.Trigger = function({ value, disabled, children, ref, className, size = "current", theme = "unstyled", type = "button", ...props }) {
|
|
174
264
|
const { api, contentValues, styles } = useTabsContext();
|
|
175
|
-
const triggerProps = mergeProps(
|
|
265
|
+
const triggerProps = mergeProps(api.getTriggerProps({
|
|
176
266
|
value,
|
|
177
267
|
disabled
|
|
178
|
-
}));
|
|
268
|
+
}), props);
|
|
269
|
+
const triggerElement = useRef(null);
|
|
270
|
+
useEffect(()=>{
|
|
271
|
+
const trigger = triggerElement.current;
|
|
272
|
+
const list = trigger?.closest('[data-part="list"]');
|
|
273
|
+
if (!(trigger && list)) return;
|
|
274
|
+
const scrollValue = list.contains(list.ownerDocument.activeElement) ? api.focusedValue ?? api.value : api.value;
|
|
275
|
+
if (scrollValue !== value) return;
|
|
276
|
+
const row = trigger.getBoundingClientRect();
|
|
277
|
+
const viewport = list.getBoundingClientRect();
|
|
278
|
+
if (row.left < viewport.left) list.scrollLeft += row.left - viewport.left;
|
|
279
|
+
else if (row.right > viewport.right) list.scrollLeft += row.right - viewport.right;
|
|
280
|
+
}, [
|
|
281
|
+
api.value,
|
|
282
|
+
api.focusedValue,
|
|
283
|
+
value
|
|
284
|
+
]);
|
|
179
285
|
return /*#__PURE__*/ jsx(Button, {
|
|
180
286
|
...triggerProps,
|
|
181
287
|
"aria-controls": contentValues.has(value) ? triggerProps["aria-controls"] : void 0,
|
|
182
288
|
className: styles.trigger({
|
|
183
289
|
className
|
|
184
290
|
}),
|
|
185
|
-
|
|
186
|
-
|
|
291
|
+
composition: true,
|
|
292
|
+
"data-disabled": disabled ? "" : void 0,
|
|
293
|
+
ref: (node)=>{
|
|
294
|
+
triggerElement.current = node;
|
|
295
|
+
if ("function" == typeof ref) return ref(node);
|
|
296
|
+
if (ref) ref.current = node;
|
|
297
|
+
},
|
|
187
298
|
size: size,
|
|
188
299
|
theme: theme,
|
|
189
300
|
type: type,
|
|
@@ -215,15 +326,100 @@ Tabs.Content = function({ value, children, ref, className, ...props }) {
|
|
|
215
326
|
children: children
|
|
216
327
|
});
|
|
217
328
|
};
|
|
329
|
+
function measureTabIndicator(indicator, list) {
|
|
330
|
+
const selected = Array.from(list.querySelectorAll('[role="tab"][aria-selected="true"]')).find((trigger)=>trigger.closest('[role="tablist"]') === list);
|
|
331
|
+
if (!selected) return null;
|
|
332
|
+
const parent = indicator.offsetParent ?? list;
|
|
333
|
+
const parentBox = parent.getBoundingClientRect();
|
|
334
|
+
const box = selected.getBoundingClientRect();
|
|
335
|
+
const scaleX = parent.offsetWidth ? parentBox.width / parent.offsetWidth : 1;
|
|
336
|
+
const scaleY = parent.offsetHeight ? parentBox.height / parent.offsetHeight : 1;
|
|
337
|
+
return {
|
|
338
|
+
x: (box.left - parentBox.left) / scaleX - parent.clientLeft + parent.scrollLeft,
|
|
339
|
+
y: (box.top - parentBox.top) / scaleY - parent.clientTop + parent.scrollTop,
|
|
340
|
+
width: box.width / scaleX,
|
|
341
|
+
height: box.height / scaleY
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
function useTabIndicatorRect(ref) {
|
|
345
|
+
const [rect, setRect] = useState(null);
|
|
346
|
+
useLayoutEffect(()=>{
|
|
347
|
+
const indicator = ref.current;
|
|
348
|
+
const list = indicator?.closest('[role="tablist"]');
|
|
349
|
+
if (!(indicator && list)) return;
|
|
350
|
+
let frame = 0;
|
|
351
|
+
const measure = ()=>{
|
|
352
|
+
const next = measureTabIndicator(indicator, list);
|
|
353
|
+
setRect((previous)=>previous?.x === next?.x && previous?.y === next?.y && previous?.width === next?.width && previous?.height === next?.height ? previous : next);
|
|
354
|
+
};
|
|
355
|
+
const schedule = ()=>{
|
|
356
|
+
cancelAnimationFrame(frame);
|
|
357
|
+
frame = requestAnimationFrame(measure);
|
|
358
|
+
};
|
|
359
|
+
const resize = new ResizeObserver(schedule);
|
|
360
|
+
const observeSizes = ()=>{
|
|
361
|
+
resize.disconnect();
|
|
362
|
+
resize.observe(list);
|
|
363
|
+
for (const trigger of list.querySelectorAll('[role="tab"]'))if (trigger.closest('[role="tablist"]') === list) resize.observe(trigger);
|
|
364
|
+
};
|
|
365
|
+
const mutation = new MutationObserver((records)=>{
|
|
366
|
+
const changes = records.filter((record)=>!indicator.contains(record.target));
|
|
367
|
+
if (changes.some((record)=>"childList" === record.type)) observeSizes();
|
|
368
|
+
if (changes.length) schedule();
|
|
369
|
+
});
|
|
370
|
+
mutation.observe(list, {
|
|
371
|
+
subtree: true,
|
|
372
|
+
childList: true,
|
|
373
|
+
attributes: true,
|
|
374
|
+
attributeFilter: [
|
|
375
|
+
"aria-selected",
|
|
376
|
+
"class",
|
|
377
|
+
"style",
|
|
378
|
+
"dir",
|
|
379
|
+
"data-orientation"
|
|
380
|
+
]
|
|
381
|
+
});
|
|
382
|
+
observeSizes();
|
|
383
|
+
list.addEventListener("scroll", schedule, {
|
|
384
|
+
passive: true
|
|
385
|
+
});
|
|
386
|
+
window.addEventListener("resize", schedule);
|
|
387
|
+
measure();
|
|
388
|
+
return ()=>{
|
|
389
|
+
cancelAnimationFrame(frame);
|
|
390
|
+
resize.disconnect();
|
|
391
|
+
mutation.disconnect();
|
|
392
|
+
list.removeEventListener("scroll", schedule);
|
|
393
|
+
window.removeEventListener("resize", schedule);
|
|
394
|
+
};
|
|
395
|
+
}, [
|
|
396
|
+
ref
|
|
397
|
+
]);
|
|
398
|
+
return rect;
|
|
399
|
+
}
|
|
218
400
|
Tabs.Indicator = function({ ref, className, ...props }) {
|
|
219
401
|
const { api, styles } = useTabsContext();
|
|
402
|
+
const indicatorElement = useRef(null);
|
|
403
|
+
const rect = useTabIndicatorRect(indicatorElement);
|
|
404
|
+
const { style: _zagStyle, onTransitionEnd: _zagTransitionEnd, ...indicatorProps } = api.getIndicatorProps();
|
|
220
405
|
return /*#__PURE__*/ jsx("div", {
|
|
221
406
|
className: styles.indicator({
|
|
222
407
|
className
|
|
223
408
|
}),
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
409
|
+
...indicatorProps,
|
|
410
|
+
hidden: !rect,
|
|
411
|
+
style: {
|
|
412
|
+
"--tabs-indicator-left": `${rect?.x ?? 0}px`,
|
|
413
|
+
"--tabs-indicator-top": `${rect?.y ?? 0}px`,
|
|
414
|
+
"--tabs-indicator-width": `${rect?.width ?? 0}px`,
|
|
415
|
+
"--tabs-indicator-height": `${rect?.height ?? 0}px`
|
|
416
|
+
},
|
|
417
|
+
...props,
|
|
418
|
+
ref: (node)=>{
|
|
419
|
+
indicatorElement.current = node;
|
|
420
|
+
if ("function" == typeof ref) return ref(node);
|
|
421
|
+
if (ref) ref.current = node;
|
|
422
|
+
}
|
|
227
423
|
});
|
|
228
424
|
};
|
|
229
425
|
Tabs.displayName = "Tabs";
|
package/dist/molecules/toast.js
CHANGED
|
@@ -1,46 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { useId } from "react";
|
|
3
|
+
import { normalizeProps, useMachine } from "@zag-js/react";
|
|
4
|
+
import { createContext, useContext, useEffect, useId, useLayoutEffect, useState } from "react";
|
|
5
|
+
import { createPortal } from "react-dom";
|
|
4
6
|
import { ActionIcon } from "../atoms/action-icon.js";
|
|
7
|
+
import { Button } from "../atoms/button.js";
|
|
8
|
+
import { useActiveModalContainer } from "../internal/overlay-portal.js";
|
|
5
9
|
import { tv } from "../utils.js";
|
|
6
10
|
import * as __rspack_external__zag_js_toast_856c971b from "@zag-js/toast";
|
|
7
11
|
const toastVariants = tv({
|
|
8
12
|
slots: {
|
|
9
13
|
root: [
|
|
10
14
|
"relative flex flex-col rounded-toast-root",
|
|
11
|
-
"border-(length:--border-width-toast) bg-toast-bg shadow-lg",
|
|
12
|
-
"
|
|
13
|
-
"data-[type=error]:border-toast-error
|
|
14
|
-
"data-[type=success]:border-toast-success
|
|
15
|
-
"data-[type=info]:border-toast-info
|
|
16
|
-
"data-[type=warning]:border-toast-warning
|
|
15
|
+
"border-(length:--border-width-toast) bg-toast-bg-surface shadow-lg",
|
|
16
|
+
"toast-responsive-width min-w-0 p-toast-root",
|
|
17
|
+
"data-[type=error]:border-toast-border-error data-[type=error]:bg-toast-bg-surface",
|
|
18
|
+
"data-[type=success]:border-toast-border-success data-[type=success]:bg-toast-bg-surface",
|
|
19
|
+
"data-[type=info]:border-toast-border-info data-[type=info]:bg-toast-bg-surface",
|
|
20
|
+
"data-[type=warning]:border-toast-border-warning data-[type=warning]:bg-toast-bg-surface",
|
|
17
21
|
"translate-x-(--x) translate-y-(--y)",
|
|
18
22
|
"scale-(--scale) opacity-(--opacity)",
|
|
19
23
|
"z-(--z-index) h-(--height)",
|
|
20
24
|
"will-change-[translate,opacity,scale]",
|
|
21
25
|
"transition-[translate,scale,opacity] duration-400 motion-reduce:transition-none"
|
|
22
26
|
],
|
|
23
|
-
group: "relative flex flex-col",
|
|
24
|
-
|
|
27
|
+
group: "pointer-events-auto relative flex flex-col",
|
|
28
|
+
viewport: "toast-notification-viewport",
|
|
29
|
+
header: "relative flex items-start gap-toast-content text-toast-title-size",
|
|
30
|
+
iconFrame: "flex h-toast-title-line shrink-0 items-center",
|
|
25
31
|
icon: [
|
|
26
32
|
"flex-shrink-0 text-toast-icon",
|
|
27
|
-
"data-[type=
|
|
28
|
-
"data-[type=
|
|
29
|
-
"data-[type=
|
|
30
|
-
"data-[type=
|
|
33
|
+
"data-[type=loading]:token-icon-spinner data-[type=loading]:text-toast-fg-readable",
|
|
34
|
+
"data-[type=error]:token-icon-toast-error data-[type=error]:text-toast-fg-error",
|
|
35
|
+
"data-[type=success]:token-icon-toast-success data-[type=success]:text-toast-fg-success",
|
|
36
|
+
"data-[type=info]:token-icon-toast-info data-[type=info]:text-toast-fg-info",
|
|
37
|
+
"data-[type=warning]:token-icon-toast-warning data-[type=warning]:text-toast-fg-warning"
|
|
31
38
|
],
|
|
32
39
|
title: [
|
|
33
|
-
"font-toast-title text-toast-fg text-toast-title",
|
|
34
|
-
"data-[type=error]:text-toast-
|
|
35
|
-
"data-[type=success]:text-toast-
|
|
36
|
-
"data-[type=info]:text-toast-
|
|
37
|
-
"data-[type=warning]:text-toast-
|
|
40
|
+
"min-w-0 flex-1 break-words font-toast-title text-toast-fg-readable text-toast-title-size",
|
|
41
|
+
"data-[type=error]:text-toast-fg-readable",
|
|
42
|
+
"data-[type=success]:text-toast-fg-readable",
|
|
43
|
+
"data-[type=info]:text-toast-fg-readable",
|
|
44
|
+
"data-[type=warning]:text-toast-fg-readable"
|
|
38
45
|
],
|
|
39
46
|
description: [
|
|
40
|
-
"mt-toast-description text-toast-description text-toast-fg"
|
|
47
|
+
"mt-toast-description break-words text-toast-description-size text-toast-fg-readable"
|
|
41
48
|
],
|
|
42
49
|
closeButton: [
|
|
43
|
-
"ms-auto"
|
|
50
|
+
"ms-auto self-start"
|
|
44
51
|
]
|
|
45
52
|
}
|
|
46
53
|
});
|
|
@@ -53,28 +60,38 @@ function Toast({ actor, index, parent, placement }) {
|
|
|
53
60
|
};
|
|
54
61
|
const service = useMachine(__rspack_external__zag_js_toast_856c971b.machine, composedProps);
|
|
55
62
|
const api = __rspack_external__zag_js_toast_856c971b.connect(service, normalizeProps);
|
|
56
|
-
const
|
|
63
|
+
const rootProps = api.getRootProps();
|
|
64
|
+
const onKeyDown = rootProps.onKeyDown;
|
|
65
|
+
rootProps.onKeyDown = (event)=>{
|
|
66
|
+
if ("Escape" === event.key && !api.closable) return;
|
|
67
|
+
onKeyDown?.(event);
|
|
68
|
+
};
|
|
69
|
+
const { root, header, iconFrame, icon, title, description, closeButton } = toastVariants();
|
|
57
70
|
return /*#__PURE__*/ jsxs("div", {
|
|
58
71
|
className: root(),
|
|
59
|
-
...
|
|
72
|
+
...rootProps,
|
|
60
73
|
children: [
|
|
61
74
|
/*#__PURE__*/ jsx("span", {
|
|
62
75
|
...api.getGhostBeforeProps()
|
|
63
76
|
}),
|
|
64
77
|
/*#__PURE__*/ jsxs("div", {
|
|
65
78
|
className: header(),
|
|
66
|
-
...api.getTitleProps(),
|
|
67
79
|
children: [
|
|
68
80
|
/*#__PURE__*/ jsx("span", {
|
|
69
|
-
|
|
70
|
-
|
|
81
|
+
"aria-hidden": "true",
|
|
82
|
+
className: iconFrame(),
|
|
83
|
+
children: /*#__PURE__*/ jsx("span", {
|
|
84
|
+
className: icon(),
|
|
85
|
+
"data-type": api.type
|
|
86
|
+
})
|
|
71
87
|
}),
|
|
72
88
|
/*#__PURE__*/ jsx("div", {
|
|
73
89
|
className: title(),
|
|
90
|
+
...api.getTitleProps(),
|
|
74
91
|
"data-type": api.type,
|
|
75
|
-
children:
|
|
92
|
+
children: api.title
|
|
76
93
|
}),
|
|
77
|
-
/*#__PURE__*/ jsx(ActionIcon, {
|
|
94
|
+
api.closable && /*#__PURE__*/ jsx(ActionIcon, {
|
|
78
95
|
className: closeButton(),
|
|
79
96
|
icon: "token-icon-toast-close",
|
|
80
97
|
size: "sm",
|
|
@@ -84,43 +101,121 @@ function Toast({ actor, index, parent, placement }) {
|
|
|
84
101
|
})
|
|
85
102
|
]
|
|
86
103
|
}),
|
|
87
|
-
/*#__PURE__*/ jsx("div", {
|
|
104
|
+
api.description && /*#__PURE__*/ jsx("div", {
|
|
88
105
|
className: description(),
|
|
89
106
|
...api.getDescriptionProps(),
|
|
90
107
|
"data-type": api.type,
|
|
91
108
|
children: api.description
|
|
92
109
|
}),
|
|
110
|
+
actor.action && /*#__PURE__*/ jsx(Button, {
|
|
111
|
+
className: "mt-toast-description self-start",
|
|
112
|
+
size: "sm",
|
|
113
|
+
theme: "outlined",
|
|
114
|
+
variant: "secondary",
|
|
115
|
+
...api.getActionTriggerProps(),
|
|
116
|
+
children: actor.action.label
|
|
117
|
+
}),
|
|
93
118
|
/*#__PURE__*/ jsx("span", {
|
|
94
119
|
...api.getGhostAfterProps()
|
|
95
120
|
})
|
|
96
121
|
]
|
|
97
122
|
});
|
|
98
123
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
124
|
+
function createToaster(options = {}) {
|
|
125
|
+
return __rspack_external__zag_js_toast_856c971b.createStore({
|
|
126
|
+
placement: "bottom-end",
|
|
127
|
+
gap: 16,
|
|
128
|
+
offsets: "24px",
|
|
129
|
+
...options
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
const ToastContext = /*#__PURE__*/ createContext(null);
|
|
133
|
+
function ToastProvider({ children }) {
|
|
134
|
+
const [store] = useState(()=>createToaster());
|
|
135
|
+
useEffect(()=>()=>store.remove(), [
|
|
136
|
+
store
|
|
137
|
+
]);
|
|
138
|
+
return /*#__PURE__*/ jsxs(ToastContext.Provider, {
|
|
139
|
+
value: store,
|
|
140
|
+
children: [
|
|
141
|
+
children,
|
|
142
|
+
/*#__PURE__*/ jsx(Toaster, {
|
|
143
|
+
store: store
|
|
144
|
+
})
|
|
145
|
+
]
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
const toaster = createToaster();
|
|
149
|
+
const scopedGroupMachine = {
|
|
150
|
+
...__rspack_external__zag_js_toast_856c971b.group.machine,
|
|
151
|
+
implementations: {
|
|
152
|
+
...__rspack_external__zag_js_toast_856c971b.group.machine.implementations,
|
|
153
|
+
actions: {
|
|
154
|
+
...__rspack_external__zag_js_toast_856c971b.group.machine.implementations?.actions,
|
|
155
|
+
focusRegionEl (params) {
|
|
156
|
+
if (0 === params.context.get("toasts").length) return;
|
|
157
|
+
__rspack_external__zag_js_toast_856c971b.group.machine.implementations?.actions?.focusRegionEl?.({
|
|
158
|
+
...params,
|
|
159
|
+
scope: {
|
|
160
|
+
...params.scope,
|
|
161
|
+
getById: (id)=>params.scope.getById(id.startsWith("toast-group:") ? `toast-group:${params.scope.id}` : id)
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
},
|
|
165
|
+
setDismissableBranch (params) {
|
|
166
|
+
__rspack_external__zag_js_toast_856c971b.group.machine.implementations?.actions?.setDismissableBranch?.({
|
|
167
|
+
...params,
|
|
168
|
+
scope: {
|
|
169
|
+
...params.scope,
|
|
170
|
+
getById: (id)=>params.scope.getById(id.startsWith("toast-group:") ? `toast-group:${params.scope.id}` : id)
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
function Toaster({ store = toaster } = {}) {
|
|
178
|
+
const groupId = useId();
|
|
179
|
+
const modalContainer = useActiveModalContainer();
|
|
180
|
+
const [portalHost, setPortalHost] = useState(null);
|
|
181
|
+
useLayoutEffect(()=>{
|
|
182
|
+
const host = document.createElement("div");
|
|
183
|
+
host.setAttribute("data-live-announcer", "");
|
|
184
|
+
host.popover = "manual";
|
|
185
|
+
host.className = toastVariants().viewport();
|
|
186
|
+
document.body.appendChild(host);
|
|
187
|
+
setPortalHost(host);
|
|
188
|
+
return ()=>host.remove();
|
|
189
|
+
}, []);
|
|
190
|
+
useLayoutEffect(()=>{
|
|
191
|
+
if (portalHost) {
|
|
192
|
+
const parent = modalContainer ?? portalHost.ownerDocument.body;
|
|
193
|
+
parent.appendChild(portalHost);
|
|
194
|
+
portalHost.showPopover();
|
|
195
|
+
}
|
|
196
|
+
}, [
|
|
197
|
+
modalContainer,
|
|
198
|
+
portalHost
|
|
199
|
+
]);
|
|
200
|
+
const service = useMachine(scopedGroupMachine, {
|
|
201
|
+
id: groupId,
|
|
202
|
+
store
|
|
108
203
|
});
|
|
109
204
|
const api = __rspack_external__zag_js_toast_856c971b.group.connect(service, normalizeProps);
|
|
110
205
|
const { group } = toastVariants();
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
});
|
|
206
|
+
if (!portalHost) return null;
|
|
207
|
+
return /*#__PURE__*/ createPortal(/*#__PURE__*/ jsx("div", {
|
|
208
|
+
className: group(),
|
|
209
|
+
...api.getGroupProps(),
|
|
210
|
+
id: `toast-group:${groupId}`,
|
|
211
|
+
children: api.getToasts().map((notification, index)=>/*#__PURE__*/ jsx(Toast, {
|
|
212
|
+
actor: notification,
|
|
213
|
+
index: index,
|
|
214
|
+
parent: service
|
|
215
|
+
}, notification.id))
|
|
216
|
+
}), portalHost);
|
|
122
217
|
}
|
|
123
218
|
function useToast() {
|
|
124
|
-
return toaster;
|
|
219
|
+
return useContext(ToastContext) ?? toaster;
|
|
125
220
|
}
|
|
126
|
-
export { Toast, Toaster, toaster, useToast };
|
|
221
|
+
export { Toast, ToastProvider, Toaster, createToaster, toaster, useToast };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
3
|
import { useId } from "react";
|
|
3
4
|
import { tv } from "../utils.js";
|
|
@@ -9,7 +10,7 @@ const totalsSummaryVariants = tv({
|
|
|
9
10
|
label: "min-w-0 flex-1 break-words",
|
|
10
11
|
value: "min-w-0 flex-1 break-words text-end",
|
|
11
12
|
note: "block text-totals-summary-note-fg text-totals-summary-note-size",
|
|
12
|
-
total: "flex min-w-0 items-baseline justify-between gap-totals-summary-columns border-
|
|
13
|
+
total: "border-t-(length:--border-width-totals-summary-divider) flex min-w-0 items-baseline justify-between gap-totals-summary-columns border-totals-summary-divider-border pt-totals-summary-total font-totals-summary-total text-totals-summary-total-size",
|
|
13
14
|
footer: "text-totals-summary-note-fg text-totals-summary-note-size",
|
|
14
15
|
actions: "flex flex-col gap-totals-summary-actions",
|
|
15
16
|
pending: "text-totals-summary-note-fg text-totals-summary-note-size"
|