@rojaostudio/ds 1.0.1 → 2.0.0-next.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 +75 -13
- package/dist/compat/generate.d.ts +0 -1
- package/dist/components/accordion.d.ts +30 -20
- package/dist/components/accordion.js +31 -87
- package/dist/components/action-bar.d.ts +24 -0
- package/dist/components/action-bar.js +55 -0
- package/dist/components/alert-dialog.d.ts +31 -0
- package/dist/components/alert-dialog.js +43 -0
- package/dist/components/alert.d.ts +31 -19
- package/dist/components/alert.js +74 -65
- package/dist/components/attachment.d.ts +37 -0
- package/dist/components/attachment.js +76 -0
- package/dist/components/avatar.d.ts +43 -36
- package/dist/components/avatar.js +59 -83
- package/dist/components/badge.d.ts +30 -41
- package/dist/components/badge.js +16 -106
- package/dist/components/banner.d.ts +27 -0
- package/dist/components/banner.js +66 -0
- package/dist/components/benefits.d.ts +30 -0
- package/dist/components/benefits.js +32 -0
- package/dist/components/breadcrumb.d.ts +25 -18
- package/dist/components/breadcrumb.js +40 -48
- package/dist/components/browser.d.ts +18 -0
- package/dist/components/browser.js +32 -0
- package/dist/components/bubble.d.ts +29 -0
- package/dist/components/bubble.js +33 -0
- package/dist/components/button-group.d.ts +19 -0
- package/dist/components/button-group.js +20 -0
- package/dist/components/button.d.ts +47 -20
- package/dist/components/button.js +51 -107
- package/dist/components/calendar.d.ts +29 -0
- package/dist/components/calendar.js +149 -0
- package/dist/components/card.d.ts +47 -19
- package/dist/components/card.js +38 -38
- package/dist/components/carousel.d.ts +28 -0
- package/dist/components/carousel.js +130 -0
- package/dist/components/chart.d.ts +49 -0
- package/dist/components/chart.js +258 -0
- package/dist/components/checkbox-group.d.ts +16 -0
- package/dist/components/checkbox-group.js +13 -0
- package/dist/components/checkbox.d.ts +25 -10
- package/dist/components/checkbox.js +86 -67
- package/dist/components/chip-input.d.ts +46 -20
- package/dist/components/chip-input.js +171 -158
- package/dist/components/chip.d.ts +28 -0
- package/dist/components/chip.js +73 -0
- package/dist/components/choice-card.d.ts +10 -13
- package/dist/components/choice-card.js +11 -56
- package/dist/components/choice-carousel.d.ts +9 -0
- package/dist/components/choice-carousel.js +67 -78
- package/dist/components/choice-preview-card.d.ts +10 -20
- package/dist/components/choice-preview-card.js +13 -30
- package/dist/components/color-input.d.ts +36 -11
- package/dist/components/color-input.js +139 -61
- package/dist/components/combobox.d.ts +60 -57
- package/dist/components/combobox.js +215 -196
- package/dist/components/command.d.ts +58 -0
- package/dist/components/command.js +177 -0
- package/dist/components/contact.d.ts +23 -0
- package/dist/components/contact.js +32 -0
- package/dist/components/context-menu.d.ts +34 -26
- package/dist/components/context-menu.js +43 -66
- package/dist/components/copy-field.d.ts +10 -5
- package/dist/components/copy-field.js +25 -27
- package/dist/components/currency-input.d.ts +25 -11
- package/dist/components/currency-input.js +39 -67
- package/dist/components/danger-zone.d.ts +10 -1
- package/dist/components/danger-zone.js +20 -14
- package/dist/components/data-table-header.d.ts +13 -2
- package/dist/components/data-table-header.js +143 -169
- package/dist/components/date-picker.d.ts +31 -32
- package/dist/components/date-picker.js +126 -242
- package/dist/components/delta.d.ts +26 -0
- package/dist/components/delta.js +24 -0
- package/dist/components/dialog.d.ts +21 -0
- package/dist/components/dialog.js +16 -0
- package/dist/components/drawer.d.ts +15 -23
- package/dist/components/drawer.js +56 -76
- package/dist/components/dropdown-menu.d.ts +63 -0
- package/dist/components/dropdown-menu.js +62 -0
- package/dist/components/dropzone.d.ts +10 -4
- package/dist/components/dropzone.js +30 -55
- package/dist/components/empty.d.ts +29 -0
- package/dist/components/empty.js +42 -0
- package/dist/components/fab.d.ts +29 -6
- package/dist/components/fab.js +51 -39
- package/dist/components/faq.d.ts +21 -0
- package/dist/components/faq.js +24 -0
- package/dist/components/file-input.d.ts +56 -0
- package/dist/components/file-input.js +244 -0
- package/dist/components/filter-chip.d.ts +34 -47
- package/dist/components/filter-chip.js +61 -57
- package/dist/components/floating-stepper.d.ts +7 -18
- package/dist/components/floating-stepper.js +17 -35
- package/dist/components/footer.d.ts +36 -0
- package/dist/components/footer.js +38 -0
- package/dist/components/form-actions.d.ts +28 -0
- package/dist/components/form-actions.js +24 -0
- package/dist/components/google-account-chooser.d.ts +25 -0
- package/dist/components/google-account-chooser.js +44 -0
- package/dist/components/google-button.d.ts +26 -0
- package/dist/components/google-button.js +38 -0
- package/dist/components/google-consent.d.ts +23 -0
- package/dist/components/google-consent.js +28 -0
- package/dist/components/google-sign-in.d.ts +26 -0
- package/dist/components/google-sign-in.js +36 -0
- package/dist/components/hover-card.d.ts +30 -0
- package/dist/components/hover-card.js +55 -0
- package/dist/components/icon-button.d.ts +41 -11
- package/dist/components/icon-button.js +47 -61
- package/dist/components/image-crop-modal.d.ts +3 -3
- package/dist/components/image-crop-modal.js +66 -52
- package/dist/components/image-upload.d.ts +21 -29
- package/dist/components/image-upload.js +59 -219
- package/dist/components/index.d.ts +105 -49
- package/dist/components/index.js +190 -68
- package/dist/components/input-otp.d.ts +35 -0
- package/dist/components/input-otp.js +119 -0
- package/dist/components/input.d.ts +23 -17
- package/dist/components/input.js +103 -108
- package/dist/components/insight-card.d.ts +25 -9
- package/dist/components/insight-card.js +45 -19
- package/dist/components/internal/announce.d.ts +3 -0
- package/dist/components/internal/announce.js +20 -0
- package/dist/components/internal/block.d.ts +15 -0
- package/dist/components/internal/block.js +14 -0
- package/dist/components/internal/button.d.ts +23 -0
- package/dist/components/internal/button.js +30 -0
- package/dist/components/internal/choice-card.d.ts +52 -0
- package/dist/components/internal/choice-card.js +117 -0
- package/dist/components/internal/choice.d.ts +25 -0
- package/dist/components/internal/choice.js +44 -0
- package/dist/components/internal/dates.d.ts +17 -0
- package/dist/components/internal/dates.js +59 -0
- package/dist/components/internal/field.d.ts +66 -0
- package/dist/components/internal/field.js +105 -0
- package/dist/components/internal/fieldset.d.ts +25 -0
- package/dist/components/internal/fieldset.js +56 -0
- package/dist/components/internal/focus-after.d.ts +3 -0
- package/dist/components/internal/focus-after.js +13 -0
- package/dist/components/internal/google.d.ts +47 -0
- package/dist/components/internal/google.js +73 -0
- package/dist/components/internal/icons.d.ts +108 -0
- package/dist/components/internal/icons.js +316 -0
- package/dist/components/internal/menu.d.ts +16 -0
- package/dist/components/internal/menu.js +14 -0
- package/dist/components/internal/modal.d.ts +50 -0
- package/dist/components/internal/modal.js +85 -0
- package/dist/components/internal/option-content.d.ts +10 -0
- package/dist/components/internal/option-content.js +13 -0
- package/dist/components/internal/radio-context.d.ts +16 -0
- package/dist/components/internal/radio-context.js +6 -0
- package/dist/components/internal/toggle.d.ts +7 -0
- package/dist/components/internal/toggle.js +13 -0
- package/dist/components/internal/use-listbox.d.ts +56 -0
- package/dist/components/internal/use-listbox.js +69 -0
- package/dist/components/internal/whatsapp.d.ts +8 -0
- package/dist/components/internal/whatsapp.js +12 -0
- package/dist/components/item.d.ts +32 -0
- package/dist/components/item.js +35 -0
- package/dist/components/kbd.d.ts +17 -0
- package/dist/components/kbd.js +18 -0
- package/dist/components/listbox.d.ts +34 -0
- package/dist/components/listbox.js +114 -0
- package/dist/components/marker.d.ts +24 -0
- package/dist/components/marker.js +28 -0
- package/dist/components/media-tile.d.ts +17 -14
- package/dist/components/media-tile.js +19 -24
- package/dist/components/message-scroller.d.ts +20 -0
- package/dist/components/message-scroller.js +108 -0
- package/dist/components/message.d.ts +33 -0
- package/dist/components/message.js +23 -0
- package/dist/components/navigation-menu.d.ts +42 -0
- package/dist/components/navigation-menu.js +30 -0
- package/dist/components/newsletter.d.ts +27 -0
- package/dist/components/newsletter.js +75 -0
- package/dist/components/number-input.d.ts +60 -0
- package/dist/components/number-input.js +234 -0
- package/dist/components/option-tile.d.ts +20 -19
- package/dist/components/option-tile.js +52 -131
- package/dist/components/page-header.d.ts +31 -0
- package/dist/components/page-header.js +25 -0
- package/dist/components/page-shell.d.ts +11 -1
- package/dist/components/page-shell.js +8 -27
- package/dist/components/page-skeleton.d.ts +15 -21
- package/dist/components/page-skeleton.js +37 -4
- package/dist/components/pagination.d.ts +32 -22
- package/dist/components/pagination.js +83 -76
- package/dist/components/password-input.d.ts +26 -0
- package/dist/components/password-input.js +112 -0
- package/dist/components/phone-input.d.ts +12 -8
- package/dist/components/phone-input.js +77 -47
- package/dist/components/phone.d.ts +27 -0
- package/dist/components/phone.js +35 -0
- package/dist/components/popover.d.ts +25 -36
- package/dist/components/popover.js +32 -129
- package/dist/components/pricing-card.d.ts +9 -25
- package/dist/components/pricing-card.js +9 -25
- package/dist/components/pricing.d.ts +48 -0
- package/dist/components/pricing.js +64 -0
- package/dist/components/progress.d.ts +30 -0
- package/dist/components/progress.js +57 -0
- package/dist/components/qr-display.d.ts +11 -6
- package/dist/components/qr-display.js +8 -19
- package/dist/components/questionnaire.d.ts +42 -0
- package/dist/components/questionnaire.js +107 -0
- package/dist/components/radio-group.d.ts +21 -0
- package/dist/components/radio-group.js +40 -0
- package/dist/components/radio.d.ts +15 -29
- package/dist/components/radio.js +46 -87
- package/dist/components/row-actions.d.ts +5 -0
- package/dist/components/row-actions.js +57 -56
- package/dist/components/saving-bar-context.d.ts +0 -5
- package/dist/components/saving-bar-context.js +16 -34
- package/dist/components/saving-bar.d.ts +26 -11
- package/dist/components/saving-bar.js +53 -65
- package/dist/components/section-card.d.ts +18 -4
- package/dist/components/section-card.js +26 -39
- package/dist/components/section-header.d.ts +8 -12
- package/dist/components/section-header.js +7 -2
- package/dist/components/select.d.ts +44 -16
- package/dist/components/select.js +85 -135
- package/dist/components/selectable-card.d.ts +11 -19
- package/dist/components/selectable-card.js +4 -21
- package/dist/components/separator.d.ts +20 -0
- package/dist/components/separator.js +19 -0
- package/dist/components/setting-row.d.ts +11 -15
- package/dist/components/setting-row.js +11 -14
- package/dist/components/settings-list.d.ts +10 -12
- package/dist/components/settings-list.js +9 -17
- package/dist/components/sheet.d.ts +21 -0
- package/dist/components/sheet.js +16 -0
- package/dist/components/sidebar.d.ts +79 -0
- package/dist/components/sidebar.js +111 -0
- package/dist/components/skeleton.d.ts +14 -20
- package/dist/components/skeleton.js +8 -36
- package/dist/components/slider.d.ts +21 -23
- package/dist/components/slider.js +65 -56
- package/dist/components/sparkline.d.ts +19 -0
- package/dist/components/sparkline.js +32 -0
- package/dist/components/spinner.d.ts +16 -8
- package/dist/components/spinner.js +35 -32
- package/dist/components/star-rating.d.ts +22 -0
- package/dist/components/star-rating.js +25 -0
- package/dist/components/stat.d.ts +33 -0
- package/dist/components/stat.js +29 -0
- package/dist/components/status.d.ts +27 -0
- package/dist/components/status.js +34 -0
- package/dist/components/step-progress.d.ts +13 -6
- package/dist/components/step-progress.js +20 -17
- package/dist/components/summary-bar.d.ts +20 -20
- package/dist/components/summary-bar.js +13 -50
- package/dist/components/switch.d.ts +20 -0
- package/dist/components/switch.js +46 -0
- package/dist/components/table.d.ts +56 -17
- package/dist/components/table.js +65 -59
- package/dist/components/tabs.d.ts +67 -0
- package/dist/components/tabs.js +56 -0
- package/dist/components/testimonial.d.ts +30 -0
- package/dist/components/testimonial.js +36 -0
- package/dist/components/textarea.d.ts +11 -16
- package/dist/components/textarea.js +55 -75
- package/dist/components/tile.d.ts +24 -0
- package/dist/components/tile.js +21 -0
- package/dist/components/time-picker.d.ts +40 -25
- package/dist/components/time-picker.js +191 -189
- package/dist/components/toast.d.ts +63 -0
- package/dist/components/toast.js +132 -0
- package/dist/components/toggle-card-compact.d.ts +15 -5
- package/dist/components/toggle-card-compact.js +22 -81
- package/dist/components/toggle-card.d.ts +11 -2
- package/dist/components/toggle-card.js +9 -70
- package/dist/components/toggle-group.d.ts +21 -59
- package/dist/components/toggle-group.js +31 -74
- package/dist/components/toggle.d.ts +19 -9
- package/dist/components/toggle.js +20 -55
- package/dist/components/tooltip.d.ts +25 -12
- package/dist/components/tooltip.js +16 -84
- package/dist/components/top-navigation.d.ts +33 -0
- package/dist/components/top-navigation.js +85 -0
- package/dist/components/typing-indicator.d.ts +6 -0
- package/dist/components/typing-indicator.js +3 -21
- package/dist/components/whatsapp-chat.d.ts +28 -0
- package/dist/components/whatsapp-chat.js +95 -0
- package/dist/components/whatsapp-message.d.ts +22 -0
- package/dist/components/whatsapp-message.js +34 -0
- package/dist/components/whatsapp-notification.d.ts +27 -0
- package/dist/components/whatsapp-notification.js +73 -0
- package/dist/components/whatsapp-template.d.ts +42 -0
- package/dist/components/whatsapp-template.js +69 -0
- package/dist/icons/index.d.ts +2 -0
- package/dist/icons/index.js +2 -0
- package/dist/icons/pix.d.ts +16 -0
- package/dist/icons/pix.js +29 -0
- package/dist/targets/native/components/accordion.js +31 -25
- package/dist/targets/native/components/alert.js +22 -16
- package/dist/targets/native/components/avatar.js +36 -29
- package/dist/targets/native/components/badge.js +4 -3
- package/dist/targets/native/components/button.js +11 -4
- package/dist/targets/native/components/card.js +2 -1
- package/dist/targets/native/components/checkbox.js +18 -15
- package/dist/targets/native/components/chips.js +19 -16
- package/dist/targets/native/components/choice-card.js +29 -23
- package/dist/targets/native/components/context-menu.js +13 -9
- package/dist/targets/native/components/currency-input.js +28 -25
- package/dist/targets/native/components/danger-zone.js +10 -4
- package/dist/targets/native/components/date-picker.js +86 -70
- package/dist/targets/native/components/divider.js +3 -2
- package/dist/targets/native/components/empty-state.js +6 -1
- package/dist/targets/native/components/fab.js +32 -26
- package/dist/targets/native/components/filter-chip.js +9 -8
- package/dist/targets/native/components/form-field.js +20 -10
- package/dist/targets/native/components/form-screen.js +50 -45
- package/dist/targets/native/components/google-icon.js +31 -25
- package/dist/targets/native/components/icon-button.js +6 -4
- package/dist/targets/native/components/icon.js +2 -1
- package/dist/targets/native/components/image-upload.js +59 -50
- package/dist/targets/native/components/index.d.ts +0 -2
- package/dist/targets/native/components/index.js +0 -4
- package/dist/targets/native/components/input.js +41 -34
- package/dist/targets/native/components/list-item.js +29 -23
- package/dist/targets/native/components/menu.js +12 -10
- package/dist/targets/native/components/modal.js +41 -32
- package/dist/targets/native/components/radio.js +19 -16
- package/dist/targets/native/components/search.js +41 -38
- package/dist/targets/native/components/select.js +71 -63
- package/dist/targets/native/components/sheet.js +36 -30
- package/dist/targets/native/components/skeleton.js +6 -5
- package/dist/targets/native/components/slider.js +51 -43
- package/dist/targets/native/components/spinner.js +2 -1
- package/dist/targets/native/components/stepper.js +14 -9
- package/dist/targets/native/components/switch.js +15 -14
- package/dist/targets/native/components/text.js +2 -1
- package/dist/targets/native/components/textarea.js +2 -1
- package/dist/targets/native/components/theme.js +2 -1
- package/dist/targets/native/components/toaster.js +24 -21
- package/dist/targets/native/index.d.ts +1 -1
- package/dist/targets/native/index.js +1 -3
- package/dist/targets/native/preset.cjs +0 -1
- package/dist/targets/native/theme.css +58 -60
- package/dist/targets/native/theme.d.ts +58 -60
- package/dist/targets/native/theme.js +58 -60
- package/package.json +35 -16
- package/styles/_primitives.generated.css +40 -0
- package/styles/base.css +15 -21
- package/styles/rds/components-styles.css +11365 -0
- package/styles/rds/components.css +993 -0
- package/styles/rds/foundation.css +74 -0
- package/styles/rds/theme.css +261 -0
- package/styles/rds.css +6 -0
- package/styles/themes/rojao.css +46 -53
- package/brand/rojao-black-on-white.png +0 -0
- package/brand/rojao-black.png +0 -0
- package/brand/rojao-white-on-black.png +0 -0
- package/brand/rojao-white.png +0 -0
- package/dist/components/blocker-card.d.ts +0 -42
- package/dist/components/blocker-card.js +0 -45
- package/dist/components/bottom-sheet.d.ts +0 -31
- package/dist/components/bottom-sheet.js +0 -120
- package/dist/components/chat-bubble.d.ts +0 -16
- package/dist/components/chat-bubble.js +0 -55
- package/dist/components/chips.d.ts +0 -22
- package/dist/components/chips.js +0 -94
- package/dist/components/copilot-hint.d.ts +0 -18
- package/dist/components/copilot-hint.js +0 -63
- package/dist/components/divider.d.ts +0 -20
- package/dist/components/divider.js +0 -47
- package/dist/components/empty-state.d.ts +0 -48
- package/dist/components/empty-state.js +0 -91
- package/dist/components/form-card-header.d.ts +0 -13
- package/dist/components/form-card-header.js +0 -8
- package/dist/components/label.d.ts +0 -16
- package/dist/components/label.js +0 -43
- package/dist/components/menu.d.ts +0 -50
- package/dist/components/menu.js +0 -80
- package/dist/components/modal.d.ts +0 -25
- package/dist/components/modal.js +0 -71
- package/dist/components/notice.d.ts +0 -50
- package/dist/components/notice.js +0 -103
- package/dist/components/page-tabs.d.ts +0 -35
- package/dist/components/page-tabs.js +0 -55
- package/dist/components/paywall-banner.d.ts +0 -37
- package/dist/components/paywall-banner.js +0 -42
- package/dist/components/paywall.d.ts +0 -44
- package/dist/components/paywall.js +0 -55
- package/dist/components/phone-frame.d.ts +0 -9
- package/dist/components/phone-frame.js +0 -18
- package/dist/components/pix-icon.d.ts +0 -8
- package/dist/components/pix-icon.js +0 -24
- package/dist/components/search.d.ts +0 -30
- package/dist/components/search.js +0 -81
- package/dist/components/themed.d.ts +0 -36
- package/dist/components/themed.js +0 -22
- package/dist/components/toaster.d.ts +0 -84
- package/dist/components/toaster.js +0 -284
- package/dist/components/use-dismiss.d.ts +0 -9
- package/dist/components/use-dismiss.js +0 -28
- package/dist/components/use-focus-trap.d.ts +0 -5
- package/dist/components/use-focus-trap.js +0 -54
- package/dist/targets/native/components/paywall-banner.d.ts +0 -11
- package/dist/targets/native/components/paywall-banner.js +0 -46
- package/dist/targets/native/components/paywall.d.ts +0 -18
- package/dist/targets/native/components/paywall.js +0 -61
|
@@ -3,211 +3,213 @@ import {
|
|
|
3
3
|
__spreadProps,
|
|
4
4
|
__spreadValues
|
|
5
5
|
} from "../chunk-ORMEWXMH.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { useMemo, useRef, useState } from "react";
|
|
8
|
+
import { FieldShell, useFieldIds, warnIfUnlabelled } from "./internal/field.js";
|
|
9
|
+
import { ClockIcon } from "./internal/icons.js";
|
|
10
|
+
import { OptionContent } from "./internal/option-content.js";
|
|
11
|
+
import { useListbox } from "./internal/use-listbox.js";
|
|
12
|
+
const toMinutes = (time) => {
|
|
13
|
+
const [h, m] = time.split(":").map(Number);
|
|
14
|
+
return h * 60 + m;
|
|
12
15
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const match =
|
|
16
|
+
const fromMinutes = (minutes) => `${String(Math.floor(minutes / 60)).padStart(2, "0")}:${String(minutes % 60).padStart(2, "0")}`;
|
|
17
|
+
function parseTime(text) {
|
|
18
|
+
const match = text.trim().toLowerCase().match(/^(\d{1,2}):?(\d{2})\s*(am|pm)?$/);
|
|
16
19
|
if (!match) return null;
|
|
17
|
-
|
|
18
|
-
const m =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
const h12 = h === 0 ? 12 : h > 12 ? h - 12 : h;
|
|
27
|
-
return `${String(h12).padStart(2, "0")}:${mm} ${period}`;
|
|
28
|
-
}
|
|
29
|
-
function clampMinute(m, step) {
|
|
30
|
-
return Math.round(m / step) * step % 60;
|
|
20
|
+
let h = Number(match[1]);
|
|
21
|
+
const m = Number(match[2]);
|
|
22
|
+
const period = match[3];
|
|
23
|
+
if (period) {
|
|
24
|
+
if (h < 1 || h > 12) return null;
|
|
25
|
+
h = h % 12 + (period === "pm" ? 12 : 0);
|
|
26
|
+
}
|
|
27
|
+
if (h > 23 || m > 59) return null;
|
|
28
|
+
return fromMinutes(h * 60 + m);
|
|
31
29
|
}
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
30
|
+
function formatTime(time, format = "24h") {
|
|
31
|
+
if (format === "24h") return time;
|
|
32
|
+
const [h, m] = time.split(":").map(Number);
|
|
33
|
+
const h12 = h % 12 === 0 ? 12 : h % 12;
|
|
34
|
+
return `${String(h12).padStart(2, "0")}:${String(m).padStart(2, "0")} ${h >= 12 ? "PM" : "AM"}`;
|
|
36
35
|
}
|
|
37
|
-
const
|
|
36
|
+
const mask24 = (text) => {
|
|
37
|
+
const digits = text.replace(/\D/g, "").slice(0, 4);
|
|
38
|
+
return digits.length > 2 ? `${digits.slice(0, 2)}:${digits.slice(2)}` : digits;
|
|
39
|
+
};
|
|
40
|
+
function TimePicker({
|
|
41
|
+
label,
|
|
42
|
+
labelPosition,
|
|
43
|
+
hint,
|
|
44
|
+
error,
|
|
45
|
+
errorMessage,
|
|
46
|
+
required,
|
|
38
47
|
value,
|
|
48
|
+
defaultValue = null,
|
|
39
49
|
onChange,
|
|
40
|
-
step =
|
|
41
|
-
format = "24h",
|
|
42
|
-
placeholder = "HH:mm",
|
|
43
|
-
size = "md",
|
|
44
|
-
width = "full",
|
|
45
|
-
disabled = false,
|
|
50
|
+
step = 30,
|
|
46
51
|
min,
|
|
47
52
|
max,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
53
|
+
format = "24h",
|
|
54
|
+
placeholder,
|
|
55
|
+
invalidMessage = "Essa hora n\xE3o existe. Use HH:mm.",
|
|
56
|
+
name,
|
|
57
|
+
disabled,
|
|
58
|
+
id,
|
|
59
|
+
className,
|
|
60
|
+
style,
|
|
61
|
+
"aria-label": ariaLabel,
|
|
62
|
+
"aria-labelledby": ariaLabelledBy
|
|
63
|
+
}) {
|
|
64
|
+
warnIfUnlabelled("TimePicker", label, ariaLabel, ariaLabelledBy);
|
|
65
|
+
const [own, setOwn] = useState(defaultValue);
|
|
66
|
+
const time = value !== void 0 ? value : own;
|
|
67
|
+
const [text, setText] = useState("");
|
|
68
|
+
const [editing, setEditing] = useState(false);
|
|
51
69
|
const [open, setOpen] = useState(false);
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
70
|
+
const input = useRef(null);
|
|
71
|
+
const low = min ? toMinutes(min) : 0;
|
|
72
|
+
const high = max ? toMinutes(max) : 23 * 60 + 59;
|
|
73
|
+
const inRange = (t) => toMinutes(t) >= low && toMinutes(t) <= high;
|
|
74
|
+
const times = useMemo(() => {
|
|
75
|
+
const list = [];
|
|
76
|
+
const every = Math.max(1, Math.round(step));
|
|
77
|
+
for (let m = low; m <= high; m += every) list.push({ value: fromMinutes(m), label: formatTime(fromMinutes(m), format) });
|
|
78
|
+
return list;
|
|
79
|
+
}, [low, high, step, format]);
|
|
80
|
+
const shown = editing ? text : time ? formatTime(time, format) : "";
|
|
81
|
+
const parsed = parseTime(shown);
|
|
82
|
+
const complete = format === "24h" ? shown.length === 5 : /\s*(am|pm)$/i.test(shown);
|
|
83
|
+
const wrong = editing && complete && (!parsed || !inRange(parsed));
|
|
84
|
+
const message = wrong ? invalidMessage : errorMessage;
|
|
85
|
+
const { controlId, hintId, errorId, invalid, describedBy } = useFieldIds(id, hint, error || wrong, message);
|
|
86
|
+
const floating = labelPosition === "floating" && Boolean(label);
|
|
87
|
+
function commit(next) {
|
|
88
|
+
if (value === void 0) setOwn(next);
|
|
89
|
+
onChange == null ? void 0 : onChange(next);
|
|
90
|
+
}
|
|
91
|
+
const { listId, setActive, onKeyDown: listKeyDown, controlProps, listProps, optionProps } = useListbox({
|
|
92
|
+
items: times,
|
|
93
|
+
showing: open,
|
|
94
|
+
selected: time ? [time] : [],
|
|
95
|
+
onOpen: () => setOpen(true),
|
|
96
|
+
onChoose: (row) => {
|
|
97
|
+
commit(row.value);
|
|
98
|
+
setEditing(false);
|
|
99
|
+
setOpen(false);
|
|
100
|
+
setActive(-1);
|
|
101
|
+
}
|
|
55
102
|
});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
103
|
+
function openList() {
|
|
104
|
+
if (open || disabled) return;
|
|
105
|
+
setOpen(true);
|
|
106
|
+
const target = time ? toMinutes(time) : -1;
|
|
107
|
+
const index = target < 0 ? -1 : times.findIndex((t) => toMinutes(t.value) >= target);
|
|
108
|
+
setActive(index);
|
|
109
|
+
if (index >= 0) {
|
|
110
|
+
requestAnimationFrame(() => {
|
|
111
|
+
var _a, _b;
|
|
112
|
+
return (_b = (_a = document.getElementById(listId)) == null ? void 0 : _a.children[index]) == null ? void 0 : _b.scrollIntoView({ block: "nearest" });
|
|
113
|
+
});
|
|
64
114
|
}
|
|
65
|
-
}, [open, value]);
|
|
66
|
-
function commit() {
|
|
67
|
-
const d = draftRef.current;
|
|
68
|
-
const t = `${String(d.h).padStart(2, "0")}:${String(d.m).padStart(2, "0")}`;
|
|
69
|
-
if (min && compareTime(t, min) < 0) return;
|
|
70
|
-
if (max && compareTime(t, max) > 0) return;
|
|
71
|
-
onChange(t);
|
|
72
115
|
}
|
|
73
|
-
function
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
let h = d.h + delta;
|
|
77
|
-
if (h < 0) h = 23;
|
|
78
|
-
if (h > 23) h = 0;
|
|
79
|
-
return __spreadProps(__spreadValues({}, d), { h });
|
|
80
|
-
}
|
|
81
|
-
let m = d.m + delta * step;
|
|
82
|
-
if (m < 0) m = 60 - step;
|
|
83
|
-
if (m >= 60) m = 0;
|
|
84
|
-
return __spreadProps(__spreadValues({}, d), { m: clampMinute(m, step) });
|
|
85
|
-
});
|
|
116
|
+
function close() {
|
|
117
|
+
setOpen(false);
|
|
118
|
+
setActive(-1);
|
|
86
119
|
}
|
|
87
|
-
function
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
120
|
+
function keyDown(event) {
|
|
121
|
+
if (!open && (event.key === "ArrowDown" || event.key === "ArrowUp")) {
|
|
122
|
+
event.preventDefault();
|
|
123
|
+
openList();
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (listKeyDown(event)) return;
|
|
127
|
+
if (event.key === "Escape" && open) {
|
|
128
|
+
event.preventDefault();
|
|
129
|
+
close();
|
|
130
|
+
}
|
|
92
131
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (!p) return "";
|
|
96
|
-
return formatTime(p.h, p.m, format);
|
|
97
|
-
})();
|
|
98
|
-
const dialog = /* @__PURE__ */ React.createElement(
|
|
99
|
-
"div",
|
|
132
|
+
return /* @__PURE__ */ jsxs(
|
|
133
|
+
FieldShell,
|
|
100
134
|
{
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
135
|
+
kind: "rds-time-picker",
|
|
136
|
+
controlId,
|
|
137
|
+
hintId,
|
|
138
|
+
errorId,
|
|
139
|
+
label,
|
|
140
|
+
labelPosition,
|
|
141
|
+
hint,
|
|
142
|
+
errorMessage: message,
|
|
143
|
+
invalid,
|
|
144
|
+
required,
|
|
145
|
+
disabled,
|
|
146
|
+
className,
|
|
147
|
+
style,
|
|
148
|
+
children: [
|
|
149
|
+
/* @__PURE__ */ jsx(
|
|
150
|
+
"input",
|
|
151
|
+
__spreadProps(__spreadValues({
|
|
152
|
+
ref: input,
|
|
153
|
+
id: controlId,
|
|
154
|
+
className: "rds-field__control",
|
|
155
|
+
type: "text",
|
|
156
|
+
role: "combobox",
|
|
157
|
+
inputMode: format === "24h" ? "numeric" : "text",
|
|
158
|
+
autoComplete: "off",
|
|
159
|
+
"aria-autocomplete": "none"
|
|
160
|
+
}, controlProps), {
|
|
161
|
+
"aria-label": ariaLabel,
|
|
162
|
+
"aria-labelledby": ariaLabelledBy,
|
|
163
|
+
"aria-invalid": invalid || void 0,
|
|
164
|
+
"aria-describedby": describedBy,
|
|
165
|
+
"aria-required": required || void 0,
|
|
166
|
+
required,
|
|
167
|
+
disabled,
|
|
168
|
+
placeholder: floating ? " " : placeholder != null ? placeholder : format === "24h" ? "HH:mm" : "hh:mm AM",
|
|
169
|
+
maxLength: format === "24h" ? 5 : 8,
|
|
170
|
+
value: shown,
|
|
171
|
+
onChange: (event) => {
|
|
172
|
+
const next = format === "24h" ? mask24(event.target.value) : event.target.value;
|
|
173
|
+
setText(next);
|
|
174
|
+
setEditing(true);
|
|
175
|
+
if (next === "") commit(null);
|
|
176
|
+
const typed = parseTime(next);
|
|
177
|
+
const done = format === "24h" ? next.length === 5 : /\s*(am|pm)$/i.test(next);
|
|
178
|
+
if (typed && done && inRange(typed)) commit(typed);
|
|
179
|
+
},
|
|
180
|
+
onClick: () => open ? close() : openList(),
|
|
181
|
+
onKeyDown: keyDown,
|
|
182
|
+
onBlur: () => {
|
|
183
|
+
close();
|
|
184
|
+
const typed = parseTime(text);
|
|
185
|
+
if (text === "" || typed && inRange(typed)) setEditing(false);
|
|
186
|
+
}
|
|
187
|
+
})
|
|
188
|
+
),
|
|
189
|
+
/* @__PURE__ */ jsx(
|
|
190
|
+
"span",
|
|
191
|
+
{
|
|
192
|
+
className: "rds-field__icon rds-time-picker__clock",
|
|
193
|
+
"aria-hidden": "true",
|
|
194
|
+
onMouseDown: (event) => {
|
|
195
|
+
var _a;
|
|
196
|
+
event.preventDefault();
|
|
197
|
+
if (disabled) return;
|
|
198
|
+
(_a = input.current) == null ? void 0 : _a.focus();
|
|
199
|
+
if (open) close();
|
|
200
|
+
else openList();
|
|
201
|
+
},
|
|
202
|
+
children: /* @__PURE__ */ jsx(ClockIcon, {})
|
|
203
|
+
}
|
|
204
|
+
),
|
|
205
|
+
name && /* @__PURE__ */ jsx("input", { type: "hidden", name, value: time != null ? time : "" }),
|
|
206
|
+
open && /* @__PURE__ */ jsx("ul", __spreadProps(__spreadValues({}, listProps), { "aria-label": typeof label === "string" ? label : ariaLabel != null ? ariaLabel : "Hor\xE1rios", className: "rds-listbox rds-time-picker__list", children: times.map((row, index) => /* @__PURE__ */ jsx("li", __spreadProps(__spreadValues({}, optionProps(row, index)), { className: "rds-listbox__option", children: /* @__PURE__ */ jsx(OptionContent, { selected: row.value === time, children: row.label }) }), row.value)) }))
|
|
207
|
+
]
|
|
208
|
+
}
|
|
142
209
|
);
|
|
143
|
-
return /* @__PURE__ */ React.createElement("div", { className: ["relative", width === "full" ? "block w-full" : "inline-block", className].join(" ") }, /* @__PURE__ */ React.createElement(
|
|
144
|
-
Popover,
|
|
145
|
-
{
|
|
146
|
-
trigger: /* @__PURE__ */ React.createElement(
|
|
147
|
-
"button",
|
|
148
|
-
{
|
|
149
|
-
ref: triggerRef,
|
|
150
|
-
type: "button",
|
|
151
|
-
onClick: (e) => {
|
|
152
|
-
e.stopPropagation();
|
|
153
|
-
if (!disabled) setOpen((o) => !o);
|
|
154
|
-
},
|
|
155
|
-
disabled,
|
|
156
|
-
"aria-label": ariaLabel != null ? ariaLabel : "Selecionar hora",
|
|
157
|
-
"aria-haspopup": "dialog",
|
|
158
|
-
"aria-expanded": open,
|
|
159
|
-
className: [
|
|
160
|
-
"w-full flex items-center gap-2 rounded-(--radius-control) border border-stroke-default bg-surface-default",
|
|
161
|
-
"transition-colors focus:outline-none focus:border-stroke-focus focus:ring-2 focus:ring-stroke-focus/20",
|
|
162
|
-
"disabled:opacity-50 disabled:cursor-not-allowed",
|
|
163
|
-
value ? "pr-7" : "",
|
|
164
|
-
SIZE_CLASS[size]
|
|
165
|
-
].join(" ")
|
|
166
|
-
},
|
|
167
|
-
/* @__PURE__ */ React.createElement(Clock, { size: 16, className: "text-fg-muted shrink-0" }),
|
|
168
|
-
/* @__PURE__ */ React.createElement("span", { className: ["flex-1 text-left truncate", display ? "text-fg-primary" : "text-fg-placeholder"].join(" ") }, display || placeholder)
|
|
169
|
-
),
|
|
170
|
-
triggerClassName: width === "full" ? "block w-full" : "inline-block",
|
|
171
|
-
placement: "bottom-start",
|
|
172
|
-
offset: 4,
|
|
173
|
-
open,
|
|
174
|
-
onOpenChange: (v) => {
|
|
175
|
-
if (!disabled) setOpen(v);
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
|
-
() => dialog
|
|
179
|
-
), value && !disabled && /* @__PURE__ */ React.createElement(
|
|
180
|
-
"button",
|
|
181
|
-
{
|
|
182
|
-
type: "button",
|
|
183
|
-
onClick: handleClear,
|
|
184
|
-
"aria-label": "Limpar hora",
|
|
185
|
-
className: "absolute right-2 top-1/2 -translate-y-1/2 text-fg-muted hover:text-fg-primary p-0.5 rounded transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-stroke-focus"
|
|
186
|
-
},
|
|
187
|
-
/* @__PURE__ */ React.createElement(X, { size: 14 })
|
|
188
|
-
));
|
|
189
|
-
});
|
|
190
|
-
function Spinner({ label, value, onUp, onDown }) {
|
|
191
|
-
return /* @__PURE__ */ React.createElement("div", { className: "flex flex-col items-center", role: "group", "aria-label": label }, /* @__PURE__ */ React.createElement(
|
|
192
|
-
"button",
|
|
193
|
-
{
|
|
194
|
-
type: "button",
|
|
195
|
-
onClick: onUp,
|
|
196
|
-
"aria-label": `Aumentar ${label.toLowerCase()}`,
|
|
197
|
-
className: "p-0.5 rounded hover:bg-surface-raised text-fg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-stroke-focus"
|
|
198
|
-
},
|
|
199
|
-
/* @__PURE__ */ React.createElement(ChevronUp, { size: 16 })
|
|
200
|
-
), /* @__PURE__ */ React.createElement("div", { className: "px-2 py-1 text-heading-lg font-mono font-semibold text-fg-primary tabular-nums select-none min-w-[3ch] text-center" }, value), /* @__PURE__ */ React.createElement(
|
|
201
|
-
"button",
|
|
202
|
-
{
|
|
203
|
-
type: "button",
|
|
204
|
-
onClick: onDown,
|
|
205
|
-
"aria-label": `Diminuir ${label.toLowerCase()}`,
|
|
206
|
-
className: "p-0.5 rounded hover:bg-surface-raised text-fg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-stroke-focus"
|
|
207
|
-
},
|
|
208
|
-
/* @__PURE__ */ React.createElement(ChevronDown, { size: 16 })
|
|
209
|
-
));
|
|
210
210
|
}
|
|
211
211
|
export {
|
|
212
|
-
TimePicker
|
|
212
|
+
TimePicker,
|
|
213
|
+
formatTime,
|
|
214
|
+
parseTime
|
|
213
215
|
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
type ToastTone = 'neutral' | 'info' | 'success' | 'warning' | 'danger';
|
|
5
|
+
/** Figma calls this property `style`: outline (white with a border, the default), soft (light plate), fill (full plate). */
|
|
6
|
+
type ToastVariant = 'outline' | 'soft' | 'fill';
|
|
7
|
+
interface ToastOptions {
|
|
8
|
+
/** What happened, in a few words (Figma: `title`). */
|
|
9
|
+
title: ReactNode;
|
|
10
|
+
/** The detail (Figma: `showDescription` + `description`). */
|
|
11
|
+
description?: ReactNode;
|
|
12
|
+
/** neutral for a plain confirmation. danger is announced at once (assertive); the others politely. */
|
|
13
|
+
tone?: ToastTone;
|
|
14
|
+
variant?: ToastVariant;
|
|
15
|
+
/** The tone's icon (Figma: `showIcon`). Decorative. */
|
|
16
|
+
showIcon?: boolean;
|
|
17
|
+
/** One action (Figma: `showAction`): "Desfazer", "Ver". With an action it stays at least 6 s. */
|
|
18
|
+
action?: {
|
|
19
|
+
label: string;
|
|
20
|
+
onClick: () => void;
|
|
21
|
+
};
|
|
22
|
+
/** ms on screen. Default 5 s, 6 s with an action. It pauses while the mouse or the focus is on it. */
|
|
23
|
+
duration?: number;
|
|
24
|
+
/** Give the same id to replace a toast that is on screen instead of stacking another one. */
|
|
25
|
+
id?: string;
|
|
26
|
+
}
|
|
27
|
+
declare const toastClassName: (tone?: ToastTone, variant?: ToastVariant, extra?: string) => string;
|
|
28
|
+
interface ToastViewProps extends Omit<ToastOptions, 'duration' | 'id'> {
|
|
29
|
+
/** Called by the ×. */
|
|
30
|
+
onClose?: () => void;
|
|
31
|
+
/** The ×'s accessible name. */
|
|
32
|
+
closeLabel?: string;
|
|
33
|
+
className?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* ToastView — the toast's drawing alone, outside the Toaster: for documentation and static previews. In the app,
|
|
37
|
+
* show toasts with `toast()` (or `useToast()`) and mount one `<Toaster />`.
|
|
38
|
+
*/
|
|
39
|
+
declare function ToastView({ title, description, tone, variant, showIcon, action, onClose, closeLabel, className, }: ToastViewProps): react.JSX.Element;
|
|
40
|
+
interface ToastFn {
|
|
41
|
+
/** Shows a toast and returns its id. Needs one `<Toaster />` mounted on the page. */
|
|
42
|
+
(options: ToastOptions): string;
|
|
43
|
+
/** Closes the toast with that id, or every toast. */
|
|
44
|
+
dismiss: (id?: string) => void;
|
|
45
|
+
}
|
|
46
|
+
/** Shows a toast from anywhere (an event handler, a mutation's onSuccess). One `<Toaster />` must be mounted. */
|
|
47
|
+
declare const toast: ToastFn;
|
|
48
|
+
/** The same `toast` function, as a hook, for components that prefer to receive it. */
|
|
49
|
+
declare function useToast(): ToastFn;
|
|
50
|
+
interface ToasterProps {
|
|
51
|
+
/** The region's name, said with the F8 shortcut that takes the focus to it. */
|
|
52
|
+
label?: string;
|
|
53
|
+
/** The app, when the Toaster wraps it. It can also be mounted alone, once, anywhere on the page. */
|
|
54
|
+
children?: ReactNode;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Toaster — the region where the toasts of the Figma [RDS] Feedback/Toast appear (Radix Toast): the bottom-right
|
|
58
|
+
* corner, up to three at a time (a fourth pushes the oldest out), each one announced in a live region (danger
|
|
59
|
+
* assertively, the others politely). F8 takes the focus to the region; swiping right dismisses. Styles: toast.css.
|
|
60
|
+
*/
|
|
61
|
+
declare function Toaster({ label, children }: ToasterProps): react.JSX.Element;
|
|
62
|
+
|
|
63
|
+
export { type ToastFn, type ToastOptions, type ToastTone, type ToastVariant, ToastView, type ToastViewProps, Toaster, type ToasterProps, toast, toastClassName, useToast };
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__spreadProps,
|
|
4
|
+
__spreadValues
|
|
5
|
+
} from "../chunk-ORMEWXMH.js";
|
|
6
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { useCallback, useEffect, useState } from "react";
|
|
8
|
+
import * as ToastPrimitive from "@radix-ui/react-toast";
|
|
9
|
+
import { Button } from "./button.js";
|
|
10
|
+
import { IconButton } from "./icon-button.js";
|
|
11
|
+
import { Tooltip } from "./tooltip.js";
|
|
12
|
+
import { AlertIcon, CircleCheckIcon, CloseIcon, InfoIcon, TriangleAlertIcon } from "./internal/icons.js";
|
|
13
|
+
const ICONS = {
|
|
14
|
+
neutral: InfoIcon,
|
|
15
|
+
info: InfoIcon,
|
|
16
|
+
success: CircleCheckIcon,
|
|
17
|
+
warning: TriangleAlertIcon,
|
|
18
|
+
danger: AlertIcon
|
|
19
|
+
};
|
|
20
|
+
const toastClassName = (tone = "neutral", variant = "outline", extra) => ["rds-toast", `rds-toast--${tone}-${variant}`, variant !== "outline" && "rds-toast--plate", extra].filter(Boolean).join(" ");
|
|
21
|
+
function ToastView({
|
|
22
|
+
title,
|
|
23
|
+
description,
|
|
24
|
+
tone = "neutral",
|
|
25
|
+
variant = "outline",
|
|
26
|
+
showIcon = true,
|
|
27
|
+
action,
|
|
28
|
+
onClose,
|
|
29
|
+
closeLabel = "Fechar",
|
|
30
|
+
className
|
|
31
|
+
}) {
|
|
32
|
+
return /* @__PURE__ */ jsxs("div", { className: toastClassName(tone, variant, className), children: [
|
|
33
|
+
/* @__PURE__ */ jsx(ToastBody, { tone, showIcon, title: /* @__PURE__ */ jsx("p", { className: "rds-toast__title", children: title }), children: description && /* @__PURE__ */ jsx("p", { className: "rds-toast__description", children: description }) }),
|
|
34
|
+
action && /* @__PURE__ */ jsx(Button, { tone: "neutral", variant: "ghost", className: "rds-toast__action", onClick: action.onClick, children: action.label }),
|
|
35
|
+
/* @__PURE__ */ jsx(Tooltip, { text: closeLabel, children: /* @__PURE__ */ jsx(IconButton, { icon: /* @__PURE__ */ jsx(CloseIcon, {}), label: closeLabel, tone: "neutral", variant: "ghost", className: "rds-toast__close", onClick: onClose }) })
|
|
36
|
+
] });
|
|
37
|
+
}
|
|
38
|
+
function ToastBody({ tone, showIcon, title, children }) {
|
|
39
|
+
const Icon = ICONS[tone];
|
|
40
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
41
|
+
showIcon && /* @__PURE__ */ jsx("span", { className: "rds-toast__icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx(Icon, {}) }),
|
|
42
|
+
/* @__PURE__ */ jsxs("div", { className: "rds-toast__content", children: [
|
|
43
|
+
title,
|
|
44
|
+
children
|
|
45
|
+
] })
|
|
46
|
+
] });
|
|
47
|
+
}
|
|
48
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
49
|
+
let counter = 0;
|
|
50
|
+
const toast = Object.assign(
|
|
51
|
+
(options) => {
|
|
52
|
+
var _a;
|
|
53
|
+
counter += 1;
|
|
54
|
+
const key = (_a = options.id) != null ? _a : `rds-toast-${counter}`;
|
|
55
|
+
if (!listeners.size && process.env.NODE_ENV !== "production") {
|
|
56
|
+
console.warn("[@rojaostudio/ds] toast(): no <Toaster /> is mounted, so the toast is not shown.");
|
|
57
|
+
}
|
|
58
|
+
listeners.forEach((listener) => listener({ type: "show", item: __spreadProps(__spreadValues({}, options), { key, open: true }) }));
|
|
59
|
+
return key;
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
dismiss: (id) => listeners.forEach((listener) => listener({ type: "dismiss", id }))
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
function useToast() {
|
|
66
|
+
return toast;
|
|
67
|
+
}
|
|
68
|
+
const MAX_VISIBLE = 3;
|
|
69
|
+
function Toaster({ label = "Notifica\xE7\xF5es", children }) {
|
|
70
|
+
const [items, setItems] = useState([]);
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
const listener = (event) => {
|
|
73
|
+
if (event.type === "show") {
|
|
74
|
+
setItems((current) => {
|
|
75
|
+
const rest = current.filter((item) => item.key !== event.item.key);
|
|
76
|
+
const open = rest.filter((item) => item.open);
|
|
77
|
+
const drop = open.length >= MAX_VISIBLE ? open[0].key : null;
|
|
78
|
+
return [...rest.map((item) => item.key === drop ? __spreadProps(__spreadValues({}, item), { open: false }) : item), event.item];
|
|
79
|
+
});
|
|
80
|
+
} else {
|
|
81
|
+
setItems(
|
|
82
|
+
(current) => current.map((item) => event.id === void 0 || item.key === event.id ? __spreadProps(__spreadValues({}, item), { open: false }) : item)
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
listeners.add(listener);
|
|
87
|
+
return () => {
|
|
88
|
+
listeners.delete(listener);
|
|
89
|
+
};
|
|
90
|
+
}, []);
|
|
91
|
+
const close = useCallback((key) => {
|
|
92
|
+
setItems((current) => current.map((item) => item.key === key ? __spreadProps(__spreadValues({}, item), { open: false }) : item));
|
|
93
|
+
window.setTimeout(() => setItems((current) => current.filter((item) => item.key !== key || item.open)), 300);
|
|
94
|
+
}, []);
|
|
95
|
+
return /* @__PURE__ */ jsxs(ToastPrimitive.Provider, { label, swipeDirection: "right", children: [
|
|
96
|
+
children,
|
|
97
|
+
items.map(({ key, open, title, description, tone = "neutral", variant = "outline", showIcon = true, action, duration }) => /* @__PURE__ */ jsxs(
|
|
98
|
+
ToastPrimitive.Root,
|
|
99
|
+
{
|
|
100
|
+
open,
|
|
101
|
+
onOpenChange: (next) => {
|
|
102
|
+
if (!next) close(key);
|
|
103
|
+
},
|
|
104
|
+
type: tone === "danger" ? "foreground" : "background",
|
|
105
|
+
duration: duration != null ? duration : action ? 6e3 : 5e3,
|
|
106
|
+
className: toastClassName(tone, variant),
|
|
107
|
+
children: [
|
|
108
|
+
/* @__PURE__ */ jsx(
|
|
109
|
+
ToastBody,
|
|
110
|
+
{
|
|
111
|
+
tone,
|
|
112
|
+
showIcon,
|
|
113
|
+
title: /* @__PURE__ */ jsx(ToastPrimitive.Title, { className: "rds-toast__title", children: title }),
|
|
114
|
+
children: description && /* @__PURE__ */ jsx(ToastPrimitive.Description, { className: "rds-toast__description", children: description })
|
|
115
|
+
}
|
|
116
|
+
),
|
|
117
|
+
action && /* @__PURE__ */ jsx(ToastPrimitive.Action, { altText: action.label, asChild: true, children: /* @__PURE__ */ jsx(Button, { tone: "neutral", variant: "ghost", className: "rds-toast__action", onClick: action.onClick, children: action.label }) }),
|
|
118
|
+
/* @__PURE__ */ jsx(Tooltip, { text: "Fechar", children: /* @__PURE__ */ jsx(ToastPrimitive.Close, { asChild: true, children: /* @__PURE__ */ jsx(IconButton, { icon: /* @__PURE__ */ jsx(CloseIcon, {}), label: "Fechar", tone: "neutral", variant: "ghost", className: "rds-toast__close" }) }) })
|
|
119
|
+
]
|
|
120
|
+
},
|
|
121
|
+
key
|
|
122
|
+
)),
|
|
123
|
+
/* @__PURE__ */ jsx(ToastPrimitive.Viewport, { className: "rds-toast-viewport", label: `${label} ({hotkey})` })
|
|
124
|
+
] });
|
|
125
|
+
}
|
|
126
|
+
export {
|
|
127
|
+
ToastView,
|
|
128
|
+
Toaster,
|
|
129
|
+
toast,
|
|
130
|
+
toastClassName,
|
|
131
|
+
useToast
|
|
132
|
+
};
|
|
@@ -2,20 +2,30 @@ import * as react from 'react';
|
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
|
|
4
4
|
interface ToggleCardCompactProps {
|
|
5
|
+
/** An icon before the text (the Item's media). */
|
|
5
6
|
icon?: ReactNode;
|
|
7
|
+
/** The setting it turns on (the Item's title and the Switch's name). */
|
|
6
8
|
label: string;
|
|
7
|
-
/**
|
|
9
|
+
/** The line under the label while off. */
|
|
8
10
|
description?: ReactNode;
|
|
9
|
-
/**
|
|
11
|
+
/** The line under the label while on (a summary of what is set); it replaces `description`. */
|
|
10
12
|
summary?: ReactNode;
|
|
11
13
|
checked: boolean;
|
|
12
14
|
onCheckedChange?: (checked: boolean) => void;
|
|
13
|
-
/**
|
|
15
|
+
/** Shows the pencil (an IconButton) while on: opens the setting's options (a Dialog). */
|
|
14
16
|
onEdit?: () => void;
|
|
17
|
+
/** The pencil's accessible name and tooltip. */
|
|
15
18
|
editLabel?: string;
|
|
16
|
-
/**
|
|
19
|
+
/** Submits 'on' (or '') under this name with a native form, through a hidden input. */
|
|
17
20
|
name?: string;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
className?: string;
|
|
18
23
|
}
|
|
19
|
-
|
|
24
|
+
/**
|
|
25
|
+
* ToggleCardCompact — a composition of the Item (outline), the Switch and the IconButton with its Tooltip: a
|
|
26
|
+
* setting in one row, its summary under the label while on and a pencil that opens its options. Styles:
|
|
27
|
+
* toggle-card-compact.css.
|
|
28
|
+
*/
|
|
29
|
+
declare function ToggleCardCompact({ icon, label, description, summary, checked, onCheckedChange, onEdit, editLabel, name, disabled, className, }: ToggleCardCompactProps): react.JSX.Element;
|
|
20
30
|
|
|
21
31
|
export { ToggleCardCompact, type ToggleCardCompactProps };
|