@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,78 +1,97 @@
|
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { useEffect, useRef } from "react";
|
|
9
|
+
import { ChoiceRow } from "./internal/choice.js";
|
|
10
|
+
import { hasContent, warnIfUnlabelled } from "./internal/field.js";
|
|
11
|
+
import { CheckIcon, MinusIcon } from "./internal/icons.js";
|
|
12
|
+
function Checkbox(_a) {
|
|
13
|
+
var _b = _a, {
|
|
14
|
+
children,
|
|
15
|
+
hint,
|
|
16
|
+
checked,
|
|
17
|
+
onCheckedChange,
|
|
18
|
+
error,
|
|
19
|
+
errorMessage,
|
|
20
|
+
required,
|
|
21
|
+
disabled,
|
|
22
|
+
id,
|
|
23
|
+
className,
|
|
24
|
+
style,
|
|
25
|
+
onChange,
|
|
26
|
+
ref
|
|
27
|
+
} = _b, input = __objRest(_b, [
|
|
28
|
+
"children",
|
|
29
|
+
"hint",
|
|
30
|
+
"checked",
|
|
31
|
+
"onCheckedChange",
|
|
32
|
+
"error",
|
|
33
|
+
"errorMessage",
|
|
34
|
+
"required",
|
|
35
|
+
"disabled",
|
|
36
|
+
"id",
|
|
37
|
+
"className",
|
|
38
|
+
"style",
|
|
39
|
+
"onChange",
|
|
40
|
+
"ref"
|
|
41
|
+
]);
|
|
42
|
+
warnIfUnlabelled("Checkbox", children, input["aria-label"], input["aria-labelledby"]);
|
|
43
|
+
const own = useRef(null);
|
|
44
|
+
const indeterminate = checked === "indeterminate";
|
|
19
45
|
useEffect(() => {
|
|
20
|
-
if (
|
|
46
|
+
if (own.current) own.current.indeterminate = indeterminate;
|
|
21
47
|
}, [indeterminate]);
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
48
|
+
const invalid = Boolean(error || hasContent(errorMessage));
|
|
49
|
+
function change(event) {
|
|
50
|
+
onChange == null ? void 0 : onChange(event);
|
|
51
|
+
onCheckedChange == null ? void 0 : onCheckedChange(event.target.checked);
|
|
52
|
+
}
|
|
53
|
+
function setRef(node) {
|
|
54
|
+
own.current = node;
|
|
55
|
+
if (node) node.indeterminate = indeterminate;
|
|
56
|
+
if (typeof ref === "function") ref(node);
|
|
57
|
+
else if (ref) ref.current = node;
|
|
58
|
+
}
|
|
59
|
+
return /* @__PURE__ */ jsx(
|
|
60
|
+
ChoiceRow,
|
|
28
61
|
{
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
/* @__PURE__ */ React.createElement("path", { d: "M3.5 8L6.5 11L12.5 5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
63
|
-
), /* @__PURE__ */ React.createElement(
|
|
64
|
-
"svg",
|
|
65
|
-
{
|
|
66
|
-
className: ["absolute inset-0 pointer-events-none hidden peer-indeterminate:block text-brand-on-primary", sz.svg].join(" "),
|
|
67
|
-
viewBox: "0 0 16 16",
|
|
68
|
-
fill: "none",
|
|
69
|
-
"aria-hidden": "true"
|
|
70
|
-
},
|
|
71
|
-
/* @__PURE__ */ React.createElement("path", { d: "M4 8H12", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })
|
|
72
|
-
)),
|
|
73
|
-
(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))
|
|
74
|
-
), error && /* @__PURE__ */ React.createElement("p", { id: errId, className: [sz.box === "size-3.5" ? "pl-5" : "pl-6", "text-caption text-danger-text"].join(" ") }, error));
|
|
75
|
-
});
|
|
62
|
+
kind: "rds-checkbox",
|
|
63
|
+
id,
|
|
64
|
+
label: children,
|
|
65
|
+
hint,
|
|
66
|
+
required,
|
|
67
|
+
disabled,
|
|
68
|
+
invalid,
|
|
69
|
+
errorMessage,
|
|
70
|
+
className,
|
|
71
|
+
style,
|
|
72
|
+
control: ({ id: controlId, describedBy }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
73
|
+
/* @__PURE__ */ jsx(
|
|
74
|
+
"input",
|
|
75
|
+
__spreadProps(__spreadValues(__spreadProps(__spreadValues({}, input), {
|
|
76
|
+
ref: setRef,
|
|
77
|
+
id: controlId,
|
|
78
|
+
type: "checkbox"
|
|
79
|
+
}), checked !== void 0 ? { checked: checked === true } : {}), {
|
|
80
|
+
required,
|
|
81
|
+
disabled,
|
|
82
|
+
"aria-invalid": invalid || void 0,
|
|
83
|
+
"aria-describedby": [describedBy, input["aria-describedby"]].filter(Boolean).join(" ") || void 0,
|
|
84
|
+
onChange: change
|
|
85
|
+
})
|
|
86
|
+
),
|
|
87
|
+
/* @__PURE__ */ jsxs("span", { className: "rds-checkbox__box", "aria-hidden": "true", children: [
|
|
88
|
+
/* @__PURE__ */ jsx("span", { className: "rds-checkbox__check", children: /* @__PURE__ */ jsx(CheckIcon, {}) }),
|
|
89
|
+
/* @__PURE__ */ jsx("span", { className: "rds-checkbox__minus", children: /* @__PURE__ */ jsx(MinusIcon, {}) })
|
|
90
|
+
] })
|
|
91
|
+
] })
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
}
|
|
76
95
|
export {
|
|
77
96
|
Checkbox
|
|
78
97
|
};
|
|
@@ -1,26 +1,52 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
2
|
+
import { ReactNode, CSSProperties } from 'react';
|
|
3
|
+
import { FieldTextProps } from './internal/field.js';
|
|
3
4
|
|
|
4
|
-
interface
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
value
|
|
10
|
-
onChange
|
|
11
|
-
/**
|
|
12
|
-
suggestions?: ChipItem[];
|
|
5
|
+
interface ChipInputProps extends Omit<FieldTextProps, 'labelPosition'> {
|
|
6
|
+
/** Controlled: the values, one Chip each (Figma: `filled` is `value.length > 0`). */
|
|
7
|
+
value?: string[];
|
|
8
|
+
/** Uncontrolled: the values at first. */
|
|
9
|
+
defaultValue?: string[];
|
|
10
|
+
/** Called with the new list when a value is added or removed. */
|
|
11
|
+
onChange?: (value: string[]) => void;
|
|
12
|
+
/** What shows in the empty field (Figma: `text`). Say how to add: "Digite e aperte Enter". */
|
|
13
13
|
placeholder?: string;
|
|
14
|
-
/**
|
|
14
|
+
/** @deprecated Use `hint`. */
|
|
15
15
|
helper?: ReactNode;
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Values to offer while typing: the list under the field filters them by the text (ignoring case and accents),
|
|
18
|
+
* the arrows move in it and Enter takes the active one.
|
|
19
|
+
*/
|
|
20
|
+
suggestions?: string[];
|
|
21
|
+
/**
|
|
22
|
+
* Called with the typed text before it becomes a Chip. Return the value to add (trimmed, normalised), or null to
|
|
23
|
+
* refuse it; nothing (undefined) adds the text as typed. May be async. With suggestions, the list offers
|
|
24
|
+
* `Criar "<texto>"` when nothing matches exactly.
|
|
25
|
+
*/
|
|
26
|
+
onCreate?: (text: string) => string | null | void | Promise<string | null | void>;
|
|
27
|
+
/** The create option's text. By default `Criar "<texto>"`. */
|
|
28
|
+
createLabel?: (text: string) => string;
|
|
29
|
+
/** The most values: past it the text does not become a Chip. Say it in the hint and show the errorMessage. */
|
|
30
|
+
max?: number;
|
|
31
|
+
/** The ×'s name for each Chip. By default "Remover <valor>". */
|
|
32
|
+
removeLabel?: (value: string) => string;
|
|
33
|
+
/** The form field name: one hidden input per value. */
|
|
34
|
+
name?: string;
|
|
35
|
+
disabled?: boolean;
|
|
36
|
+
id?: string;
|
|
37
|
+
className?: string;
|
|
38
|
+
style?: CSSProperties;
|
|
39
|
+
/** The name when there is no visible label. */
|
|
40
|
+
'aria-label'?: string;
|
|
41
|
+
'aria-labelledby'?: string;
|
|
23
42
|
}
|
|
24
|
-
|
|
43
|
+
/**
|
|
44
|
+
* ChipInput — Figma [RDS] Forms/ChipInput. A field that turns what is typed into Chips: Enter or a comma makes the
|
|
45
|
+
* text a Chip, Backspace on the empty field takes the last one, and each Chip's × removes it. For several short,
|
|
46
|
+
* free values: tags, guests' e-mails, keywords. Choosing from a closed list is the Combobox (multiple) or the
|
|
47
|
+
* CheckboxGroup. Label, hint, error and required as in the Input. Styles: chip-input.css, internal/field.css,
|
|
48
|
+
* internal/listbox.css and chip.css.
|
|
49
|
+
*/
|
|
50
|
+
declare function ChipInput({ label, hint, helper, error, errorMessage, required, value, defaultValue, onChange, placeholder, suggestions, onCreate, createLabel, max, removeLabel, name, disabled, id, className, style, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, }: ChipInputProps): react.JSX.Element;
|
|
25
51
|
|
|
26
|
-
export { ChipInput, type ChipInputProps
|
|
52
|
+
export { ChipInput, type ChipInputProps };
|
|
@@ -1,181 +1,194 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import {
|
|
3
|
+
__spreadProps,
|
|
4
|
+
__spreadValues
|
|
5
|
+
} from "../chunk-ORMEWXMH.js";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { useRef, useState } from "react";
|
|
8
|
+
import { Chip } from "./chip.js";
|
|
9
|
+
import { announce } from "./internal/announce.js";
|
|
10
|
+
import { FieldShell, useFieldIds, warnIfUnlabelled } from "./internal/field.js";
|
|
11
|
+
import { PlusIcon } from "./internal/icons.js";
|
|
12
|
+
import { OptionContent } from "./internal/option-content.js";
|
|
13
|
+
import { useListbox } from "./internal/use-listbox.js";
|
|
14
|
+
const CREATE = "\0create";
|
|
15
|
+
const normalize = (text) => text.normalize("NFD").replace(new RegExp("\\p{Diacritic}", "gu"), "").toLowerCase();
|
|
6
16
|
function ChipInput({
|
|
17
|
+
label,
|
|
18
|
+
hint,
|
|
19
|
+
helper,
|
|
20
|
+
error,
|
|
21
|
+
errorMessage,
|
|
22
|
+
required,
|
|
7
23
|
value,
|
|
24
|
+
defaultValue = [],
|
|
8
25
|
onChange,
|
|
9
|
-
suggestions = [],
|
|
10
26
|
placeholder,
|
|
11
|
-
|
|
27
|
+
suggestions,
|
|
12
28
|
onCreate,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
29
|
+
createLabel = (text) => `Criar "${text}"`,
|
|
30
|
+
max,
|
|
31
|
+
removeLabel,
|
|
32
|
+
name,
|
|
33
|
+
disabled,
|
|
34
|
+
id,
|
|
35
|
+
className,
|
|
36
|
+
style,
|
|
37
|
+
"aria-label": ariaLabel,
|
|
38
|
+
"aria-labelledby": ariaLabelledBy
|
|
16
39
|
}) {
|
|
17
|
-
|
|
40
|
+
warnIfUnlabelled("ChipInput", label, ariaLabel, ariaLabelledBy);
|
|
41
|
+
const shownHint = hint != null ? hint : helper;
|
|
42
|
+
const { controlId, hintId, errorId, invalid, describedBy } = useFieldIds(id, shownHint, error, errorMessage);
|
|
43
|
+
const [own, setOwn] = useState(defaultValue);
|
|
44
|
+
const values = value != null ? value : own;
|
|
45
|
+
const input = useRef(null);
|
|
46
|
+
const [text, setText] = useState("");
|
|
18
47
|
const [open, setOpen] = useState(false);
|
|
19
|
-
const [
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
setOpen(false);
|
|
30
|
-
}
|
|
31
|
-
document.addEventListener("mousedown", onOutside);
|
|
32
|
-
return () => document.removeEventListener("mousedown", onOutside);
|
|
33
|
-
}, []);
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
if (!open) return;
|
|
36
|
-
function update() {
|
|
37
|
-
const el = containerRef.current;
|
|
38
|
-
if (!el) return;
|
|
39
|
-
const r = el.getBoundingClientRect();
|
|
40
|
-
setPos({ top: r.bottom + 4, left: r.left, width: r.width });
|
|
41
|
-
}
|
|
42
|
-
update();
|
|
43
|
-
window.addEventListener("scroll", update, true);
|
|
44
|
-
window.addEventListener("resize", update);
|
|
45
|
-
return () => {
|
|
46
|
-
window.removeEventListener("scroll", update, true);
|
|
47
|
-
window.removeEventListener("resize", update);
|
|
48
|
-
};
|
|
49
|
-
}, [open]);
|
|
50
|
-
const trimmed = input.trim();
|
|
51
|
-
const filtered = suggestions.filter(
|
|
52
|
-
(s) => !value.some((v) => v.id === s.id) && s.label.toLowerCase().includes(trimmed.toLowerCase())
|
|
53
|
-
);
|
|
54
|
-
const exactMatch = suggestions.some((s) => s.label.toLowerCase() === trimmed.toLowerCase());
|
|
55
|
-
const showCreate = !!onCreate && trimmed.length > 0 && !exactMatch;
|
|
56
|
-
function selectChip(chip) {
|
|
57
|
-
if (value.some((v) => v.id === chip.id)) return;
|
|
58
|
-
onChange([...value, chip]);
|
|
59
|
-
setInput("");
|
|
60
|
-
setOpen(false);
|
|
48
|
+
const [busy, setBusy] = useState(false);
|
|
49
|
+
const typed = text.trim();
|
|
50
|
+
const offered = (suggestions != null ? suggestions : []).filter((s) => !values.includes(s) && normalize(s).includes(normalize(typed)));
|
|
51
|
+
const exact = [...suggestions != null ? suggestions : [], ...values].some((s) => normalize(s) === normalize(typed));
|
|
52
|
+
const rows = offered.map((s) => ({ value: s, label: s }));
|
|
53
|
+
if (suggestions && typed && !exact) rows.push({ value: CREATE, label: createLabel(typed), create: typed });
|
|
54
|
+
const showList = open && !disabled && suggestions !== void 0 && rows.length > 0;
|
|
55
|
+
function commit(next) {
|
|
56
|
+
if (value === void 0) setOwn(next);
|
|
57
|
+
onChange == null ? void 0 : onChange(next);
|
|
61
58
|
}
|
|
62
|
-
function
|
|
63
|
-
|
|
59
|
+
function add(list) {
|
|
60
|
+
let next = values;
|
|
61
|
+
for (const item of list) {
|
|
62
|
+
if (!item || next.includes(item)) continue;
|
|
63
|
+
if (max !== void 0 && next.length >= max) break;
|
|
64
|
+
next = [...next, item];
|
|
65
|
+
announce(`${item} adicionado`);
|
|
66
|
+
}
|
|
67
|
+
if (next !== values) commit(next);
|
|
64
68
|
}
|
|
65
|
-
async function
|
|
66
|
-
|
|
67
|
-
|
|
69
|
+
async function create(raw) {
|
|
70
|
+
const parts = raw.split(",").map((part) => part.trim()).filter(Boolean);
|
|
71
|
+
if (!parts.length) return;
|
|
72
|
+
if (!onCreate) {
|
|
73
|
+
add(parts);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
setBusy(true);
|
|
68
77
|
try {
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
78
|
+
const made = await Promise.all(parts.map(async (part) => {
|
|
79
|
+
const result = await onCreate(part);
|
|
80
|
+
return result === void 0 ? part : result;
|
|
81
|
+
}));
|
|
82
|
+
add(made.filter((m) => typeof m === "string"));
|
|
75
83
|
} finally {
|
|
76
|
-
|
|
84
|
+
setBusy(false);
|
|
77
85
|
}
|
|
78
86
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
87
|
+
const { setActive, onKeyDown: listKeyDown, controlProps, listProps, optionProps } = useListbox({
|
|
88
|
+
items: rows,
|
|
89
|
+
showing: showList,
|
|
90
|
+
selected: [],
|
|
91
|
+
onOpen: () => setOpen(true),
|
|
92
|
+
onChoose: (row) => {
|
|
93
|
+
if (row.create) void create(row.create);
|
|
94
|
+
else add([row.value]);
|
|
95
|
+
setText("");
|
|
96
|
+
setActive(-1);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
function keyDown(event) {
|
|
100
|
+
if (suggestions && listKeyDown(event)) return;
|
|
101
|
+
if (event.key === "Enter" || event.key === ",") {
|
|
102
|
+
if (!typed) {
|
|
103
|
+
if (event.key === ",") event.preventDefault();
|
|
84
104
|
return;
|
|
85
105
|
}
|
|
86
|
-
|
|
87
|
-
return;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
106
|
+
event.preventDefault();
|
|
107
|
+
if (busy) return;
|
|
108
|
+
void create(text);
|
|
109
|
+
setText("");
|
|
110
|
+
setActive(-1);
|
|
111
|
+
} else if (event.key === "Escape" && open) {
|
|
112
|
+
event.preventDefault();
|
|
113
|
+
setOpen(false);
|
|
114
|
+
setActive(-1);
|
|
115
|
+
} else if (event.key === "Backspace" && text === "" && values.length) {
|
|
116
|
+
const last = values[values.length - 1];
|
|
117
|
+
commit(values.slice(0, -1));
|
|
118
|
+
announce(`${last} removido`);
|
|
91
119
|
}
|
|
92
120
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
onClick: () => {
|
|
98
|
-
var _a;
|
|
99
|
-
return (_a = inputRef.current) == null ? void 0 : _a.focus();
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
value.map((chip) => {
|
|
121
|
+
function remove(item) {
|
|
122
|
+
const next = values.filter((v) => v !== item);
|
|
123
|
+
commit(next);
|
|
124
|
+
if (next.length === 0) requestAnimationFrame(() => {
|
|
103
125
|
var _a;
|
|
104
|
-
return
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
126
|
+
return (_a = input.current) == null ? void 0 : _a.focus();
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
const listName = typeof label === "string" ? `Sugest\xF5es para ${label}` : "Sugest\xF5es";
|
|
130
|
+
return /* @__PURE__ */ jsxs(
|
|
131
|
+
FieldShell,
|
|
132
|
+
{
|
|
133
|
+
kind: "rds-chip-input",
|
|
134
|
+
controlId,
|
|
135
|
+
hintId,
|
|
136
|
+
errorId,
|
|
137
|
+
label,
|
|
138
|
+
hint: shownHint,
|
|
139
|
+
errorMessage,
|
|
140
|
+
invalid,
|
|
141
|
+
required,
|
|
142
|
+
disabled,
|
|
143
|
+
boxClassName: "rds-chip-input__box",
|
|
144
|
+
className,
|
|
145
|
+
style,
|
|
146
|
+
children: [
|
|
147
|
+
values.length > 0 && /* @__PURE__ */ jsx("ul", { className: "rds-chip-input__chips", role: "list", "aria-label": `Valores: ${values.length}`, children: values.map((item) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(Chip, { disabled, onRemove: () => remove(item), removeLabel: removeLabel == null ? void 0 : removeLabel(item), children: item }) }, item)) }),
|
|
148
|
+
/* @__PURE__ */ jsx(
|
|
149
|
+
"input",
|
|
150
|
+
__spreadProps(__spreadValues({
|
|
151
|
+
ref: input,
|
|
152
|
+
id: controlId,
|
|
153
|
+
className: "rds-field__control",
|
|
154
|
+
type: "text",
|
|
155
|
+
autoComplete: "off",
|
|
156
|
+
enterKeyHint: "enter"
|
|
157
|
+
}, suggestions ? __spreadValues({ role: "combobox", "aria-autocomplete": "list" }, controlProps) : {}), {
|
|
158
|
+
"aria-label": ariaLabel,
|
|
159
|
+
"aria-labelledby": ariaLabelledBy,
|
|
160
|
+
"aria-invalid": invalid || void 0,
|
|
161
|
+
"aria-describedby": describedBy,
|
|
162
|
+
"aria-required": required || void 0,
|
|
163
|
+
"aria-busy": busy || void 0,
|
|
164
|
+
disabled,
|
|
165
|
+
placeholder: values.length ? void 0 : placeholder,
|
|
166
|
+
value: text,
|
|
167
|
+
onChange: (event) => {
|
|
168
|
+
const next = event.target.value;
|
|
169
|
+
const cut = next.lastIndexOf(",");
|
|
170
|
+
if (cut >= 0) {
|
|
171
|
+
void create(next.slice(0, cut));
|
|
172
|
+
setText(next.slice(cut + 1).trimStart());
|
|
173
|
+
} else {
|
|
174
|
+
setText(next);
|
|
175
|
+
}
|
|
176
|
+
setOpen(true);
|
|
177
|
+
setActive(-1);
|
|
118
178
|
},
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
onChange: (e) => {
|
|
133
|
-
setInput(e.target.value);
|
|
134
|
-
setOpen(true);
|
|
135
|
-
},
|
|
136
|
-
onKeyDown: handleKeyDown,
|
|
137
|
-
onFocus: () => setOpen(true),
|
|
138
|
-
placeholder: value.length === 0 ? placeholder : "",
|
|
139
|
-
className: "flex-1 min-w-[120px] bg-transparent text-label text-(--text-secondary) placeholder:text-(--text-disabled) focus:outline-none"
|
|
140
|
-
}
|
|
141
|
-
)
|
|
142
|
-
), open && pos && (filtered.length > 0 || showCreate) && createPortal(
|
|
143
|
-
/* @__PURE__ */ React.createElement(
|
|
144
|
-
"ul",
|
|
145
|
-
{
|
|
146
|
-
ref: listRef,
|
|
147
|
-
style: { position: "fixed", top: pos.top, left: pos.left, width: pos.width },
|
|
148
|
-
className: "z-50 bg-surface-default border border-stroke-control rounded-(--radius-control) shadow-md max-h-48 overflow-auto"
|
|
149
|
-
},
|
|
150
|
-
filtered.map((s) => /* @__PURE__ */ React.createElement("li", { key: s.id }, /* @__PURE__ */ React.createElement(
|
|
151
|
-
"button",
|
|
152
|
-
{
|
|
153
|
-
type: "button",
|
|
154
|
-
onMouseDown: (e) => {
|
|
155
|
-
e.preventDefault();
|
|
156
|
-
selectChip(s);
|
|
157
|
-
},
|
|
158
|
-
className: "w-full text-left px-3 py-2 text-label text-(--text-secondary) hover:bg-(--surface-page) transition-colors"
|
|
159
|
-
},
|
|
160
|
-
s.label
|
|
161
|
-
))),
|
|
162
|
-
showCreate && /* @__PURE__ */ React.createElement("li", { className: filtered.length > 0 ? "border-t border-stroke-subtle" : "" }, /* @__PURE__ */ React.createElement(
|
|
163
|
-
"button",
|
|
164
|
-
{
|
|
165
|
-
type: "button",
|
|
166
|
-
disabled: creating,
|
|
167
|
-
onMouseDown: (e) => {
|
|
168
|
-
e.preventDefault();
|
|
169
|
-
void handleCreate();
|
|
170
|
-
},
|
|
171
|
-
className: "w-full text-left px-3 py-2 text-label font-medium text-(--text-primary) hover:bg-(--surface-page) transition-colors flex items-center gap-2 disabled:opacity-50"
|
|
172
|
-
},
|
|
173
|
-
/* @__PURE__ */ React.createElement("span", { className: "text-(--text-disabled)" }, "+"),
|
|
174
|
-
creating ? creatingLabel : /* @__PURE__ */ React.createElement(React.Fragment, null, createPrefix, " ", /* @__PURE__ */ React.createElement("span", { className: "font-semibold" }, `"${trimmed}"`))
|
|
175
|
-
))
|
|
176
|
-
),
|
|
177
|
-
document.body
|
|
178
|
-
), helper && /* @__PURE__ */ React.createElement("p", { className: "mt-1 text-caption text-(--text-disabled)" }, helper));
|
|
179
|
+
onFocus: () => setOpen(true),
|
|
180
|
+
onKeyDown: keyDown,
|
|
181
|
+
onBlur: () => {
|
|
182
|
+
setOpen(false);
|
|
183
|
+
setActive(-1);
|
|
184
|
+
}
|
|
185
|
+
})
|
|
186
|
+
),
|
|
187
|
+
name && values.map((item) => /* @__PURE__ */ jsx("input", { type: "hidden", name, value: item }, item)),
|
|
188
|
+
showList && /* @__PURE__ */ jsx("ul", __spreadProps(__spreadValues({}, listProps), { "aria-label": listName, className: "rds-listbox rds-chip-input__list", children: rows.map((row, index) => /* @__PURE__ */ jsx("li", __spreadProps(__spreadValues({}, optionProps(row, index)), { className: "rds-listbox__option", children: /* @__PURE__ */ jsx(OptionContent, { icon: row.create ? /* @__PURE__ */ jsx(PlusIcon, {}) : void 0, selected: false, children: row.label }) }), row.value)) }))
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
);
|
|
179
192
|
}
|
|
180
193
|
export {
|
|
181
194
|
ChipInput
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
interface ChipProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'children'> {
|
|
5
|
+
/** The chosen value (Figma: `label`): an applied filter, a recipient, a typed tag. */
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
/** Icon before the label (Figma: `showIcon` + `iconName`). Decorative, rendered with aria-hidden. */
|
|
8
|
+
icon?: ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* Shows the × (Figma: `showRemove`) and is called when it is pressed. Only the × removes: the chip
|
|
11
|
+
* itself is not a button. After the removal, focus goes to the next chip's × in the same list (or the
|
|
12
|
+
* previous one).
|
|
13
|
+
*/
|
|
14
|
+
onRemove?: () => void;
|
|
15
|
+
/** The ×'s accessible name. By default "Remover <label>", which needs a text label. */
|
|
16
|
+
removeLabel?: string;
|
|
17
|
+
/** Said to screen readers after the removal. By default "<label> removido". */
|
|
18
|
+
removedMessage?: string;
|
|
19
|
+
/** Rendered as aria-disabled="true": the × stays in the tab order, but pressing it does nothing. */
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Chip — Figma [RDS] Actions/Chip. A chosen value that can be taken away. Not for choosing options
|
|
24
|
+
* (Toggle, ToggleGroup) and not for labelling without an action (Badge). Styles: chip.css.
|
|
25
|
+
*/
|
|
26
|
+
declare function Chip({ children, icon, onRemove, removeLabel, removedMessage, disabled, className, ...rest }: ChipProps): react.JSX.Element;
|
|
27
|
+
|
|
28
|
+
export { Chip, type ChipProps };
|