@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
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__objRest,
|
|
4
|
+
__spreadProps,
|
|
5
|
+
__spreadValues
|
|
6
|
+
} from "../chunk-ORMEWXMH.js";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { Button } from "./button.js";
|
|
9
|
+
import { CheckboxGroup } from "./checkbox-group.js";
|
|
10
|
+
import { ChoiceCardGroup } from "./choice-card.js";
|
|
11
|
+
import { AlertIcon } from "./internal/icons.js";
|
|
12
|
+
import { Progress } from "./progress.js";
|
|
13
|
+
import { RadioGroup } from "./radio-group.js";
|
|
14
|
+
function Questionnaire(_a) {
|
|
15
|
+
var _b = _a, {
|
|
16
|
+
step,
|
|
17
|
+
steps,
|
|
18
|
+
title,
|
|
19
|
+
description,
|
|
20
|
+
answer = "single",
|
|
21
|
+
children,
|
|
22
|
+
value,
|
|
23
|
+
defaultValue,
|
|
24
|
+
onValueChange,
|
|
25
|
+
error,
|
|
26
|
+
onBack,
|
|
27
|
+
onSkip,
|
|
28
|
+
onNext,
|
|
29
|
+
className
|
|
30
|
+
} = _b, rest = __objRest(_b, [
|
|
31
|
+
"step",
|
|
32
|
+
"steps",
|
|
33
|
+
"title",
|
|
34
|
+
"description",
|
|
35
|
+
"answer",
|
|
36
|
+
"children",
|
|
37
|
+
"value",
|
|
38
|
+
"defaultValue",
|
|
39
|
+
"onValueChange",
|
|
40
|
+
"error",
|
|
41
|
+
"onBack",
|
|
42
|
+
"onSkip",
|
|
43
|
+
"onNext",
|
|
44
|
+
"className"
|
|
45
|
+
]);
|
|
46
|
+
const errorMessage = error ? /* @__PURE__ */ jsxs("span", { className: "rds-questionnaire__error", children: [
|
|
47
|
+
/* @__PURE__ */ jsx("span", { className: "rds-questionnaire__error-icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx(AlertIcon, {}) }),
|
|
48
|
+
/* @__PURE__ */ jsx("span", { children: error })
|
|
49
|
+
] }) : void 0;
|
|
50
|
+
const legend = /* @__PURE__ */ jsx("span", { className: "rds-questionnaire__title", children: title });
|
|
51
|
+
const hint = description ? /* @__PURE__ */ jsx("span", { className: "rds-questionnaire__description", children: description }) : void 0;
|
|
52
|
+
let body;
|
|
53
|
+
if (answer === "single") {
|
|
54
|
+
body = /* @__PURE__ */ jsx(
|
|
55
|
+
RadioGroup,
|
|
56
|
+
{
|
|
57
|
+
legend,
|
|
58
|
+
hint,
|
|
59
|
+
errorMessage,
|
|
60
|
+
value,
|
|
61
|
+
defaultValue,
|
|
62
|
+
onValueChange,
|
|
63
|
+
children
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
} else if (answer === "multiple") {
|
|
67
|
+
body = /* @__PURE__ */ jsx(CheckboxGroup, { legend, hint, errorMessage, children });
|
|
68
|
+
} else {
|
|
69
|
+
const heading = /* @__PURE__ */ jsxs("span", { className: "rds-questionnaire__heading", children: [
|
|
70
|
+
legend,
|
|
71
|
+
hint
|
|
72
|
+
] });
|
|
73
|
+
body = /* @__PURE__ */ jsxs("div", { className: "rds-questionnaire__body", children: [
|
|
74
|
+
answer === "card" ? /* @__PURE__ */ jsx(ChoiceCardGroup, { legend: heading, value, defaultValue, onValueChange, children }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
75
|
+
/* @__PURE__ */ jsx("p", { className: "rds-questionnaire__text-heading", children: heading }),
|
|
76
|
+
children
|
|
77
|
+
] }),
|
|
78
|
+
errorMessage && /* @__PURE__ */ jsx("p", { role: "alert", className: "rds-questionnaire__alert", children: errorMessage })
|
|
79
|
+
] });
|
|
80
|
+
}
|
|
81
|
+
return /* @__PURE__ */ jsxs(
|
|
82
|
+
"form",
|
|
83
|
+
__spreadProps(__spreadValues({
|
|
84
|
+
noValidate: true,
|
|
85
|
+
"aria-label": title
|
|
86
|
+
}, rest), {
|
|
87
|
+
className: ["rds-questionnaire", className].filter(Boolean).join(" "),
|
|
88
|
+
onSubmit: (event) => {
|
|
89
|
+
event.preventDefault();
|
|
90
|
+
onNext();
|
|
91
|
+
},
|
|
92
|
+
children: [
|
|
93
|
+
/* @__PURE__ */ jsx(Progress, { size: "sm", value: step, max: steps, label: `Pergunta ${step} de ${steps}`, showValue: false }),
|
|
94
|
+
body,
|
|
95
|
+
/* @__PURE__ */ jsxs("div", { className: "rds-questionnaire__actions", children: [
|
|
96
|
+
onBack && /* @__PURE__ */ jsx(Button, { tone: "neutral", variant: "ghost", onClick: onBack, children: "Voltar" }),
|
|
97
|
+
/* @__PURE__ */ jsx("span", { className: "rds-questionnaire__spacer" }),
|
|
98
|
+
onSkip && /* @__PURE__ */ jsx(Button, { tone: "neutral", variant: "ghost", onClick: onSkip, children: "Pular" }),
|
|
99
|
+
/* @__PURE__ */ jsx(Button, { type: "submit", children: step >= steps ? "Enviar" : "Pr\xF3xima" })
|
|
100
|
+
] })
|
|
101
|
+
]
|
|
102
|
+
})
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
export {
|
|
106
|
+
Questionnaire
|
|
107
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ChoiceFieldsetProps } from './internal/fieldset.js';
|
|
3
|
+
|
|
4
|
+
interface RadioGroupProps extends Omit<ChoiceFieldsetProps, 'onChange' | 'defaultValue'> {
|
|
5
|
+
/** The form field name shared by every option. By default a generated one. */
|
|
6
|
+
name?: string;
|
|
7
|
+
/** Controlled: the chosen option's value. */
|
|
8
|
+
value?: string;
|
|
9
|
+
/** Uncontrolled: the option chosen at first. */
|
|
10
|
+
defaultValue?: string;
|
|
11
|
+
onValueChange?: (value: string) => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* RadioGroup — Figma [RDS] Forms/RadioGroup. A question and 2 to 5 single-choice options (Radio children,
|
|
15
|
+
* Figma slot `options`) in a <fieldset role="radiogroup">, with the group's hint and error. Tab enters on the
|
|
16
|
+
* chosen option; the arrows move and choose (native radios sharing one name). Styles: radio-group.css and
|
|
17
|
+
* internal/fieldset.css.
|
|
18
|
+
*/
|
|
19
|
+
declare function RadioGroup({ name, value, defaultValue, onValueChange, required, disabled, error, ...rest }: RadioGroupProps): react.JSX.Element;
|
|
20
|
+
|
|
21
|
+
export { RadioGroup, type RadioGroupProps };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__objRest,
|
|
4
|
+
__spreadValues
|
|
5
|
+
} from "../chunk-ORMEWXMH.js";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { Children, isValidElement, useId } from "react";
|
|
8
|
+
import { hasContent } from "./internal/field.js";
|
|
9
|
+
import { ChoiceFieldset } from "./internal/fieldset.js";
|
|
10
|
+
import { RadioGroupContext } from "./internal/radio-context.js";
|
|
11
|
+
function RadioGroup(_a) {
|
|
12
|
+
var _b = _a, { name, value, defaultValue, onValueChange, required, disabled, error } = _b, rest = __objRest(_b, ["name", "value", "defaultValue", "onValueChange", "required", "disabled", "error"]);
|
|
13
|
+
const generated = useId();
|
|
14
|
+
const invalid = Boolean(error || hasContent(rest.errorMessage));
|
|
15
|
+
const first = Children.toArray(rest.children).find(
|
|
16
|
+
(child) => isValidElement(child) && child.props.value !== void 0
|
|
17
|
+
);
|
|
18
|
+
const firstValue = isValidElement(first) ? first.props.value : void 0;
|
|
19
|
+
return /* @__PURE__ */ jsx(
|
|
20
|
+
RadioGroupContext.Provider,
|
|
21
|
+
{
|
|
22
|
+
value: { name: name != null ? name : generated, value, defaultValue, onValueChange, required, firstValue, disabled, error: invalid },
|
|
23
|
+
children: /* @__PURE__ */ jsx(
|
|
24
|
+
ChoiceFieldset,
|
|
25
|
+
__spreadValues({
|
|
26
|
+
kind: "rds-radio-group",
|
|
27
|
+
role: "radiogroup",
|
|
28
|
+
"aria-required": required || void 0,
|
|
29
|
+
"aria-invalid": invalid || void 0,
|
|
30
|
+
required,
|
|
31
|
+
disabled,
|
|
32
|
+
error: invalid
|
|
33
|
+
}, rest)
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
RadioGroup
|
|
40
|
+
};
|
|
@@ -1,33 +1,19 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ComponentPropsWithRef, ReactNode } from 'react';
|
|
3
3
|
|
|
4
|
-
interface RadioProps extends Omit<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
interface RadioProps extends Omit<ComponentPropsWithRef<'input'>, 'type' | 'children' | 'name' | 'value' | 'checked' | 'defaultChecked' | 'size'> {
|
|
5
|
+
/** The option's value, sent with the form and used by the RadioGroup's `value`. */
|
|
6
|
+
value: string;
|
|
7
|
+
/** The option's text (Figma: `showLabel` + `label`). Without it, pass aria-label. */
|
|
8
|
+
children?: ReactNode;
|
|
9
|
+
/** A line under the label (Figma: `showHint` + `hint`), tied by aria-describedby. */
|
|
10
|
+
hint?: ReactNode;
|
|
9
11
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
interface RadioGroupProps<T extends string = string> {
|
|
18
|
-
name: string;
|
|
19
|
-
value: T | null;
|
|
20
|
-
onChange: (value: T) => void;
|
|
21
|
-
options: RadioOption<T>[];
|
|
22
|
-
/** Layout. default = vertical. */
|
|
23
|
-
orientation?: 'horizontal' | 'vertical';
|
|
24
|
-
size?: 'sm' | 'md';
|
|
25
|
-
error?: string;
|
|
26
|
-
/** Label do group como `<legend>`. */
|
|
27
|
-
legend?: ReactNode;
|
|
28
|
-
required?: boolean;
|
|
29
|
-
className?: string;
|
|
30
|
-
}
|
|
31
|
-
declare function RadioGroup<T extends string = string>({ name, value, onChange, options, orientation, size, error, legend, required, className, }: RadioGroupProps<T>): react.JSX.Element;
|
|
12
|
+
/**
|
|
13
|
+
* Radio — Figma [RDS] Forms/Radio. One single-choice option. It only exists inside a RadioGroup, which gives
|
|
14
|
+
* it the name, the chosen value, required, disabled and the error. Native <input type="radio">.
|
|
15
|
+
* Styles: radio.css and internal/choice.css.
|
|
16
|
+
*/
|
|
17
|
+
declare function Radio({ value, children, hint, disabled, id, className, style, onChange, ...input }: RadioProps): react.JSX.Element;
|
|
32
18
|
|
|
33
|
-
export { Radio,
|
|
19
|
+
export { Radio, type RadioProps };
|
package/dist/components/radio.js
CHANGED
|
@@ -1,97 +1,56 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
__objRest,
|
|
4
|
+
__spreadProps,
|
|
4
5
|
__spreadValues
|
|
5
6
|
} from "../chunk-ORMEWXMH.js";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
var _b = _a, {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
htmlFor: inputId,
|
|
21
|
-
className: [
|
|
22
|
-
"inline-flex items-start gap-2 cursor-pointer",
|
|
23
|
-
"has-[:disabled]:opacity-50 has-[:disabled]:cursor-not-allowed",
|
|
24
|
-
className
|
|
25
|
-
].filter(Boolean).join(" ")
|
|
26
|
-
},
|
|
27
|
-
/* @__PURE__ */ React.createElement("span", { className: ["relative flex shrink-0 mt-0.5", sz.box].join(" ") }, /* @__PURE__ */ React.createElement(
|
|
28
|
-
"input",
|
|
29
|
-
__spreadValues({
|
|
30
|
-
ref,
|
|
31
|
-
type: "radio",
|
|
32
|
-
id: inputId,
|
|
33
|
-
"aria-invalid": error ? true : void 0,
|
|
34
|
-
"aria-describedby": error ? errId : void 0,
|
|
35
|
-
className: [
|
|
36
|
-
"peer appearance-none rounded-full shrink-0 cursor-pointer",
|
|
37
|
-
sz.box,
|
|
38
|
-
"bg-surface-default",
|
|
39
|
-
error ? "border border-danger checked:border-danger" : "border border-stroke-control checked:border-brand-primary",
|
|
40
|
-
"focus-visible:ring-2 focus-visible:ring-stroke-focus/30 focus-visible:outline-none",
|
|
41
|
-
"disabled:cursor-not-allowed transition-colors"
|
|
42
|
-
].join(" ")
|
|
43
|
-
}, props)
|
|
44
|
-
), /* @__PURE__ */ React.createElement(
|
|
45
|
-
"span",
|
|
46
|
-
{
|
|
47
|
-
"aria-hidden": true,
|
|
48
|
-
className: [
|
|
49
|
-
"absolute inset-0 m-auto rounded-full bg-transparent transition-colors pointer-events-none",
|
|
50
|
-
sz.dot,
|
|
51
|
-
error ? "peer-checked:bg-danger" : "peer-checked:bg-brand-primary"
|
|
52
|
-
].join(" ")
|
|
53
|
-
}
|
|
54
|
-
)),
|
|
55
|
-
(label || description) && /* @__PURE__ */ React.createElement("span", { className: "flex flex-col gap-0.5 select-none" }, label && /* @__PURE__ */ React.createElement("span", { className: [sz.label, "text-fg-primary leading-snug"].join(" ") }, label), description && /* @__PURE__ */ React.createElement("span", { className: "text-caption text-fg-muted leading-snug" }, description))
|
|
56
|
-
), error && /* @__PURE__ */ React.createElement("p", { id: errId, className: [sz.box === "size-3.5" ? "pl-5" : "pl-6", "text-caption text-danger-text"].join(" ") }, error));
|
|
57
|
-
});
|
|
58
|
-
function RadioGroup({
|
|
59
|
-
name,
|
|
60
|
-
value,
|
|
61
|
-
onChange,
|
|
62
|
-
options,
|
|
63
|
-
orientation = "vertical",
|
|
64
|
-
size = "md",
|
|
65
|
-
error,
|
|
66
|
-
legend,
|
|
67
|
-
required,
|
|
68
|
-
className = ""
|
|
69
|
-
}) {
|
|
70
|
-
return /* @__PURE__ */ React.createElement(
|
|
71
|
-
"fieldset",
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { useContext } from "react";
|
|
9
|
+
import { ChoiceRow } from "./internal/choice.js";
|
|
10
|
+
import { warnIfUnlabelled } from "./internal/field.js";
|
|
11
|
+
import { RadioGroupContext } from "./internal/radio-context.js";
|
|
12
|
+
function Radio(_a) {
|
|
13
|
+
var _b = _a, { value, children, hint, disabled, id, className, style, onChange } = _b, input = __objRest(_b, ["value", "children", "hint", "disabled", "id", "className", "style", "onChange"]);
|
|
14
|
+
const group = useContext(RadioGroupContext);
|
|
15
|
+
if (!group) console.warn("[@rojaostudio/ds] Radio: use it inside a RadioGroup. A Radio alone is not a choice.");
|
|
16
|
+
warnIfUnlabelled("Radio", children, input["aria-label"], input["aria-labelledby"]);
|
|
17
|
+
const controlled = (group == null ? void 0 : group.value) !== void 0;
|
|
18
|
+
const off = disabled || (group == null ? void 0 : group.disabled);
|
|
19
|
+
return /* @__PURE__ */ jsx(
|
|
20
|
+
ChoiceRow,
|
|
72
21
|
{
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
22
|
+
kind: "rds-radio",
|
|
23
|
+
id,
|
|
24
|
+
label: children,
|
|
25
|
+
hint,
|
|
26
|
+
disabled: off,
|
|
27
|
+
invalid: group == null ? void 0 : group.error,
|
|
28
|
+
className,
|
|
29
|
+
style,
|
|
30
|
+
control: ({ id: controlId, describedBy }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
31
|
+
/* @__PURE__ */ jsx(
|
|
32
|
+
"input",
|
|
33
|
+
__spreadProps(__spreadValues(__spreadProps(__spreadValues({}, input), {
|
|
34
|
+
id: controlId,
|
|
35
|
+
type: "radio",
|
|
36
|
+
name: group == null ? void 0 : group.name,
|
|
37
|
+
value,
|
|
38
|
+
required: (group == null ? void 0 : group.required) && (group.firstValue === void 0 || group.firstValue === value),
|
|
39
|
+
disabled: off,
|
|
40
|
+
"aria-describedby": [describedBy, input["aria-describedby"]].filter(Boolean).join(" ") || void 0
|
|
41
|
+
}), controlled ? { checked: (group == null ? void 0 : group.value) === value } : { defaultChecked: (group == null ? void 0 : group.defaultValue) === value }), {
|
|
42
|
+
onChange: (event) => {
|
|
43
|
+
var _a2;
|
|
44
|
+
onChange == null ? void 0 : onChange(event);
|
|
45
|
+
if (event.target.checked) (_a2 = group == null ? void 0 : group.onValueChange) == null ? void 0 : _a2.call(group, value);
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
),
|
|
49
|
+
/* @__PURE__ */ jsx("span", { className: "rds-radio__circle", "aria-hidden": "true" })
|
|
50
|
+
] })
|
|
51
|
+
}
|
|
92
52
|
);
|
|
93
53
|
}
|
|
94
54
|
export {
|
|
95
|
-
Radio
|
|
96
|
-
RadioGroup
|
|
55
|
+
Radio
|
|
97
56
|
};
|
|
@@ -8,6 +8,11 @@ interface RowActionItem {
|
|
|
8
8
|
disabled?: boolean;
|
|
9
9
|
onClick: () => void;
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* RowActions — a composition of the Button (outline, neutral), the IconButton with its Tooltip and the
|
|
13
|
+
* DropdownMenu: the actions at the end of a table row. One action in view, the rest behind "Mais ações"; danger
|
|
14
|
+
* items go last, after a separator. Clicks do not reach the row. Styles: row-actions.css.
|
|
15
|
+
*/
|
|
11
16
|
interface RowActionsProps {
|
|
12
17
|
/** Rótulo do botão principal (ex: "Ver detalhes"). */
|
|
13
18
|
primaryLabel: string;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "../chunk-ORMEWXMH.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { Button } from "./button.js";
|
|
5
|
+
import { DropdownMenu, DropdownMenuItem, DropdownMenuSeparator } from "./dropdown-menu.js";
|
|
5
6
|
import { IconButton } from "./icon-button.js";
|
|
7
|
+
import { Tooltip } from "./tooltip.js";
|
|
8
|
+
import { MoreVerticalIcon } from "./internal/icons.js";
|
|
6
9
|
function RowActions({
|
|
7
10
|
primaryLabel,
|
|
8
11
|
primaryHref,
|
|
@@ -14,62 +17,60 @@ function RowActions({
|
|
|
14
17
|
const showSep = dangerSeparator != null ? dangerSeparator : hasDanger;
|
|
15
18
|
const normalItems = showSep ? items.filter((i) => i.variant !== "danger") : items;
|
|
16
19
|
const dangerItems = showSep ? items.filter((i) => i.variant === "danger") : [];
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
{
|
|
21
|
-
type: "button",
|
|
22
|
-
className: primaryCls,
|
|
23
|
-
onClick: (e) => {
|
|
24
|
-
e.stopPropagation();
|
|
25
|
-
primaryOnClick();
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
primaryLabel
|
|
29
|
-
) : null, items.length > 0 && /* @__PURE__ */ React.createElement("div", { onClick: (e) => e.stopPropagation() }, /* @__PURE__ */ React.createElement(
|
|
30
|
-
Menu,
|
|
31
|
-
{
|
|
32
|
-
trigger: /* @__PURE__ */ React.createElement(
|
|
33
|
-
IconButton,
|
|
34
|
-
{
|
|
35
|
-
icon: /* @__PURE__ */ React.createElement(MoreVertical, null),
|
|
36
|
-
"aria-label": "Mais a\xE7\xF5es",
|
|
37
|
-
size: "sm",
|
|
38
|
-
variant: "ghost",
|
|
39
|
-
color: "secondary"
|
|
40
|
-
}
|
|
41
|
-
),
|
|
42
|
-
placement: "bottom-end",
|
|
43
|
-
minWidth: 160
|
|
44
|
-
},
|
|
45
|
-
({ close }) => /* @__PURE__ */ React.createElement(React.Fragment, null, normalItems.map((item, i) => /* @__PURE__ */ React.createElement(
|
|
46
|
-
MenuItem,
|
|
20
|
+
return /* @__PURE__ */ jsxs("div", { className: "rds-row-actions", children: [
|
|
21
|
+
primaryHref ? /* @__PURE__ */ jsx(Button, { asChild: true, variant: "outline", tone: "neutral", children: /* @__PURE__ */ jsx("a", { href: primaryHref, onClick: (e) => e.stopPropagation(), children: primaryLabel }) }) : primaryOnClick ? /* @__PURE__ */ jsx(
|
|
22
|
+
Button,
|
|
47
23
|
{
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
MenuItem,
|
|
24
|
+
variant: "outline",
|
|
25
|
+
tone: "neutral",
|
|
26
|
+
onClick: (e) => {
|
|
27
|
+
e.stopPropagation();
|
|
28
|
+
primaryOnClick();
|
|
29
|
+
},
|
|
30
|
+
children: primaryLabel
|
|
31
|
+
}
|
|
32
|
+
) : null,
|
|
33
|
+
items.length > 0 && /* @__PURE__ */ jsx("div", { className: "rds-row-actions__more", onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsxs(
|
|
34
|
+
DropdownMenu,
|
|
60
35
|
{
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
36
|
+
trigger: /* @__PURE__ */ jsx(Tooltip, { text: "Mais a\xE7\xF5es", children: /* @__PURE__ */ jsx(
|
|
37
|
+
IconButton,
|
|
38
|
+
{
|
|
39
|
+
icon: /* @__PURE__ */ jsx(MoreVerticalIcon, {}),
|
|
40
|
+
label: "Mais a\xE7\xF5es",
|
|
41
|
+
variant: "ghost",
|
|
42
|
+
tone: "neutral"
|
|
43
|
+
}
|
|
44
|
+
) }),
|
|
45
|
+
align: "end",
|
|
46
|
+
children: [
|
|
47
|
+
normalItems.map((item, i) => /* @__PURE__ */ jsx(
|
|
48
|
+
DropdownMenuItem,
|
|
49
|
+
{
|
|
50
|
+
icon: item.icon,
|
|
51
|
+
tone: item.variant,
|
|
52
|
+
disabled: item.disabled,
|
|
53
|
+
onSelect: item.onClick,
|
|
54
|
+
children: item.label
|
|
55
|
+
},
|
|
56
|
+
i
|
|
57
|
+
)),
|
|
58
|
+
showSep && dangerItems.length > 0 && /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
59
|
+
dangerItems.map((item, i) => /* @__PURE__ */ jsx(
|
|
60
|
+
DropdownMenuItem,
|
|
61
|
+
{
|
|
62
|
+
icon: item.icon,
|
|
63
|
+
tone: "danger",
|
|
64
|
+
disabled: item.disabled,
|
|
65
|
+
onSelect: item.onClick,
|
|
66
|
+
children: item.label
|
|
67
|
+
},
|
|
68
|
+
`d-${i}`
|
|
69
|
+
))
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
) })
|
|
73
|
+
] });
|
|
73
74
|
}
|
|
74
75
|
export {
|
|
75
76
|
RowActions
|
|
@@ -11,11 +11,6 @@ type SavingBarRegistration = {
|
|
|
11
11
|
pending?: boolean;
|
|
12
12
|
saveLabel?: string;
|
|
13
13
|
discardLabel?: string;
|
|
14
|
-
/** Optional third button shown between Discard and Save. Hidden when bars are aggregated. */
|
|
15
|
-
secondary?: {
|
|
16
|
-
label: string;
|
|
17
|
-
onClick: () => void;
|
|
18
|
-
};
|
|
19
14
|
};
|
|
20
15
|
declare function SavingBarProvider({ children }: {
|
|
21
16
|
children: ReactNode;
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
__spreadProps,
|
|
4
4
|
__spreadValues
|
|
5
5
|
} from "../chunk-ORMEWXMH.js";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
7
|
import {
|
|
7
8
|
createContext,
|
|
8
9
|
useCallback,
|
|
@@ -13,7 +14,7 @@ import {
|
|
|
13
14
|
useRef,
|
|
14
15
|
useState
|
|
15
16
|
} from "react";
|
|
16
|
-
import {
|
|
17
|
+
import { SavingBar } from "./saving-bar.js";
|
|
17
18
|
const SavingBarContext = createContext({
|
|
18
19
|
bars: /* @__PURE__ */ new Map(),
|
|
19
20
|
register: () => {
|
|
@@ -39,7 +40,7 @@ function SavingBarProvider({ children }) {
|
|
|
39
40
|
});
|
|
40
41
|
}, []);
|
|
41
42
|
const value = useMemo(() => ({ bars, register, unregister }), [bars, register, unregister]);
|
|
42
|
-
return /* @__PURE__ */
|
|
43
|
+
return /* @__PURE__ */ jsx(SavingBarContext.Provider, { value, children });
|
|
43
44
|
}
|
|
44
45
|
function usePageSavingBar(reg, deps = []) {
|
|
45
46
|
const id = useId();
|
|
@@ -58,7 +59,7 @@ function useSavingBarActive() {
|
|
|
58
59
|
return false;
|
|
59
60
|
}
|
|
60
61
|
function SavingBarRoot() {
|
|
61
|
-
var _a, _b
|
|
62
|
+
var _a, _b;
|
|
62
63
|
const { bars } = useContext(SavingBarContext);
|
|
63
64
|
const [aggPending, setAggPending] = useState(false);
|
|
64
65
|
const visible = useMemo(
|
|
@@ -82,40 +83,21 @@ function SavingBarRoot() {
|
|
|
82
83
|
var _a2;
|
|
83
84
|
for (const b of visible) (_a2 = b.onDiscard) == null ? void 0 : _a2.call(b);
|
|
84
85
|
}
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
const discardLabel = (_c = single == null ? void 0 : single.discardLabel) != null ? _c : "Descartar tudo";
|
|
86
|
+
const saveLabel = (_a = single == null ? void 0 : single.saveLabel) != null ? _a : "Salvar tudo";
|
|
87
|
+
const discardLabel = (_b = single == null ? void 0 : single.discardLabel) != null ? _b : "Descartar tudo";
|
|
88
88
|
const onSave = single ? single.onSave : saveAll;
|
|
89
89
|
const onDiscard = single ? single.onDiscard : discardAll;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
"button",
|
|
90
|
+
return /* @__PURE__ */ jsx("div", { className: "rds-saving-bar-root", children: /* @__PURE__ */ jsx(
|
|
91
|
+
SavingBar,
|
|
93
92
|
{
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
{
|
|
103
|
-
type: "button",
|
|
104
|
-
onClick: secondary.onClick,
|
|
105
|
-
disabled: anyPending,
|
|
106
|
-
className: "rounded-(--radius-card) border px-3 py-1.5 text-label font-medium transition-colors disabled:opacity-40 [border-color:var(--saving-bar-discard-border)] [color:var(--saving-bar-discard-text)] hover:[border-color:var(--saving-bar-discard-border-hover)] hover:[color:var(--saving-bar-discard-text-hover)]"
|
|
107
|
-
},
|
|
108
|
-
secondary.label
|
|
109
|
-
), onSave && /* @__PURE__ */ React.createElement(
|
|
110
|
-
"button",
|
|
111
|
-
{
|
|
112
|
-
type: "button",
|
|
113
|
-
onClick: () => onSave(),
|
|
114
|
-
disabled: anyPending,
|
|
115
|
-
className: "rounded-(--radius-card) px-4 py-1.5 text-label font-medium transition-colors disabled:opacity-50 flex items-center gap-2 min-w-[80px] justify-center [background:var(--saving-bar-save-bg)] [color:var(--saving-bar-save-text)] hover:[background:var(--saving-bar-save-bg-hover)]"
|
|
116
|
-
},
|
|
117
|
-
anyPending ? /* @__PURE__ */ React.createElement(Loader2, { className: "w-4 h-4 animate-spin" }) : saveLabel
|
|
118
|
-
)));
|
|
93
|
+
status: anyPending ? "saving" : "unsaved",
|
|
94
|
+
message: single ? single.message : `${visible.length} altera\xE7\xF5es pendentes`,
|
|
95
|
+
saveLabel,
|
|
96
|
+
discardLabel,
|
|
97
|
+
onSave: () => void (onSave == null ? void 0 : onSave()),
|
|
98
|
+
onDiscard
|
|
99
|
+
}
|
|
100
|
+
) });
|
|
119
101
|
}
|
|
120
102
|
export {
|
|
121
103
|
SavingBarProvider,
|
|
@@ -1,18 +1,33 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
2
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
type SavingBarStatus = 'unsaved' | 'saving' | 'error';
|
|
5
|
+
interface SavingBarProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
/**
|
|
7
|
+
* unsaved: the message and the actions; saving: a turning loader and `savingMessage`, buttons off;
|
|
8
|
+
* error: an alert, `errorMessage`, and Salvar becomes `retryLabel` (Figma: `status`).
|
|
9
|
+
*/
|
|
10
|
+
status?: SavingBarStatus;
|
|
11
|
+
/** The unsaved text (Figma: `message`). */
|
|
12
|
+
message?: ReactNode;
|
|
13
|
+
/** The text while saving. */
|
|
14
|
+
savingMessage?: ReactNode;
|
|
15
|
+
/** The error text. */
|
|
16
|
+
errorMessage?: ReactNode;
|
|
17
|
+
/** Called by Salvar (and by Tentar de novo, on error). */
|
|
18
|
+
onSave: () => void;
|
|
19
|
+
/** Shows Descartar and is called when it is pressed (Figma: `showDiscard`). */
|
|
7
20
|
onDiscard?: () => void;
|
|
8
|
-
pending?: boolean;
|
|
9
21
|
saveLabel?: string;
|
|
22
|
+
retryLabel?: string;
|
|
10
23
|
discardLabel?: string;
|
|
11
|
-
message?: string;
|
|
12
|
-
children?: ReactNode;
|
|
13
|
-
/** floating = fixed bottom-right; inline = inside page flow */
|
|
14
|
-
variant?: 'floating' | 'inline';
|
|
15
24
|
}
|
|
16
|
-
|
|
25
|
+
/**
|
|
26
|
+
* SavingBar — Figma [RDS] Actions/SavingBar. Shows at the foot of the screen while a change is not
|
|
27
|
+
* saved, and leaves once saved. Painted with colors/primary on purpose: a state that waits for a
|
|
28
|
+
* decision, not a notice. It does not place itself: put it sticky or fixed at the bottom.
|
|
29
|
+
* Its Buttons use the inverse tone, drawn for the colors/primary band in both modes. Styles: saving-bar.css.
|
|
30
|
+
*/
|
|
31
|
+
declare function SavingBar({ status, message, savingMessage, errorMessage, onSave, onDiscard, saveLabel, retryLabel, discardLabel, className, ...rest }: SavingBarProps): react.JSX.Element;
|
|
17
32
|
|
|
18
|
-
export { SavingBar, type SavingBarProps };
|
|
33
|
+
export { SavingBar, type SavingBarProps, type SavingBarStatus };
|