@primecoderin/fast-ui-react 0.0.0-stage → 0.1.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/CHANGELOG.md +90 -0
- package/LICENSE +21 -0
- package/README.md +180 -3
- package/dist/_virtual/_rolldown/runtime.js +12 -0
- package/dist/charts.d.ts +7 -0
- package/dist/charts.js +7 -0
- package/dist/components/Avatar/Avatar.d.ts +12 -0
- package/dist/components/Avatar/Avatar.js +92 -0
- package/dist/components/Button/Button.d.ts +44 -0
- package/dist/components/Button/Button.js +221 -0
- package/dist/components/Checkbox/CheckboxBox.d.ts +33 -0
- package/dist/components/Checkbox/CheckboxBox.js +148 -0
- package/dist/components/CodeSnippet/CodeSnippet.d.ts +26 -0
- package/dist/components/CodeSnippet/CodeSnippet.js +153 -0
- package/dist/components/Collapsible/Collapsible.d.ts +20 -0
- package/dist/components/Collapsible/Collapsible.js +97 -0
- package/dist/components/Container/Container.d.ts +301 -0
- package/dist/components/Container/Container.js +20 -0
- package/dist/components/FloatingActionButton/FloatingActionButton.d.ts +22 -0
- package/dist/components/FloatingActionButton/FloatingActionButton.js +141 -0
- package/dist/components/Grid/Grid.d.ts +311 -0
- package/dist/components/Grid/Grid.js +30 -0
- package/dist/components/IconTile/IconTile.d.ts +12 -0
- package/dist/components/IconTile/IconTile.js +70 -0
- package/dist/components/InlineError/InlineError.d.ts +9 -0
- package/dist/components/InlineError/InlineError.js +62 -0
- package/dist/components/Kbd/Kbd.d.ts +11 -0
- package/dist/components/Kbd/Kbd.js +31 -0
- package/dist/components/Link/Link.d.ts +18 -0
- package/dist/components/Link/Link.js +68 -0
- package/dist/components/Menu/ContextMenu.d.ts +18 -0
- package/dist/components/Menu/ContextMenu.js +68 -0
- package/dist/components/Menu/Menu.d.ts +86 -0
- package/dist/components/Menu/Menu.js +394 -0
- package/dist/components/OtpInput/OtpInput.d.ts +32 -0
- package/dist/components/OtpInput/OtpInput.js +177 -0
- package/dist/components/Popover/HoverPopover.d.ts +22 -0
- package/dist/components/Popover/HoverPopover.js +74 -0
- package/dist/components/Popover/Popover.d.ts +21 -0
- package/dist/components/Popover/Popover.js +64 -0
- package/dist/components/ProgressBar/ProgressBar.d.ts +17 -0
- package/dist/components/ProgressBar/ProgressBar.js +44 -0
- package/dist/components/Rating/Rating.d.ts +49 -0
- package/dist/components/Rating/Rating.js +241 -0
- package/dist/components/ScrollArea/ScrollArea.d.ts +23 -0
- package/dist/components/ScrollArea/ScrollArea.js +90 -0
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +29 -0
- package/dist/components/SegmentedControl/SegmentedControl.js +99 -0
- package/dist/components/Separator/Separator.d.ts +9 -0
- package/dist/components/Separator/Separator.js +34 -0
- package/dist/components/Skeleton/Skeleton.d.ts +31 -0
- package/dist/components/Skeleton/Skeleton.js +152 -0
- package/dist/components/Slider/Slider.d.ts +54 -0
- package/dist/components/Slider/Slider.js +178 -0
- package/dist/components/Spinner/Spinner.d.ts +17 -0
- package/dist/components/Spinner/Spinner.js +118 -0
- package/dist/components/Stack/Stack.d.ts +302 -0
- package/dist/components/Stack/Stack.js +14 -0
- package/dist/components/StateIcon/StateIcon.d.ts +11 -0
- package/dist/components/StateIcon/StateIcon.js +65 -0
- package/dist/components/StatusBadge/StatusBadge.d.ts +19 -0
- package/dist/components/StatusBadge/StatusBadge.js +82 -0
- package/dist/components/Tabs/Tabs.d.ts +28 -0
- package/dist/components/Tabs/Tabs.js +109 -0
- package/dist/components/Tag/Tag.d.ts +11 -0
- package/dist/components/Tag/Tag.js +66 -0
- package/dist/components/Toast/AppToaster.d.ts +8 -0
- package/dist/components/Toast/AppToaster.js +135 -0
- package/dist/components/Toast/toast-manager.d.ts +28 -0
- package/dist/components/Toast/toast-manager.js +47 -0
- package/dist/components/ToggleButton/ToggleButton.d.ts +26 -0
- package/dist/components/ToggleButton/ToggleButton.js +106 -0
- package/dist/components/ToggleGroup/ToggleGroup.d.ts +32 -0
- package/dist/components/ToggleGroup/ToggleGroup.js +79 -0
- package/dist/components/Tooltip/Tooltip.d.ts +16 -0
- package/dist/components/Tooltip/Tooltip.js +58 -0
- package/dist/components/Tooltip/TooltipGroup.d.ts +22 -0
- package/dist/components/Tooltip/TooltipGroup.js +65 -0
- package/dist/components/Typography/Typography.d.ts +17 -0
- package/dist/components/Typography/Typography.js +100 -0
- package/dist/editor-forms.d.ts +1 -0
- package/dist/editor-forms.js +1 -0
- package/dist/editor.d.ts +1 -0
- package/dist/editor.js +1 -0
- package/dist/fonts/LICENSE +93 -0
- package/dist/fonts/inter-cyrillic-ext-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-cyrillic-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-greek-ext-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-greek-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-latin-ext-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-latin-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-vietnamese-wght-normal.woff2 +0 -0
- package/dist/fonts.css +69 -0
- package/dist/forms.d.ts +22 -0
- package/dist/forms.js +23 -0
- package/dist/foundation.css +23 -0
- package/dist/global.css +116 -0
- package/dist/hooks/useAppToast.d.ts +12 -0
- package/dist/hooks/useAppToast.js +29 -0
- package/dist/icons/icons.d.ts +43 -0
- package/dist/icons/icons.js +44 -0
- package/dist/index.d.ts +106 -0
- package/dist/index.js +101 -0
- package/dist/patterns/Accordion/Accordion.d.ts +35 -0
- package/dist/patterns/Accordion/Accordion.js +139 -0
- package/dist/patterns/Alert/Alert.d.ts +38 -0
- package/dist/patterns/Alert/Alert.js +151 -0
- package/dist/patterns/AppShell/AppShell.d.ts +39 -0
- package/dist/patterns/AppShell/AppShell.js +218 -0
- package/dist/patterns/Breadcrumbs/Breadcrumbs.d.ts +21 -0
- package/dist/patterns/Breadcrumbs/Breadcrumbs.js +73 -0
- package/dist/patterns/Calendar/Calendar.d.ts +59 -0
- package/dist/patterns/Calendar/Calendar.js +283 -0
- package/dist/patterns/Calendar/DateRangePicker.d.ts +53 -0
- package/dist/patterns/Calendar/DateRangePicker.js +266 -0
- package/dist/patterns/Calendar/FormDateRangeField.d.ts +24 -0
- package/dist/patterns/Calendar/FormDateRangeField.js +138 -0
- package/dist/patterns/Card/Card.d.ts +26 -0
- package/dist/patterns/Card/Card.js +125 -0
- package/dist/patterns/Carousel/Carousel.d.ts +33 -0
- package/dist/patterns/Carousel/Carousel.js +127 -0
- package/dist/patterns/Cascader/Cascader.d.ts +53 -0
- package/dist/patterns/Cascader/Cascader.js +371 -0
- package/dist/patterns/Cascader/FormCascaderField.d.ts +21 -0
- package/dist/patterns/Cascader/FormCascaderField.js +130 -0
- package/dist/patterns/Charts/AreaChart.d.ts +13 -0
- package/dist/patterns/Charts/AreaChart.js +220 -0
- package/dist/patterns/Charts/BarChart.d.ts +11 -0
- package/dist/patterns/Charts/BarChart.js +220 -0
- package/dist/patterns/Charts/DonutChart.d.ts +37 -0
- package/dist/patterns/Charts/DonutChart.js +215 -0
- package/dist/patterns/Charts/GaugeChart.d.ts +44 -0
- package/dist/patterns/Charts/GaugeChart.js +210 -0
- package/dist/patterns/Charts/LineChart.d.ts +14 -0
- package/dist/patterns/Charts/LineChart.js +222 -0
- package/dist/patterns/Charts/Sparkline.d.ts +24 -0
- package/dist/patterns/Charts/Sparkline.js +81 -0
- package/dist/patterns/Charts/chart-parts.d.ts +139 -0
- package/dist/patterns/Charts/chart-parts.js +385 -0
- package/dist/patterns/Charts/gauge-math.d.ts +20 -0
- package/dist/patterns/Charts/gauge-math.js +21 -0
- package/dist/patterns/Charts/sparkline-path.d.ts +11 -0
- package/dist/patterns/Charts/sparkline-path.js +24 -0
- package/dist/patterns/ColorPicker/ColorPicker.d.ts +50 -0
- package/dist/patterns/ColorPicker/ColorPicker.js +590 -0
- package/dist/patterns/ColorPicker/FormColorField.d.ts +21 -0
- package/dist/patterns/ColorPicker/FormColorField.js +130 -0
- package/dist/patterns/ColorPicker/color-value.d.ts +19 -0
- package/dist/patterns/ColorPicker/color-value.js +72 -0
- package/dist/patterns/Combobox/Autocomplete.d.ts +48 -0
- package/dist/patterns/Combobox/Autocomplete.js +158 -0
- package/dist/patterns/Combobox/Combobox.d.ts +52 -0
- package/dist/patterns/Combobox/Combobox.js +195 -0
- package/dist/patterns/Combobox/ComboboxPopup.d.ts +24 -0
- package/dist/patterns/Combobox/ComboboxPopup.js +107 -0
- package/dist/patterns/Combobox/FormAutocompleteField.d.ts +17 -0
- package/dist/patterns/Combobox/FormAutocompleteField.js +119 -0
- package/dist/patterns/Combobox/FormComboboxField.d.ts +18 -0
- package/dist/patterns/Combobox/FormComboboxField.js +119 -0
- package/dist/patterns/Combobox/FormMultiSelectField.d.ts +18 -0
- package/dist/patterns/Combobox/FormMultiSelectField.js +119 -0
- package/dist/patterns/Combobox/MultiSelect.d.ts +54 -0
- package/dist/patterns/Combobox/MultiSelect.js +175 -0
- package/dist/patterns/CommandPalette/CommandPalette.d.ts +50 -0
- package/dist/patterns/CommandPalette/CommandPalette.js +193 -0
- package/dist/patterns/DataTable/DataTable.d.ts +107 -0
- package/dist/patterns/DataTable/DataTable.js +364 -0
- package/dist/patterns/DateTimePicker/DateTimePanel.d.ts +28 -0
- package/dist/patterns/DateTimePicker/DateTimePanel.js +444 -0
- package/dist/patterns/DateTimePicker/DateTimePicker.d.ts +75 -0
- package/dist/patterns/DateTimePicker/DateTimePicker.js +271 -0
- package/dist/patterns/DateTimePicker/FormDateTimeField.d.ts +32 -0
- package/dist/patterns/DateTimePicker/FormDateTimeField.js +148 -0
- package/dist/patterns/DateTimePicker/TimeSliders.d.ts +14 -0
- package/dist/patterns/DateTimePicker/TimeSliders.js +206 -0
- package/dist/patterns/DateTimePicker/picker-labels.d.ts +30 -0
- package/dist/patterns/DateTimePicker/picker-labels.js +23 -0
- package/dist/patterns/DateTimePicker/picker-values.d.ts +98 -0
- package/dist/patterns/DateTimePicker/picker-values.js +194 -0
- package/dist/patterns/DescriptionList/DescriptionList.d.ts +20 -0
- package/dist/patterns/DescriptionList/DescriptionList.js +57 -0
- package/dist/patterns/Dialog/Dialog.d.ts +26 -0
- package/dist/patterns/Dialog/Dialog.js +212 -0
- package/dist/patterns/Drawer/Drawer.d.ts +33 -0
- package/dist/patterns/Drawer/Drawer.js +153 -0
- package/dist/patterns/EmptyState/EmptyState.d.ts +35 -0
- package/dist/patterns/EmptyState/EmptyState.js +44 -0
- package/dist/patterns/FileUpload/FileUpload.d.ts +87 -0
- package/dist/patterns/FileUpload/FileUpload.js +417 -0
- package/dist/patterns/FileUpload/FormFileUploadField.d.ts +19 -0
- package/dist/patterns/FileUpload/FormFileUploadField.js +117 -0
- package/dist/patterns/FileUpload/add-files.d.ts +26 -0
- package/dist/patterns/FileUpload/add-files.js +35 -0
- package/dist/patterns/FileUpload/file-size.d.ts +14 -0
- package/dist/patterns/FileUpload/file-size.js +44 -0
- package/dist/patterns/FormField/CheckboxField.d.ts +26 -0
- package/dist/patterns/FormField/CheckboxField.js +97 -0
- package/dist/patterns/FormField/FieldFrame.d.ts +85 -0
- package/dist/patterns/FormField/FieldFrame.js +257 -0
- package/dist/patterns/FormField/FormCheckboxField.d.ts +17 -0
- package/dist/patterns/FormField/FormCheckboxField.js +92 -0
- package/dist/patterns/FormField/FormRadioGroupField.d.ts +16 -0
- package/dist/patterns/FormField/FormRadioGroupField.js +97 -0
- package/dist/patterns/FormField/FormRatingField.d.ts +19 -0
- package/dist/patterns/FormField/FormRatingField.js +119 -0
- package/dist/patterns/FormField/FormSelectField.d.ts +16 -0
- package/dist/patterns/FormField/FormSelectField.js +91 -0
- package/dist/patterns/FormField/FormSliderField.d.ts +22 -0
- package/dist/patterns/FormField/FormSliderField.js +128 -0
- package/dist/patterns/FormField/FormSwitchField.d.ts +19 -0
- package/dist/patterns/FormField/FormSwitchField.js +88 -0
- package/dist/patterns/FormField/FormTextAreaField.d.ts +12 -0
- package/dist/patterns/FormField/FormTextAreaField.js +91 -0
- package/dist/patterns/FormField/FormTextField.d.ts +23 -0
- package/dist/patterns/FormField/FormTextField.js +103 -0
- package/dist/patterns/FormField/RadioGroupField.d.ts +38 -0
- package/dist/patterns/FormField/RadioGroupField.js +201 -0
- package/dist/patterns/FormField/SelectField.d.ts +43 -0
- package/dist/patterns/FormField/SelectField.js +211 -0
- package/dist/patterns/FormField/SwitchField.d.ts +27 -0
- package/dist/patterns/FormField/SwitchField.js +105 -0
- package/dist/patterns/FormField/TextAreaField.d.ts +37 -0
- package/dist/patterns/FormField/TextAreaField.js +134 -0
- package/dist/patterns/FormField/TextField.d.ts +51 -0
- package/dist/patterns/FormField/TextField.js +256 -0
- package/dist/patterns/FormField/error-message.d.ts +6 -0
- package/dist/patterns/FormField/error-message.js +8 -0
- package/dist/patterns/FormField/field-styles.d.ts +44 -0
- package/dist/patterns/FormField/field-styles.js +89 -0
- package/dist/patterns/FormField/field-types.d.ts +4 -0
- package/dist/patterns/FormField/use-field-ids.d.ts +18 -0
- package/dist/patterns/FormField/use-field-ids.js +53 -0
- package/dist/patterns/List/List.d.ts +38 -0
- package/dist/patterns/List/List.js +174 -0
- package/dist/patterns/MentionsInput/FormMentionsField.d.ts +18 -0
- package/dist/patterns/MentionsInput/FormMentionsField.js +124 -0
- package/dist/patterns/MentionsInput/MentionsInput.d.ts +57 -0
- package/dist/patterns/MentionsInput/MentionsInput.js +133 -0
- package/dist/patterns/MentionsInput/mention-text.d.ts +24 -0
- package/dist/patterns/MentionsInput/mention-text.js +31 -0
- package/dist/patterns/Menubar/Menubar.d.ts +22 -0
- package/dist/patterns/Menubar/Menubar.js +79 -0
- package/dist/patterns/NavigationMenu/NavigationMenu.d.ts +27 -0
- package/dist/patterns/NavigationMenu/NavigationMenu.js +104 -0
- package/dist/patterns/NumberField/FormNumberField.d.ts +18 -0
- package/dist/patterns/NumberField/FormNumberField.js +119 -0
- package/dist/patterns/NumberField/NumberField.d.ts +57 -0
- package/dist/patterns/NumberField/NumberField.js +242 -0
- package/dist/patterns/Pagination/Pagination.d.ts +31 -0
- package/dist/patterns/Pagination/Pagination.js +275 -0
- package/dist/patterns/Pagination/page-items.d.ts +18 -0
- package/dist/patterns/Pagination/page-items.js +40 -0
- package/dist/patterns/PhoneField/FormPhoneField.d.ts +22 -0
- package/dist/patterns/PhoneField/FormPhoneField.js +97 -0
- package/dist/patterns/PhoneField/PhoneField.d.ts +60 -0
- package/dist/patterns/PhoneField/PhoneField.js +448 -0
- package/dist/patterns/PhoneField/phone-value.d.ts +26 -0
- package/dist/patterns/PhoneField/phone-value.js +38 -0
- package/dist/patterns/QRCode/QRCode.d.ts +37 -0
- package/dist/patterns/QRCode/QRCode.js +120 -0
- package/dist/patterns/QRCode/qr-path.d.ts +7 -0
- package/dist/patterns/QRCode/qr-path.js +25 -0
- package/dist/patterns/ResizablePanels/ResizablePanels.d.ts +34 -0
- package/dist/patterns/ResizablePanels/ResizablePanels.js +175 -0
- package/dist/patterns/ResizablePanels/panel-sizes.d.ts +31 -0
- package/dist/patterns/ResizablePanels/panel-sizes.js +54 -0
- package/dist/patterns/RichTextEditor/FormRichTextField.d.ts +18 -0
- package/dist/patterns/RichTextEditor/FormRichTextField.js +118 -0
- package/dist/patterns/RichTextEditor/RichTextEditor.d.ts +71 -0
- package/dist/patterns/RichTextEditor/RichTextEditor.js +453 -0
- package/dist/patterns/SearchInput/SearchInput.d.ts +26 -0
- package/dist/patterns/SearchInput/SearchInput.js +98 -0
- package/dist/patterns/SideNav/SideNav.d.ts +50 -0
- package/dist/patterns/SideNav/SideNav.js +269 -0
- package/dist/patterns/Stat/Stat.d.ts +51 -0
- package/dist/patterns/Stat/Stat.js +292 -0
- package/dist/patterns/Stepper/Stepper.d.ts +35 -0
- package/dist/patterns/Stepper/Stepper.js +110 -0
- package/dist/patterns/TagGroup/TagGroup.d.ts +44 -0
- package/dist/patterns/TagGroup/TagGroup.js +151 -0
- package/dist/patterns/TagsInput/FormTagsInputField.d.ts +18 -0
- package/dist/patterns/TagsInput/FormTagsInputField.js +124 -0
- package/dist/patterns/TagsInput/TagsInput.d.ts +51 -0
- package/dist/patterns/TagsInput/TagsInput.js +97 -0
- package/dist/patterns/Timeline/Timeline.d.ts +29 -0
- package/dist/patterns/Timeline/Timeline.js +85 -0
- package/dist/patterns/Toolbar/Toolbar.d.ts +31 -0
- package/dist/patterns/Toolbar/Toolbar.js +105 -0
- package/dist/patterns/Tour/Tour.d.ts +38 -0
- package/dist/patterns/Tour/Tour.js +333 -0
- package/dist/patterns/TransferList/FormTransferListField.d.ts +19 -0
- package/dist/patterns/TransferList/FormTransferListField.js +117 -0
- package/dist/patterns/TransferList/TransferList.d.ts +53 -0
- package/dist/patterns/TransferList/TransferList.js +441 -0
- package/dist/patterns/TreeSelect/FormTreeSelectField.d.ts +28 -0
- package/dist/patterns/TreeSelect/FormTreeSelectField.js +88 -0
- package/dist/patterns/TreeSelect/TreeSelect.d.ts +49 -0
- package/dist/patterns/TreeSelect/TreeSelect.js +375 -0
- package/dist/patterns/TreeView/TreeView.d.ts +40 -0
- package/dist/patterns/TreeView/TreeView.js +296 -0
- package/dist/provider/DesignSystemProvider.d.ts +54 -0
- package/dist/provider/DesignSystemProvider.js +270 -0
- package/dist/provider/nonce.d.ts +7 -0
- package/dist/provider/nonce.js +13 -0
- package/dist/styles.css +2 -0
- package/dist/theme/chart-palette.d.ts +51 -0
- package/dist/theme/chart-palette.js +112 -0
- package/dist/theme/create-theme.d.ts +52 -0
- package/dist/theme/create-theme.js +75 -0
- package/dist/theme/style-element.d.ts +28 -0
- package/dist/theme/style-element.js +79 -0
- package/dist/theme/tenant-branding.d.ts +48 -0
- package/dist/theme/tenant-branding.js +65 -0
- package/dist/theme/theme-switch.d.ts +25 -0
- package/dist/theme/theme-switch.js +90 -0
- package/dist/theme/token-names.d.ts +3 -0
- package/dist/theme/token-names.js +166 -0
- package/dist/theme.css +241 -0
- package/dist/tokens.css +383 -0
- package/dist/types/direction.d.ts +4 -0
- package/dist/types/tone.d.ts +7 -0
- package/dist/utils/cn.d.ts +7 -0
- package/dist/utils/cn.js +50 -0
- package/dist/utils/first-field.d.ts +8 -0
- package/dist/utils/first-field.js +10 -0
- package/dist/utils/layout.d.ts +33 -0
- package/dist/utils/layout.js +30 -0
- package/dist/utils/popup.d.ts +12 -0
- package/dist/utils/popup.js +27 -0
- package/docs/accessibility.md +61 -0
- package/docs/advanced-components.md +38 -0
- package/docs/ai-assistants.md +44 -0
- package/docs/architecture.md +65 -0
- package/docs/browser-support.md +30 -0
- package/docs/charts.md +56 -0
- package/docs/components.md +2928 -0
- package/docs/conventions.md +19 -0
- package/docs/customization.md +79 -0
- package/docs/dates-files-data.md +48 -0
- package/docs/design-principles.md +50 -0
- package/docs/faq.md +68 -0
- package/docs/forms.md +114 -0
- package/docs/getting-started.md +64 -0
- package/docs/icons.md +48 -0
- package/docs/internationalization.md +64 -0
- package/docs/layout-and-navigation.md +51 -0
- package/docs/nextjs.md +69 -0
- package/docs/releasing.md +41 -0
- package/docs/testing.md +242 -0
- package/docs/theming.md +118 -0
- package/docs/typescript.md +62 -0
- package/llms-full.txt +4574 -0
- package/llms.txt +52 -0
- package/package.json +166 -6
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { type Ref } from "react";
|
|
2
|
+
/** The texts of the editor. The design system has no i18n, so the caller supplies them. */
|
|
3
|
+
export interface RichTextEditorLabels {
|
|
4
|
+
/** The toolbar's accessible name, e.g. "Text formatting". */
|
|
5
|
+
toolbar: string;
|
|
6
|
+
/** The bold button, e.g. "Bold". */
|
|
7
|
+
bold: string;
|
|
8
|
+
/** The italic button, e.g. "Italic". */
|
|
9
|
+
italic: string;
|
|
10
|
+
/** The heading button, e.g. "Heading". */
|
|
11
|
+
heading: string;
|
|
12
|
+
/** The bulleted list button, e.g. "Bulleted list". */
|
|
13
|
+
bulletList: string;
|
|
14
|
+
/** The numbered list button, e.g. "Numbered list". */
|
|
15
|
+
orderedList: string;
|
|
16
|
+
/** The link button, e.g. "Link". It also names the group of the address field. */
|
|
17
|
+
link: string;
|
|
18
|
+
/** The undo button, e.g. "Undo". */
|
|
19
|
+
undo: string;
|
|
20
|
+
/** The redo button, e.g. "Redo". */
|
|
21
|
+
redo: string;
|
|
22
|
+
/** The accessible name of the address field of a link, e.g. "Link address". */
|
|
23
|
+
linkUrl: string;
|
|
24
|
+
/** Sets the link, e.g. "Apply". */
|
|
25
|
+
linkApply: string;
|
|
26
|
+
/** Takes the link off the selected text, e.g. "Remove link". */
|
|
27
|
+
linkRemove: string;
|
|
28
|
+
/** Closes the address field without changing the link, e.g. "Cancel". */
|
|
29
|
+
linkCancel: string;
|
|
30
|
+
}
|
|
31
|
+
export interface RichTextEditorProps {
|
|
32
|
+
/**
|
|
33
|
+
* The text as HTML. An empty string for none. The editor writes paragraphs, headings (levels 2 and 3), bulleted
|
|
34
|
+
* and numbered lists, bold, italic, links and line breaks (Shift+Enter). Anything else in a value it is given or in
|
|
35
|
+
* pasted HTML is dropped (its text is kept), and a link keeps only its address, with
|
|
36
|
+
* `rel="noopener noreferrer nofollow"`.
|
|
37
|
+
*/
|
|
38
|
+
value: string;
|
|
39
|
+
/** Called with the HTML as it is edited, or "" while the document is empty. */
|
|
40
|
+
onValueChange: (value: string) => void;
|
|
41
|
+
/** The texts of the toolbar and the link field. */
|
|
42
|
+
labels: RichTextEditorLabels;
|
|
43
|
+
/** Makes the text read only: the toolbar is off and the writing area says it is disabled. */
|
|
44
|
+
disabled?: boolean | undefined;
|
|
45
|
+
/** Draws the box red and marks the editor invalid for assistive technology. */
|
|
46
|
+
invalid?: boolean | undefined;
|
|
47
|
+
/** Marks the editor required for assistive technology; the label shows the asterisk. */
|
|
48
|
+
required?: boolean | undefined;
|
|
49
|
+
/** The height of the writing area at least, in pixels. Default 160. */
|
|
50
|
+
minHeight?: number | undefined;
|
|
51
|
+
/** What names the editor when there is no visible label. */
|
|
52
|
+
"aria-label"?: string | undefined;
|
|
53
|
+
/** The id of the element that names the editor, such as a field's label. */
|
|
54
|
+
"aria-labelledby"?: string | undefined;
|
|
55
|
+
/** The ids of the field's message and hint, read after the name. */
|
|
56
|
+
"aria-describedby"?: string | undefined;
|
|
57
|
+
/** The editor was left (focus moved out of the writing area). */
|
|
58
|
+
onBlur?: (() => void) | undefined;
|
|
59
|
+
/** The editor's box, for a form library to find the first invalid field. */
|
|
60
|
+
editorRef?: Ref<HTMLDivElement> | undefined;
|
|
61
|
+
/** Extra classes for the editor's box. Merged last. */
|
|
62
|
+
className?: string | undefined;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* A text editor for formatted text: a toolbar of bold, italic, a heading, lists and a link over a writing area,
|
|
66
|
+
* with the usual shortcuts: Ctrl or Cmd with B, I and Z, Ctrl or Cmd with K to open the link field, and Shift+Enter
|
|
67
|
+
* for a line break. The value is HTML. The editor writes only those elements and drops the rest of what is pasted,
|
|
68
|
+
* but a request to the app's server can carry any HTML, so the app cleans the value before it shows one person's
|
|
69
|
+
* text to another. It is built on TipTap, so the app installs the TipTap packages to use it.
|
|
70
|
+
*/
|
|
71
|
+
export declare const RichTextEditor: ({ value, onValueChange, labels, disabled, invalid, required, minHeight, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, onBlur, editorRef, className, }: RichTextEditorProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { EditorContent, Extension, useEditor, useEditorState } from "@tiptap/react";
|
|
5
|
+
import StarterKit from "@tiptap/starter-kit";
|
|
6
|
+
import { Bold, Heading2, Italic, Link2, List, ListOrdered, Redo2, Undo2 } from "lucide-react";
|
|
7
|
+
import { cn } from "../../utils/cn.js";
|
|
8
|
+
import { useNonce } from "../../provider/nonce.js";
|
|
9
|
+
import { Button } from "../../components/Button/Button.js";
|
|
10
|
+
import { Toolbar, ToolbarButton, ToolbarSeparator } from "../Toolbar/Toolbar.js";
|
|
11
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
// src/patterns/RichTextEditor/RichTextEditor.tsx
|
|
13
|
+
/** What every link is written with. The editor sets no target, so a link opens where the page showing it decides. */
|
|
14
|
+
var LINK_REL = "noopener noreferrer nofollow";
|
|
15
|
+
/** An attribute of the link that is always the same: what a pasted or given link carries is not read. */
|
|
16
|
+
var fixedAttribute = (value) => ({
|
|
17
|
+
default: value,
|
|
18
|
+
parseHTML: () => value
|
|
19
|
+
});
|
|
20
|
+
/**
|
|
21
|
+
* StarterKit with only what the toolbar offers. TipTap 3's StarterKit also brings quotes, inline code, code blocks,
|
|
22
|
+
* rules, strikethrough and underline, which the value would then hold (from Markdown shortcuts, Ctrl+U or a paste)
|
|
23
|
+
* though nothing on screen makes them. Line breaks (Shift+Enter) stay. A link keeps its address only: a pasted
|
|
24
|
+
* class, target, title or rel is dropped.
|
|
25
|
+
*/
|
|
26
|
+
var KIT = StarterKit.extend({ addExtensions() {
|
|
27
|
+
return (this.parent?.() ?? []).map((extension) => extension.name === "link" ? extension.extend({ addAttributes() {
|
|
28
|
+
return {
|
|
29
|
+
...this.parent?.(),
|
|
30
|
+
target: fixedAttribute(null),
|
|
31
|
+
rel: fixedAttribute(LINK_REL),
|
|
32
|
+
class: fixedAttribute(null),
|
|
33
|
+
title: fixedAttribute(null)
|
|
34
|
+
};
|
|
35
|
+
} }) : extension);
|
|
36
|
+
} }).configure({
|
|
37
|
+
heading: { levels: [2, 3] },
|
|
38
|
+
link: {
|
|
39
|
+
openOnClick: false,
|
|
40
|
+
autolink: true,
|
|
41
|
+
HTMLAttributes: {
|
|
42
|
+
target: null,
|
|
43
|
+
rel: LINK_REL,
|
|
44
|
+
class: null
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
blockquote: false,
|
|
48
|
+
code: false,
|
|
49
|
+
codeBlock: false,
|
|
50
|
+
horizontalRule: false,
|
|
51
|
+
strike: false,
|
|
52
|
+
underline: false
|
|
53
|
+
});
|
|
54
|
+
/** What the writing area looks like: the elements TipTap writes, styled with the design system's tokens. */
|
|
55
|
+
var CONTENT = cn("[&_.ProseMirror]:min-h-(--editor-min-height) [&_.ProseMirror]:px-3 [&_.ProseMirror]:py-2.5 [&_.ProseMirror]:text-body-sm [&_.ProseMirror]:text-fg [&_.ProseMirror]:outline-none", "[&_.ProseMirror_p]:m-0 [&_.ProseMirror_p+p]:mt-2", "[&_.ProseMirror_h2]:mt-3 [&_.ProseMirror_h2]:mb-1 [&_.ProseMirror_h2]:text-h4 [&_.ProseMirror_h2]:font-semibold [&_.ProseMirror_h3]:mt-3 [&_.ProseMirror_h3]:mb-1 [&_.ProseMirror_h3]:text-body [&_.ProseMirror_h3]:font-semibold", "[&_.ProseMirror_ul]:my-2 [&_.ProseMirror_ul]:list-disc [&_.ProseMirror_ul]:ps-6 [&_.ProseMirror_ol]:my-2 [&_.ProseMirror_ol]:list-decimal [&_.ProseMirror_ol]:ps-6", "[&_.ProseMirror_a]:text-primary-text [&_.ProseMirror_a]:underline");
|
|
56
|
+
var SHELL = cn("overflow-hidden rounded-md border border-line bg-surface transition-[border-color,box-shadow] duration-150 ease-standard", "focus-within:border-primary-active focus-within:ring-3 focus-within:ring-primary/12", "data-invalid:border-error-solid data-invalid:ring-3 data-invalid:ring-error-solid/8 data-disabled:bg-subtle data-disabled:text-fg-secondary");
|
|
57
|
+
/** The HTML of the document, or "" while it is empty (an empty editor holds one empty paragraph). */
|
|
58
|
+
var htmlOf = (editor) => editor.isEmpty ? "" : editor.getHTML();
|
|
59
|
+
/**
|
|
60
|
+
* A text editor for formatted text: a toolbar of bold, italic, a heading, lists and a link over a writing area,
|
|
61
|
+
* with the usual shortcuts: Ctrl or Cmd with B, I and Z, Ctrl or Cmd with K to open the link field, and Shift+Enter
|
|
62
|
+
* for a line break. The value is HTML. The editor writes only those elements and drops the rest of what is pasted,
|
|
63
|
+
* but a request to the app's server can carry any HTML, so the app cleans the value before it shows one person's
|
|
64
|
+
* text to another. It is built on TipTap, so the app installs the TipTap packages to use it.
|
|
65
|
+
*/
|
|
66
|
+
var RichTextEditor = (t0) => {
|
|
67
|
+
const $ = c(55);
|
|
68
|
+
const { value, onValueChange, labels, disabled: t1, invalid: t2, required: t3, minHeight: t4, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, onBlur, editorRef, className } = t0;
|
|
69
|
+
const disabled = t1 === void 0 ? false : t1;
|
|
70
|
+
const invalid = t2 === void 0 ? false : t2;
|
|
71
|
+
const required = t3 === void 0 ? false : t3;
|
|
72
|
+
const minHeight = t4 === void 0 ? 160 : t4;
|
|
73
|
+
const nonce = useNonce();
|
|
74
|
+
const linkShortcut = useRef(null);
|
|
75
|
+
let t5;
|
|
76
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
77
|
+
t5 = () => [KIT, Extension.create({
|
|
78
|
+
name: "linkShortcut",
|
|
79
|
+
addKeyboardShortcuts: () => ({ "Mod-k": () => {
|
|
80
|
+
const open = linkShortcut.current;
|
|
81
|
+
if (!open) return false;
|
|
82
|
+
open();
|
|
83
|
+
return true;
|
|
84
|
+
} })
|
|
85
|
+
})];
|
|
86
|
+
$[0] = t5;
|
|
87
|
+
} else t5 = $[0];
|
|
88
|
+
const [extensions] = useState(t5);
|
|
89
|
+
let t6;
|
|
90
|
+
if ($[1] !== ariaLabel) {
|
|
91
|
+
t6 = ariaLabel ? { "aria-label": ariaLabel } : {};
|
|
92
|
+
$[1] = ariaLabel;
|
|
93
|
+
$[2] = t6;
|
|
94
|
+
} else t6 = $[2];
|
|
95
|
+
let t7;
|
|
96
|
+
if ($[3] !== ariaLabelledBy) {
|
|
97
|
+
t7 = ariaLabelledBy ? { "aria-labelledby": ariaLabelledBy } : {};
|
|
98
|
+
$[3] = ariaLabelledBy;
|
|
99
|
+
$[4] = t7;
|
|
100
|
+
} else t7 = $[4];
|
|
101
|
+
let t8;
|
|
102
|
+
if ($[5] !== ariaDescribedBy) {
|
|
103
|
+
t8 = ariaDescribedBy ? { "aria-describedby": ariaDescribedBy } : {};
|
|
104
|
+
$[5] = ariaDescribedBy;
|
|
105
|
+
$[6] = t8;
|
|
106
|
+
} else t8 = $[6];
|
|
107
|
+
let t9;
|
|
108
|
+
if ($[7] !== invalid) {
|
|
109
|
+
t9 = invalid ? { "aria-invalid": "true" } : {};
|
|
110
|
+
$[7] = invalid;
|
|
111
|
+
$[8] = t9;
|
|
112
|
+
} else t9 = $[8];
|
|
113
|
+
let t10;
|
|
114
|
+
if ($[9] !== required) {
|
|
115
|
+
t10 = required ? { "aria-required": "true" } : {};
|
|
116
|
+
$[9] = required;
|
|
117
|
+
$[10] = t10;
|
|
118
|
+
} else t10 = $[10];
|
|
119
|
+
let t11;
|
|
120
|
+
if ($[11] !== disabled) {
|
|
121
|
+
t11 = disabled ? { "aria-disabled": "true" } : {};
|
|
122
|
+
$[11] = disabled;
|
|
123
|
+
$[12] = t11;
|
|
124
|
+
} else t11 = $[12];
|
|
125
|
+
let t12;
|
|
126
|
+
if ($[13] !== t10 || $[14] !== t11 || $[15] !== t6 || $[16] !== t7 || $[17] !== t8 || $[18] !== t9) {
|
|
127
|
+
t12 = {
|
|
128
|
+
role: "textbox",
|
|
129
|
+
"aria-multiline": "true",
|
|
130
|
+
...t6,
|
|
131
|
+
...t7,
|
|
132
|
+
...t8,
|
|
133
|
+
...t9,
|
|
134
|
+
...t10,
|
|
135
|
+
...t11
|
|
136
|
+
};
|
|
137
|
+
$[13] = t10;
|
|
138
|
+
$[14] = t11;
|
|
139
|
+
$[15] = t6;
|
|
140
|
+
$[16] = t7;
|
|
141
|
+
$[17] = t8;
|
|
142
|
+
$[18] = t9;
|
|
143
|
+
$[19] = t12;
|
|
144
|
+
} else t12 = $[19];
|
|
145
|
+
const attributes = t12;
|
|
146
|
+
const t13 = !disabled;
|
|
147
|
+
let t14;
|
|
148
|
+
if ($[20] !== nonce) {
|
|
149
|
+
t14 = nonce ? { injectNonce: nonce } : {};
|
|
150
|
+
$[20] = nonce;
|
|
151
|
+
$[21] = t14;
|
|
152
|
+
} else t14 = $[21];
|
|
153
|
+
let t15;
|
|
154
|
+
if ($[22] !== attributes) {
|
|
155
|
+
t15 = { attributes };
|
|
156
|
+
$[22] = attributes;
|
|
157
|
+
$[23] = t15;
|
|
158
|
+
} else t15 = $[23];
|
|
159
|
+
let t16;
|
|
160
|
+
if ($[24] !== onValueChange) {
|
|
161
|
+
t16 = (t17) => {
|
|
162
|
+
const { editor: updated } = t17;
|
|
163
|
+
onValueChange(htmlOf(updated));
|
|
164
|
+
};
|
|
165
|
+
$[24] = onValueChange;
|
|
166
|
+
$[25] = t16;
|
|
167
|
+
} else t16 = $[25];
|
|
168
|
+
let t17;
|
|
169
|
+
if ($[26] !== onBlur) {
|
|
170
|
+
t17 = () => {
|
|
171
|
+
onBlur?.();
|
|
172
|
+
};
|
|
173
|
+
$[26] = onBlur;
|
|
174
|
+
$[27] = t17;
|
|
175
|
+
} else t17 = $[27];
|
|
176
|
+
let t18;
|
|
177
|
+
if ($[28] !== extensions || $[29] !== t13 || $[30] !== t14 || $[31] !== t15 || $[32] !== t16 || $[33] !== t17 || $[34] !== value) {
|
|
178
|
+
t18 = {
|
|
179
|
+
extensions,
|
|
180
|
+
content: value,
|
|
181
|
+
editable: t13,
|
|
182
|
+
immediatelyRender: false,
|
|
183
|
+
shouldRerenderOnTransaction: false,
|
|
184
|
+
...t14,
|
|
185
|
+
editorProps: t15,
|
|
186
|
+
onUpdate: t16,
|
|
187
|
+
onBlur: t17
|
|
188
|
+
};
|
|
189
|
+
$[28] = extensions;
|
|
190
|
+
$[29] = t13;
|
|
191
|
+
$[30] = t14;
|
|
192
|
+
$[31] = t15;
|
|
193
|
+
$[32] = t16;
|
|
194
|
+
$[33] = t17;
|
|
195
|
+
$[34] = value;
|
|
196
|
+
$[35] = t18;
|
|
197
|
+
} else t18 = $[35];
|
|
198
|
+
const editor = useEditor(t18);
|
|
199
|
+
const t19 = invalid || void 0;
|
|
200
|
+
const t20 = disabled || void 0;
|
|
201
|
+
let t21;
|
|
202
|
+
if ($[36] !== className) {
|
|
203
|
+
t21 = cn(SHELL, className);
|
|
204
|
+
$[36] = className;
|
|
205
|
+
$[37] = t21;
|
|
206
|
+
} else t21 = $[37];
|
|
207
|
+
let t22;
|
|
208
|
+
if ($[38] !== editor || $[39] !== minHeight) {
|
|
209
|
+
t22 = editor ? void 0 : { minHeight: minHeight + 44 };
|
|
210
|
+
$[38] = editor;
|
|
211
|
+
$[39] = minHeight;
|
|
212
|
+
$[40] = t22;
|
|
213
|
+
} else t22 = $[40];
|
|
214
|
+
let t23;
|
|
215
|
+
if ($[41] !== attributes || $[42] !== disabled || $[43] !== editor || $[44] !== labels || $[45] !== minHeight || $[46] !== value) {
|
|
216
|
+
t23 = editor ? /* @__PURE__ */ jsx(Surface, {
|
|
217
|
+
editor,
|
|
218
|
+
value,
|
|
219
|
+
labels,
|
|
220
|
+
disabled,
|
|
221
|
+
minHeight,
|
|
222
|
+
attributes,
|
|
223
|
+
linkShortcut
|
|
224
|
+
}) : null;
|
|
225
|
+
$[41] = attributes;
|
|
226
|
+
$[42] = disabled;
|
|
227
|
+
$[43] = editor;
|
|
228
|
+
$[44] = labels;
|
|
229
|
+
$[45] = minHeight;
|
|
230
|
+
$[46] = value;
|
|
231
|
+
$[47] = t23;
|
|
232
|
+
} else t23 = $[47];
|
|
233
|
+
let t24;
|
|
234
|
+
if ($[48] !== editorRef || $[49] !== t19 || $[50] !== t20 || $[51] !== t21 || $[52] !== t22 || $[53] !== t23) {
|
|
235
|
+
t24 = /* @__PURE__ */ jsx("div", {
|
|
236
|
+
ref: editorRef,
|
|
237
|
+
"data-invalid": t19,
|
|
238
|
+
"data-disabled": t20,
|
|
239
|
+
className: t21,
|
|
240
|
+
style: t22,
|
|
241
|
+
children: t23
|
|
242
|
+
});
|
|
243
|
+
$[48] = editorRef;
|
|
244
|
+
$[49] = t19;
|
|
245
|
+
$[50] = t20;
|
|
246
|
+
$[51] = t21;
|
|
247
|
+
$[52] = t22;
|
|
248
|
+
$[53] = t23;
|
|
249
|
+
$[54] = t24;
|
|
250
|
+
} else t24 = $[54];
|
|
251
|
+
return t24;
|
|
252
|
+
};
|
|
253
|
+
/** The toolbar, the link field and the writing area: what needs an editor to exist. */
|
|
254
|
+
var Surface = ({ editor, value, labels, disabled, minHeight, attributes, linkShortcut }) => {
|
|
255
|
+
const [linkOpen, setLinkOpen] = useState(false);
|
|
256
|
+
const [address, setAddress] = useState("");
|
|
257
|
+
const [refused, setRefused] = useState(false);
|
|
258
|
+
const attributesKey = JSON.stringify(attributes);
|
|
259
|
+
const state = useEditorState({
|
|
260
|
+
editor,
|
|
261
|
+
selector: ({ editor: current }) => ({
|
|
262
|
+
bold: current.isActive("bold"),
|
|
263
|
+
italic: current.isActive("italic"),
|
|
264
|
+
heading: current.isActive("heading", { level: 2 }),
|
|
265
|
+
bulletList: current.isActive("bulletList"),
|
|
266
|
+
orderedList: current.isActive("orderedList"),
|
|
267
|
+
link: current.isActive("link"),
|
|
268
|
+
canUndo: current.can().undo(),
|
|
269
|
+
canRedo: current.can().redo()
|
|
270
|
+
})
|
|
271
|
+
});
|
|
272
|
+
useEffect(() => {
|
|
273
|
+
editor.setEditable(!disabled);
|
|
274
|
+
}, [editor, disabled]);
|
|
275
|
+
useEffect(() => {
|
|
276
|
+
editor.setOptions({ editorProps: { attributes: JSON.parse(attributesKey) } });
|
|
277
|
+
}, [editor, attributesKey]);
|
|
278
|
+
useEffect(() => {
|
|
279
|
+
if (value !== htmlOf(editor)) editor.commands.setContent(value, { emitUpdate: false });
|
|
280
|
+
}, [editor, value]);
|
|
281
|
+
const run = (command) => {
|
|
282
|
+
command(editor.chain().focus()).run();
|
|
283
|
+
};
|
|
284
|
+
const openLink = () => {
|
|
285
|
+
setAddress(editor.getAttributes("link")["href"] ?? "");
|
|
286
|
+
setRefused(false);
|
|
287
|
+
setLinkOpen(true);
|
|
288
|
+
};
|
|
289
|
+
const closeLink = () => {
|
|
290
|
+
setLinkOpen(false);
|
|
291
|
+
setRefused(false);
|
|
292
|
+
editor.commands.focus();
|
|
293
|
+
};
|
|
294
|
+
const applyLink = () => {
|
|
295
|
+
const href = address.trim();
|
|
296
|
+
if (href === "") {
|
|
297
|
+
editor.chain().focus().extendMarkRange("link").unsetLink().run();
|
|
298
|
+
setLinkOpen(false);
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
if (!editor.chain().extendMarkRange("link").setLink({ href }).run()) {
|
|
302
|
+
setRefused(true);
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
setLinkOpen(false);
|
|
306
|
+
setRefused(false);
|
|
307
|
+
editor.commands.focus();
|
|
308
|
+
};
|
|
309
|
+
useEffect(() => {
|
|
310
|
+
linkShortcut.current = disabled ? null : openLink;
|
|
311
|
+
return () => {
|
|
312
|
+
linkShortcut.current = null;
|
|
313
|
+
};
|
|
314
|
+
});
|
|
315
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
316
|
+
/* @__PURE__ */ jsxs(Toolbar, {
|
|
317
|
+
"aria-label": labels.toolbar,
|
|
318
|
+
className: "w-full flex-wrap rounded-none border-0 border-b border-line",
|
|
319
|
+
children: [
|
|
320
|
+
/* @__PURE__ */ jsx(ToolbarButton, {
|
|
321
|
+
icon: /* @__PURE__ */ jsx(Bold, {}),
|
|
322
|
+
"aria-label": labels.bold,
|
|
323
|
+
pressed: state.bold,
|
|
324
|
+
disabled,
|
|
325
|
+
onClick: () => {
|
|
326
|
+
run((chain) => chain.toggleBold());
|
|
327
|
+
}
|
|
328
|
+
}),
|
|
329
|
+
/* @__PURE__ */ jsx(ToolbarButton, {
|
|
330
|
+
icon: /* @__PURE__ */ jsx(Italic, {}),
|
|
331
|
+
"aria-label": labels.italic,
|
|
332
|
+
pressed: state.italic,
|
|
333
|
+
disabled,
|
|
334
|
+
onClick: () => {
|
|
335
|
+
run((chain_0) => chain_0.toggleItalic());
|
|
336
|
+
}
|
|
337
|
+
}),
|
|
338
|
+
/* @__PURE__ */ jsx(ToolbarSeparator, {}),
|
|
339
|
+
/* @__PURE__ */ jsx(ToolbarButton, {
|
|
340
|
+
icon: /* @__PURE__ */ jsx(Heading2, {}),
|
|
341
|
+
"aria-label": labels.heading,
|
|
342
|
+
pressed: state.heading,
|
|
343
|
+
disabled,
|
|
344
|
+
onClick: () => {
|
|
345
|
+
run((chain_1) => chain_1.toggleHeading({ level: 2 }));
|
|
346
|
+
}
|
|
347
|
+
}),
|
|
348
|
+
/* @__PURE__ */ jsx(ToolbarButton, {
|
|
349
|
+
icon: /* @__PURE__ */ jsx(List, {}),
|
|
350
|
+
"aria-label": labels.bulletList,
|
|
351
|
+
pressed: state.bulletList,
|
|
352
|
+
disabled,
|
|
353
|
+
onClick: () => {
|
|
354
|
+
run((chain_2) => chain_2.toggleBulletList());
|
|
355
|
+
}
|
|
356
|
+
}),
|
|
357
|
+
/* @__PURE__ */ jsx(ToolbarButton, {
|
|
358
|
+
icon: /* @__PURE__ */ jsx(ListOrdered, {}),
|
|
359
|
+
"aria-label": labels.orderedList,
|
|
360
|
+
pressed: state.orderedList,
|
|
361
|
+
disabled,
|
|
362
|
+
onClick: () => {
|
|
363
|
+
run((chain_3) => chain_3.toggleOrderedList());
|
|
364
|
+
}
|
|
365
|
+
}),
|
|
366
|
+
/* @__PURE__ */ jsx(ToolbarSeparator, {}),
|
|
367
|
+
/* @__PURE__ */ jsx(ToolbarButton, {
|
|
368
|
+
icon: /* @__PURE__ */ jsx(Link2, {}),
|
|
369
|
+
"aria-label": labels.link,
|
|
370
|
+
pressed: state.link,
|
|
371
|
+
disabled,
|
|
372
|
+
onClick: openLink
|
|
373
|
+
}),
|
|
374
|
+
/* @__PURE__ */ jsx(ToolbarSeparator, {}),
|
|
375
|
+
/* @__PURE__ */ jsx(ToolbarButton, {
|
|
376
|
+
icon: /* @__PURE__ */ jsx(Undo2, {}),
|
|
377
|
+
"aria-label": labels.undo,
|
|
378
|
+
disabled: disabled || !state.canUndo,
|
|
379
|
+
onClick: () => {
|
|
380
|
+
run((chain_4) => chain_4.undo());
|
|
381
|
+
}
|
|
382
|
+
}),
|
|
383
|
+
/* @__PURE__ */ jsx(ToolbarButton, {
|
|
384
|
+
icon: /* @__PURE__ */ jsx(Redo2, {}),
|
|
385
|
+
"aria-label": labels.redo,
|
|
386
|
+
disabled: disabled || !state.canRedo,
|
|
387
|
+
onClick: () => {
|
|
388
|
+
run((chain_5) => chain_5.redo());
|
|
389
|
+
}
|
|
390
|
+
})
|
|
391
|
+
]
|
|
392
|
+
}),
|
|
393
|
+
linkOpen ? /* @__PURE__ */ jsxs("div", {
|
|
394
|
+
role: "group",
|
|
395
|
+
"aria-label": labels.link,
|
|
396
|
+
className: "flex flex-wrap items-center gap-2 border-b border-line bg-subtle px-3 py-2",
|
|
397
|
+
children: [
|
|
398
|
+
/* @__PURE__ */ jsx("input", {
|
|
399
|
+
type: "text",
|
|
400
|
+
inputMode: "url",
|
|
401
|
+
autoComplete: "off",
|
|
402
|
+
spellCheck: false,
|
|
403
|
+
autoFocus: true,
|
|
404
|
+
"aria-label": labels.linkUrl,
|
|
405
|
+
"aria-invalid": refused || void 0,
|
|
406
|
+
value: address,
|
|
407
|
+
className: "m-0 h-8 min-w-48 flex-1 rounded-sm border border-line bg-surface px-2.5 text-body-sm text-fg outline-none focus:border-primary-active focus:ring-2 focus:ring-primary/12 aria-invalid:border-error-solid aria-invalid:ring-error-solid/8",
|
|
408
|
+
onChange: (event) => {
|
|
409
|
+
setAddress(event.target.value);
|
|
410
|
+
setRefused(false);
|
|
411
|
+
},
|
|
412
|
+
onKeyDown: (event_0) => {
|
|
413
|
+
if (event_0.key === "Escape") {
|
|
414
|
+
event_0.preventDefault();
|
|
415
|
+
closeLink();
|
|
416
|
+
} else if (event_0.key === "Enter") {
|
|
417
|
+
event_0.preventDefault();
|
|
418
|
+
applyLink();
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}),
|
|
422
|
+
/* @__PURE__ */ jsx(Button, {
|
|
423
|
+
variant: "primary",
|
|
424
|
+
size: "small",
|
|
425
|
+
className: "shadow-none",
|
|
426
|
+
onClick: applyLink,
|
|
427
|
+
children: labels.linkApply
|
|
428
|
+
}),
|
|
429
|
+
state.link ? /* @__PURE__ */ jsx(Button, {
|
|
430
|
+
variant: "secondary",
|
|
431
|
+
size: "small",
|
|
432
|
+
onClick: () => {
|
|
433
|
+
editor.chain().focus().extendMarkRange("link").unsetLink().run();
|
|
434
|
+
setLinkOpen(false);
|
|
435
|
+
},
|
|
436
|
+
children: labels.linkRemove
|
|
437
|
+
}) : null,
|
|
438
|
+
/* @__PURE__ */ jsx(Button, {
|
|
439
|
+
variant: "subtle",
|
|
440
|
+
size: "small",
|
|
441
|
+
onClick: closeLink,
|
|
442
|
+
children: labels.linkCancel
|
|
443
|
+
})
|
|
444
|
+
]
|
|
445
|
+
}) : null,
|
|
446
|
+
/* @__PURE__ */ jsx(EditorContent, {
|
|
447
|
+
editor,
|
|
448
|
+
className: CONTENT,
|
|
449
|
+
style: { "--editor-min-height": `${String(minHeight)}px` }
|
|
450
|
+
})
|
|
451
|
+
] });
|
|
452
|
+
};
|
|
453
|
+
export { RichTextEditor };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { FieldSize } from "../FormField/field-types.js";
|
|
2
|
+
export interface SearchInputProps {
|
|
3
|
+
/** The search text. */
|
|
4
|
+
value: string;
|
|
5
|
+
/** Called with the whole text as each key is pressed, and with "" when the clear button empties it. Debounce it yourself. */
|
|
6
|
+
onValueChange: (value: string) => void;
|
|
7
|
+
/** Shown while the input is empty, e.g. "Search projects". It does not name the input: give `aria-label`. */
|
|
8
|
+
placeholder?: string | undefined;
|
|
9
|
+
/** Accessible name of the input. */
|
|
10
|
+
"aria-label": string;
|
|
11
|
+
/** Accessible name of the clear button that appears once there is text. */
|
|
12
|
+
clearLabel: string;
|
|
13
|
+
/** The box's height: "small" 32px, "medium" 42px (the default), "large" 46px, as the other fields. */
|
|
14
|
+
size?: FieldSize | undefined;
|
|
15
|
+
/** Greys the box out; the input cannot be focused and the clear button is not shown. */
|
|
16
|
+
disabled?: boolean | undefined;
|
|
17
|
+
/** Classes for the box around the input, merged last. */
|
|
18
|
+
className?: string | undefined;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Figma's search input: a magnifier at the start and, once there is text, a
|
|
22
|
+
* clear button at the end. It is the box every input uses (`fieldControl`), so
|
|
23
|
+
* it hovers, focuses and disables like them and lines up beside a FormTextField
|
|
24
|
+
* in a filter bar. Controlled; the caller debounces.
|
|
25
|
+
*/
|
|
26
|
+
export declare const SearchInput: ({ value, onValueChange: onChange, placeholder, "aria-label": ariaLabel, clearLabel, size, disabled, className, }: SearchInputProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { useRef } from "react";
|
|
4
|
+
import { Input } from "@base-ui/react/input";
|
|
5
|
+
import { Search, X } from "lucide-react";
|
|
6
|
+
import { Button } from "../../components/Button/Button.js";
|
|
7
|
+
import { cn } from "../../utils/cn.js";
|
|
8
|
+
import { fieldControl, fieldInput } from "../FormField/field-styles.js";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
// src/patterns/SearchInput/SearchInput.tsx
|
|
11
|
+
/**
|
|
12
|
+
* Figma's search input: a magnifier at the start and, once there is text, a
|
|
13
|
+
* clear button at the end. It is the box every input uses (`fieldControl`), so
|
|
14
|
+
* it hovers, focuses and disables like them and lines up beside a FormTextField
|
|
15
|
+
* in a filter bar. Controlled; the caller debounces.
|
|
16
|
+
*/
|
|
17
|
+
var SearchInput = (t0) => {
|
|
18
|
+
const $ = c(21);
|
|
19
|
+
const { value, onValueChange: onChange, placeholder, "aria-label": ariaLabel, clearLabel, size: t1, disabled: t2, className } = t0;
|
|
20
|
+
const size = t1 === void 0 ? "medium" : t1;
|
|
21
|
+
const disabled = t2 === void 0 ? false : t2;
|
|
22
|
+
const inputRef = useRef(null);
|
|
23
|
+
let t3;
|
|
24
|
+
if ($[0] !== className || $[1] !== size) {
|
|
25
|
+
t3 = cn(fieldControl({ size }), "gap-2", className);
|
|
26
|
+
$[0] = className;
|
|
27
|
+
$[1] = size;
|
|
28
|
+
$[2] = t3;
|
|
29
|
+
} else t3 = $[2];
|
|
30
|
+
const t4 = disabled || void 0;
|
|
31
|
+
let t5;
|
|
32
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
33
|
+
t5 = /* @__PURE__ */ jsx(Search, { "aria-hidden": "true" });
|
|
34
|
+
$[3] = t5;
|
|
35
|
+
} else t5 = $[3];
|
|
36
|
+
let t6;
|
|
37
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
38
|
+
t6 = cn(fieldInput, "[&::-webkit-search-cancel-button]:appearance-none");
|
|
39
|
+
$[4] = t6;
|
|
40
|
+
} else t6 = $[4];
|
|
41
|
+
let t7;
|
|
42
|
+
if ($[5] !== ariaLabel || $[6] !== disabled || $[7] !== onChange || $[8] !== placeholder || $[9] !== value) {
|
|
43
|
+
t7 = /* @__PURE__ */ jsx(Input, {
|
|
44
|
+
ref: inputRef,
|
|
45
|
+
type: "search",
|
|
46
|
+
className: t6,
|
|
47
|
+
"aria-label": ariaLabel,
|
|
48
|
+
placeholder,
|
|
49
|
+
disabled,
|
|
50
|
+
value,
|
|
51
|
+
onValueChange: onChange
|
|
52
|
+
});
|
|
53
|
+
$[5] = ariaLabel;
|
|
54
|
+
$[6] = disabled;
|
|
55
|
+
$[7] = onChange;
|
|
56
|
+
$[8] = placeholder;
|
|
57
|
+
$[9] = value;
|
|
58
|
+
$[10] = t7;
|
|
59
|
+
} else t7 = $[10];
|
|
60
|
+
let t8;
|
|
61
|
+
if ($[11] !== clearLabel || $[12] !== disabled || $[13] !== onChange || $[14] !== value) {
|
|
62
|
+
t8 = value && !disabled ? /* @__PURE__ */ jsx(Button, {
|
|
63
|
+
variant: "subtle",
|
|
64
|
+
size: "small",
|
|
65
|
+
"aria-label": clearLabel,
|
|
66
|
+
icon: /* @__PURE__ */ jsx(X, {}),
|
|
67
|
+
className: "-me-1.5 text-fg-secondary not-data-disabled:hover:text-fg",
|
|
68
|
+
onClick: () => {
|
|
69
|
+
onChange("");
|
|
70
|
+
inputRef.current?.focus();
|
|
71
|
+
}
|
|
72
|
+
}) : null;
|
|
73
|
+
$[11] = clearLabel;
|
|
74
|
+
$[12] = disabled;
|
|
75
|
+
$[13] = onChange;
|
|
76
|
+
$[14] = value;
|
|
77
|
+
$[15] = t8;
|
|
78
|
+
} else t8 = $[15];
|
|
79
|
+
let t9;
|
|
80
|
+
if ($[16] !== t3 || $[17] !== t4 || $[18] !== t7 || $[19] !== t8) {
|
|
81
|
+
t9 = /* @__PURE__ */ jsxs("div", {
|
|
82
|
+
className: t3,
|
|
83
|
+
"data-disabled": t4,
|
|
84
|
+
children: [
|
|
85
|
+
t5,
|
|
86
|
+
t7,
|
|
87
|
+
t8
|
|
88
|
+
]
|
|
89
|
+
});
|
|
90
|
+
$[16] = t3;
|
|
91
|
+
$[17] = t4;
|
|
92
|
+
$[18] = t7;
|
|
93
|
+
$[19] = t8;
|
|
94
|
+
$[20] = t9;
|
|
95
|
+
} else t9 = $[20];
|
|
96
|
+
return t9;
|
|
97
|
+
};
|
|
98
|
+
export { SearchInput };
|