@krak-stack/registry 0.10.20 → 0.11.2
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 +89 -3
- package/README.md +11 -8
- package/dist/components/agent/index.d.ts +454 -0
- package/dist/components/agent/react.d.ts +55 -0
- package/dist/components/agent/react.js +2440 -0
- package/dist/components/agent/schema.d.ts +55 -0
- package/dist/components/animated-list/classes.d.ts +9 -0
- package/dist/components/animated-list/html.d.ts +11 -0
- package/dist/components/animated-list/html.js +533 -0
- package/dist/components/animated-list/index.d.ts +205 -0
- package/dist/components/animated-list/react.d.ts +11 -0
- package/dist/components/{ui/animated-list.js → animated-list/react.js} +199 -54
- package/dist/components/animated-list/schema.d.ts +44 -0
- package/dist/components/animated-number/html.d.ts +19 -0
- package/dist/components/animated-number/html.js +101 -0
- package/dist/components/animated-number/index.d.ts +80 -0
- package/dist/components/{ui/animated-number.d.ts → animated-number/react.d.ts} +2 -7
- package/dist/components/animated-number/react.js +124 -0
- package/dist/components/animated-number/schema.d.ts +9 -0
- package/dist/components/app-brand/classes.d.ts +11 -0
- package/dist/components/app-brand/html.d.ts +26 -0
- package/dist/components/app-brand/html.js +78 -0
- package/dist/components/app-brand/react.d.ts +12 -0
- package/dist/components/app-brand/react.js +86 -0
- package/dist/components/app-brand/schema.d.ts +36 -0
- package/dist/components/app-switcher/classes.d.ts +15 -0
- package/dist/components/app-switcher/html.d.ts +72 -0
- package/dist/components/app-switcher/html.js +327 -0
- package/dist/components/app-switcher/index.d.ts +47 -0
- package/dist/components/app-switcher/react.d.ts +12 -0
- package/dist/components/{ui/app-switcher.js → app-switcher/react.js} +84 -15
- package/dist/components/app-switcher/schema.d.ts +39 -0
- package/dist/components/async-action-button/classes.d.ts +11 -0
- package/dist/components/async-action-button/html.d.ts +46 -0
- package/dist/components/async-action-button/html.js +266 -0
- package/dist/components/async-action-button/index.d.ts +73 -0
- package/dist/components/async-action-button/react.d.ts +10 -0
- package/dist/components/async-action-button/react.js +224 -0
- package/dist/components/async-action-button/schema.d.ts +28 -0
- package/dist/{services/events/client/audit-log-table.d.ts → components/audit-log-table/react.d.ts} +2 -2
- package/dist/{services/events/client/audit-log-table.js → components/audit-log-table/react.js} +1964 -847
- package/dist/components/auto-height/html.d.ts +8 -0
- package/dist/components/auto-height/html.js +81 -0
- package/dist/components/auto-height/index.d.ts +2 -0
- package/dist/components/{ui/auto-height.d.ts → auto-height/react.d.ts} +2 -4
- package/dist/components/auto-height/react.js +75 -0
- package/dist/components/auto-height/schema.d.ts +7 -0
- package/dist/components/bulk-list-input/classes.d.ts +7 -0
- package/dist/components/bulk-list-input/html.d.ts +41 -0
- package/dist/components/bulk-list-input/html.js +265 -0
- package/dist/components/bulk-list-input/index.d.ts +76 -0
- package/dist/components/bulk-list-input/react.d.ts +12 -0
- package/dist/components/{ui/bulk-list-input.js → bulk-list-input/react.js} +71 -4
- package/dist/components/bulk-list-input/schema.d.ts +33 -0
- package/dist/components/choice-cards/classes.d.ts +19 -0
- package/dist/components/choice-cards/html.d.ts +76 -0
- package/dist/components/choice-cards/html.js +237 -0
- package/dist/components/choice-cards/index.d.ts +1 -0
- package/dist/components/choice-cards/react.d.ts +21 -0
- package/dist/components/{ui/choice-cards.js → choice-cards/react.js} +29 -10
- package/dist/components/choice-cards/schema.d.ts +100 -0
- package/dist/components/code-block/classes.d.ts +13 -0
- package/dist/components/code-block/html.d.ts +21 -0
- package/dist/components/code-block/html.js +381 -0
- package/dist/components/code-block/index.d.ts +4 -0
- package/dist/components/code-block/react.d.ts +4 -0
- package/dist/components/{ui/code-block.js → code-block/react.js} +168 -50
- package/dist/components/code-block/schema.d.ts +29 -0
- package/dist/components/color-input/classes.d.ts +9 -0
- package/dist/components/color-input/html.d.ts +48 -0
- package/dist/components/color-input/html.js +187 -0
- package/dist/components/color-input/index.d.ts +88 -0
- package/dist/components/color-input/react.d.ts +7 -0
- package/dist/components/{ui/color-picker.js → color-input/react.js} +165 -233
- package/dist/components/color-input/schema.d.ts +40 -0
- package/dist/components/copy-button/html.d.ts +48 -0
- package/dist/components/copy-button/html.js +266 -0
- package/dist/components/copy-button/index.d.ts +73 -0
- package/dist/components/copy-button/react.d.ts +12 -0
- package/dist/components/copy-button/react.js +234 -0
- package/dist/components/copy-button/schema.d.ts +37 -0
- package/dist/components/copy-value/html.d.ts +37 -0
- package/dist/components/copy-value/html.js +426 -0
- package/dist/components/copy-value/index.d.ts +57 -0
- package/dist/components/copy-value/react.d.ts +9 -0
- package/dist/components/{ui/copy-value.js → copy-value/react.js} +243 -65
- package/dist/components/copy-value/schema.d.ts +45 -0
- package/dist/components/cron-input/classes.d.ts +25 -0
- package/dist/components/cron-input/html.d.ts +36 -0
- package/dist/components/cron-input/html.js +204 -0
- package/dist/components/cron-input/index.d.ts +59 -0
- package/dist/components/cron-input/react.d.ts +7 -0
- package/dist/components/{ui/cron-expression-editor.js → cron-input/react.js} +126 -54
- package/dist/components/cron-input/schema.d.ts +24 -0
- package/dist/components/danger-confirmation/classes.d.ts +7 -0
- package/dist/components/danger-confirmation/html.d.ts +39 -0
- package/dist/components/danger-confirmation/html.js +227 -0
- package/dist/components/danger-confirmation/index.d.ts +113 -0
- package/dist/components/{ui/danger-confirmation.d.ts → danger-confirmation/react.d.ts} +3 -12
- package/dist/components/{ui/danger-confirmation.js → danger-confirmation/react.js} +203 -205
- package/dist/components/danger-confirmation/schema.d.ts +34 -0
- package/dist/components/data-table/classes.d.ts +63 -0
- package/dist/components/data-table/html.d.ts +1938 -0
- package/dist/components/data-table/html.js +2682 -0
- package/dist/components/data-table/index.d.ts +2686 -0
- package/dist/components/data-table/react.d.ts +578 -0
- package/dist/components/{ui/data-table.js → data-table/react.js} +1958 -835
- package/dist/components/data-table/schema.d.ts +3012 -0
- package/dist/components/date-input/classes.d.ts +17 -0
- package/dist/components/date-input/html.d.ts +60 -0
- package/dist/components/date-input/html.js +418 -0
- package/dist/components/date-input/index.d.ts +91 -0
- package/dist/components/date-input/react.d.ts +10 -0
- package/dist/components/{ui/date-picker.js → date-input/react.js} +233 -79
- package/dist/components/date-input/schema.d.ts +41 -0
- package/dist/components/editable-text/classes.d.ts +17 -0
- package/dist/components/editable-text/html.d.ts +51 -0
- package/dist/components/editable-text/html.js +370 -0
- package/dist/components/editable-text/index.d.ts +143 -0
- package/dist/components/editable-text/react.d.ts +6 -0
- package/dist/components/editable-text/react.js +345 -0
- package/dist/components/editable-text/schema.d.ts +31 -0
- package/dist/components/editing-locale-switcher/classes.d.ts +7 -0
- package/dist/components/editing-locale-switcher/html.d.ts +27 -0
- package/dist/components/editing-locale-switcher/html.js +250 -0
- package/dist/components/editing-locale-switcher/index.d.ts +52 -0
- package/dist/components/editing-locale-switcher/react.d.ts +7 -0
- package/dist/components/{ui/editing-locale-switcher.js → editing-locale-switcher/react.js} +63 -10
- package/dist/components/editing-locale-switcher/schema.d.ts +16 -0
- package/dist/components/{ui/effect-form.d.ts → effect-form/react.d.ts} +2 -2
- package/dist/components/{ui/effect-form.js → effect-form/react.js} +302 -76
- package/dist/components/effectcn/alert-dialog.d.ts +13 -0
- package/dist/components/effectcn/button.d.ts +31 -0
- package/dist/components/effectcn/calendar.d.ts +12 -0
- package/dist/components/effectcn/checkbox.d.ts +10 -0
- package/dist/components/effectcn/combobox.d.ts +25 -0
- package/dist/components/effectcn/dialog.d.ts +19 -0
- package/dist/components/effectcn/field.d.ts +11 -0
- package/dist/components/effectcn/file-drop.d.ts +8 -0
- package/dist/components/effectcn/input.d.ts +26 -0
- package/dist/components/effectcn/menu.d.ts +85 -0
- package/dist/components/effectcn/menubar.d.ts +8 -0
- package/dist/components/effectcn/popover.d.ts +18 -0
- package/dist/components/effectcn/scroll-area.d.ts +12 -0
- package/dist/components/effectcn/select.d.ts +68 -0
- package/dist/components/effectcn/toast.d.ts +29 -0
- package/dist/components/email-composer/index.d.ts +229 -0
- package/dist/components/email-composer/labels.d.ts +12 -0
- package/dist/components/email-composer/react.d.ts +5 -0
- package/dist/components/{ui/email-composer.js → email-composer/react.js} +461 -127
- package/dist/components/email-composer/schema.d.ts +42 -0
- package/dist/components/email-editor/classes.d.ts +21 -0
- package/dist/components/email-editor/html.d.ts +360 -0
- package/dist/components/email-editor/html.js +1706 -0
- package/dist/components/email-editor/index.d.ts +693 -0
- package/dist/components/{ui/email-editor.d.ts → email-editor/labels.d.ts} +1 -21
- package/dist/components/email-editor/legacy-editor.html.d.ts +160 -0
- package/dist/components/email-editor/react.d.ts +11 -0
- package/dist/components/{ui/email-editor.js → email-editor/react.js} +600 -230
- package/dist/components/email-editor/schema.d.ts +162 -0
- package/dist/components/error-component/classes.d.ts +7 -0
- package/dist/components/error-component/html.d.ts +120 -0
- package/dist/components/error-component/html.js +346 -0
- package/dist/components/error-component/index.d.ts +69 -0
- package/dist/components/error-component/react.d.ts +8 -0
- package/dist/components/{ui/error-component.js → error-component/react.js} +281 -78
- package/dist/components/error-component/schema.d.ts +56 -0
- package/dist/components/file-input/classes.d.ts +7 -0
- package/dist/components/file-input/html.d.ts +95 -0
- package/dist/components/file-input/html.js +368 -0
- package/dist/components/file-input/index.d.ts +99 -0
- package/dist/components/file-input/react.d.ts +11 -0
- package/dist/components/{ui/file-picker.js → file-input/react.js} +122 -19
- package/dist/components/file-input/schema.d.ts +37 -0
- package/dist/components/{ui/form.d.ts → form/react.d.ts} +7 -7
- package/dist/components/{ui/form.js → form/react.js} +300 -74
- package/dist/components/icon-input/html.d.ts +55 -0
- package/dist/components/icon-input/html.js +538 -0
- package/dist/components/icon-input/index.d.ts +143 -0
- package/dist/components/icon-input/react.d.ts +6 -0
- package/dist/components/{ui/icon-input.js → icon-input/react.js} +305 -89
- package/dist/components/icon-input/schema.d.ts +23 -0
- package/dist/components/image-crop-editor/classes.d.ts +19 -0
- package/dist/components/image-crop-editor/html.d.ts +66 -0
- package/dist/components/image-crop-editor/html.js +561 -0
- package/dist/components/image-crop-editor/index.d.ts +183 -0
- package/dist/components/image-crop-editor/react.d.ts +8 -0
- package/dist/components/image-crop-editor/react.js +648 -0
- package/dist/components/image-crop-editor/schema.d.ts +54 -0
- package/dist/components/krakstack-provider/html.d.ts +17 -0
- package/dist/components/krakstack-provider/html.js +37 -0
- package/dist/components/krakstack-provider/index.d.ts +7 -0
- package/dist/components/krakstack-provider/react.d.ts +8 -0
- package/dist/components/{ui/krakstack-provider.js → krakstack-provider/react.js} +14 -5
- package/dist/components/krakstack-provider/schema.d.ts +6 -0
- package/dist/components/loading/classes.d.ts +5 -0
- package/dist/components/loading/html.d.ts +18 -0
- package/dist/components/loading/html.js +166 -0
- package/dist/components/loading/index.d.ts +6 -0
- package/dist/components/loading/react.d.ts +4 -0
- package/dist/components/loading/react.js +51 -0
- package/dist/components/loading/schema.d.ts +23 -0
- package/dist/components/locale-switcher/html.d.ts +22 -0
- package/dist/components/locale-switcher/html.js +264 -0
- package/dist/components/locale-switcher/index.d.ts +50 -0
- package/dist/components/locale-switcher/react.d.ts +7 -0
- package/dist/components/{ui/locale-switcher.js → locale-switcher/react.js} +55 -22
- package/dist/components/locale-switcher/schema.d.ts +12 -0
- package/dist/components/map-menu/classes.d.ts +13 -0
- package/dist/components/map-menu/google-maps.d.ts +80 -0
- package/dist/components/map-menu/google-viewport.d.ts +7 -0
- package/dist/components/map-menu/html.d.ts +274 -0
- package/dist/components/map-menu/html.js +934 -0
- package/dist/components/map-menu/index.d.ts +246 -0
- package/dist/components/map-menu/map.d.ts +47 -0
- package/dist/components/map-menu/react.d.ts +40 -0
- package/dist/components/{ui/map-menu.js → map-menu/react.js} +321 -83
- package/dist/components/map-menu/schema.d.ts +132 -0
- package/dist/components/markdown/classes.d.ts +1 -0
- package/dist/components/markdown/html.d.ts +23 -0
- package/dist/components/markdown/html.js +510 -0
- package/dist/components/markdown/index.d.ts +6 -0
- package/dist/components/markdown/react.d.ts +3 -0
- package/dist/components/markdown/react.js +392 -0
- package/dist/components/markdown/schema.d.ts +20 -0
- package/dist/components/notification-menu/classes.d.ts +11 -0
- package/dist/components/notification-menu/html.d.ts +67 -0
- package/dist/components/notification-menu/html.js +425 -0
- package/dist/components/notification-menu/index.d.ts +132 -0
- package/dist/components/notification-menu/react.d.ts +57 -0
- package/dist/components/notification-menu/react.js +829 -0
- package/dist/components/notification-menu/schema.d.ts +59 -0
- package/dist/components/pagination/classes.d.ts +19 -0
- package/dist/components/pagination/html.d.ts +49 -0
- package/dist/components/pagination/html.js +387 -0
- package/dist/components/pagination/index.d.ts +109 -0
- package/dist/components/pagination/react.d.ts +9 -0
- package/dist/components/{ui/pagination.js → pagination/react.js} +123 -23
- package/dist/components/pagination/schema.d.ts +36 -0
- package/dist/components/phone-number-input/classes.d.ts +17 -0
- package/dist/components/phone-number-input/html.d.ts +52 -0
- package/dist/components/phone-number-input/html.js +655 -0
- package/dist/components/phone-number-input/index.d.ts +59 -0
- package/dist/components/phone-number-input/react.d.ts +11 -0
- package/dist/components/{ui/phone-number-input.js → phone-number-input/react.js} +368 -138
- package/dist/components/phone-number-input/schema.d.ts +31 -0
- package/dist/components/presence-transition/html.d.ts +13 -0
- package/dist/components/presence-transition/html.js +128 -0
- package/dist/components/presence-transition/index.d.ts +57 -0
- package/dist/components/{ui/presence-transition.d.ts → presence-transition/react.d.ts} +3 -5
- package/dist/components/presence-transition/react.js +139 -0
- package/dist/components/presence-transition/schema.d.ts +7 -0
- package/dist/components/registry-previews/component-example.d.ts +31 -0
- package/dist/components/registry-previews/component-example.js +525 -0
- package/dist/components/registry-previews/html-preview.d.ts +17 -0
- package/dist/components/registry-previews/html-preview.js +83 -0
- package/dist/components/rich-text-editor/classes.d.ts +15 -0
- package/dist/components/rich-text-editor/engine.d.ts +9 -0
- package/dist/components/rich-text-editor/html.d.ts +246 -0
- package/dist/components/rich-text-editor/html.js +830 -0
- package/dist/components/rich-text-editor/index.d.ts +453 -0
- package/dist/components/rich-text-editor/labels.d.ts +42 -0
- package/dist/components/rich-text-editor/react.d.ts +19 -0
- package/dist/components/{ui/rich-text-editor.js → rich-text-editor/react.js} +365 -96
- package/dist/components/rich-text-editor/schema.d.ts +116 -0
- package/dist/components/search-menu/classes.d.ts +9 -0
- package/dist/components/search-menu/html.d.ts +127 -0
- package/dist/components/search-menu/html.js +432 -0
- package/dist/components/search-menu/index.d.ts +85 -0
- package/dist/components/search-menu/react.d.ts +18 -0
- package/dist/components/{ui/search-menu.js → search-menu/react.js} +128 -23
- package/dist/components/search-menu/schema.d.ts +78 -0
- package/dist/components/select-with-custom-input/classes.d.ts +17 -0
- package/dist/components/select-with-custom-input/html.d.ts +60 -0
- package/dist/components/select-with-custom-input/html.js +238 -0
- package/dist/components/select-with-custom-input/index.d.ts +114 -0
- package/dist/components/select-with-custom-input/react.d.ts +7 -0
- package/dist/components/{ui/select-with-custom-input.js → select-with-custom-input/react.js} +127 -22
- package/dist/components/select-with-custom-input/schema.d.ts +54 -0
- package/dist/components/sidebar-layout/classes.d.ts +21 -0
- package/dist/components/sidebar-layout/html.d.ts +97 -0
- package/dist/components/sidebar-layout/html.js +361 -0
- package/dist/components/sidebar-layout/index.d.ts +57 -0
- package/dist/components/sidebar-layout/react.d.ts +30 -0
- package/dist/components/{ui/sidebar-layout.js → sidebar-layout/react.js} +199 -39
- package/dist/components/sidebar-layout/schema.d.ts +54 -0
- package/dist/components/stats-card/classes.d.ts +11 -0
- package/dist/components/stats-card/html.d.ts +15 -0
- package/dist/components/stats-card/html.js +55 -0
- package/dist/components/stats-card/react.d.ts +7 -0
- package/dist/components/{ui/stats-card.js → stats-card/react.js} +19 -15
- package/dist/components/stats-card/schema.d.ts +14 -0
- package/dist/components/stepper/classes.d.ts +39 -0
- package/dist/components/stepper/html.d.ts +107 -0
- package/dist/components/stepper/html.js +397 -0
- package/dist/components/stepper/index.d.ts +83 -0
- package/dist/components/stepper/react.d.ts +17 -0
- package/dist/components/{ui/stepper.js → stepper/react.js} +120 -21
- package/dist/components/stepper/schema.d.ts +52 -0
- package/dist/components/support/classes.d.ts +55 -0
- package/dist/components/support/form.d.ts +19 -0
- package/dist/components/support/html.d.ts +266 -0
- package/dist/components/support/html.js +604 -0
- package/dist/components/support/index.d.ts +226 -0
- package/dist/components/support/multipart.d.ts +21 -0
- package/dist/components/support/react.d.ts +54 -0
- package/dist/components/support/react.js +1098 -0
- package/dist/components/support/schema.d.ts +69 -0
- package/dist/components/support.d.ts +1 -66
- package/dist/components/theme-switcher/html.d.ts +28 -0
- package/dist/components/theme-switcher/html.js +288 -0
- package/dist/components/theme-switcher/index.d.ts +59 -0
- package/dist/components/{ui/theme-switcher.d.ts → theme-switcher/react.d.ts} +4 -12
- package/dist/components/{ui/theme-switcher.js → theme-switcher/react.js} +69 -35
- package/dist/components/theme-switcher/schema.d.ts +33 -0
- package/dist/components/time-input/classes.d.ts +23 -0
- package/dist/components/time-input/html.d.ts +75 -0
- package/dist/components/time-input/html.js +571 -0
- package/dist/components/time-input/index.d.ts +164 -0
- package/dist/components/time-input/react.d.ts +7 -0
- package/dist/components/{ui/time-picker.js → time-input/react.js} +286 -114
- package/dist/components/time-input/schema.d.ts +96 -0
- package/dist/components/timezone-input/classes.d.ts +13 -0
- package/dist/components/timezone-input/html.d.ts +58 -0
- package/dist/components/timezone-input/html.js +804 -0
- package/dist/components/timezone-input/index.d.ts +170 -0
- package/dist/components/timezone-input/react.d.ts +9 -0
- package/dist/components/{ui/timezone-select.js → timezone-input/react.js} +337 -104
- package/dist/components/timezone-input/schema.d.ts +43 -0
- package/dist/components/toast/classes.d.ts +7 -0
- package/dist/components/toast/html.d.ts +34 -0
- package/dist/components/toast/html.js +280 -0
- package/dist/components/toast/index.d.ts +10 -0
- package/dist/components/toast/react.d.ts +9 -0
- package/dist/components/{ui/toast.js → toast/react.js} +35 -15
- package/dist/components/toast/schema.d.ts +24 -0
- package/dist/{services/events/client/tracking-notice.d.ts → components/tracking-notice/react.d.ts} +7 -1
- package/dist/{services/events/client/tracking-notice.js → components/tracking-notice/react.js} +13 -7
- package/dist/components/ui/animated-list.d.ts +1 -21
- package/dist/components/ui/app-brand.d.ts +1 -33
- package/dist/components/ui/async-action-button.d.ts +1 -17
- package/dist/components/ui/code-block.d.ts +1 -14
- package/dist/components/ui/copy-button.d.ts +1 -21
- package/dist/components/ui/data-table.d.ts +1 -584
- package/dist/components/ui/krakstack-provider.d.ts +1 -9
- package/dist/components/ui/loading.d.ts +1 -13
- package/dist/components/ui/pagination.d.ts +1 -47
- package/dist/components/ui/rich-text-editor.d.ts +1 -72
- package/dist/components/ui/search-menu.d.ts +1 -36
- package/dist/components/ui/sidebar-layout.d.ts +1 -40
- package/dist/components/ui/virtualized-combobox.d.ts +1 -59
- package/dist/components/unsaved-changes-guard/html.d.ts +34 -0
- package/dist/components/unsaved-changes-guard/html.js +172 -0
- package/dist/components/unsaved-changes-guard/index.d.ts +56 -0
- package/dist/components/unsaved-changes-guard/react.d.ts +4 -0
- package/dist/components/{ui/unsaved-changes-guard.js → unsaved-changes-guard/react.js} +74 -11
- package/dist/components/unsaved-changes-guard/schema.d.ts +37 -0
- package/dist/components/upload-attachment/classes.d.ts +11 -0
- package/dist/components/upload-attachment/html.d.ts +84 -0
- package/dist/components/upload-attachment/html.js +312 -0
- package/dist/components/upload-attachment/index.d.ts +72 -0
- package/dist/components/upload-attachment/react.d.ts +9 -0
- package/dist/components/{ui/upload-attachment.js → upload-attachment/react.js} +114 -17
- package/dist/components/upload-attachment/schema.d.ts +53 -0
- package/dist/components/virtualized-combobox/classes.d.ts +7 -0
- package/dist/components/virtualized-combobox/html.d.ts +97 -0
- package/dist/components/virtualized-combobox/html.js +310 -0
- package/dist/components/virtualized-combobox/index.d.ts +182 -0
- package/dist/components/virtualized-combobox/react.d.ts +31 -0
- package/dist/components/{ui/virtualized-combobox.js → virtualized-combobox/react.js} +160 -40
- package/dist/components/virtualized-combobox/schema.d.ts +92 -0
- package/dist/components/webhook-delivery-table/html.d.ts +216 -0
- package/dist/components/webhook-delivery-table/html.js +3008 -0
- package/dist/components/webhook-delivery-table/index.d.ts +405 -0
- package/dist/components/webhook-delivery-table/react.d.ts +13 -0
- package/dist/{services/webhooks/client/delivery-table.js → components/webhook-delivery-table/react.js} +2278 -917
- package/dist/components/webhook-delivery-table/schema.d.ts +134 -0
- package/dist/lib/docs.d.ts +17 -1
- package/dist/lib/docs.integrations.server.js +341 -75
- package/dist/lib/docs.js +715 -299
- package/dist/lib/docs.server.js +325 -59
- package/dist/lib/documentation-toolkit.d.ts +4 -4
- package/dist/lib/documentation-toolkit.js +337 -71
- package/dist/lib/effect-ui-adapter/model-runtime.d.ts +17 -0
- package/dist/lib/effect-ui-adapter/use-model.d.ts +9 -0
- package/dist/lib/effect-ui-adapter/use-model.js +158 -0
- package/dist/lib/effectcn-form.d.ts +3 -0
- package/dist/lib/effectcn-form.js +54 -0
- package/dist/lib/email-composer/index.d.ts +12 -0
- package/dist/lib/email-composer/schema.d.ts +14 -0
- package/dist/lib/httpapi-toolkit.d.ts +1 -1
- package/dist/lib/lucide-effect.d.ts +39 -0
- package/dist/lib/markdown/content.d.ts +1 -12
- package/dist/lib/rich-text/model.d.ts +5 -0
- package/dist/lib/webfetch-toolkit.d.ts +1 -1
- package/dist/services/agent/client/index.js +530 -168
- package/dist/services/agent/client/widget.d.ts +1 -55
- package/dist/services/notification/client/index.js +138 -27
- package/dist/services/notification/client/notification-menu.d.ts +1 -85
- package/dist/services/notification/public.js +138 -27
- package/dist/services/opentelemetry/browser.js +15 -9
- package/dist/services/webhooks/index.d.ts +4 -3
- package/package.json +185 -142
- package/dist/components/support-dialog.js +0 -881
- package/dist/components/support.js +0 -881
- package/dist/components/ui/animated-number.js +0 -75
- package/dist/components/ui/app-brand.js +0 -126
- package/dist/components/ui/app-switcher.d.ts +0 -26
- package/dist/components/ui/async-action-button.js +0 -149
- package/dist/components/ui/auto-height.js +0 -86
- package/dist/components/ui/bulk-list-input.d.ts +0 -25
- package/dist/components/ui/choice-cards.d.ts +0 -33
- package/dist/components/ui/color-picker.d.ts +0 -31
- package/dist/components/ui/copy-button.js +0 -138
- package/dist/components/ui/copy-value.d.ts +0 -24
- package/dist/components/ui/cron-expression-editor.d.ts +0 -16
- package/dist/components/ui/cron-expression-editor.schema.d.ts +0 -7
- package/dist/components/ui/date-picker.d.ts +0 -33
- package/dist/components/ui/date-picker.schema.d.ts +0 -9
- package/dist/components/ui/editable-text.d.ts +0 -19
- package/dist/components/ui/editable-text.js +0 -341
- package/dist/components/ui/editing-locale-switcher.d.ts +0 -11
- package/dist/components/ui/error-component.d.ts +0 -34
- package/dist/components/ui/file-picker.d.ts +0 -37
- package/dist/components/ui/icon-input.d.ts +0 -58
- package/dist/components/ui/image-crop-editor.d.ts +0 -41
- package/dist/components/ui/image-crop-editor.js +0 -417
- package/dist/components/ui/loading.js +0 -39
- package/dist/components/ui/locale-switcher.d.ts +0 -11
- package/dist/components/ui/map-menu-map.d.ts +0 -115
- package/dist/components/ui/map-menu.d.ts +0 -87
- package/dist/components/ui/phone-number-input.d.ts +0 -22
- package/dist/components/ui/phone-number-input.schema.d.ts +0 -7
- package/dist/components/ui/presence-transition.js +0 -94
- package/dist/components/ui/select-with-custom-input.d.ts +0 -36
- package/dist/components/ui/stats-card.d.ts +0 -12
- package/dist/components/ui/stepper.d.ts +0 -37
- package/dist/components/ui/time-picker.d.ts +0 -50
- package/dist/components/ui/time-picker.schema.d.ts +0 -28
- package/dist/components/ui/timezone-select.d.ts +0 -57
- package/dist/components/ui/timezone-select.schema.d.ts +0 -9
- package/dist/components/ui/toast.d.ts +0 -18
- package/dist/components/ui/unsaved-changes-guard.d.ts +0 -16
- package/dist/components/ui/upload-attachment.d.ts +0 -39
- package/dist/services/notification/persistence/drizzle.d.ts +0 -868
- package/dist/services/notification/persistence/drizzle.js +0 -214
- package/dist/services/notification/persistence/index.d.ts +0 -2
- package/dist/services/notification/persistence/index.js +0 -227
- package/dist/services/notification/persistence/schema.d.ts +0 -143
- package/dist/services/notification/persistence/schema.js +0 -118
- package/dist/services/webhooks/client/delivery-table.d.ts +0 -62
|
@@ -0,0 +1,1706 @@
|
|
|
1
|
+
// ../../src/components/email-editor/html.ts
|
|
2
|
+
import { Schema as Schema12 } from "effect";
|
|
3
|
+
import { Html as Html2 } from "effect/ui/html";
|
|
4
|
+
import { Popover, Tabs } from "effect/ui/kit";
|
|
5
|
+
|
|
6
|
+
// ../../src/components/effectcn/button.ts
|
|
7
|
+
import {
|
|
8
|
+
Button as KitButton
|
|
9
|
+
} from "effect/ui/kit";
|
|
10
|
+
|
|
11
|
+
// ../../src/lib/utils.ts
|
|
12
|
+
import { cn } from "cn";
|
|
13
|
+
|
|
14
|
+
// ../../src/components/effectcn/button.ts
|
|
15
|
+
var base = "inline-flex h-8.5 shrink-0 items-center justify-center gap-1.5 rounded-md border border-transparent px-3.5 text-[13px] leading-none font-medium whitespace-nowrap no-underline select-none transition-[background-color,border-color,color,opacity] duration-150 active:translate-y-px data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 [&_svg]:size-[15px] [&_svg]:shrink-0 data-[loading]:before:size-3 data-[loading]:before:animate-spin data-[loading]:before:rounded-full data-[loading]:before:border-2 data-[loading]:before:border-current data-[loading]:before:border-r-transparent";
|
|
16
|
+
var variants = {
|
|
17
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/85",
|
|
18
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-accent",
|
|
19
|
+
outline: "border-input bg-background text-foreground shadow-sm hover:bg-accent hover:text-accent-foreground",
|
|
20
|
+
ghost: "text-foreground hover:bg-accent hover:text-accent-foreground",
|
|
21
|
+
brand: "bg-brand-soft text-brand-soft-foreground hover:bg-brand-soft/85",
|
|
22
|
+
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/85",
|
|
23
|
+
link: "h-auto px-0 text-foreground underline decoration-transparent underline-offset-4 hover:decoration-current"
|
|
24
|
+
};
|
|
25
|
+
var sizes = {
|
|
26
|
+
default: "",
|
|
27
|
+
sm: "h-7 rounded-sm px-2.5 text-xs",
|
|
28
|
+
lg: "h-10 px-5 text-sm",
|
|
29
|
+
icon: "w-8.5 px-0",
|
|
30
|
+
"icon-sm": "h-7 w-7 rounded-sm px-0"
|
|
31
|
+
};
|
|
32
|
+
var buttonVariants = (options = {}) => cn(base, variants[options.variant ?? "default"], sizes[options.size ?? "default"], options.class);
|
|
33
|
+
var Button = (h, options = {}) => KitButton(h, {
|
|
34
|
+
element: options.element,
|
|
35
|
+
onPress: options.onPress,
|
|
36
|
+
props: options.loading ? { ...options.props, disabled: true, focusableWhenDisabled: true } : options.props
|
|
37
|
+
}).class(buttonVariants(options)).attr("data-loading", options.loading ? "" : undefined);
|
|
38
|
+
|
|
39
|
+
// ../../src/components/effectcn/input.ts
|
|
40
|
+
import {
|
|
41
|
+
Input as KitInput
|
|
42
|
+
} from "effect/ui/kit";
|
|
43
|
+
var base2 = "block h-8.5 w-full min-w-0 rounded-md border border-input bg-background px-3 text-[13px] text-foreground shadow-sm outline-none " + "transition-[border-color,box-shadow] duration-150 placeholder:text-muted-foreground " + "focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/20 " + "aria-invalid:border-destructive aria-invalid:focus-visible:ring-destructive/20 " + "data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 " + "[&[readonly]]:bg-muted [&[readonly]]:text-muted-foreground [&[readonly]]:shadow-none " + "[&[type=file]]:cursor-pointer [&[type=file]]:pl-0 [&[type=file]]:leading-8 [&[type=file]]:text-muted-foreground " + "file:mr-3 file:h-8 file:cursor-pointer file:border-0 file:border-r file:border-solid file:border-input file:bg-muted file:px-3 " + "file:text-[13px] file:font-medium file:text-foreground";
|
|
44
|
+
var sizes2 = {
|
|
45
|
+
default: "",
|
|
46
|
+
sm: "h-7 rounded-sm px-2.5 text-xs",
|
|
47
|
+
lg: "h-10 px-3.5 text-sm"
|
|
48
|
+
};
|
|
49
|
+
var inputVariants = (options = {}) => cn(base2, sizes2[options.size ?? "default"], options.class);
|
|
50
|
+
var Input = (h, options) => KitInput(h, options).class(inputVariants(options));
|
|
51
|
+
|
|
52
|
+
// ../../src/components/effectcn/popover.ts
|
|
53
|
+
var sizes3 = { sm: "w-56", default: "w-72", auto: "w-auto" };
|
|
54
|
+
var PopoverPositioner = (h, popover, options = {}) => popover.positioner(h.div.class(cn("z-50 outline-none", options.class)));
|
|
55
|
+
var PopoverPopup = (h, popover, options = {}) => popover.popup(h.div.class(cn("bg-popover relative flex origin-[var(--transform-origin)] flex-col gap-2 rounded-lg border p-4 text-[13px]", "text-popover-foreground shadow-md outline-none", "h-[var(--popup-height,auto)] transition-[opacity,scale,height] duration-150 ease-out", "data-[ending-style]:scale-95 data-[ending-style]:opacity-0", "data-[starting-style]:scale-95 data-[starting-style]:opacity-0", "data-[instant]:duration-0", sizes3[options.size ?? "default"], options.class)));
|
|
56
|
+
var PopoverTitle = (h, popover, options = {}) => popover.title(h.h2.class(cn("m-0 border-0 p-0 text-sm leading-snug font-semibold", options.class)));
|
|
57
|
+
|
|
58
|
+
// ../../src/components/email-editor/html.ts
|
|
59
|
+
import { krakstackLocaleRead } from "@krak-stack/registry/krakstack-provider/html";
|
|
60
|
+
|
|
61
|
+
// ../../src/lib/lucide-effect.ts
|
|
62
|
+
import {
|
|
63
|
+
ArrowDown as arrowDown,
|
|
64
|
+
ArrowUp as arrowUp,
|
|
65
|
+
ListFilter as listFilter,
|
|
66
|
+
Check as check,
|
|
67
|
+
ChevronLeft as chevronLeft,
|
|
68
|
+
ChevronDown as chevronDown,
|
|
69
|
+
ChevronRight as chevronRight,
|
|
70
|
+
ChevronsLeft as chevronsLeft,
|
|
71
|
+
ChevronsRight as chevronsRight,
|
|
72
|
+
ChevronsUpDown as chevronsUpDown,
|
|
73
|
+
Copy as copy,
|
|
74
|
+
Download as download,
|
|
75
|
+
Eye as eye,
|
|
76
|
+
EyeOff as eyeOff,
|
|
77
|
+
Ellipsis as ellipsis,
|
|
78
|
+
FileJson as fileJson,
|
|
79
|
+
FileText as fileText,
|
|
80
|
+
GripVertical as gripVertical,
|
|
81
|
+
Image as image,
|
|
82
|
+
LayoutGrid as layoutGrid,
|
|
83
|
+
LoaderCircle as loaderCircle,
|
|
84
|
+
Mail as mail,
|
|
85
|
+
Paperclip as paperclip,
|
|
86
|
+
RefreshCw as refreshCw,
|
|
87
|
+
RotateCcw as rotateCcw,
|
|
88
|
+
Rows3 as rows3,
|
|
89
|
+
Search as search,
|
|
90
|
+
Settings2 as settings2,
|
|
91
|
+
TriangleAlert as triangleAlert,
|
|
92
|
+
X as x
|
|
93
|
+
} from "lucide";
|
|
94
|
+
var createLucideIcon = (icon) => (h, {
|
|
95
|
+
size = 24,
|
|
96
|
+
color = "currentColor",
|
|
97
|
+
strokeWidth = 2,
|
|
98
|
+
className
|
|
99
|
+
} = {}) => h.svg.attrs({
|
|
100
|
+
class: className,
|
|
101
|
+
width: String(size),
|
|
102
|
+
height: String(size),
|
|
103
|
+
viewBox: "0 0 24 24",
|
|
104
|
+
fill: "none",
|
|
105
|
+
stroke: color,
|
|
106
|
+
"stroke-width": String(strokeWidth),
|
|
107
|
+
"stroke-linecap": "round",
|
|
108
|
+
"stroke-linejoin": "round",
|
|
109
|
+
"aria-hidden": "true"
|
|
110
|
+
}).children(...icon.map(([tag, attributes]) => {
|
|
111
|
+
const attrs = Object.fromEntries(Object.entries(attributes).flatMap(([name, value]) => value === undefined ? [] : [[name, String(value)]]));
|
|
112
|
+
switch (tag) {
|
|
113
|
+
case "path":
|
|
114
|
+
return h.path.attrs(attrs);
|
|
115
|
+
case "circle":
|
|
116
|
+
return h.circle.attrs(attrs);
|
|
117
|
+
case "ellipse":
|
|
118
|
+
return h.ellipse.attrs(attrs);
|
|
119
|
+
case "line":
|
|
120
|
+
return h.line.attrs(attrs);
|
|
121
|
+
case "polyline":
|
|
122
|
+
return h.polyline.attrs(attrs);
|
|
123
|
+
case "polygon":
|
|
124
|
+
return h.polygon.attrs(attrs);
|
|
125
|
+
case "rect":
|
|
126
|
+
return h.rect.attrs(attrs);
|
|
127
|
+
default:
|
|
128
|
+
throw new Error(`Unsupported Lucide SVG element: ${tag}`);
|
|
129
|
+
}
|
|
130
|
+
}));
|
|
131
|
+
var Check = createLucideIcon(check);
|
|
132
|
+
var ArrowDown = createLucideIcon(arrowDown);
|
|
133
|
+
var ArrowUp = createLucideIcon(arrowUp);
|
|
134
|
+
var ListFilter = createLucideIcon(listFilter);
|
|
135
|
+
var ChevronLeft = createLucideIcon(chevronLeft);
|
|
136
|
+
var ChevronDown = createLucideIcon(chevronDown);
|
|
137
|
+
var ChevronRight = createLucideIcon(chevronRight);
|
|
138
|
+
var ChevronsLeft = createLucideIcon(chevronsLeft);
|
|
139
|
+
var ChevronsRight = createLucideIcon(chevronsRight);
|
|
140
|
+
var ChevronsUpDown = createLucideIcon(chevronsUpDown);
|
|
141
|
+
var Copy = createLucideIcon(copy);
|
|
142
|
+
var Download = createLucideIcon(download);
|
|
143
|
+
var Eye = createLucideIcon(eye);
|
|
144
|
+
var EyeOff = createLucideIcon(eyeOff);
|
|
145
|
+
var Ellipsis = createLucideIcon(ellipsis);
|
|
146
|
+
var FileJson = createLucideIcon(fileJson);
|
|
147
|
+
var FileText = createLucideIcon(fileText);
|
|
148
|
+
var GripVertical = createLucideIcon(gripVertical);
|
|
149
|
+
var Image = createLucideIcon(image);
|
|
150
|
+
var LayoutGrid = createLucideIcon(layoutGrid);
|
|
151
|
+
var LoaderCircle = createLucideIcon(loaderCircle);
|
|
152
|
+
var Mail = createLucideIcon(mail);
|
|
153
|
+
var Paperclip = createLucideIcon(paperclip);
|
|
154
|
+
var RefreshCw = createLucideIcon(refreshCw);
|
|
155
|
+
var RotateCcw = createLucideIcon(rotateCcw);
|
|
156
|
+
var Rows3 = createLucideIcon(rows3);
|
|
157
|
+
var Search = createLucideIcon(search);
|
|
158
|
+
var Settings2 = createLucideIcon(settings2);
|
|
159
|
+
var TriangleAlert = createLucideIcon(triangleAlert);
|
|
160
|
+
var X = createLucideIcon(x);
|
|
161
|
+
|
|
162
|
+
// ../../src/components/email-editor/html.ts
|
|
163
|
+
import { GripVertical as GripVertical2, Pencil, Plus, Trash2 } from "lucide";
|
|
164
|
+
|
|
165
|
+
// ../../src/lib/email-document/model.ts
|
|
166
|
+
import { Schema as Schema4 } from "effect";
|
|
167
|
+
|
|
168
|
+
// ../../src/lib/email-document/legacy-rich-text/schema.ts
|
|
169
|
+
import { Schema } from "effect";
|
|
170
|
+
var RichTextLink = Schema.String.check(Schema.isMaxLength(2000), Schema.makeFilter((value) => {
|
|
171
|
+
if (/[\s\p{Cc}\\{}]/u.test(value))
|
|
172
|
+
return false;
|
|
173
|
+
const url = URL.parse(value);
|
|
174
|
+
return url !== null && ["https:", "mailto:"].includes(url.protocol) && !url.username && !url.password;
|
|
175
|
+
})).annotate({ identifier: "RichTextLink" });
|
|
176
|
+
var RichTextMarks = Schema.Struct({
|
|
177
|
+
bold: Schema.optional(Schema.Boolean),
|
|
178
|
+
italic: Schema.optional(Schema.Boolean),
|
|
179
|
+
underline: Schema.optional(Schema.Boolean),
|
|
180
|
+
href: Schema.optional(RichTextLink)
|
|
181
|
+
}).annotate({ identifier: "RichTextMarks" });
|
|
182
|
+
var RichTextInline = Schema.Union([
|
|
183
|
+
Schema.Struct({
|
|
184
|
+
type: Schema.Literal("text"),
|
|
185
|
+
text: Schema.String.check(Schema.isMaxLength(20000)),
|
|
186
|
+
marks: Schema.optional(RichTextMarks)
|
|
187
|
+
}),
|
|
188
|
+
Schema.Struct({
|
|
189
|
+
type: Schema.Literal("variable"),
|
|
190
|
+
key: Schema.String.check(Schema.isPattern(/^[a-zA-Z][a-zA-Z0-9_.]{0,79}$/)),
|
|
191
|
+
marks: Schema.optional(RichTextMarks)
|
|
192
|
+
})
|
|
193
|
+
]).annotate({ identifier: "RichTextInline" });
|
|
194
|
+
var RichTextBlockKind = Schema.Literals([
|
|
195
|
+
"paragraph",
|
|
196
|
+
"heading",
|
|
197
|
+
"bullet",
|
|
198
|
+
"numbered"
|
|
199
|
+
]).annotate({ identifier: "RichTextBlockKind" });
|
|
200
|
+
var RichTextDocument = Schema.Struct({
|
|
201
|
+
version: Schema.Literal(1),
|
|
202
|
+
blocks: Schema.Array(Schema.Struct({
|
|
203
|
+
type: RichTextBlockKind,
|
|
204
|
+
content: Schema.Array(RichTextInline).check(Schema.isMaxLength(2000))
|
|
205
|
+
})).check(Schema.isMinLength(1), Schema.isMaxLength(100))
|
|
206
|
+
}).check(Schema.makeFilter((value) => value.blocks.reduce((size, block) => size + block.content.reduce((count, inline) => count + (inline.type === "text" ? inline.text.length : 1), 0), 0) <= 20000)).annotate({ identifier: "RichTextDocument" });
|
|
207
|
+
var RichTextVariable = Schema.Struct({
|
|
208
|
+
key: Schema.String.check(Schema.isPattern(/^[a-zA-Z][a-zA-Z0-9_.]{0,79}$/)),
|
|
209
|
+
label: Schema.String,
|
|
210
|
+
type: Schema.Literals(["text", "url"]),
|
|
211
|
+
sample: Schema.String
|
|
212
|
+
}).annotate({ identifier: "RichTextVariable" });
|
|
213
|
+
|
|
214
|
+
// ../../src/lib/email-document/legacy-rich-text/model.ts
|
|
215
|
+
import { Schema as Schema2 } from "effect";
|
|
216
|
+
var sameMarks = Schema2.toEquivalence(RichTextMarks);
|
|
217
|
+
var richTextFromString = (text) => ({
|
|
218
|
+
version: 1,
|
|
219
|
+
blocks: text.split(/\r\n?|\n/).map((line) => ({
|
|
220
|
+
type: "paragraph",
|
|
221
|
+
content: line ? [{ type: "text", text: line }] : []
|
|
222
|
+
}))
|
|
223
|
+
});
|
|
224
|
+
var richTextPlainText = (value, variables) => value.blocks.map((block) => block.content.map((inline) => inline.type === "text" ? inline.text : variables?.[inline.key] ?? `{{${inline.key}}}`).join("")).join(`
|
|
225
|
+
`);
|
|
226
|
+
|
|
227
|
+
// ../../src/lib/email-document/schema.ts
|
|
228
|
+
import { Schema as Schema3 } from "effect";
|
|
229
|
+
var EmailImageUrl = RichTextLink.check(Schema3.isPattern(/^https:\/\//)).annotate({ identifier: "EmailImageUrl" });
|
|
230
|
+
var EmailColor = Schema3.String.check(Schema3.isPattern(/^#[0-9a-fA-F]{6}$/)).annotate({ identifier: "EmailColor" });
|
|
231
|
+
var EmailAlignment = Schema3.Literals([
|
|
232
|
+
"left",
|
|
233
|
+
"center",
|
|
234
|
+
"right"
|
|
235
|
+
]).annotate({ identifier: "EmailAlignment" });
|
|
236
|
+
var EmailFont = Schema3.Literals(["sans", "serif", "mono"]).annotate({
|
|
237
|
+
identifier: "EmailFont"
|
|
238
|
+
});
|
|
239
|
+
var spacing = Schema3.Int.check(Schema3.isBetween({ minimum: 0, maximum: 96 }));
|
|
240
|
+
var common = {
|
|
241
|
+
id: Schema3.NonEmptyString.check(Schema3.isMaxLength(80)),
|
|
242
|
+
alignment: EmailAlignment,
|
|
243
|
+
paddingTop: spacing,
|
|
244
|
+
paddingBottom: spacing
|
|
245
|
+
};
|
|
246
|
+
var EmailDestination = Schema3.Union([
|
|
247
|
+
Schema3.Struct({ type: Schema3.Literal("url"), url: RichTextLink }),
|
|
248
|
+
Schema3.Struct({
|
|
249
|
+
type: Schema3.Literal("variable"),
|
|
250
|
+
key: RichTextVariable.fields.key
|
|
251
|
+
})
|
|
252
|
+
]).annotate({ identifier: "EmailDestination" });
|
|
253
|
+
var EmailElement = Schema3.Union([
|
|
254
|
+
Schema3.Struct({
|
|
255
|
+
...common,
|
|
256
|
+
type: Schema3.Literal("text"),
|
|
257
|
+
content: RichTextDocument
|
|
258
|
+
}),
|
|
259
|
+
Schema3.Struct({
|
|
260
|
+
...common,
|
|
261
|
+
type: Schema3.Literal("button"),
|
|
262
|
+
label: Schema3.String.check(Schema3.isMaxLength(200)),
|
|
263
|
+
destination: EmailDestination
|
|
264
|
+
}),
|
|
265
|
+
Schema3.Struct({
|
|
266
|
+
...common,
|
|
267
|
+
type: Schema3.Literal("code"),
|
|
268
|
+
variable: RichTextVariable.fields.key
|
|
269
|
+
}),
|
|
270
|
+
Schema3.Struct({
|
|
271
|
+
...common,
|
|
272
|
+
type: Schema3.Literals(["logo", "image"]),
|
|
273
|
+
src: EmailImageUrl,
|
|
274
|
+
alt: Schema3.String.check(Schema3.isMaxLength(200)),
|
|
275
|
+
width: Schema3.Int.check(Schema3.isBetween({ minimum: 32, maximum: 560 }))
|
|
276
|
+
}),
|
|
277
|
+
Schema3.Struct({ ...common, type: Schema3.Literal("divider") }),
|
|
278
|
+
Schema3.Struct({ ...common, type: Schema3.Literal("spacer"), height: spacing })
|
|
279
|
+
]).annotate({ identifier: "EmailElement" });
|
|
280
|
+
var subject = Schema3.String.check(Schema3.isMaxLength(200), Schema3.isPattern(/^[^\r\n]*$/));
|
|
281
|
+
var EmailDocument = Schema3.Struct({
|
|
282
|
+
version: Schema3.Literal(1),
|
|
283
|
+
subject,
|
|
284
|
+
preview: subject,
|
|
285
|
+
appearance: Schema3.Struct({
|
|
286
|
+
background: EmailColor,
|
|
287
|
+
surface: EmailColor,
|
|
288
|
+
text: EmailColor,
|
|
289
|
+
primary: EmailColor,
|
|
290
|
+
primaryText: EmailColor,
|
|
291
|
+
font: EmailFont,
|
|
292
|
+
radius: Schema3.Int.check(Schema3.isBetween({ minimum: 0, maximum: 32 }))
|
|
293
|
+
}),
|
|
294
|
+
elements: Schema3.Array(EmailElement).check(Schema3.isMaxLength(40))
|
|
295
|
+
}).check(Schema3.makeFilter((document) => new Set(document.elements.map((element) => element.id)).size === document.elements.length)).annotate({ identifier: "EmailDocument" });
|
|
296
|
+
var EmailRenderInput = Schema3.Struct({
|
|
297
|
+
document: EmailDocument,
|
|
298
|
+
variables: Schema3.Array(RichTextVariable),
|
|
299
|
+
values: Schema3.Record(Schema3.String, Schema3.String),
|
|
300
|
+
requiredVariables: Schema3.optional(Schema3.Array(Schema3.String))
|
|
301
|
+
}).annotate({ identifier: "EmailRenderInput" });
|
|
302
|
+
var EmailRenderResult = Schema3.Struct({
|
|
303
|
+
subject: Schema3.String,
|
|
304
|
+
html: Schema3.String,
|
|
305
|
+
text: Schema3.String
|
|
306
|
+
}).annotate({ identifier: "EmailRenderResult" });
|
|
307
|
+
|
|
308
|
+
// ../../src/lib/email-document/model.ts
|
|
309
|
+
var emailElementTypes = [
|
|
310
|
+
"text",
|
|
311
|
+
"button",
|
|
312
|
+
"code",
|
|
313
|
+
"logo",
|
|
314
|
+
"image",
|
|
315
|
+
"divider",
|
|
316
|
+
"spacer"
|
|
317
|
+
];
|
|
318
|
+
var newEmailElement = (type, input) => {
|
|
319
|
+
const common = {
|
|
320
|
+
id: input.id,
|
|
321
|
+
alignment: "left",
|
|
322
|
+
paddingTop: 8,
|
|
323
|
+
paddingBottom: 8
|
|
324
|
+
};
|
|
325
|
+
switch (type) {
|
|
326
|
+
case "text":
|
|
327
|
+
return { ...common, type, content: richTextFromString(input.text) };
|
|
328
|
+
case "button":
|
|
329
|
+
return {
|
|
330
|
+
...common,
|
|
331
|
+
type,
|
|
332
|
+
label: input.button,
|
|
333
|
+
destination: input.urlVariable ? { type: "variable", key: input.urlVariable } : { type: "url", url: "https://example.com" }
|
|
334
|
+
};
|
|
335
|
+
case "code":
|
|
336
|
+
return { ...common, type, variable: input.codeVariable ?? "code" };
|
|
337
|
+
case "logo":
|
|
338
|
+
case "image":
|
|
339
|
+
return {
|
|
340
|
+
...common,
|
|
341
|
+
type,
|
|
342
|
+
src: "https://krakstack.net/favicon.svg",
|
|
343
|
+
alt: input.imageAlt,
|
|
344
|
+
width: type === "logo" ? 48 : 160
|
|
345
|
+
};
|
|
346
|
+
case "divider":
|
|
347
|
+
return { ...common, type };
|
|
348
|
+
case "spacer":
|
|
349
|
+
return { ...common, type, height: 24 };
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
var richTextFromEmailText = (text) => ({
|
|
353
|
+
version: 1,
|
|
354
|
+
blocks: [
|
|
355
|
+
{
|
|
356
|
+
type: "paragraph",
|
|
357
|
+
content: text.split(/(\{\{[a-zA-Z][a-zA-Z0-9_.]*\}\})/g).filter(Boolean).map((part) => /^\{\{[a-zA-Z][a-zA-Z0-9_.]*\}\}$/.test(part) ? { type: "variable", key: part.slice(2, -2) } : { type: "text", text: part })
|
|
358
|
+
}
|
|
359
|
+
]
|
|
360
|
+
});
|
|
361
|
+
var textReferences = (text) => [...text.matchAll(/\{\{([a-zA-Z][a-zA-Z0-9_.]*)\}\}/g)].map((match) => match[1] ?? "");
|
|
362
|
+
var emailDocumentReferences = (document) => [
|
|
363
|
+
...new Set([
|
|
364
|
+
...textReferences(document.subject),
|
|
365
|
+
...textReferences(document.preview),
|
|
366
|
+
...document.elements.flatMap((element) => {
|
|
367
|
+
switch (element.type) {
|
|
368
|
+
case "text":
|
|
369
|
+
return element.content.blocks.flatMap((block) => block.content.flatMap((inline) => inline.type === "variable" ? [inline.key] : []));
|
|
370
|
+
case "code":
|
|
371
|
+
return [element.variable];
|
|
372
|
+
case "button":
|
|
373
|
+
return [
|
|
374
|
+
...textReferences(element.label),
|
|
375
|
+
...element.destination.type === "variable" ? [element.destination.key] : []
|
|
376
|
+
];
|
|
377
|
+
default:
|
|
378
|
+
return [];
|
|
379
|
+
}
|
|
380
|
+
})
|
|
381
|
+
])
|
|
382
|
+
];
|
|
383
|
+
var validateEmailDocument = ({
|
|
384
|
+
document,
|
|
385
|
+
variables,
|
|
386
|
+
values,
|
|
387
|
+
requiredVariables = []
|
|
388
|
+
}) => {
|
|
389
|
+
if (!Schema4.is(EmailDocument)(document))
|
|
390
|
+
return [{ code: "invalid-document" }];
|
|
391
|
+
const references = emailDocumentReferences(document);
|
|
392
|
+
const issues = [];
|
|
393
|
+
for (const key of references) {
|
|
394
|
+
if (!variables.some((variable) => variable.key === key))
|
|
395
|
+
issues.push({ code: "unknown-variable", key });
|
|
396
|
+
if (values && !values[key])
|
|
397
|
+
issues.push({ code: "missing-variable", key });
|
|
398
|
+
}
|
|
399
|
+
for (const element of document.elements) {
|
|
400
|
+
if (element.type === "button" && element.destination.type === "variable") {
|
|
401
|
+
const key = element.destination.key;
|
|
402
|
+
if (variables.find((variable) => variable.key === key)?.type !== "url" || values && !Schema4.is(RichTextLink)(values[key]))
|
|
403
|
+
issues.push({ code: "invalid-url", key });
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
for (const key of requiredVariables)
|
|
407
|
+
if (!document.elements.some((element) => element.type === "code" && element.variable === key || element.type === "button" && element.destination.type === "variable" && element.destination.key === key || element.type === "text" && element.content.blocks.some((block) => block.content.some((inline) => inline.type === "variable" && inline.key === key))))
|
|
408
|
+
issues.push({ code: "missing-required-variable", key });
|
|
409
|
+
return issues;
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
// ../../src/components/email-editor/classes.ts
|
|
413
|
+
var emailEditorClasses = {
|
|
414
|
+
inspectorField: "grid min-w-0 gap-1.5 text-xs font-medium",
|
|
415
|
+
inspector: "min-w-0 space-y-4",
|
|
416
|
+
sectionHeading: "text-xs font-medium",
|
|
417
|
+
previewPlaceholder: "p-8 text-center text-sm",
|
|
418
|
+
image: "inline-block max-w-full",
|
|
419
|
+
metadata: "text-muted-foreground text-xs",
|
|
420
|
+
actionGrid: "grid grid-cols-2 gap-2",
|
|
421
|
+
error: "text-destructive text-xs"
|
|
422
|
+
};
|
|
423
|
+
var resolveEmailEditorClasses = (overrides) => ({
|
|
424
|
+
...emailEditorClasses,
|
|
425
|
+
...overrides
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
// ../../src/components/email-editor/index.ts
|
|
429
|
+
import { Schema as Schema6 } from "effect";
|
|
430
|
+
import { Component, UiSchema } from "effect/ui";
|
|
431
|
+
|
|
432
|
+
// ../../src/components/email-editor/labels.ts
|
|
433
|
+
var defaultMessages = {
|
|
434
|
+
en: {
|
|
435
|
+
edit: "Design",
|
|
436
|
+
preview: "Preview",
|
|
437
|
+
subject: "Subject",
|
|
438
|
+
preheader: "Preview text",
|
|
439
|
+
add: "Add element",
|
|
440
|
+
text: "Text",
|
|
441
|
+
button: "Button",
|
|
442
|
+
code: "Verification code",
|
|
443
|
+
logo: "Logo",
|
|
444
|
+
image: "Image",
|
|
445
|
+
divider: "Divider",
|
|
446
|
+
spacer: "Spacer",
|
|
447
|
+
content: "Email content",
|
|
448
|
+
properties: "Element settings",
|
|
449
|
+
select: "Select an element to edit its settings.",
|
|
450
|
+
alignment: "Alignment",
|
|
451
|
+
left: "Left",
|
|
452
|
+
center: "Center",
|
|
453
|
+
right: "Right",
|
|
454
|
+
paddingTop: "Space above",
|
|
455
|
+
paddingBottom: "Space below",
|
|
456
|
+
width: "Width",
|
|
457
|
+
height: "Height",
|
|
458
|
+
src: "Image URL",
|
|
459
|
+
alt: "Alternative text",
|
|
460
|
+
label: "Button label",
|
|
461
|
+
destination: "Destination",
|
|
462
|
+
url: "Custom URL",
|
|
463
|
+
variable: "Variable",
|
|
464
|
+
insertVariable: "Insert variable",
|
|
465
|
+
close: "Close settings",
|
|
466
|
+
duplicate: "Duplicate element",
|
|
467
|
+
remove: "Remove element",
|
|
468
|
+
background: "Canvas",
|
|
469
|
+
surface: "Paper",
|
|
470
|
+
primary: "Accent",
|
|
471
|
+
primaryText: "Button text",
|
|
472
|
+
foreground: "Text color",
|
|
473
|
+
font: "Font",
|
|
474
|
+
sans: "Sans serif",
|
|
475
|
+
serif: "Serif",
|
|
476
|
+
mono: "Monospace",
|
|
477
|
+
branding: "Branding",
|
|
478
|
+
invalid: "Fix invalid settings or missing variables before using this email.",
|
|
479
|
+
newText: "Write your message here.",
|
|
480
|
+
newButton: "Continue",
|
|
481
|
+
newImage: "Your image",
|
|
482
|
+
empty: "Start with an element. Everything can be moved.",
|
|
483
|
+
editElement: "Edit element",
|
|
484
|
+
local: "Drag by the grip or use the arrow keys on it. Your changes stay in this editor."
|
|
485
|
+
},
|
|
486
|
+
fr: {
|
|
487
|
+
edit: "Création",
|
|
488
|
+
preview: "Aperçu",
|
|
489
|
+
subject: "Objet",
|
|
490
|
+
preheader: "Texte d’aperçu",
|
|
491
|
+
add: "Ajouter un élément",
|
|
492
|
+
text: "Texte",
|
|
493
|
+
button: "Bouton",
|
|
494
|
+
code: "Code de vérification",
|
|
495
|
+
logo: "Logo",
|
|
496
|
+
image: "Image",
|
|
497
|
+
divider: "Séparateur",
|
|
498
|
+
spacer: "Espacement",
|
|
499
|
+
content: "Contenu du courriel",
|
|
500
|
+
properties: "Réglages de l’élément",
|
|
501
|
+
select: "Sélectionnez un élément pour modifier ses réglages.",
|
|
502
|
+
alignment: "Alignement",
|
|
503
|
+
left: "Gauche",
|
|
504
|
+
center: "Centre",
|
|
505
|
+
right: "Droite",
|
|
506
|
+
paddingTop: "Espace au-dessus",
|
|
507
|
+
paddingBottom: "Espace en dessous",
|
|
508
|
+
width: "Largeur",
|
|
509
|
+
height: "Hauteur",
|
|
510
|
+
src: "URL de l’image",
|
|
511
|
+
alt: "Texte de remplacement",
|
|
512
|
+
label: "Libellé du bouton",
|
|
513
|
+
destination: "Destination",
|
|
514
|
+
url: "URL personnalisée",
|
|
515
|
+
variable: "Variable",
|
|
516
|
+
insertVariable: "Insérer une variable",
|
|
517
|
+
close: "Fermer les réglages",
|
|
518
|
+
duplicate: "Dupliquer l’élément",
|
|
519
|
+
remove: "Retirer l’élément",
|
|
520
|
+
background: "Fond",
|
|
521
|
+
surface: "Papier",
|
|
522
|
+
primary: "Accent",
|
|
523
|
+
primaryText: "Texte du bouton",
|
|
524
|
+
foreground: "Couleur du texte",
|
|
525
|
+
font: "Police",
|
|
526
|
+
sans: "Sans empattement",
|
|
527
|
+
serif: "Avec empattement",
|
|
528
|
+
mono: "Chasse fixe",
|
|
529
|
+
branding: "Identité visuelle",
|
|
530
|
+
invalid: "Corrigez les réglages invalides ou les variables manquantes avant d’utiliser ce courriel.",
|
|
531
|
+
newText: "Rédigez votre message ici.",
|
|
532
|
+
newButton: "Continuer",
|
|
533
|
+
newImage: "Votre image",
|
|
534
|
+
empty: "Commencez par un élément. Tout peut être déplacé.",
|
|
535
|
+
editElement: "Modifier l’élément",
|
|
536
|
+
local: "Glissez avec la poignée ou utilisez ses touches fléchées. Vos modifications restent dans cet éditeur."
|
|
537
|
+
}
|
|
538
|
+
};
|
|
539
|
+
|
|
540
|
+
// ../../src/components/email-editor/schema.ts
|
|
541
|
+
import { Schema as Schema5, Struct } from "effect";
|
|
542
|
+
var Overrides = Schema5.Struct({
|
|
543
|
+
edit: Schema5.optional(Schema5.String),
|
|
544
|
+
preview: Schema5.optional(Schema5.String),
|
|
545
|
+
subject: Schema5.optional(Schema5.String),
|
|
546
|
+
preheader: Schema5.optional(Schema5.String),
|
|
547
|
+
add: Schema5.optional(Schema5.String),
|
|
548
|
+
text: Schema5.optional(Schema5.String),
|
|
549
|
+
button: Schema5.optional(Schema5.String),
|
|
550
|
+
code: Schema5.optional(Schema5.String),
|
|
551
|
+
logo: Schema5.optional(Schema5.String),
|
|
552
|
+
image: Schema5.optional(Schema5.String),
|
|
553
|
+
divider: Schema5.optional(Schema5.String),
|
|
554
|
+
spacer: Schema5.optional(Schema5.String),
|
|
555
|
+
content: Schema5.optional(Schema5.String),
|
|
556
|
+
properties: Schema5.optional(Schema5.String),
|
|
557
|
+
select: Schema5.optional(Schema5.String),
|
|
558
|
+
alignment: Schema5.optional(Schema5.String),
|
|
559
|
+
left: Schema5.optional(Schema5.String),
|
|
560
|
+
center: Schema5.optional(Schema5.String),
|
|
561
|
+
right: Schema5.optional(Schema5.String),
|
|
562
|
+
paddingTop: Schema5.optional(Schema5.String),
|
|
563
|
+
paddingBottom: Schema5.optional(Schema5.String),
|
|
564
|
+
width: Schema5.optional(Schema5.String),
|
|
565
|
+
height: Schema5.optional(Schema5.String),
|
|
566
|
+
src: Schema5.optional(Schema5.String),
|
|
567
|
+
alt: Schema5.optional(Schema5.String),
|
|
568
|
+
label: Schema5.optional(Schema5.String),
|
|
569
|
+
destination: Schema5.optional(Schema5.String),
|
|
570
|
+
url: Schema5.optional(Schema5.String),
|
|
571
|
+
variable: Schema5.optional(Schema5.String),
|
|
572
|
+
insertVariable: Schema5.optional(Schema5.String),
|
|
573
|
+
close: Schema5.optional(Schema5.String),
|
|
574
|
+
duplicate: Schema5.optional(Schema5.String),
|
|
575
|
+
remove: Schema5.optional(Schema5.String),
|
|
576
|
+
background: Schema5.optional(Schema5.String),
|
|
577
|
+
surface: Schema5.optional(Schema5.String),
|
|
578
|
+
primary: Schema5.optional(Schema5.String),
|
|
579
|
+
primaryText: Schema5.optional(Schema5.String),
|
|
580
|
+
foreground: Schema5.optional(Schema5.String),
|
|
581
|
+
font: Schema5.optional(Schema5.String),
|
|
582
|
+
sans: Schema5.optional(Schema5.String),
|
|
583
|
+
serif: Schema5.optional(Schema5.String),
|
|
584
|
+
mono: Schema5.optional(Schema5.String),
|
|
585
|
+
branding: Schema5.optional(Schema5.String),
|
|
586
|
+
invalid: Schema5.optional(Schema5.String),
|
|
587
|
+
newText: Schema5.optional(Schema5.String),
|
|
588
|
+
newButton: Schema5.optional(Schema5.String),
|
|
589
|
+
newImage: Schema5.optional(Schema5.String),
|
|
590
|
+
empty: Schema5.optional(Schema5.String),
|
|
591
|
+
editElement: Schema5.optional(Schema5.String),
|
|
592
|
+
local: Schema5.optional(Schema5.String)
|
|
593
|
+
});
|
|
594
|
+
var EmailEditorClassesOverridesSchema = Schema5.Record(Schema5.Literals(Struct.keys(emailEditorClasses)), Schema5.optionalKey(Schema5.String)).annotate({ identifier: "EmailEditorClassesOverrides" });
|
|
595
|
+
var EmailEditorPropsSchema = Schema5.Struct({
|
|
596
|
+
classes: Schema5.optional(EmailEditorClassesOverridesSchema),
|
|
597
|
+
value: EmailDocument,
|
|
598
|
+
variables: Schema5.optional(Schema5.Array(RichTextVariable)),
|
|
599
|
+
requiredVariables: Schema5.optional(Schema5.Array(Schema5.String)),
|
|
600
|
+
disabled: Schema5.optional(Schema5.Boolean),
|
|
601
|
+
locale: Schema5.optional(Schema5.String),
|
|
602
|
+
messages: Schema5.optional(Schema5.Record(Schema5.String, Schema5.UndefinedOr(Overrides)))
|
|
603
|
+
}).annotate({ identifier: "EmailEditorProps" });
|
|
604
|
+
|
|
605
|
+
// ../../src/components/email-editor/index.ts
|
|
606
|
+
var emailEditorMessages = (locale, messages) => ({
|
|
607
|
+
...locale.startsWith("fr") ? defaultMessages.fr : defaultMessages.en,
|
|
608
|
+
...messages?.[locale.split("-")[0] ?? locale],
|
|
609
|
+
...messages?.[locale]
|
|
610
|
+
});
|
|
611
|
+
var fonts = {
|
|
612
|
+
sans: "Arial, sans-serif",
|
|
613
|
+
serif: "Georgia, serif",
|
|
614
|
+
mono: "'Courier New', monospace"
|
|
615
|
+
};
|
|
616
|
+
var createElement = (type, id, copy, variables) => newEmailElement(type, {
|
|
617
|
+
id,
|
|
618
|
+
text: copy.newText,
|
|
619
|
+
button: copy.newButton,
|
|
620
|
+
imageAlt: copy.newImage,
|
|
621
|
+
codeVariable: variables.find(({ key }) => key === "code")?.key ?? variables.find(({ type }) => type === "text")?.key,
|
|
622
|
+
urlVariable: variables.find(({ type }) => type === "url")?.key
|
|
623
|
+
});
|
|
624
|
+
var replaceElement = (value, element) => ({
|
|
625
|
+
...value,
|
|
626
|
+
elements: value.elements.map((item) => item.id === element.id ? element : item)
|
|
627
|
+
});
|
|
628
|
+
var duplicateElement = (value, target, id) => ({
|
|
629
|
+
...value,
|
|
630
|
+
elements: value.elements.flatMap((item) => item.id === target ? [item, { ...item, id }] : [item])
|
|
631
|
+
});
|
|
632
|
+
var removeElement = (value, target) => ({
|
|
633
|
+
...value,
|
|
634
|
+
elements: value.elements.filter(({ id }) => id !== target)
|
|
635
|
+
});
|
|
636
|
+
var moveElement = (value, source, target) => {
|
|
637
|
+
const from = value.elements.findIndex(({ id }) => id === source);
|
|
638
|
+
const to = value.elements.findIndex(({ id }) => id === target);
|
|
639
|
+
if (from < 0 || to < 0 || from === to)
|
|
640
|
+
return value;
|
|
641
|
+
const elements = [...value.elements];
|
|
642
|
+
const [element] = elements.splice(from, 1);
|
|
643
|
+
if (!element)
|
|
644
|
+
return value;
|
|
645
|
+
elements.splice(to, 0, element);
|
|
646
|
+
return { ...value, elements };
|
|
647
|
+
};
|
|
648
|
+
var initialActive = (value) => value.elements.find(({ type }) => type === "text")?.id ?? null;
|
|
649
|
+
var EmailEditorEvents = UiSchema.TaggedEnum({
|
|
650
|
+
Changed: { value: EmailDocument }
|
|
651
|
+
}).annotate({ identifier: "EmailEditorEvents" });
|
|
652
|
+
var EmailEditorMessage = UiSchema.TaggedEnum({
|
|
653
|
+
Mode: { mode: Schema6.Literals(["design", "preview"]) },
|
|
654
|
+
SetDesignPopover: {
|
|
655
|
+
popover: Schema6.Literals(["add", "branding"]),
|
|
656
|
+
open: Schema6.Boolean
|
|
657
|
+
},
|
|
658
|
+
Select: { id: Schema6.String },
|
|
659
|
+
Close: {},
|
|
660
|
+
Add: {
|
|
661
|
+
id: Schema6.String,
|
|
662
|
+
kind: Schema6.Literals(emailElementTypes),
|
|
663
|
+
text: Schema6.String,
|
|
664
|
+
button: Schema6.String,
|
|
665
|
+
image: Schema6.String
|
|
666
|
+
},
|
|
667
|
+
Duplicate: { id: Schema6.String, target: Schema6.String },
|
|
668
|
+
Remove: { id: Schema6.String },
|
|
669
|
+
Move: { source: Schema6.String, target: Schema6.String },
|
|
670
|
+
Content: { id: Schema6.String, content: RichTextDocument },
|
|
671
|
+
Header: {
|
|
672
|
+
key: Schema6.Literals(["subject", "preview"]),
|
|
673
|
+
content: RichTextDocument
|
|
674
|
+
},
|
|
675
|
+
Appearance: {
|
|
676
|
+
key: Schema6.Literals([
|
|
677
|
+
"background",
|
|
678
|
+
"surface",
|
|
679
|
+
"primary",
|
|
680
|
+
"primaryText",
|
|
681
|
+
"text",
|
|
682
|
+
"font"
|
|
683
|
+
]),
|
|
684
|
+
value: Schema6.String
|
|
685
|
+
},
|
|
686
|
+
Setting: {
|
|
687
|
+
id: Schema6.String,
|
|
688
|
+
key: Schema6.Literals([
|
|
689
|
+
"alignment",
|
|
690
|
+
"paddingTop",
|
|
691
|
+
"paddingBottom",
|
|
692
|
+
"label",
|
|
693
|
+
"destination",
|
|
694
|
+
"url",
|
|
695
|
+
"variable",
|
|
696
|
+
"src",
|
|
697
|
+
"alt",
|
|
698
|
+
"width",
|
|
699
|
+
"height"
|
|
700
|
+
]),
|
|
701
|
+
value: Schema6.String
|
|
702
|
+
}
|
|
703
|
+
}).annotate({ identifier: "EmailEditorMessage" });
|
|
704
|
+
var emailEditorOptions = {
|
|
705
|
+
name: "EmailEditor",
|
|
706
|
+
props: EmailEditorPropsSchema,
|
|
707
|
+
model: Schema6.Struct({
|
|
708
|
+
active: Schema6.NullOr(Schema6.String),
|
|
709
|
+
settingsOpen: Schema6.Boolean,
|
|
710
|
+
mode: Schema6.Literals(["design", "preview"]),
|
|
711
|
+
designPopover: Schema6.NullOr(Schema6.Literals(["add", "branding"]))
|
|
712
|
+
}).annotate({ identifier: "EmailEditorModel" }),
|
|
713
|
+
message: EmailEditorMessage,
|
|
714
|
+
events: EmailEditorEvents,
|
|
715
|
+
restore: false
|
|
716
|
+
};
|
|
717
|
+
var update = Component.define(emailEditorOptions).update({
|
|
718
|
+
Mode: ($, { mode }) => $.evolve({ mode, designPopover: null }),
|
|
719
|
+
SetDesignPopover: ($, { popover, open }) => $.evolve({
|
|
720
|
+
designPopover: open ? popover : $.model.designPopover === popover ? null : $.model.designPopover
|
|
721
|
+
}),
|
|
722
|
+
Select: ($, { id }) => $.props.disabled ? $.model : $.evolve({ active: id, settingsOpen: true }),
|
|
723
|
+
Close: ($) => $.evolve({ settingsOpen: false }),
|
|
724
|
+
Add: ($, { kind, id, text, button, image }) => $.props.disabled || $.props.value.elements.length >= 40 ? $.model : $.evolve({ active: id, designPopover: null }).emit(EmailEditorEvents.Changed({
|
|
725
|
+
value: {
|
|
726
|
+
...$.props.value,
|
|
727
|
+
elements: [
|
|
728
|
+
...$.props.value.elements,
|
|
729
|
+
createElement(kind, id, { newText: text, newButton: button, newImage: image }, $.props.variables ?? [])
|
|
730
|
+
]
|
|
731
|
+
}
|
|
732
|
+
})),
|
|
733
|
+
Duplicate: ($, { id, target }) => $.props.disabled || $.props.value.elements.length >= 40 ? $.model : $.evolve({ active: id }).emit(EmailEditorEvents.Changed({
|
|
734
|
+
value: duplicateElement($.props.value, target, id)
|
|
735
|
+
})),
|
|
736
|
+
Remove: ($, { id }) => $.props.disabled ? $.model : $.evolve({ active: null, settingsOpen: false }).emit(EmailEditorEvents.Changed({
|
|
737
|
+
value: removeElement($.props.value, id)
|
|
738
|
+
})),
|
|
739
|
+
Move: ($, { source, target }) => {
|
|
740
|
+
const value = moveElement($.props.value, source, target);
|
|
741
|
+
return $.props.disabled || value === $.props.value ? $.model : $.set($.model).emit(EmailEditorEvents.Changed({ value }));
|
|
742
|
+
},
|
|
743
|
+
Content: ($, { id, content }) => {
|
|
744
|
+
const element = $.props.value.elements.find((item) => item.id === id);
|
|
745
|
+
return $.props.disabled || element?.type !== "text" ? $.model : $.set($.model).emit(EmailEditorEvents.Changed({
|
|
746
|
+
value: replaceElement($.props.value, { ...element, content })
|
|
747
|
+
}));
|
|
748
|
+
},
|
|
749
|
+
Header: ($, { key, content }) => $.props.disabled ? $.model : $.set($.model).emit(EmailEditorEvents.Changed({
|
|
750
|
+
value: { ...$.props.value, [key]: richTextPlainText(content) }
|
|
751
|
+
})),
|
|
752
|
+
Appearance: ($, { key, value }) => $.props.disabled ? $.model : $.set($.model).emit(EmailEditorEvents.Changed({
|
|
753
|
+
value: {
|
|
754
|
+
...$.props.value,
|
|
755
|
+
appearance: { ...$.props.value.appearance, [key]: value }
|
|
756
|
+
}
|
|
757
|
+
})),
|
|
758
|
+
Setting: ($, { id, key, value }) => {
|
|
759
|
+
const element = $.props.value.elements.find((item) => item.id === id);
|
|
760
|
+
if ($.props.disabled || !element)
|
|
761
|
+
return $.model;
|
|
762
|
+
const updated = key === "destination" && element.type === "button" ? {
|
|
763
|
+
...element,
|
|
764
|
+
destination: value === "__url" ? { type: "url", url: "https://example.com" } : { type: "variable", key: value }
|
|
765
|
+
} : key === "url" && element.type === "button" ? { ...element, destination: { type: "url", url: value } } : {
|
|
766
|
+
...element,
|
|
767
|
+
[key]: key === "width" || key === "height" || key === "paddingTop" || key === "paddingBottom" ? value === "" ? 0 : Number(value) : value
|
|
768
|
+
};
|
|
769
|
+
return $.set($.model).emit(EmailEditorEvents.Changed({
|
|
770
|
+
value: replaceElement($.props.value, updated)
|
|
771
|
+
}));
|
|
772
|
+
}
|
|
773
|
+
});
|
|
774
|
+
var emailEditorBehaviours = {
|
|
775
|
+
init: ({ props }) => ({
|
|
776
|
+
designPopover: null,
|
|
777
|
+
active: initialActive(props.value),
|
|
778
|
+
settingsOpen: false,
|
|
779
|
+
mode: "design"
|
|
780
|
+
}),
|
|
781
|
+
update
|
|
782
|
+
};
|
|
783
|
+
|
|
784
|
+
// ../../src/components/email-editor/legacy-editor.html.ts
|
|
785
|
+
import { Editor } from "@tiptap/core";
|
|
786
|
+
import { closeHistory } from "@tiptap/pm/history";
|
|
787
|
+
import { EditorState } from "@tiptap/pm/state";
|
|
788
|
+
import { Effect, Option as Option2, Queue, Schema as Schema11, Stream } from "effect";
|
|
789
|
+
import { Mount, UiSchema as UiSchema3 } from "effect/ui";
|
|
790
|
+
import { Html } from "effect/ui/html";
|
|
791
|
+
|
|
792
|
+
// ../../src/lib/email-document/legacy-rich-text/tiptap.ts
|
|
793
|
+
import { Extension, Node } from "@tiptap/core";
|
|
794
|
+
import { Plugin } from "@tiptap/pm/state";
|
|
795
|
+
import StarterKit from "@tiptap/starter-kit";
|
|
796
|
+
import { Option, Schema as Schema7 } from "effect";
|
|
797
|
+
var toTiptapDocument = (value, singleLine = false) => {
|
|
798
|
+
const blocks = singleLine ? [
|
|
799
|
+
{
|
|
800
|
+
type: "paragraph",
|
|
801
|
+
content: value.blocks.flatMap((block, index) => [
|
|
802
|
+
...index ? [{ type: "text", text: " " }] : [],
|
|
803
|
+
...block.content.map((inline) => inline.type === "text" ? { type: "text", text: inline.text.replace(/[\r\n]+/g, " ") } : { type: "variable", key: inline.key })
|
|
804
|
+
])
|
|
805
|
+
}
|
|
806
|
+
] : value.blocks;
|
|
807
|
+
return {
|
|
808
|
+
type: "doc",
|
|
809
|
+
content: blocks.map((block) => ({
|
|
810
|
+
type: "paragraph",
|
|
811
|
+
attrs: { kind: block.type },
|
|
812
|
+
content: block.content.filter((inline) => inline.type !== "text" || inline.text.length > 0).map((inline) => {
|
|
813
|
+
const marks = [];
|
|
814
|
+
if (inline.marks?.bold)
|
|
815
|
+
marks.push({ type: "bold" });
|
|
816
|
+
if (inline.marks?.italic)
|
|
817
|
+
marks.push({ type: "italic" });
|
|
818
|
+
if (inline.marks?.underline)
|
|
819
|
+
marks.push({ type: "underline" });
|
|
820
|
+
if (inline.marks?.href)
|
|
821
|
+
marks.push({ type: "link", attrs: { href: inline.marks.href } });
|
|
822
|
+
return inline.type === "text" ? { type: "text", text: inline.text, marks } : { type: "variable", attrs: { key: inline.key }, marks };
|
|
823
|
+
})
|
|
824
|
+
}))
|
|
825
|
+
};
|
|
826
|
+
};
|
|
827
|
+
var fromTiptapDocument = (doc) => {
|
|
828
|
+
const blocks = [];
|
|
829
|
+
doc.forEach((block) => {
|
|
830
|
+
const content = [];
|
|
831
|
+
block.forEach((inline) => {
|
|
832
|
+
let marks = {};
|
|
833
|
+
for (const mark of inline.marks) {
|
|
834
|
+
if (mark.type.name === "bold")
|
|
835
|
+
marks = { ...marks, bold: true };
|
|
836
|
+
if (mark.type.name === "italic")
|
|
837
|
+
marks = { ...marks, italic: true };
|
|
838
|
+
if (mark.type.name === "underline")
|
|
839
|
+
marks = { ...marks, underline: true };
|
|
840
|
+
if (mark.type.name === "link")
|
|
841
|
+
marks = { ...marks, href: mark.attrs.href };
|
|
842
|
+
}
|
|
843
|
+
const value = inline.isText ? { type: "text", text: inline.text } : { type: inline.type.name, key: inline.attrs.key };
|
|
844
|
+
content.push(Object.keys(marks).length ? { ...value, marks } : value);
|
|
845
|
+
});
|
|
846
|
+
blocks.push({ type: block.attrs.kind, content });
|
|
847
|
+
});
|
|
848
|
+
return Schema7.decodeUnknownOption(RichTextDocument)({ version: 1, blocks });
|
|
849
|
+
};
|
|
850
|
+
var SingleLineDocument = RichTextDocument.check(Schema7.makeFilter((value) => value.blocks.length === 1 && value.blocks.every((block) => block.type === "paragraph" && block.content.every((inline) => !inline.marks && (inline.type !== "text" || !/[\r\n]/.test(inline.text)))))).annotate({ identifier: "SingleLineRichTextDocument" });
|
|
851
|
+
var richTextExtensions = ({
|
|
852
|
+
singleLine = false,
|
|
853
|
+
maxLength = () => {
|
|
854
|
+
return;
|
|
855
|
+
},
|
|
856
|
+
variables = () => [],
|
|
857
|
+
onInvalid = () => {}
|
|
858
|
+
} = {}) => [
|
|
859
|
+
StarterKit.configure({
|
|
860
|
+
blockquote: false,
|
|
861
|
+
bulletList: false,
|
|
862
|
+
code: false,
|
|
863
|
+
codeBlock: false,
|
|
864
|
+
dropcursor: false,
|
|
865
|
+
gapcursor: false,
|
|
866
|
+
hardBreak: false,
|
|
867
|
+
heading: false,
|
|
868
|
+
horizontalRule: false,
|
|
869
|
+
listItem: false,
|
|
870
|
+
listKeymap: false,
|
|
871
|
+
orderedList: false,
|
|
872
|
+
paragraph: false,
|
|
873
|
+
strike: false,
|
|
874
|
+
trailingNode: false,
|
|
875
|
+
bold: singleLine ? false : {},
|
|
876
|
+
italic: singleLine ? false : {},
|
|
877
|
+
underline: singleLine ? false : {},
|
|
878
|
+
link: singleLine ? false : {
|
|
879
|
+
openOnClick: false,
|
|
880
|
+
autolink: false,
|
|
881
|
+
linkOnPaste: false,
|
|
882
|
+
isAllowedUri: (url) => Schema7.is(RichTextLink)(url),
|
|
883
|
+
HTMLAttributes: { class: "underline" }
|
|
884
|
+
},
|
|
885
|
+
undoRedo: { depth: 100 }
|
|
886
|
+
}),
|
|
887
|
+
Node.create({
|
|
888
|
+
name: "paragraph",
|
|
889
|
+
group: "block",
|
|
890
|
+
content: "inline*",
|
|
891
|
+
marks: singleLine ? "" : "_",
|
|
892
|
+
addAttributes: () => ({ kind: { default: "paragraph" } }),
|
|
893
|
+
parseHTML: () => [{ tag: "p" }],
|
|
894
|
+
renderHTML: ({ node }) => {
|
|
895
|
+
const kind = Schema7.decodeUnknownSync(RichTextBlockKind)(node.attrs.kind);
|
|
896
|
+
if (kind === "heading")
|
|
897
|
+
return ["h2", { class: "text-xl font-semibold" }, 0];
|
|
898
|
+
return [
|
|
899
|
+
"div",
|
|
900
|
+
{
|
|
901
|
+
"data-rich-kind": kind,
|
|
902
|
+
style: kind === "bullet" || kind === "numbered" ? `display:list-item;margin-left:1.5em;list-style-type:${kind === "bullet" ? "disc" : "decimal"}` : null
|
|
903
|
+
},
|
|
904
|
+
0
|
|
905
|
+
];
|
|
906
|
+
},
|
|
907
|
+
addKeyboardShortcuts() {
|
|
908
|
+
return {
|
|
909
|
+
Enter: () => {
|
|
910
|
+
if (singleLine)
|
|
911
|
+
return true;
|
|
912
|
+
const { $from } = this.editor.state.selection;
|
|
913
|
+
if (!$from.parent.content.size && $from.parent.attrs.kind !== "paragraph")
|
|
914
|
+
return this.editor.commands.updateAttributes("paragraph", {
|
|
915
|
+
kind: "paragraph"
|
|
916
|
+
});
|
|
917
|
+
return this.editor.commands.splitBlock();
|
|
918
|
+
},
|
|
919
|
+
"Shift-Enter": () => singleLine || this.editor.commands.splitBlock()
|
|
920
|
+
};
|
|
921
|
+
}
|
|
922
|
+
}),
|
|
923
|
+
Node.create({
|
|
924
|
+
name: "variable",
|
|
925
|
+
group: "inline",
|
|
926
|
+
inline: true,
|
|
927
|
+
atom: true,
|
|
928
|
+
selectable: true,
|
|
929
|
+
addAttributes: () => ({ key: { default: null } }),
|
|
930
|
+
renderText: ({ node }) => `{{${node.attrs.key}}}`,
|
|
931
|
+
renderHTML: ({ node }) => {
|
|
932
|
+
const key = Schema7.decodeUnknownSync(Schema7.String)(node.attrs.key);
|
|
933
|
+
return [
|
|
934
|
+
"span",
|
|
935
|
+
{
|
|
936
|
+
"data-rich-variable": key,
|
|
937
|
+
contenteditable: "false",
|
|
938
|
+
class: "inline-block rounded bg-indigo-50 px-1.5 font-mono text-[0.85em] text-indigo-800 select-all"
|
|
939
|
+
},
|
|
940
|
+
`{{${variables().find((variable) => variable.key === key)?.label ?? key}}}`
|
|
941
|
+
];
|
|
942
|
+
}
|
|
943
|
+
}),
|
|
944
|
+
Extension.create({
|
|
945
|
+
name: "richTextValidation",
|
|
946
|
+
addProseMirrorPlugins: () => [
|
|
947
|
+
new Plugin({
|
|
948
|
+
filterTransaction: (transaction) => {
|
|
949
|
+
if (!transaction.docChanged)
|
|
950
|
+
return true;
|
|
951
|
+
const decoded = fromTiptapDocument(transaction.doc);
|
|
952
|
+
const limit = maxLength();
|
|
953
|
+
const valid = Option.isSome(decoded) && (!singleLine || Schema7.is(SingleLineDocument)(decoded.value)) && (limit === undefined || richTextPlainText(decoded.value).length <= limit);
|
|
954
|
+
onInvalid?.(!valid);
|
|
955
|
+
return valid;
|
|
956
|
+
}
|
|
957
|
+
})
|
|
958
|
+
]
|
|
959
|
+
})
|
|
960
|
+
];
|
|
961
|
+
|
|
962
|
+
// ../../src/components/rich-text-editor/index.ts
|
|
963
|
+
import { Schema as Schema10 } from "effect";
|
|
964
|
+
import { Component as Component2, UiSchema as UiSchema2, View } from "effect/ui";
|
|
965
|
+
|
|
966
|
+
// ../../src/lib/rich-text/schema.ts
|
|
967
|
+
import { Schema as Schema8 } from "effect";
|
|
968
|
+
var RichTextLink2 = Schema8.String.check(Schema8.isMaxLength(2000), Schema8.makeFilter((value) => {
|
|
969
|
+
if (/[\s\p{Cc}\\{}]/u.test(value))
|
|
970
|
+
return false;
|
|
971
|
+
const url = URL.parse(value);
|
|
972
|
+
return url !== null && ["https:", "mailto:"].includes(url.protocol) && !url.username && !url.password;
|
|
973
|
+
})).annotate({ identifier: "RichTextLink" });
|
|
974
|
+
var attributes = Schema8.Record(Schema8.String, Schema8.Json);
|
|
975
|
+
var variableKey = Schema8.String.check(Schema8.isPattern(/^[a-zA-Z][a-zA-Z0-9_.]{0,79}$/));
|
|
976
|
+
var mark = Schema8.Struct({
|
|
977
|
+
type: Schema8.String,
|
|
978
|
+
attrs: Schema8.optional(attributes)
|
|
979
|
+
}).check(Schema8.makeFilter((value) => value.type !== "link" || Schema8.is(RichTextLink2)(value.attrs?.href)));
|
|
980
|
+
var TiptapNode = Schema8.Struct({
|
|
981
|
+
type: Schema8.String,
|
|
982
|
+
attrs: Schema8.optional(attributes),
|
|
983
|
+
content: Schema8.optional(Schema8.mutable(Schema8.Array(Schema8.suspend(() => TiptapNode)))),
|
|
984
|
+
marks: Schema8.optional(Schema8.mutable(Schema8.Array(mark))),
|
|
985
|
+
text: Schema8.optional(Schema8.String)
|
|
986
|
+
}).check(Schema8.makeFilter((node) => node.type !== "mention" || Schema8.is(variableKey)(node.attrs?.id))).annotate({ identifier: "TiptapNode" });
|
|
987
|
+
var RichTextDocument3 = TiptapNode.check(Schema8.makeFilter((node) => node.type === "doc")).annotate({ identifier: "TiptapDocument" });
|
|
988
|
+
var RichTextVariable2 = Schema8.Struct({
|
|
989
|
+
key: variableKey,
|
|
990
|
+
label: Schema8.String,
|
|
991
|
+
type: Schema8.Literals(["text", "url"]),
|
|
992
|
+
sample: Schema8.String
|
|
993
|
+
}).annotate({ identifier: "RichTextVariable" });
|
|
994
|
+
|
|
995
|
+
// ../../src/components/rich-text-editor/schema.ts
|
|
996
|
+
import { Schema as Schema9, Struct as Struct2 } from "effect";
|
|
997
|
+
|
|
998
|
+
// ../../src/components/rich-text-editor/classes.ts
|
|
999
|
+
var richTextEditorClasses = {
|
|
1000
|
+
toolbar: "bg-muted/30 flex flex-wrap items-center gap-1 border-b p-2",
|
|
1001
|
+
linkForm: "flex flex-wrap items-end gap-2 border-b p-3",
|
|
1002
|
+
linkField: "grid min-w-0 flex-1 gap-1 text-xs",
|
|
1003
|
+
linkError: "text-destructive w-full text-xs",
|
|
1004
|
+
editorError: "text-destructive px-4 pb-3 text-xs"
|
|
1005
|
+
};
|
|
1006
|
+
|
|
1007
|
+
// ../../src/components/rich-text-editor/schema.ts
|
|
1008
|
+
var RichTextEditorMessageFields = {
|
|
1009
|
+
bold: Schema9.String,
|
|
1010
|
+
italic: Schema9.String,
|
|
1011
|
+
underline: Schema9.String,
|
|
1012
|
+
undo: Schema9.String,
|
|
1013
|
+
redo: Schema9.String,
|
|
1014
|
+
link: Schema9.String,
|
|
1015
|
+
unlink: Schema9.String,
|
|
1016
|
+
linkUrl: Schema9.String,
|
|
1017
|
+
apply: Schema9.String,
|
|
1018
|
+
cancel: Schema9.String,
|
|
1019
|
+
variable: Schema9.String,
|
|
1020
|
+
paragraph: Schema9.String,
|
|
1021
|
+
heading: Schema9.String,
|
|
1022
|
+
bullet: Schema9.String,
|
|
1023
|
+
numbered: Schema9.String,
|
|
1024
|
+
toolbar: Schema9.String,
|
|
1025
|
+
invalid: Schema9.String,
|
|
1026
|
+
invalidLink: Schema9.String
|
|
1027
|
+
};
|
|
1028
|
+
var RichTextEditorCopy = Schema9.Struct(RichTextEditorMessageFields);
|
|
1029
|
+
var RichTextEditorClassesOverridesSchema = Schema9.Record(Schema9.Literals(Struct2.keys(richTextEditorClasses)), Schema9.optionalKey(Schema9.String)).annotate({ identifier: "RichTextEditorClassesOverrides" });
|
|
1030
|
+
var RichTextEditorFields = {
|
|
1031
|
+
classes: Schema9.optional(RichTextEditorClassesOverridesSchema),
|
|
1032
|
+
value: RichTextDocument3,
|
|
1033
|
+
label: Schema9.String,
|
|
1034
|
+
variables: Schema9.optional(Schema9.Array(RichTextVariable2)),
|
|
1035
|
+
disabled: Schema9.optional(Schema9.Boolean),
|
|
1036
|
+
locale: Schema9.optional(Schema9.String),
|
|
1037
|
+
messages: Schema9.optional(Schema9.Record(Schema9.String, Schema9.UndefinedOr(Schema9.Struct(Struct2.map(RichTextEditorMessageFields, Schema9.optional))))),
|
|
1038
|
+
className: Schema9.optional(Schema9.String),
|
|
1039
|
+
maxLength: Schema9.optional(Schema9.Number)
|
|
1040
|
+
};
|
|
1041
|
+
var RichTextEditorPropsSchema = Schema9.Struct(RichTextEditorFields).annotate({ identifier: "RichTextEditorProps" });
|
|
1042
|
+
|
|
1043
|
+
// ../../src/components/rich-text-editor/labels.ts
|
|
1044
|
+
var defaultMessages2 = {
|
|
1045
|
+
en: {
|
|
1046
|
+
bold: "Bold",
|
|
1047
|
+
italic: "Italic",
|
|
1048
|
+
underline: "Underline",
|
|
1049
|
+
undo: "Undo",
|
|
1050
|
+
redo: "Redo",
|
|
1051
|
+
link: "Link",
|
|
1052
|
+
unlink: "Remove link",
|
|
1053
|
+
linkUrl: "Link URL",
|
|
1054
|
+
apply: "Apply link",
|
|
1055
|
+
cancel: "Cancel",
|
|
1056
|
+
variable: "Insert variable",
|
|
1057
|
+
paragraph: "Paragraph",
|
|
1058
|
+
heading: "Heading",
|
|
1059
|
+
bullet: "Bulleted list",
|
|
1060
|
+
numbered: "Numbered list",
|
|
1061
|
+
toolbar: "Text formatting",
|
|
1062
|
+
invalid: "The content is too long or contains an unsupported value.",
|
|
1063
|
+
invalidLink: "Enter an HTTPS or mailto link."
|
|
1064
|
+
},
|
|
1065
|
+
fr: {
|
|
1066
|
+
bold: "Gras",
|
|
1067
|
+
italic: "Italique",
|
|
1068
|
+
underline: "Souligné",
|
|
1069
|
+
undo: "Annuler",
|
|
1070
|
+
redo: "Rétablir",
|
|
1071
|
+
link: "Lien",
|
|
1072
|
+
unlink: "Retirer le lien",
|
|
1073
|
+
linkUrl: "URL du lien",
|
|
1074
|
+
apply: "Appliquer le lien",
|
|
1075
|
+
cancel: "Annuler",
|
|
1076
|
+
variable: "Insérer une variable",
|
|
1077
|
+
paragraph: "Paragraphe",
|
|
1078
|
+
heading: "Titre",
|
|
1079
|
+
bullet: "Liste à puces",
|
|
1080
|
+
numbered: "Liste numérotée",
|
|
1081
|
+
toolbar: "Mise en forme",
|
|
1082
|
+
invalid: "Le contenu est trop long ou contient une valeur non prise en charge.",
|
|
1083
|
+
invalidLink: "Saisissez un lien HTTPS ou mailto."
|
|
1084
|
+
}
|
|
1085
|
+
};
|
|
1086
|
+
|
|
1087
|
+
// ../../src/components/rich-text-editor/index.ts
|
|
1088
|
+
var richTextEditorMessages = (locale, messages) => ({
|
|
1089
|
+
...locale.startsWith("fr") ? defaultMessages2.fr : defaultMessages2.en,
|
|
1090
|
+
...messages?.[locale.split("-")[0] ?? locale],
|
|
1091
|
+
...messages?.[locale]
|
|
1092
|
+
});
|
|
1093
|
+
var EditorAction = UiSchema2.TaggedEnum({
|
|
1094
|
+
Format: {
|
|
1095
|
+
kind: Schema10.Literals([
|
|
1096
|
+
"bold",
|
|
1097
|
+
"italic",
|
|
1098
|
+
"underline",
|
|
1099
|
+
"paragraph",
|
|
1100
|
+
"heading",
|
|
1101
|
+
"bullet",
|
|
1102
|
+
"numbered",
|
|
1103
|
+
"undo",
|
|
1104
|
+
"redo",
|
|
1105
|
+
"unlink"
|
|
1106
|
+
])
|
|
1107
|
+
},
|
|
1108
|
+
Insert: { key: Schema10.String },
|
|
1109
|
+
Link: { href: RichTextLink2 }
|
|
1110
|
+
}).annotate({ identifier: "RichTextEditorAction" });
|
|
1111
|
+
var EditorStatus = Schema10.Struct({
|
|
1112
|
+
ready: Schema10.Boolean,
|
|
1113
|
+
undo: Schema10.Boolean,
|
|
1114
|
+
redo: Schema10.Boolean,
|
|
1115
|
+
bold: Schema10.Boolean,
|
|
1116
|
+
italic: Schema10.Boolean,
|
|
1117
|
+
underline: Schema10.Boolean,
|
|
1118
|
+
block: Schema10.Literals(["paragraph", "heading", "bullet", "numbered"]),
|
|
1119
|
+
href: Schema10.NullOr(Schema10.String)
|
|
1120
|
+
});
|
|
1121
|
+
var RichTextEditorEvents = UiSchema2.TaggedEnum({
|
|
1122
|
+
Changed: { value: RichTextDocument3 }
|
|
1123
|
+
}).annotate({ identifier: "RichTextEditorEvents" });
|
|
1124
|
+
var RichTextEditorMessage = UiSchema2.TaggedEnum({
|
|
1125
|
+
Changed: { value: RichTextDocument3 },
|
|
1126
|
+
Status: { status: EditorStatus },
|
|
1127
|
+
Invalid: { invalid: Schema10.Boolean },
|
|
1128
|
+
Replaced: {},
|
|
1129
|
+
SetToolbarPopup: {
|
|
1130
|
+
popup: Schema10.Literals(["block", "variable"]),
|
|
1131
|
+
open: Schema10.Boolean
|
|
1132
|
+
},
|
|
1133
|
+
ToggleLink: {},
|
|
1134
|
+
EditLink: { link: Schema10.String },
|
|
1135
|
+
ApplyLink: {},
|
|
1136
|
+
CloseLink: {},
|
|
1137
|
+
Action: { action: EditorAction }
|
|
1138
|
+
}).annotate({ identifier: "RichTextEditorMessage" });
|
|
1139
|
+
var modelOptions = {
|
|
1140
|
+
name: "RichTextEditor",
|
|
1141
|
+
props: RichTextEditorPropsSchema,
|
|
1142
|
+
model: Schema10.Struct({
|
|
1143
|
+
status: EditorStatus,
|
|
1144
|
+
invalid: Schema10.Boolean,
|
|
1145
|
+
toolbarPopup: Schema10.NullOr(Schema10.Literals(["block", "variable"])),
|
|
1146
|
+
linkOpen: Schema10.Boolean,
|
|
1147
|
+
link: Schema10.String,
|
|
1148
|
+
linkError: Schema10.Boolean,
|
|
1149
|
+
request: Schema10.NullOr(Schema10.Struct({ serial: Schema10.Int, action: EditorAction }))
|
|
1150
|
+
}).annotate({ identifier: "RichTextEditorModel" }),
|
|
1151
|
+
message: RichTextEditorMessage,
|
|
1152
|
+
restore: false
|
|
1153
|
+
};
|
|
1154
|
+
var richTextEditorOptions = {
|
|
1155
|
+
...modelOptions,
|
|
1156
|
+
events: RichTextEditorEvents
|
|
1157
|
+
};
|
|
1158
|
+
var transition = (model, message, disabled) => {
|
|
1159
|
+
switch (message._tag) {
|
|
1160
|
+
case "Changed":
|
|
1161
|
+
return model;
|
|
1162
|
+
case "Status":
|
|
1163
|
+
return { ...model, status: message.status };
|
|
1164
|
+
case "Invalid":
|
|
1165
|
+
return { ...model, invalid: message.invalid };
|
|
1166
|
+
case "Replaced":
|
|
1167
|
+
return { ...model, invalid: false, toolbarPopup: null, linkOpen: false };
|
|
1168
|
+
case "SetToolbarPopup":
|
|
1169
|
+
return {
|
|
1170
|
+
...model,
|
|
1171
|
+
toolbarPopup: disabled ? null : message.open ? message.popup : model.toolbarPopup === message.popup ? null : model.toolbarPopup
|
|
1172
|
+
};
|
|
1173
|
+
case "ToggleLink":
|
|
1174
|
+
return {
|
|
1175
|
+
...model,
|
|
1176
|
+
linkOpen: !model.linkOpen,
|
|
1177
|
+
link: model.status.href ?? "",
|
|
1178
|
+
linkError: false
|
|
1179
|
+
};
|
|
1180
|
+
case "EditLink":
|
|
1181
|
+
return { ...model, link: message.link };
|
|
1182
|
+
case "ApplyLink":
|
|
1183
|
+
if (disabled)
|
|
1184
|
+
return model;
|
|
1185
|
+
if (!Schema10.is(RichTextLink2)(model.link))
|
|
1186
|
+
return { ...model, linkError: true };
|
|
1187
|
+
return {
|
|
1188
|
+
...model,
|
|
1189
|
+
linkOpen: false,
|
|
1190
|
+
request: {
|
|
1191
|
+
serial: (model.request?.serial ?? 0) + 1,
|
|
1192
|
+
action: EditorAction.Link({ href: model.link })
|
|
1193
|
+
}
|
|
1194
|
+
};
|
|
1195
|
+
case "CloseLink":
|
|
1196
|
+
return { ...model, linkOpen: false };
|
|
1197
|
+
case "Action":
|
|
1198
|
+
if (disabled)
|
|
1199
|
+
return model;
|
|
1200
|
+
return {
|
|
1201
|
+
...model,
|
|
1202
|
+
linkOpen: message.action._tag === "Format" && message.action.kind === "unlink" ? false : model.linkOpen,
|
|
1203
|
+
request: {
|
|
1204
|
+
serial: (model.request?.serial ?? 0) + 1,
|
|
1205
|
+
action: message.action
|
|
1206
|
+
}
|
|
1207
|
+
};
|
|
1208
|
+
}
|
|
1209
|
+
};
|
|
1210
|
+
var update2 = ($, message) => transition($.model, message, $.props.disabled);
|
|
1211
|
+
var richTextEditorBehaviours = {
|
|
1212
|
+
init: () => ({
|
|
1213
|
+
status: {
|
|
1214
|
+
ready: false,
|
|
1215
|
+
undo: false,
|
|
1216
|
+
redo: false,
|
|
1217
|
+
bold: false,
|
|
1218
|
+
italic: false,
|
|
1219
|
+
underline: false,
|
|
1220
|
+
block: "paragraph",
|
|
1221
|
+
href: null
|
|
1222
|
+
},
|
|
1223
|
+
invalid: false,
|
|
1224
|
+
toolbarPopup: null,
|
|
1225
|
+
linkOpen: false,
|
|
1226
|
+
link: "",
|
|
1227
|
+
linkError: false,
|
|
1228
|
+
request: null
|
|
1229
|
+
}),
|
|
1230
|
+
update: update2
|
|
1231
|
+
};
|
|
1232
|
+
var RichTextEditorModel = Component2.define(modelOptions).make({
|
|
1233
|
+
...richTextEditorBehaviours,
|
|
1234
|
+
view: () => View.text("")
|
|
1235
|
+
});
|
|
1236
|
+
|
|
1237
|
+
// ../../src/components/email-editor/legacy-editor.html.ts
|
|
1238
|
+
var Props = Schema11.Struct({
|
|
1239
|
+
value: RichTextDocument,
|
|
1240
|
+
label: Schema11.String,
|
|
1241
|
+
locale: Schema11.String,
|
|
1242
|
+
variables: Schema11.Array(RichTextVariable),
|
|
1243
|
+
disabled: Schema11.Boolean,
|
|
1244
|
+
singleLine: Schema11.Boolean
|
|
1245
|
+
}).annotate({ identifier: "EmailEditorLegacyTextProps" });
|
|
1246
|
+
var Action = UiSchema3.TaggedEnum({
|
|
1247
|
+
Insert: { key: Schema11.String },
|
|
1248
|
+
Format: {
|
|
1249
|
+
kind: Schema11.Literals([
|
|
1250
|
+
"bold",
|
|
1251
|
+
"italic",
|
|
1252
|
+
"underline",
|
|
1253
|
+
"undo",
|
|
1254
|
+
"redo",
|
|
1255
|
+
"unlink"
|
|
1256
|
+
])
|
|
1257
|
+
},
|
|
1258
|
+
Block: { kind: RichTextBlockKind },
|
|
1259
|
+
Link: { href: RichTextLink }
|
|
1260
|
+
}).annotate({ identifier: "EmailEditorLegacyTextAction" });
|
|
1261
|
+
var Events = UiSchema3.TaggedEnum({
|
|
1262
|
+
Changed: { value: RichTextDocument }
|
|
1263
|
+
}).annotate({ identifier: "EmailEditorLegacyTextEvents" });
|
|
1264
|
+
var Status = Schema11.Struct({
|
|
1265
|
+
undo: Schema11.Boolean,
|
|
1266
|
+
redo: Schema11.Boolean,
|
|
1267
|
+
bold: Schema11.Boolean,
|
|
1268
|
+
italic: Schema11.Boolean,
|
|
1269
|
+
underline: Schema11.Boolean,
|
|
1270
|
+
link: Schema11.String,
|
|
1271
|
+
block: RichTextBlockKind
|
|
1272
|
+
});
|
|
1273
|
+
var Message = UiSchema3.TaggedEnum({
|
|
1274
|
+
Changed: { value: RichTextDocument },
|
|
1275
|
+
Status: { status: Status },
|
|
1276
|
+
Invalid: { invalid: Schema11.Boolean },
|
|
1277
|
+
Action: { action: Action },
|
|
1278
|
+
ToggleLink: {},
|
|
1279
|
+
EditLink: { value: Schema11.String },
|
|
1280
|
+
ApplyLink: {},
|
|
1281
|
+
CloseLink: {}
|
|
1282
|
+
}).annotate({ identifier: "EmailEditorLegacyTextMessage" });
|
|
1283
|
+
var Request = Schema11.NullOr(Schema11.Struct({ serial: Schema11.Int, action: Action }));
|
|
1284
|
+
var Attach = Mount.makeStream("EmailEditor.legacyEditor", {
|
|
1285
|
+
args: {
|
|
1286
|
+
props: Props,
|
|
1287
|
+
request: Request,
|
|
1288
|
+
errorId: Schema11.String,
|
|
1289
|
+
invalid: Schema11.Boolean
|
|
1290
|
+
}
|
|
1291
|
+
}, (node, initial, changes) => Stream.callback((queue) => Effect.gen(function* () {
|
|
1292
|
+
let current = initial;
|
|
1293
|
+
let lastStatus = "";
|
|
1294
|
+
const send = (message) => Queue.offerUnsafe(queue, message);
|
|
1295
|
+
const getStatus = (editor) => {
|
|
1296
|
+
const status = {
|
|
1297
|
+
undo: editor.can().undo(),
|
|
1298
|
+
redo: editor.can().redo(),
|
|
1299
|
+
bold: editor.isActive("bold"),
|
|
1300
|
+
italic: editor.isActive("italic"),
|
|
1301
|
+
underline: editor.isActive("underline"),
|
|
1302
|
+
link: editor.getAttributes("link").href ?? "",
|
|
1303
|
+
block: Schema11.decodeUnknownSync(RichTextBlockKind)(editor.getAttributes("paragraph").kind ?? "paragraph")
|
|
1304
|
+
};
|
|
1305
|
+
const key = JSON.stringify(status);
|
|
1306
|
+
if (key !== lastStatus) {
|
|
1307
|
+
lastStatus = key;
|
|
1308
|
+
send(Message.Status({ status }));
|
|
1309
|
+
}
|
|
1310
|
+
};
|
|
1311
|
+
const attrs = () => ({
|
|
1312
|
+
role: "textbox",
|
|
1313
|
+
"aria-label": current.props.label,
|
|
1314
|
+
"aria-multiline": String(!current.props.singleLine),
|
|
1315
|
+
"aria-describedby": current.invalid ? current.errorId : "",
|
|
1316
|
+
class: `${current.props.singleLine ? "min-h-8" : "min-h-24"} px-3 py-2 text-sm outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`
|
|
1317
|
+
});
|
|
1318
|
+
const editor = yield* Effect.acquireRelease(Effect.sync(() => new Editor({
|
|
1319
|
+
element: node,
|
|
1320
|
+
editable: !current.props.disabled,
|
|
1321
|
+
content: toTiptapDocument(current.props.value, current.props.singleLine),
|
|
1322
|
+
extensions: richTextExtensions({
|
|
1323
|
+
singleLine: initial.props.singleLine,
|
|
1324
|
+
maxLength: () => initial.props.singleLine ? 200 : undefined,
|
|
1325
|
+
variables: () => current.props.variables,
|
|
1326
|
+
onInvalid: (invalid) => send(Message.Invalid({ invalid }))
|
|
1327
|
+
}),
|
|
1328
|
+
editorProps: {
|
|
1329
|
+
attributes: attrs(),
|
|
1330
|
+
...initial.props.singleLine ? {
|
|
1331
|
+
handlePaste: (_view, event) => {
|
|
1332
|
+
const text = event.clipboardData?.getData("text/plain").replace(/[\r\n]+/g, " ") ?? "";
|
|
1333
|
+
if (text)
|
|
1334
|
+
editor.commands.insertContent(text.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">"));
|
|
1335
|
+
return true;
|
|
1336
|
+
}
|
|
1337
|
+
} : {}
|
|
1338
|
+
},
|
|
1339
|
+
onUpdate: ({ editor }) => {
|
|
1340
|
+
const value = fromTiptapDocument(editor.state.doc);
|
|
1341
|
+
if (Option2.isSome(value))
|
|
1342
|
+
send(Message.Changed({ value: value.value }));
|
|
1343
|
+
},
|
|
1344
|
+
onTransaction: ({ editor }) => getStatus(editor)
|
|
1345
|
+
})), (editor) => Effect.sync(() => editor.destroy()));
|
|
1346
|
+
getStatus(editor);
|
|
1347
|
+
yield* Stream.runForEach(changes, (next) => Effect.sync(() => {
|
|
1348
|
+
const previous = current;
|
|
1349
|
+
current = next;
|
|
1350
|
+
const incoming = editor.schema.nodeFromJSON(toTiptapDocument(current.props.value, current.props.singleLine));
|
|
1351
|
+
if (!editor.state.doc.eq(incoming) && previous.props.value !== next.props.value) {
|
|
1352
|
+
editor.view.updateState(EditorState.create({
|
|
1353
|
+
schema: editor.schema,
|
|
1354
|
+
doc: incoming,
|
|
1355
|
+
plugins: editor.state.plugins
|
|
1356
|
+
}));
|
|
1357
|
+
getStatus(editor);
|
|
1358
|
+
send(Message.Invalid({ invalid: false }));
|
|
1359
|
+
}
|
|
1360
|
+
if (previous.props.disabled !== next.props.disabled)
|
|
1361
|
+
editor.setEditable(!next.props.disabled, false);
|
|
1362
|
+
editor.setOptions({
|
|
1363
|
+
editorProps: {
|
|
1364
|
+
...editor.options.editorProps,
|
|
1365
|
+
attributes: attrs()
|
|
1366
|
+
}
|
|
1367
|
+
});
|
|
1368
|
+
if (previous.props.variables !== next.props.variables) {
|
|
1369
|
+
for (const chip of editor.view.dom.querySelectorAll("[data-rich-variable]")) {
|
|
1370
|
+
const key = chip.getAttribute("data-rich-variable");
|
|
1371
|
+
const text = `{{${current.props.variables.find((variable) => variable.key === key)?.label ?? key}}}`;
|
|
1372
|
+
if (text !== chip.textContent)
|
|
1373
|
+
chip.textContent = text;
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
if (!next.request || next.request.serial === previous.request?.serial || !editor.isEditable)
|
|
1377
|
+
return;
|
|
1378
|
+
const { action } = next.request;
|
|
1379
|
+
const chain = editor.chain().focus();
|
|
1380
|
+
switch (action._tag) {
|
|
1381
|
+
case "Insert":
|
|
1382
|
+
editor.view.dispatch(closeHistory(editor.state.tr));
|
|
1383
|
+
editor.chain().focus().insertContent({
|
|
1384
|
+
type: "variable",
|
|
1385
|
+
attrs: { key: action.key }
|
|
1386
|
+
}).run();
|
|
1387
|
+
editor.view.dispatch(closeHistory(editor.state.tr));
|
|
1388
|
+
break;
|
|
1389
|
+
case "Link":
|
|
1390
|
+
chain.extendMarkRange("link").setLink({ href: action.href }).run();
|
|
1391
|
+
break;
|
|
1392
|
+
case "Block":
|
|
1393
|
+
chain.updateAttributes("paragraph", { kind: action.kind }).run();
|
|
1394
|
+
break;
|
|
1395
|
+
case "Format":
|
|
1396
|
+
switch (action.kind) {
|
|
1397
|
+
case "undo":
|
|
1398
|
+
chain.undo().run();
|
|
1399
|
+
break;
|
|
1400
|
+
case "redo":
|
|
1401
|
+
chain.redo().run();
|
|
1402
|
+
break;
|
|
1403
|
+
case "bold":
|
|
1404
|
+
chain.toggleBold().run();
|
|
1405
|
+
break;
|
|
1406
|
+
case "italic":
|
|
1407
|
+
chain.toggleItalic().run();
|
|
1408
|
+
break;
|
|
1409
|
+
case "underline":
|
|
1410
|
+
chain.toggleUnderline().run();
|
|
1411
|
+
break;
|
|
1412
|
+
case "unlink":
|
|
1413
|
+
chain.extendMarkRange("link").unsetLink().run();
|
|
1414
|
+
break;
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
}));
|
|
1418
|
+
})));
|
|
1419
|
+
var LegacyEditor = Html.component({
|
|
1420
|
+
name: "EmailEditorLegacyText",
|
|
1421
|
+
props: Props,
|
|
1422
|
+
message: Message,
|
|
1423
|
+
events: Events,
|
|
1424
|
+
restore: false,
|
|
1425
|
+
model: Schema11.Struct({
|
|
1426
|
+
status: Status,
|
|
1427
|
+
request: Request,
|
|
1428
|
+
invalid: Schema11.Boolean,
|
|
1429
|
+
linkOpen: Schema11.Boolean,
|
|
1430
|
+
link: Schema11.String,
|
|
1431
|
+
linkError: Schema11.Boolean
|
|
1432
|
+
}).annotate({ identifier: "EmailEditorLegacyTextModel" })
|
|
1433
|
+
}).make({
|
|
1434
|
+
init: () => ({
|
|
1435
|
+
status: {
|
|
1436
|
+
undo: false,
|
|
1437
|
+
redo: false,
|
|
1438
|
+
bold: false,
|
|
1439
|
+
italic: false,
|
|
1440
|
+
underline: false,
|
|
1441
|
+
link: "",
|
|
1442
|
+
block: "paragraph"
|
|
1443
|
+
},
|
|
1444
|
+
request: null,
|
|
1445
|
+
invalid: false,
|
|
1446
|
+
linkOpen: false,
|
|
1447
|
+
link: "",
|
|
1448
|
+
linkError: false
|
|
1449
|
+
}),
|
|
1450
|
+
update: {
|
|
1451
|
+
Changed: ($, { value }) => $.set($.model).emit(Events.Changed({ value })),
|
|
1452
|
+
Status: ($, { status }) => $.evolve({ status }),
|
|
1453
|
+
Invalid: ($, { invalid }) => $.evolve({ invalid }),
|
|
1454
|
+
Action: ($, { action }) => $.props.disabled ? $.model : $.evolve({
|
|
1455
|
+
request: { serial: ($.model.request?.serial ?? 0) + 1, action },
|
|
1456
|
+
linkOpen: action._tag === "Format" && action.kind === "unlink" ? false : $.model.linkOpen
|
|
1457
|
+
}),
|
|
1458
|
+
ToggleLink: ($) => $.evolve({
|
|
1459
|
+
linkOpen: !$.model.linkOpen,
|
|
1460
|
+
linkError: false,
|
|
1461
|
+
link: $.model.status.link
|
|
1462
|
+
}),
|
|
1463
|
+
EditLink: ($, { value }) => $.evolve({ link: value }),
|
|
1464
|
+
ApplyLink: ($) => Schema11.is(RichTextLink)($.model.link) ? $.evolve({
|
|
1465
|
+
linkOpen: false,
|
|
1466
|
+
request: {
|
|
1467
|
+
serial: ($.model.request?.serial ?? 0) + 1,
|
|
1468
|
+
action: Action.Link({ href: $.model.link })
|
|
1469
|
+
}
|
|
1470
|
+
}) : $.evolve({ linkError: true }),
|
|
1471
|
+
CloseLink: ($) => $.evolve({ linkOpen: false })
|
|
1472
|
+
},
|
|
1473
|
+
view: (h, model) => {
|
|
1474
|
+
const props = h.props;
|
|
1475
|
+
const copy = richTextEditorMessages(props.locale);
|
|
1476
|
+
const errorId = h.id("error");
|
|
1477
|
+
const action = (action) => Message.Action({ action });
|
|
1478
|
+
const format = (kind) => action(Action.Format({ kind }));
|
|
1479
|
+
const button = (label, onPress, disabled = props.disabled, pressed) => Button(h, {
|
|
1480
|
+
element: h.button.on("mousedown", () => {
|
|
1481
|
+
return;
|
|
1482
|
+
}, {
|
|
1483
|
+
preventDefault: "always"
|
|
1484
|
+
}),
|
|
1485
|
+
size: "sm",
|
|
1486
|
+
variant: pressed ? "secondary" : "ghost",
|
|
1487
|
+
props: { type: "button", disabled },
|
|
1488
|
+
onPress
|
|
1489
|
+
}).attr("aria-pressed", pressed === undefined ? undefined : pressed ? "true" : "false").children(label);
|
|
1490
|
+
return h.div.class("overflow-hidden rounded-lg border").children(h.div.attrs({ role: "group", "aria-label": copy.toolbar }).class("flex flex-wrap items-center gap-1 border-b bg-muted/30 p-1").children(button(copy.undo, format("undo"), !model.status.undo || props.disabled), button(copy.redo, format("redo"), !model.status.redo || props.disabled), !props.singleLine && h.select.class("rounded border bg-background px-1 text-xs").attr("aria-label", copy.paragraph).disabled(props.disabled).on("change", ({ value }) => Schema11.is(RichTextBlockKind)(value) ? action(Action.Block({ kind: value })) : undefined).children(...["paragraph", "heading", "bullet", "numbered"].map((kind) => h.option.attrs({
|
|
1491
|
+
value: kind,
|
|
1492
|
+
selected: kind === model.status.block ? "" : undefined
|
|
1493
|
+
}).children(copy[kind]))), ...!props.singleLine ? ["bold", "italic", "underline"].map((kind) => button(copy[kind], format(kind), props.disabled, model.status[kind])) : [], !props.singleLine && button(copy.link, Message.ToggleLink(), props.disabled, model.linkOpen || !!model.status.link), !!props.variables.length && h.select.key(`variable-${model.request?.serial ?? 0}`).class(inputVariants({ size: "sm", class: "ml-auto w-auto" })).attr("aria-label", copy.variable).disabled(props.disabled).on("change", ({ value }) => value ? action(Action.Insert({ key: value })) : undefined).children(h.option.attrs({ value: "", selected: "" }).children(copy.variable), ...props.variables.map(({ key, label }) => h.option.key(key).attr("value", key).children(label)))), model.linkOpen && h.div.class("flex flex-wrap items-end gap-1 border-b p-2").children(h.label.class("grid text-xs").children(copy.linkUrl, Input(h, {
|
|
1494
|
+
size: "sm",
|
|
1495
|
+
props: { value: model.link },
|
|
1496
|
+
onUpdate: ({ value }) => Message.EditLink({ value })
|
|
1497
|
+
})), button(copy.apply, Message.ApplyLink()), !!model.status.link && button(copy.unlink, format("unlink")), button(copy.cancel, Message.CloseLink(), false), model.linkError && h.p.attr("role", "alert").class("text-destructive text-xs").children(copy.invalidLink)), h.div.onMount(Attach({
|
|
1498
|
+
props,
|
|
1499
|
+
request: model.request,
|
|
1500
|
+
invalid: model.invalid,
|
|
1501
|
+
errorId
|
|
1502
|
+
}).pipe(Mount.map((message) => message))), model.invalid && h.p.attrs({ id: errorId, role: "alert" }).class("px-3 text-destructive text-xs").children(copy.invalid));
|
|
1503
|
+
}
|
|
1504
|
+
});
|
|
1505
|
+
|
|
1506
|
+
// ../../src/components/email-editor/html.ts
|
|
1507
|
+
var Grip = createLucideIcon(GripVertical2);
|
|
1508
|
+
var Edit = createLucideIcon(Pencil);
|
|
1509
|
+
var Add = createLucideIcon(Plus);
|
|
1510
|
+
var Remove = createLucideIcon(Trash2);
|
|
1511
|
+
var EmailEditor = Html2.component({
|
|
1512
|
+
...emailEditorOptions,
|
|
1513
|
+
reads: { localeConfig: krakstackLocaleRead },
|
|
1514
|
+
slots: ["preview"]
|
|
1515
|
+
}).make({
|
|
1516
|
+
...emailEditorBehaviours,
|
|
1517
|
+
view: (h, model) => {
|
|
1518
|
+
const emailEditorClasses = resolveEmailEditorClasses(h.props.classes);
|
|
1519
|
+
const {
|
|
1520
|
+
value,
|
|
1521
|
+
variables = [],
|
|
1522
|
+
requiredVariables,
|
|
1523
|
+
messages,
|
|
1524
|
+
disabled = false
|
|
1525
|
+
} = h.props;
|
|
1526
|
+
const locale = h.props.locale ?? h.reads.localeConfig?.locale ?? "en";
|
|
1527
|
+
const copy = emailEditorMessages(locale, messages);
|
|
1528
|
+
const selected = value.elements.find(({ id }) => id === model.active);
|
|
1529
|
+
const invalid = validateEmailDocument({ document: value, variables, requiredVariables }).length > 0;
|
|
1530
|
+
const field = (label, child) => h.label.class(emailEditorClasses.inspectorField).children(label, child);
|
|
1531
|
+
const input = (label, current, onInput, options = {}) => field(label, Input(h, {
|
|
1532
|
+
props: { value: String(current), disabled },
|
|
1533
|
+
onUpdate: ({ value }) => onInput(value)
|
|
1534
|
+
}).attrs({
|
|
1535
|
+
type: options.type ?? "text",
|
|
1536
|
+
min: options.min?.toString(),
|
|
1537
|
+
max: options.max?.toString()
|
|
1538
|
+
}));
|
|
1539
|
+
const select = (label, current, values, change) => field(label, h.select.class(inputVariants()).disabled(disabled).on("change", ({ value }) => change(value)).children(...values.map(({ value, label }) => h.option.key(value).attrs({ value, selected: value === current ? "" : undefined }).children(label))));
|
|
1540
|
+
const choices = (keys) => keys.map((value) => ({ value, label: copy[value] }));
|
|
1541
|
+
const button = (message, blocked = disabled, variant = "outline") => Button(h, {
|
|
1542
|
+
size: "sm",
|
|
1543
|
+
variant,
|
|
1544
|
+
props: { type: "button", disabled: blocked },
|
|
1545
|
+
onPress: message
|
|
1546
|
+
});
|
|
1547
|
+
const editText = (key, label, doc, onChange, singleLine = false) => LegacyEditor(h, {
|
|
1548
|
+
key,
|
|
1549
|
+
props: { value: doc, label, disabled, variables, singleLine, locale },
|
|
1550
|
+
onEmit: { Changed: ({ value }) => onChange(value) }
|
|
1551
|
+
});
|
|
1552
|
+
const setting = (key) => (value) => EmailEditorMessage.Setting({ id: selected.id, key, value });
|
|
1553
|
+
const color = (value, fallback) => Schema12.is(EmailColor)(value) ? value : fallback;
|
|
1554
|
+
const dragType = `application/x-krak-email-${h.id("canvas").replaceAll(/[^a-zA-Z0-9]/g, "").toLowerCase()}`;
|
|
1555
|
+
const max = value.elements.length >= 40;
|
|
1556
|
+
const designPopover = (popover, children) => Popover(h, {
|
|
1557
|
+
key: popover,
|
|
1558
|
+
props: {
|
|
1559
|
+
open: model.designPopover === popover,
|
|
1560
|
+
align: popover === "add" ? "start" : "end",
|
|
1561
|
+
sideOffset: 4
|
|
1562
|
+
},
|
|
1563
|
+
onEmit: {
|
|
1564
|
+
RequestedOpen: () => EmailEditorMessage.SetDesignPopover({ popover, open: true }),
|
|
1565
|
+
RequestedClose: () => EmailEditorMessage.SetDesignPopover({ popover, open: false }),
|
|
1566
|
+
Settled: () => {
|
|
1567
|
+
return;
|
|
1568
|
+
}
|
|
1569
|
+
},
|
|
1570
|
+
view: (parts) => h.div.children(parts.trigger({
|
|
1571
|
+
element: h.button.class(buttonVariants({ variant: "outline", size: "sm" }))
|
|
1572
|
+
}).children(popover === "add" && Add(h, { size: 16 }), copy[popover]), parts.portal(h.div)?.children(PopoverPositioner(h, parts).children(PopoverPopup(h, parts).children(PopoverTitle(h, parts).children(copy[popover]), children()))))
|
|
1573
|
+
});
|
|
1574
|
+
const design = () => h.div.class("space-y-4").children(...["subject", "preview"].map((key) => {
|
|
1575
|
+
const label = key === "subject" ? copy.subject : copy.preheader;
|
|
1576
|
+
return h.div.key(key).class("space-y-1.5").children(h.p.class(emailEditorClasses.sectionHeading).children(label), editText(`header-${key}`, label, richTextFromEmailText(value[key]), (content) => EmailEditorMessage.Header({ key, content }), true));
|
|
1577
|
+
}), h.div.class("flex flex-wrap items-start justify-between gap-2 rounded-xl border bg-muted/20 p-2").children(designPopover("add", () => h.div.class("grid gap-1").children(...emailElementTypes.map((kind) => Button(h, {
|
|
1578
|
+
element: h.button.on("click", () => EmailEditorMessage.Add({
|
|
1579
|
+
id: crypto.randomUUID(),
|
|
1580
|
+
kind,
|
|
1581
|
+
text: copy.newText,
|
|
1582
|
+
button: copy.newButton,
|
|
1583
|
+
image: copy.newImage
|
|
1584
|
+
})),
|
|
1585
|
+
props: { disabled: disabled || max, type: "button" },
|
|
1586
|
+
size: "sm",
|
|
1587
|
+
variant: "ghost"
|
|
1588
|
+
}).children(copy[kind])))), designPopover("branding", () => h.div.class(emailEditorClasses.actionGrid).children(...[
|
|
1589
|
+
"background",
|
|
1590
|
+
"surface",
|
|
1591
|
+
"primary",
|
|
1592
|
+
"primaryText",
|
|
1593
|
+
"text"
|
|
1594
|
+
].map((key) => input(key === "text" ? copy.foreground : copy[key], value.appearance[key], (value) => EmailEditorMessage.Appearance({ key, value }), { type: "color" })), select(copy.font, value.appearance.font, choices(["sans", "serif", "mono"]), (value) => EmailEditorMessage.Appearance({ key: "font", value }))))), h.div.class("min-w-0 rounded-xl border p-3").attr("data-slot", "email-editor-canvas").style({
|
|
1595
|
+
backgroundColor: color(value.appearance.background, "#f4f4f5")
|
|
1596
|
+
}).children(h.div.class("min-w-0 rounded-lg p-2 shadow-sm").style({
|
|
1597
|
+
backgroundColor: color(value.appearance.surface, "#ffffff"),
|
|
1598
|
+
color: color(value.appearance.text, "#18181b"),
|
|
1599
|
+
fontFamily: fonts[value.appearance.font]
|
|
1600
|
+
}).children(!value.elements.length && h.p.class(emailEditorClasses.previewPlaceholder).children(copy.empty), h.ol.class("grid gap-1").attr("aria-label", copy.content).children(...value.elements.map((element, index) => {
|
|
1601
|
+
let item = h.li.key(element.id).class("flex items-start gap-1 rounded-lg");
|
|
1602
|
+
let grip = h.button.attr("type", "button").attr("disabled", disabled ? "" : undefined).class("cursor-grab p-1").attr("aria-label", `${copy[element.type]}: ${copy.local}`);
|
|
1603
|
+
if (!disabled) {
|
|
1604
|
+
item = item.dropTarget({
|
|
1605
|
+
accepts: [dragType],
|
|
1606
|
+
dropEffect: "move"
|
|
1607
|
+
}).on("drop", ({ data }) => {
|
|
1608
|
+
const source = data[dragType];
|
|
1609
|
+
return source ? EmailEditorMessage.Move({
|
|
1610
|
+
source,
|
|
1611
|
+
target: element.id
|
|
1612
|
+
}) : undefined;
|
|
1613
|
+
});
|
|
1614
|
+
grip = grip.draggable({ [dragType]: element.id }, { effectAllowed: "move" }).on("dragstart", () => {
|
|
1615
|
+
return;
|
|
1616
|
+
}).on("keydown", ({ key }) => {
|
|
1617
|
+
const target = key === "Home" ? value.elements[0] : key === "End" ? value.elements.at(-1) : value.elements[index + (key === "ArrowUp" ? -1 : key === "ArrowDown" ? 1 : 0)];
|
|
1618
|
+
return target && target !== element ? EmailEditorMessage.Move({
|
|
1619
|
+
source: element.id,
|
|
1620
|
+
target: target.id
|
|
1621
|
+
}) : undefined;
|
|
1622
|
+
}, { preventDefault: true });
|
|
1623
|
+
}
|
|
1624
|
+
const edit = EmailEditorMessage.Select({ id: element.id });
|
|
1625
|
+
return item.children(grip.children(Grip(h, { size: 16 })), h.div.class("min-w-0 flex-1 rounded-lg border p-1").style({
|
|
1626
|
+
borderColor: element.id === model.active ? color(value.appearance.primary, "#4338ca") : "transparent"
|
|
1627
|
+
}).children(button(edit, disabled, "ghost").attr("aria-label", `${copy.editElement}: ${copy[element.type]}`).children(Edit(h, { size: 14 }), copy[element.type]), h.div.class("px-2").style({
|
|
1628
|
+
textAlign: element.alignment,
|
|
1629
|
+
paddingTop: `${element.paddingTop}px`,
|
|
1630
|
+
paddingBottom: `${element.paddingBottom}px`
|
|
1631
|
+
}).children(element.type === "text" ? element.id === model.active ? editText(`element-${element.id}`, copy.text, element.content, (content) => EmailEditorMessage.Content({
|
|
1632
|
+
id: element.id,
|
|
1633
|
+
content
|
|
1634
|
+
})) : h.div.class("space-y-1 text-sm").children(...element.content.blocks.map((block) => h.div.class(block.type === "heading" ? "text-xl font-semibold" : block.type === "bullet" ? "ml-6 list-item list-disc" : block.type === "numbered" ? "ml-6 list-item list-decimal" : "").children(...block.content.map((inline) => {
|
|
1635
|
+
const content = inline.type === "text" ? inline.text : `{{${variables.find(({ key }) => key === inline.key)?.label ?? inline.key}}}`;
|
|
1636
|
+
const text = h.span.class(`${inline.marks?.bold ? "font-bold " : ""}${inline.marks?.italic ? "italic " : ""}${inline.marks?.underline || inline.marks?.href ? "underline " : ""}${inline.type === "variable" ? "rounded bg-primary/10 px-1 font-mono text-primary" : ""}`).children(content);
|
|
1637
|
+
return inline.marks?.href && Schema12.is(RichTextLink)(inline.marks.href) ? h.a.attr("href", inline.marks.href).children(text) : text;
|
|
1638
|
+
})))) : element.type === "button" ? button(edit).style({
|
|
1639
|
+
backgroundColor: color(value.appearance.primary, "#4338ca"),
|
|
1640
|
+
color: color(value.appearance.primaryText, "#ffffff")
|
|
1641
|
+
}).children(element.label) : element.type === "code" ? button(edit).class("w-full font-mono tracking-widest").children(`{{${element.variable}}}`) : element.type === "image" || element.type === "logo" ? Schema12.is(EmailImageUrl)(element.src) ? h.img.class(emailEditorClasses.image).attrs({
|
|
1642
|
+
src: element.src,
|
|
1643
|
+
width: String(element.width),
|
|
1644
|
+
alt: element.alt
|
|
1645
|
+
}) : Image(h, {
|
|
1646
|
+
size: 32,
|
|
1647
|
+
className: "mx-auto"
|
|
1648
|
+
}) : element.type === "divider" ? h.hr.class("border-[#e5e7eb]") : element.type === "spacer" ? h.div.class("min-h-2 rounded border border-dashed").style({
|
|
1649
|
+
height: `${element.height}px`
|
|
1650
|
+
}) : false)));
|
|
1651
|
+
})))), model.settingsOpen && !!selected && h.section.class("space-y-3 rounded-xl border bg-popover p-4 text-popover-foreground").attr("aria-label", copy.properties).children(h.div.class("flex items-center justify-between").children(h.h3.class("text-sm font-semibold").children(copy[selected.type]), button(EmailEditorMessage.Close(), false, "ghost").attr("aria-label", copy.close).children(X(h, { size: 16 }))), h.div.class("grid grid-cols-2 gap-3").children(select(copy.alignment, selected.alignment, choices(["left", "center", "right"]), setting("alignment")), input(copy.paddingTop, selected.paddingTop, setting("paddingTop"), { type: "number", min: 0, max: 96 }), input(copy.paddingBottom, selected.paddingBottom, setting("paddingBottom"), { type: "number", min: 0, max: 96 }), ...selected.type === "button" ? [
|
|
1652
|
+
input(copy.label, selected.label, setting("label")),
|
|
1653
|
+
select(copy.destination, selected.destination.type === "variable" ? selected.destination.key : "__url", [
|
|
1654
|
+
{ value: "__url", label: copy.url },
|
|
1655
|
+
...variables.filter(({ type }) => type === "url").map(({ key, label }) => ({
|
|
1656
|
+
value: key,
|
|
1657
|
+
label
|
|
1658
|
+
}))
|
|
1659
|
+
], setting("destination")),
|
|
1660
|
+
selected.destination.type === "url" && input(copy.url, selected.destination.url, setting("url"), { type: "url" })
|
|
1661
|
+
] : [], selected.type === "code" && select(copy.variable, selected.variable, variables.filter(({ type }) => type === "text").map(({ key, label }) => ({ value: key, label })), setting("variable")), ...selected.type === "image" || selected.type === "logo" ? [
|
|
1662
|
+
input(copy.src, selected.src, setting("src"), {
|
|
1663
|
+
type: "url"
|
|
1664
|
+
}),
|
|
1665
|
+
input(copy.alt, selected.alt, setting("alt")),
|
|
1666
|
+
input(copy.width, selected.width, setting("width"), {
|
|
1667
|
+
type: "number",
|
|
1668
|
+
min: 32,
|
|
1669
|
+
max: 560
|
|
1670
|
+
})
|
|
1671
|
+
] : [], selected.type === "spacer" && input(copy.height, selected.height, setting("height"), {
|
|
1672
|
+
type: "number",
|
|
1673
|
+
min: 0,
|
|
1674
|
+
max: 96
|
|
1675
|
+
})), h.div.class("flex flex-wrap gap-2").children(Button(h, {
|
|
1676
|
+
element: h.button.on("click", () => EmailEditorMessage.Duplicate({
|
|
1677
|
+
id: crypto.randomUUID(),
|
|
1678
|
+
target: selected.id
|
|
1679
|
+
})),
|
|
1680
|
+
props: { disabled: disabled || max, type: "button" },
|
|
1681
|
+
size: "sm",
|
|
1682
|
+
variant: "outline"
|
|
1683
|
+
}).children(Copy(h, { size: 16 }), copy.duplicate), button(EmailEditorMessage.Remove({ id: selected.id }), disabled, "ghost").class("text-destructive").children(Remove(h, { size: 16 }), copy.remove))), h.p.class(emailEditorClasses.metadata).children(copy.local));
|
|
1684
|
+
return h.div.class(emailEditorClasses.inspector).attr("data-slot", "email-editor").children(Tabs(h, {
|
|
1685
|
+
props: {
|
|
1686
|
+
value: model.mode,
|
|
1687
|
+
tabs: [{ value: "design" }, { value: "preview" }]
|
|
1688
|
+
},
|
|
1689
|
+
onEmit: {
|
|
1690
|
+
Selected: ({ value }) => value === "design" || value === "preview" ? EmailEditorMessage.Mode({ mode: value }) : undefined
|
|
1691
|
+
},
|
|
1692
|
+
view: (tabs) => tabs.root(h.div.class("space-y-4")).children(tabs.list(h.div.class("flex gap-1")).children(...["design", "preview"].map((value) => tabs.tab({
|
|
1693
|
+
element: h.button.class(buttonVariants({
|
|
1694
|
+
variant: model.mode === value ? "outline" : "ghost",
|
|
1695
|
+
size: "sm"
|
|
1696
|
+
})),
|
|
1697
|
+
value
|
|
1698
|
+
}).children(value === "design" ? copy.edit : copy.preview))), tabs.panel({ element: h.div, value: "design" })?.children(design()), tabs.panel({ element: h.div, value: "preview" })?.children(h.slots.preview))
|
|
1699
|
+
}), invalid && h.p.attr("role", "alert").class(emailEditorClasses.error).children(copy.invalid));
|
|
1700
|
+
}
|
|
1701
|
+
});
|
|
1702
|
+
export {
|
|
1703
|
+
EmailEditor,
|
|
1704
|
+
EmailEditorEvents,
|
|
1705
|
+
EmailEditorPropsSchema
|
|
1706
|
+
};
|