@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
|
@@ -1,82 +1,62 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
document.body.style.overflow = "hidden";
|
|
37
|
-
const onKey = (e) => {
|
|
38
|
-
if (e.key === "Escape") onClose();
|
|
39
|
-
};
|
|
40
|
-
document.addEventListener("keydown", onKey);
|
|
41
|
-
return () => {
|
|
42
|
-
document.body.style.overflow = prev;
|
|
43
|
-
document.removeEventListener("keydown", onKey);
|
|
44
|
-
};
|
|
45
|
-
}, [open, onClose]);
|
|
46
|
-
if (!open) return null;
|
|
47
|
-
return createPortal(
|
|
48
|
-
/* @__PURE__ */ React.createElement("div", { className: "fixed inset-0 z-50 flex" }, /* @__PURE__ */ React.createElement("div", { className: "absolute inset-0 [background:var(--overlay-scrim)]", onClick: closeOnBackdrop ? onClose : void 0, "aria-hidden": "true" }), /* @__PURE__ */ React.createElement(
|
|
49
|
-
"div",
|
|
50
|
-
{
|
|
51
|
-
ref: panelRef,
|
|
52
|
-
role: "dialog",
|
|
53
|
-
"aria-modal": "true",
|
|
54
|
-
"aria-labelledby": title ? titleId : void 0,
|
|
55
|
-
tabIndex: -1,
|
|
56
|
-
className: [
|
|
57
|
-
"relative z-10 flex flex-col bg-surface-default shadow-xl h-full max-w-full",
|
|
58
|
-
"focus:outline-none",
|
|
59
|
-
widthClass,
|
|
60
|
-
side === "right" ? "ml-auto" : "mr-auto",
|
|
61
|
-
className
|
|
62
|
-
].join(" ")
|
|
2
|
+
import {
|
|
3
|
+
__objRest,
|
|
4
|
+
__spreadValues
|
|
5
|
+
} from "../chunk-ORMEWXMH.js";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { useRef, useState } from "react";
|
|
8
|
+
import { ModalClose, ModalShell } from "./internal/modal.js";
|
|
9
|
+
const DISMISS_DISTANCE = 80;
|
|
10
|
+
function Drawer(_a) {
|
|
11
|
+
var _b = _a, { open, defaultOpen, onOpenChange } = _b, props = __objRest(_b, ["open", "defaultOpen", "onOpenChange"]);
|
|
12
|
+
const [own, setOwn] = useState(defaultOpen != null ? defaultOpen : false);
|
|
13
|
+
const isOpen = open != null ? open : own;
|
|
14
|
+
const setOpen = (next) => {
|
|
15
|
+
setOwn(next);
|
|
16
|
+
onOpenChange == null ? void 0 : onOpenChange(next);
|
|
17
|
+
};
|
|
18
|
+
const start = useRef(null);
|
|
19
|
+
const [drag, setDrag] = useState(0);
|
|
20
|
+
const reset = () => {
|
|
21
|
+
start.current = null;
|
|
22
|
+
setDrag(0);
|
|
23
|
+
};
|
|
24
|
+
const handle = /* @__PURE__ */ jsx(
|
|
25
|
+
"div",
|
|
26
|
+
{
|
|
27
|
+
className: "rds-drawer__handle-area",
|
|
28
|
+
"aria-hidden": "true",
|
|
29
|
+
onPointerDown: (event) => {
|
|
30
|
+
var _a2, _b2;
|
|
31
|
+
start.current = event.clientY;
|
|
32
|
+
(_b2 = (_a2 = event.currentTarget).setPointerCapture) == null ? void 0 : _b2.call(_a2, event.pointerId);
|
|
33
|
+
},
|
|
34
|
+
onPointerMove: (event) => {
|
|
35
|
+
if (start.current !== null) setDrag(Math.max(0, event.clientY - start.current));
|
|
63
36
|
},
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
37
|
+
onPointerUp: (event) => {
|
|
38
|
+
if (start.current !== null && event.clientY - start.current > DISMISS_DISTANCE) setOpen(false);
|
|
39
|
+
reset();
|
|
40
|
+
},
|
|
41
|
+
onPointerCancel: reset,
|
|
42
|
+
children: /* @__PURE__ */ jsx("span", { className: "rds-drawer__handle" })
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
return /* @__PURE__ */ jsx(
|
|
46
|
+
ModalShell,
|
|
47
|
+
__spreadValues({
|
|
48
|
+
prefix: "rds-drawer",
|
|
49
|
+
closeButton: false,
|
|
50
|
+
stackedFooter: true,
|
|
51
|
+
handle,
|
|
52
|
+
open: isOpen,
|
|
53
|
+
onOpenChange: setOpen,
|
|
54
|
+
boxStyle: drag ? { transform: `translateY(${drag}px)`, animation: "none" } : void 0
|
|
55
|
+
}, props)
|
|
78
56
|
);
|
|
79
57
|
}
|
|
58
|
+
const DrawerClose = ModalClose;
|
|
80
59
|
export {
|
|
81
|
-
Drawer
|
|
60
|
+
Drawer,
|
|
61
|
+
DrawerClose
|
|
82
62
|
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactElement, ReactNode } from 'react';
|
|
3
|
+
import { MenuItemContentProps, MenuItemTone } from './internal/menu.js';
|
|
4
|
+
|
|
5
|
+
type DropdownMenuAlign = 'start' | 'center' | 'end';
|
|
6
|
+
type DropdownMenuSide = 'top' | 'bottom' | 'left' | 'right';
|
|
7
|
+
type DropdownMenuItemTone = MenuItemTone;
|
|
8
|
+
interface DropdownMenuProps {
|
|
9
|
+
/** The button that opens it, usually the "⋯" IconButton named after the item whose actions it lists. */
|
|
10
|
+
trigger: ReactElement;
|
|
11
|
+
/** The DropdownMenuItems, with a DropdownMenuSeparator between groups (Figma: the `items` slot). */
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
/** Where it lines up with the button: start (its left edge), end (its right edge). */
|
|
14
|
+
align?: DropdownMenuAlign;
|
|
15
|
+
side?: DropdownMenuSide;
|
|
16
|
+
open?: boolean;
|
|
17
|
+
defaultOpen?: boolean;
|
|
18
|
+
onOpenChange?: (open: boolean) => void;
|
|
19
|
+
/** The menu's name, when the trigger's own name doesn't say it. */
|
|
20
|
+
'aria-label'?: string;
|
|
21
|
+
className?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* DropdownMenu — Figma [RDS] Overlays/DropdownMenu. The actions of an item that don't fit on the screen (Radix
|
|
25
|
+
* DropdownMenu): role="menu"; the focus goes to the first item; the arrows move (disabled items are skipped),
|
|
26
|
+
* typing a letter jumps, Enter or Space chooses, Escape closes and gives the focus back to the button.
|
|
27
|
+
* Up to 7 items; the one that destroys goes last, after a separator. Styles: internal/menu.css.
|
|
28
|
+
*/
|
|
29
|
+
declare function DropdownMenu({ trigger, children, align, side, open, defaultOpen, onOpenChange, className, 'aria-label': ariaLabel, }: DropdownMenuProps): react.JSX.Element;
|
|
30
|
+
interface DropdownMenuItemProps extends MenuItemContentProps {
|
|
31
|
+
/** Runs when the item is chosen (click, Enter or Space); the menu then closes. A destructive action asks first (AlertDialog). */
|
|
32
|
+
onSelect?: () => void;
|
|
33
|
+
/** danger for what destroys: last, after a separator (Figma: `tone`). */
|
|
34
|
+
tone?: DropdownMenuItemTone;
|
|
35
|
+
/** Stays in the list, can't be chosen, and the arrows skip it. */
|
|
36
|
+
disabled?: boolean;
|
|
37
|
+
/** The text typing jumps by, when the label is not plain text. */
|
|
38
|
+
textValue?: string;
|
|
39
|
+
/** Render the single child element (a link) as the item: a place to go instead of an action. */
|
|
40
|
+
asChild?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/** One action (Figma .menu/item): role="menuitem". */
|
|
43
|
+
declare function DropdownMenuItem({ children, icon, shortcut, onSelect, tone, disabled, textValue, asChild }: DropdownMenuItemProps): react.JSX.Element;
|
|
44
|
+
interface DropdownMenuRadioGroupProps {
|
|
45
|
+
/** The chosen item's value. */
|
|
46
|
+
value: string;
|
|
47
|
+
onValueChange: (value: string) => void;
|
|
48
|
+
/** The DropdownMenuRadioItems. */
|
|
49
|
+
children: ReactNode;
|
|
50
|
+
}
|
|
51
|
+
/** A group of items of which one is chosen (a filter's options): role="group" of menuitemradio. */
|
|
52
|
+
declare function DropdownMenuRadioGroup({ value, onValueChange, children }: DropdownMenuRadioGroupProps): react.JSX.Element;
|
|
53
|
+
interface DropdownMenuRadioItemProps extends MenuItemContentProps {
|
|
54
|
+
value: string;
|
|
55
|
+
disabled?: boolean;
|
|
56
|
+
textValue?: string;
|
|
57
|
+
}
|
|
58
|
+
/** One option of a DropdownMenuRadioGroup: role="menuitemradio", aria-checked; the chosen one shows a check. */
|
|
59
|
+
declare function DropdownMenuRadioItem({ value, children, icon, shortcut, disabled, textValue }: DropdownMenuRadioItemProps): react.JSX.Element;
|
|
60
|
+
/** The line between groups of actions (Figma: the Separator in the `items` slot). */
|
|
61
|
+
declare function DropdownMenuSeparator(): react.JSX.Element;
|
|
62
|
+
|
|
63
|
+
export { DropdownMenu, type DropdownMenuAlign, DropdownMenuItem, type DropdownMenuItemProps, type DropdownMenuItemTone, type DropdownMenuProps, DropdownMenuRadioGroup, type DropdownMenuRadioGroupProps, DropdownMenuRadioItem, type DropdownMenuRadioItemProps, DropdownMenuSeparator, type DropdownMenuSide };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../chunk-ORMEWXMH.js";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import * as Menu from "@radix-ui/react-dropdown-menu";
|
|
5
|
+
import { CheckIcon } from "./internal/icons.js";
|
|
6
|
+
import { MenuItemContent, menuItemClassName } from "./internal/menu.js";
|
|
7
|
+
function DropdownMenu({
|
|
8
|
+
trigger,
|
|
9
|
+
children,
|
|
10
|
+
align = "start",
|
|
11
|
+
side = "bottom",
|
|
12
|
+
open,
|
|
13
|
+
defaultOpen,
|
|
14
|
+
onOpenChange,
|
|
15
|
+
className,
|
|
16
|
+
"aria-label": ariaLabel
|
|
17
|
+
}) {
|
|
18
|
+
return (
|
|
19
|
+
// Not modal: the page is not hidden from screen readers (aria-hidden over the focusable trigger) nor locked; a
|
|
20
|
+
// click outside, Escape or Tab still close it, and the focus goes back to the trigger.
|
|
21
|
+
/* @__PURE__ */ jsxs(Menu.Root, { open, defaultOpen, onOpenChange, modal: false, children: [
|
|
22
|
+
/* @__PURE__ */ jsx(Menu.Trigger, { asChild: true, children: trigger }),
|
|
23
|
+
/* @__PURE__ */ jsx(Menu.Portal, { children: /* @__PURE__ */ jsx(
|
|
24
|
+
Menu.Content,
|
|
25
|
+
{
|
|
26
|
+
align,
|
|
27
|
+
side,
|
|
28
|
+
sideOffset: 4,
|
|
29
|
+
collisionPadding: 8,
|
|
30
|
+
"aria-label": ariaLabel,
|
|
31
|
+
className: ["rds-menu", "rds-dropdown-menu", className].filter(Boolean).join(" "),
|
|
32
|
+
children
|
|
33
|
+
}
|
|
34
|
+
) })
|
|
35
|
+
] })
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
function DropdownMenuItem({ children, icon, shortcut, onSelect, tone, disabled, textValue, asChild }) {
|
|
39
|
+
if (asChild) {
|
|
40
|
+
return /* @__PURE__ */ jsx(Menu.Item, { asChild: true, onSelect, disabled, textValue, className: menuItemClassName(tone), children });
|
|
41
|
+
}
|
|
42
|
+
return /* @__PURE__ */ jsx(Menu.Item, { onSelect, disabled, textValue, className: menuItemClassName(tone), children: /* @__PURE__ */ jsx(MenuItemContent, { icon, shortcut, children }) });
|
|
43
|
+
}
|
|
44
|
+
function DropdownMenuRadioGroup({ value, onValueChange, children }) {
|
|
45
|
+
return /* @__PURE__ */ jsx(Menu.RadioGroup, { value, onValueChange, children });
|
|
46
|
+
}
|
|
47
|
+
function DropdownMenuRadioItem({ value, children, icon, shortcut, disabled, textValue }) {
|
|
48
|
+
return /* @__PURE__ */ jsxs(Menu.RadioItem, { value, disabled, textValue, className: menuItemClassName(), children: [
|
|
49
|
+
/* @__PURE__ */ jsx(MenuItemContent, { icon, shortcut, children }),
|
|
50
|
+
/* @__PURE__ */ jsx(Menu.ItemIndicator, { className: "rds-menu__check", "aria-hidden": "true", children: /* @__PURE__ */ jsx(CheckIcon, {}) })
|
|
51
|
+
] });
|
|
52
|
+
}
|
|
53
|
+
function DropdownMenuSeparator() {
|
|
54
|
+
return /* @__PURE__ */ jsx(Menu.Separator, { className: "rds-menu__separator" });
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
DropdownMenu,
|
|
58
|
+
DropdownMenuItem,
|
|
59
|
+
DropdownMenuRadioGroup,
|
|
60
|
+
DropdownMenuRadioItem,
|
|
61
|
+
DropdownMenuSeparator
|
|
62
|
+
};
|
|
@@ -2,9 +2,8 @@ import * as react from 'react';
|
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* Gerencia estado de drag, input file escondido e clique. O conteúdo (ícone + texto) é livre.
|
|
5
|
+
* @deprecated Use `<FileInput variant="dropzone">` (Figma [RDS] Forms/FileInput), which has the label, the hint, the
|
|
6
|
+
* error and the chosen file's row. Kept as a thin wrapper so 1.x code keeps compiling.
|
|
8
7
|
*/
|
|
9
8
|
interface DropzoneProps {
|
|
10
9
|
onFiles: (files: FileList) => void;
|
|
@@ -12,8 +11,15 @@ interface DropzoneProps {
|
|
|
12
11
|
multiple?: boolean;
|
|
13
12
|
disabled?: boolean;
|
|
14
13
|
className?: string;
|
|
14
|
+
/** The call inside the area (FileInput's `dropTitle`). */
|
|
15
15
|
children: ReactNode;
|
|
16
|
+
/** The area's name for screen readers: a Dropzone has no visible label. */
|
|
17
|
+
'aria-label'?: string;
|
|
16
18
|
}
|
|
17
|
-
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Use `<FileInput variant="dropzone">`. A drop target only: it hands the files over and stays empty,
|
|
21
|
+
* ready for the next ones, as the 1.x Dropzone did.
|
|
22
|
+
*/
|
|
23
|
+
declare function Dropzone({ onFiles, accept, multiple, disabled, className, children, 'aria-label': ariaLabel, }: DropzoneProps): react.JSX.Element;
|
|
18
24
|
|
|
19
25
|
export { Dropzone, type DropzoneProps };
|
|
@@ -1,63 +1,38 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "../chunk-ORMEWXMH.js";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return /* @__PURE__ */
|
|
15
|
-
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { FileInput } from "./file-input.js";
|
|
5
|
+
function Dropzone({
|
|
6
|
+
onFiles,
|
|
7
|
+
accept,
|
|
8
|
+
multiple = false,
|
|
9
|
+
disabled = false,
|
|
10
|
+
className,
|
|
11
|
+
children,
|
|
12
|
+
"aria-label": ariaLabel = "Enviar arquivo"
|
|
13
|
+
}) {
|
|
14
|
+
return /* @__PURE__ */ jsx(
|
|
15
|
+
FileInput,
|
|
16
16
|
{
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
variant: "dropzone",
|
|
18
|
+
"aria-label": ariaLabel,
|
|
19
|
+
dropTitle: children,
|
|
20
|
+
fileName: "",
|
|
21
|
+
accept,
|
|
22
|
+
multiple,
|
|
23
|
+
disabled,
|
|
24
|
+
className,
|
|
25
|
+
onFiles: (files) => {
|
|
26
|
+
const copy = new DataTransfer();
|
|
27
|
+
for (const file of Array.from(files)) copy.items.add(file);
|
|
28
|
+
onFiles(copy.files);
|
|
22
29
|
},
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
(_a = inputRef.current) == null ? void 0 : _a.click();
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
onDragOver: (e) => {
|
|
31
|
-
e.preventDefault();
|
|
32
|
-
if (!disabled) setDragging(true);
|
|
33
|
-
},
|
|
34
|
-
onDragLeave: () => setDragging(false),
|
|
35
|
-
onDrop: handleDrop,
|
|
36
|
-
className: [
|
|
37
|
-
"flex flex-col items-center justify-center gap-3 rounded-(--radius-card) border-2 border-dashed py-10 transition-colors",
|
|
38
|
-
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-stroke-focus",
|
|
39
|
-
disabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer",
|
|
40
|
-
dragging ? "border-stroke-focus bg-surface-raised" : "border-stroke-control hover:border-stroke-strong hover:bg-surface-page",
|
|
41
|
-
className
|
|
42
|
-
].filter(Boolean).join(" ")
|
|
43
|
-
},
|
|
44
|
-
/* @__PURE__ */ React.createElement(
|
|
45
|
-
"input",
|
|
46
|
-
{
|
|
47
|
-
ref: inputRef,
|
|
48
|
-
type: "file",
|
|
49
|
-
accept,
|
|
50
|
-
multiple,
|
|
51
|
-
disabled,
|
|
52
|
-
className: "hidden",
|
|
53
|
-
onChange: (e) => {
|
|
54
|
-
var _a;
|
|
55
|
-
if ((_a = e.target.files) == null ? void 0 : _a.length) onFiles(e.target.files);
|
|
56
|
-
e.target.value = "";
|
|
57
|
-
}
|
|
30
|
+
onChange: (event) => {
|
|
31
|
+
queueMicrotask(() => {
|
|
32
|
+
event.target.value = "";
|
|
33
|
+
});
|
|
58
34
|
}
|
|
59
|
-
|
|
60
|
-
children
|
|
35
|
+
}
|
|
61
36
|
);
|
|
62
37
|
}
|
|
63
38
|
export {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
type Heading = 'h2' | 'h3' | 'h4';
|
|
5
|
+
interface EmptyProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
6
|
+
/** What is missing (Figma: `title`): "Nenhum pedido por aqui". No "Ops!", and no blaming the person. */
|
|
7
|
+
title: ReactNode;
|
|
8
|
+
/** The heading level that fits the page's heading order. */
|
|
9
|
+
titleAs?: Heading;
|
|
10
|
+
/** How to change that (Figma: `showDescription` + `description`). */
|
|
11
|
+
description?: ReactNode;
|
|
12
|
+
/** The screen's subject (Figma: `showIcon`), an inline SVG shown in a soft lg Tile. */
|
|
13
|
+
icon?: ReactNode;
|
|
14
|
+
/**
|
|
15
|
+
* The Tile's tone. neutral (the Figma), or danger when the content failed to load (the Table's error state).
|
|
16
|
+
*/
|
|
17
|
+
tone?: 'neutral' | 'danger';
|
|
18
|
+
/** The way out (Figma: `showAction`): a fill Button. */
|
|
19
|
+
action?: ReactNode;
|
|
20
|
+
/** A second way (Figma: `showSecondaryAction`): an outline Button. */
|
|
21
|
+
secondaryAction?: ReactNode;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Empty — Figma [RDS] Content/Empty. The empty state: what is missing, why, and what to do. A system error is an
|
|
25
|
+
* Alert, not an Empty. Styles: empty.css.
|
|
26
|
+
*/
|
|
27
|
+
declare function Empty({ title, titleAs: Title, description, icon, tone, action, secondaryAction, className, ...rest }: EmptyProps): react.JSX.Element;
|
|
28
|
+
|
|
29
|
+
export { Empty, type EmptyProps };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__objRest,
|
|
3
|
+
__spreadProps,
|
|
4
|
+
__spreadValues
|
|
5
|
+
} from "../chunk-ORMEWXMH.js";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { Tile } from "./tile.js";
|
|
8
|
+
function Empty(_a) {
|
|
9
|
+
var _b = _a, {
|
|
10
|
+
title,
|
|
11
|
+
titleAs: Title = "h3",
|
|
12
|
+
description,
|
|
13
|
+
icon,
|
|
14
|
+
tone = "neutral",
|
|
15
|
+
action,
|
|
16
|
+
secondaryAction,
|
|
17
|
+
className
|
|
18
|
+
} = _b, rest = __objRest(_b, [
|
|
19
|
+
"title",
|
|
20
|
+
"titleAs",
|
|
21
|
+
"description",
|
|
22
|
+
"icon",
|
|
23
|
+
"tone",
|
|
24
|
+
"action",
|
|
25
|
+
"secondaryAction",
|
|
26
|
+
"className"
|
|
27
|
+
]);
|
|
28
|
+
return /* @__PURE__ */ jsxs("div", __spreadProps(__spreadValues({}, rest), { className: ["rds-empty", className].filter(Boolean).join(" "), children: [
|
|
29
|
+
icon && /* @__PURE__ */ jsx(Tile, { icon, tone, variant: "soft", size: "lg" }),
|
|
30
|
+
/* @__PURE__ */ jsxs("div", { className: "rds-empty__text", children: [
|
|
31
|
+
/* @__PURE__ */ jsx(Title, { className: "rds-empty__title", children: title }),
|
|
32
|
+
description && /* @__PURE__ */ jsx("p", { className: "rds-empty__description", children: description })
|
|
33
|
+
] }),
|
|
34
|
+
(action || secondaryAction) && /* @__PURE__ */ jsxs("div", { className: "rds-empty__actions", children: [
|
|
35
|
+
action,
|
|
36
|
+
secondaryAction
|
|
37
|
+
] })
|
|
38
|
+
] }));
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
Empty
|
|
42
|
+
};
|
package/dist/components/fab.d.ts
CHANGED
|
@@ -1,14 +1,38 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
2
|
+
import { ComponentPropsWithRef, ReactNode } from 'react';
|
|
3
3
|
|
|
4
|
+
interface FABProps extends ComponentPropsWithRef<'button'> {
|
|
5
|
+
/** The action's name, a verb ("Novo pedido") (Figma: `label`). Always shown: it is the accessible name. */
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
/** Icon before the text (Figma: `hasIcon`). Decorative, rendered with aria-hidden. */
|
|
8
|
+
icon?: ReactNode;
|
|
9
|
+
/** Rendered as aria-disabled="true": stays in the tab order and takes focus, but clicks do nothing. */
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Render the single child element (an `<a>`, a framework `Link`) with the FAB's classes and behaviour
|
|
13
|
+
* instead of a `<button>`. Use it when the action navigates.
|
|
14
|
+
*/
|
|
15
|
+
asChild?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* FAB — Figma [RDS] Actions/FAB. The floating button of a screen's main action: a 56 pill in the brand
|
|
19
|
+
* colour, raised. One per screen, never beside a visible button that does the same thing. It does not
|
|
20
|
+
* place itself: FABRoot (below) or the page puts it in the corner. Styles: fab.css.
|
|
21
|
+
*/
|
|
22
|
+
declare function FAB({ children, icon, disabled, asChild, type, className, onClick, ...rest }: FABProps): react.JSX.Element;
|
|
4
23
|
type FABConfig = {
|
|
5
24
|
label: string;
|
|
25
|
+
/** The FAB's icon. Defaults to a plus. */
|
|
26
|
+
icon?: ReactNode;
|
|
27
|
+
/** Navigates with a plain `<a>`. For client-side routing, render <FAB asChild><Link/></FAB> yourself. */
|
|
6
28
|
href?: string;
|
|
7
29
|
onClick?: () => void;
|
|
8
|
-
/** cta =
|
|
30
|
+
/** cta = the FAB | save = a SavingBar (label saves, secondary discards) */
|
|
9
31
|
variant?: 'cta' | 'save';
|
|
10
32
|
disabled?: boolean;
|
|
33
|
+
/** Only for `save`: the bar shows its saving status. */
|
|
11
34
|
loading?: boolean;
|
|
35
|
+
/** Only for `save`: the discard action. */
|
|
12
36
|
secondary?: {
|
|
13
37
|
label: string;
|
|
14
38
|
onClick: () => void;
|
|
@@ -28,11 +52,10 @@ declare function FABProvider({ children }: {
|
|
|
28
52
|
}): react.JSX.Element;
|
|
29
53
|
declare function useFAB(): FABContextValue;
|
|
30
54
|
/**
|
|
31
|
-
* Register the page's primary FAB action.
|
|
32
|
-
* Clears the FAB automatically on unmount.
|
|
55
|
+
* Register the page's primary FAB action. Clears the FAB automatically on unmount.
|
|
33
56
|
* Pass a stable deps array to avoid re-registering on every render.
|
|
34
57
|
*/
|
|
35
58
|
declare function usePageFAB(config: FABConfig | null, deps?: unknown[]): void;
|
|
36
|
-
declare function FABRoot(): react.JSX.Element;
|
|
59
|
+
declare function FABRoot(): react.JSX.Element | null;
|
|
37
60
|
|
|
38
|
-
export { type FABConfig, FABProvider, FABRoot, useFAB, usePageFAB };
|
|
61
|
+
export { FAB, type FABConfig, type FABProps, FABProvider, FABRoot, useFAB, usePageFAB };
|
package/dist/components/fab.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import
|
|
2
|
+
import {
|
|
3
|
+
__objRest,
|
|
4
|
+
__spreadProps,
|
|
5
|
+
__spreadValues
|
|
6
|
+
} from "../chunk-ORMEWXMH.js";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
8
|
import {
|
|
4
9
|
createContext,
|
|
5
10
|
useCallback,
|
|
@@ -8,9 +13,28 @@ import {
|
|
|
8
13
|
useRef,
|
|
9
14
|
useState
|
|
10
15
|
} from "react";
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
16
|
+
import { Slot, Slottable } from "@radix-ui/react-slot";
|
|
17
|
+
import { blockWhenDisabled } from "./internal/button.js";
|
|
18
|
+
import { PlusIcon } from "./internal/icons.js";
|
|
19
|
+
import { SavingBar } from "./saving-bar.js";
|
|
13
20
|
import { useSavingBarActive } from "./saving-bar-context.js";
|
|
21
|
+
function FAB(_a) {
|
|
22
|
+
var _b = _a, { children, icon, disabled, asChild, type = "button", className, onClick } = _b, rest = __objRest(_b, ["children", "icon", "disabled", "asChild", "type", "className", "onClick"]);
|
|
23
|
+
const Root = asChild ? Slot : "button";
|
|
24
|
+
return /* @__PURE__ */ jsxs(
|
|
25
|
+
Root,
|
|
26
|
+
__spreadProps(__spreadValues({}, rest), {
|
|
27
|
+
type: asChild ? void 0 : type,
|
|
28
|
+
className: ["rds-fab", className].filter(Boolean).join(" "),
|
|
29
|
+
"aria-disabled": disabled || void 0,
|
|
30
|
+
onClick: blockWhenDisabled(disabled, onClick),
|
|
31
|
+
children: [
|
|
32
|
+
icon && /* @__PURE__ */ jsx("span", { className: "rds-fab__icon", "aria-hidden": "true", children: icon }),
|
|
33
|
+
/* @__PURE__ */ jsx(Slottable, { children })
|
|
34
|
+
]
|
|
35
|
+
})
|
|
36
|
+
);
|
|
37
|
+
}
|
|
14
38
|
const FABContext = createContext({
|
|
15
39
|
config: null,
|
|
16
40
|
setFAB: () => {
|
|
@@ -30,7 +54,7 @@ function FABProvider({ children }) {
|
|
|
30
54
|
const [fabHidden, setFabHidden] = useState(false);
|
|
31
55
|
const setFAB = useCallback((cfg) => setConfig(cfg), []);
|
|
32
56
|
const clearFAB = useCallback(() => setConfig(null), []);
|
|
33
|
-
return /* @__PURE__ */
|
|
57
|
+
return /* @__PURE__ */ jsx(FABContext.Provider, { value: { config, setFAB, clearFAB, bottomOffset, setBottomOffset, fabHidden, setFabHidden }, children });
|
|
34
58
|
}
|
|
35
59
|
function useFAB() {
|
|
36
60
|
return useContext(FABContext);
|
|
@@ -49,50 +73,38 @@ function usePageFAB(config, deps = []) {
|
|
|
49
73
|
}, [setFAB, clearFAB, ...deps]);
|
|
50
74
|
}
|
|
51
75
|
function FABRoot() {
|
|
76
|
+
var _a, _b, _c;
|
|
52
77
|
const { config, bottomOffset, fabHidden } = useFAB();
|
|
53
78
|
const savingBarActive = useSavingBarActive();
|
|
54
79
|
const hiddenByBar = savingBarActive && (config == null ? void 0 : config.variant) !== "save";
|
|
55
80
|
const visible = !!config && !fabHidden && !hiddenByBar;
|
|
56
81
|
const wrapCls = [
|
|
57
|
-
"
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
onClick: config.secondary.onClick,
|
|
67
|
-
disabled: config.loading,
|
|
68
|
-
className: "rounded-(--radius-control) border px-3 py-1.5 text-label font-medium transition-colors disabled:opacity-40 cursor-pointer [border-color:var(--fab-save-discard-border)] [color:var(--fab-save-discard-text)] hover:[border-color:var(--fab-save-discard-border-hover)] hover:[color:var(--fab-save-discard-text-hover)]"
|
|
69
|
-
},
|
|
70
|
-
config.secondary.label
|
|
71
|
-
), /* @__PURE__ */ React.createElement(
|
|
72
|
-
"button",
|
|
82
|
+
"rds-fab-root",
|
|
83
|
+
(config == null ? void 0 : config.variant) === "save" ? "rds-fab-root--bar" : "rds-fab-root--fab",
|
|
84
|
+
!visible && "rds-fab-root--hidden"
|
|
85
|
+
].filter(Boolean).join(" ");
|
|
86
|
+
const bottomStyle = { bottom: `${((config == null ? void 0 : config.variant) === "save" ? 0 : 24) + bottomOffset}px` };
|
|
87
|
+
if (!config) return null;
|
|
88
|
+
if (config.variant === "save") {
|
|
89
|
+
return /* @__PURE__ */ jsx("div", { className: wrapCls, style: bottomStyle, children: /* @__PURE__ */ jsx(
|
|
90
|
+
SavingBar,
|
|
73
91
|
{
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
92
|
+
status: config.loading ? "saving" : "unsaved",
|
|
93
|
+
saveLabel: config.label,
|
|
94
|
+
onSave: () => {
|
|
95
|
+
var _a2;
|
|
96
|
+
return (_a2 = config.onClick) == null ? void 0 : _a2.call(config);
|
|
97
|
+
},
|
|
98
|
+
onDiscard: (_a = config.secondary) == null ? void 0 : _a.onClick,
|
|
99
|
+
discardLabel: (_b = config.secondary) == null ? void 0 : _b.label
|
|
100
|
+
}
|
|
101
|
+
) });
|
|
81
102
|
}
|
|
82
|
-
const
|
|
83
|
-
return /* @__PURE__ */
|
|
84
|
-
"button",
|
|
85
|
-
{
|
|
86
|
-
type: "button",
|
|
87
|
-
onClick: config == null ? void 0 : config.onClick,
|
|
88
|
-
disabled: config == null ? void 0 : config.disabled,
|
|
89
|
-
className: btnCls + " disabled:opacity-50"
|
|
90
|
-
},
|
|
91
|
-
/* @__PURE__ */ React.createElement(Plus, { size: 16, strokeWidth: 2.5 }),
|
|
92
|
-
config == null ? void 0 : config.label
|
|
93
|
-
));
|
|
103
|
+
const icon = (_c = config.icon) != null ? _c : /* @__PURE__ */ jsx(PlusIcon, {});
|
|
104
|
+
return /* @__PURE__ */ jsx("div", { className: wrapCls, style: bottomStyle, children: config.href ? /* @__PURE__ */ jsx(FAB, { asChild: true, icon, disabled: config.disabled, children: /* @__PURE__ */ jsx("a", { href: config.href, children: config.label }) }) : /* @__PURE__ */ jsx(FAB, { icon, disabled: config.disabled, onClick: config.onClick, children: config.label }) });
|
|
94
105
|
}
|
|
95
106
|
export {
|
|
107
|
+
FAB,
|
|
96
108
|
FABProvider,
|
|
97
109
|
FABRoot,
|
|
98
110
|
useFAB,
|