@sprawlify/primitives 0.0.1
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/dist/anatomy.cjs +3 -0
- package/dist/anatomy.d.cts +2 -0
- package/dist/anatomy.d.mts +2 -0
- package/dist/anatomy.mjs +3 -0
- package/dist/aria-hidden-DqYx0f_y.mjs +177 -0
- package/dist/aria-hidden-DtLU6hSU.cjs +182 -0
- package/dist/aria-hidden.cjs +4 -0
- package/dist/aria-hidden.d.cts +16 -0
- package/dist/aria-hidden.d.mts +16 -0
- package/dist/aria-hidden.mjs +4 -0
- package/dist/auto-resize-D3qHtFy1.mjs +114 -0
- package/dist/auto-resize-xzlPFDyD.cjs +125 -0
- package/dist/auto-resize.cjs +5 -0
- package/dist/auto-resize.d.cts +17 -0
- package/dist/auto-resize.d.mts +17 -0
- package/dist/auto-resize.mjs +4 -0
- package/dist/chunk-CbDLau6x.cjs +34 -0
- package/dist/collection-8XqaNHs_.mjs +1279 -0
- package/dist/collection-DIoIDISa.cjs +1326 -0
- package/dist/collection.cjs +11 -0
- package/dist/collection.d.cts +5 -0
- package/dist/collection.d.mts +5 -0
- package/dist/collection.mjs +4 -0
- package/dist/color-BkAP1Tkd.d.mts +60 -0
- package/dist/color-VKewNv2e.d.cts +60 -0
- package/dist/color-utils-Cc5GVXZh.mjs +657 -0
- package/dist/color-utils-LER_6Zwu.cjs +680 -0
- package/dist/color-utils.cjs +7 -0
- package/dist/color-utils.d.cts +19 -0
- package/dist/color-utils.d.mts +19 -0
- package/dist/color-utils.mjs +4 -0
- package/dist/core-30pJjyC2.d.mts +49 -0
- package/dist/core-CQFbMdTl.cjs +176 -0
- package/dist/core-CefBjbst.d.cts +49 -0
- package/dist/core-DCFNMTZF.mjs +129 -0
- package/dist/core.cjs +12 -0
- package/dist/core.d.cts +3 -0
- package/dist/core.d.mts +3 -0
- package/dist/core.mjs +5 -0
- package/dist/create-anatomy-B3XYc-qG.d.mts +70 -0
- package/dist/create-anatomy-BGQ8pv8J.d.cts +70 -0
- package/dist/create-anatomy-BbDZbHpC.mjs +39 -0
- package/dist/create-anatomy-CDsIFUXg.cjs +45 -0
- package/dist/create-props-BnF_vl-E.mjs +5 -0
- package/dist/create-props-YKy7JIKj.cjs +11 -0
- package/dist/data-url-C3ITPVRX.d.cts +10 -0
- package/dist/data-url-DLwZ9M77.d.mts +10 -0
- package/dist/date-utils-D2xPHa_I.cjs +738 -0
- package/dist/date-utils-wEa1hhpc.mjs +474 -0
- package/dist/date-utils.cjs +46 -0
- package/dist/date-utils.d.cts +101 -0
- package/dist/date-utils.d.mts +2 -0
- package/dist/date-utils.mjs +3 -0
- package/dist/defineProperty-BoUOT9Ie.cjs +49 -0
- package/dist/defineProperty-DrXfyjd4.mjs +43 -0
- package/dist/dismissable-CTfKZ4OG.cjs +282 -0
- package/dist/dismissable-DDrx0xnH.mjs +271 -0
- package/dist/dismissable-layer-C7pZU2wi.d.cts +39 -0
- package/dist/dismissable-layer-t_b0fk-p.d.mts +39 -0
- package/dist/dismissable.cjs +7 -0
- package/dist/dismissable.d.cts +3 -0
- package/dist/dismissable.d.mts +3 -0
- package/dist/dismissable.mjs +6 -0
- package/dist/dom-query-CWZdWUGp.cjs +2141 -0
- package/dist/dom-query-DFCRhyj1.mjs +1374 -0
- package/dist/dom-query.cjs +130 -0
- package/dist/dom-query.d.cts +307 -0
- package/dist/dom-query.d.mts +307 -0
- package/dist/dom-query.mjs +3 -0
- package/dist/file-utils.cjs +220 -0
- package/dist/file-utils.d.cts +51 -0
- package/dist/file-utils.d.mts +51 -0
- package/dist/file-utils.mjs +210 -0
- package/dist/focus-trap-D-bypQEJ.mjs +485 -0
- package/dist/focus-trap-D4i52S9A.cjs +496 -0
- package/dist/focus-trap.cjs +5 -0
- package/dist/focus-trap.d.cts +88 -0
- package/dist/focus-trap.d.mts +88 -0
- package/dist/focus-trap.mjs +4 -0
- package/dist/focus-visible-DYTWdWpa.cjs +210 -0
- package/dist/focus-visible-irppYatv.mjs +175 -0
- package/dist/focus-visible.cjs +9 -0
- package/dist/focus-visible.d.cts +31 -0
- package/dist/focus-visible.d.mts +31 -0
- package/dist/focus-visible.mjs +4 -0
- package/dist/functions-BOkTDEFM.d.cts +15 -0
- package/dist/functions-IZtWcC8Q.d.mts +15 -0
- package/dist/highlight-word.cjs +100 -0
- package/dist/highlight-word.d.cts +24 -0
- package/dist/highlight-word.d.mts +24 -0
- package/dist/highlight-word.mjs +99 -0
- package/dist/hotkeys.cjs +758 -0
- package/dist/hotkeys.d.cts +130 -0
- package/dist/hotkeys.d.mts +130 -0
- package/dist/hotkeys.mjs +754 -0
- package/dist/i18n-utils.cjs +450 -0
- package/dist/i18n-utils.d.cts +61 -0
- package/dist/i18n-utils.d.mts +61 -0
- package/dist/i18n-utils.mjs +440 -0
- package/dist/index-BkzYij2j.d.mts +25 -0
- package/dist/index-Bqw3r34-.d.cts +1383 -0
- package/dist/index-C0MKXQmE.d.mts +1383 -0
- package/dist/index-C9-feK5c.d.cts +25 -0
- package/dist/index-CD5FN7kY.d.mts +114 -0
- package/dist/index-CJji6wHl.d.cts +15 -0
- package/dist/index-CNi5FkPe.d.mts +15 -0
- package/dist/index-D96rs8B0.d.mts +115 -0
- package/dist/index.cjs +0 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +1 -0
- package/dist/interact-outside-BplxR9cR.mjs +200 -0
- package/dist/interact-outside-C8-oFBpB.cjs +205 -0
- package/dist/interact-outside.cjs +5 -0
- package/dist/interact-outside.d.cts +2 -0
- package/dist/interact-outside.d.mts +2 -0
- package/dist/interact-outside.mjs +5 -0
- package/dist/json-tree-utils.cjs +1512 -0
- package/dist/json-tree-utils.d.cts +117 -0
- package/dist/json-tree-utils.d.mts +117 -0
- package/dist/json-tree-utils.mjs +1463 -0
- package/dist/list-collection-BIMJGQjn.d.cts +61 -0
- package/dist/list-collection-Db3eixRU.d.mts +61 -0
- package/dist/live-region-CcZPGo89.cjs +52 -0
- package/dist/live-region-CnPh21WH.mjs +46 -0
- package/dist/live-region.cjs +3 -0
- package/dist/live-region.d.cts +2 -0
- package/dist/live-region.d.mts +2 -0
- package/dist/live-region.mjs +3 -0
- package/dist/machines/accordion/index.cjs +328 -0
- package/dist/machines/accordion/index.d.cts +83 -0
- package/dist/machines/accordion/index.d.mts +83 -0
- package/dist/machines/accordion/index.mjs +322 -0
- package/dist/machines/async-list/index.cjs +311 -0
- package/dist/machines/async-list/index.d.cts +89 -0
- package/dist/machines/async-list/index.d.mts +89 -0
- package/dist/machines/async-list/index.mjs +310 -0
- package/dist/machines/avatar/index.cjs +169 -0
- package/dist/machines/avatar/index.d.cts +63 -0
- package/dist/machines/avatar/index.d.mts +63 -0
- package/dist/machines/avatar/index.mjs +165 -0
- package/dist/machines/bottom-sheet/index.cjs +676 -0
- package/dist/machines/bottom-sheet/index.d.cts +239 -0
- package/dist/machines/bottom-sheet/index.d.mts +239 -0
- package/dist/machines/bottom-sheet/index.mjs +672 -0
- package/dist/machines/carousel/index.cjs +859 -0
- package/dist/machines/carousel/index.d.cts +146 -0
- package/dist/machines/carousel/index.d.mts +146 -0
- package/dist/machines/carousel/index.mjs +851 -0
- package/dist/machines/checkbox/index.cjs +316 -0
- package/dist/machines/checkbox/index.d.cts +81 -0
- package/dist/machines/checkbox/index.d.mts +81 -0
- package/dist/machines/checkbox/index.mjs +312 -0
- package/dist/machines/clipboard/index.cjs +225 -0
- package/dist/machines/clipboard/index.d.cts +68 -0
- package/dist/machines/clipboard/index.d.mts +68 -0
- package/dist/machines/clipboard/index.mjs +219 -0
- package/dist/machines/collapsible/index.cjs +362 -0
- package/dist/machines/collapsible/index.d.cts +82 -0
- package/dist/machines/collapsible/index.d.mts +82 -0
- package/dist/machines/collapsible/index.mjs +358 -0
- package/dist/machines/color-picker/index.cjs +1529 -0
- package/dist/machines/color-picker/index.d.cts +205 -0
- package/dist/machines/color-picker/index.d.mts +205 -0
- package/dist/machines/color-picker/index.mjs +1514 -0
- package/dist/machines/combobox/index.cjs +1593 -0
- package/dist/machines/combobox/index.d.cts +214 -0
- package/dist/machines/combobox/index.d.mts +214 -0
- package/dist/machines/combobox/index.mjs +1582 -0
- package/dist/machines/date-picker/index.cjs +2177 -0
- package/dist/machines/date-picker/index.d.cts +350 -0
- package/dist/machines/date-picker/index.d.mts +350 -0
- package/dist/machines/date-picker/index.mjs +2161 -0
- package/dist/machines/dialog/index.cjs +325 -0
- package/dist/machines/dialog/index.d.cts +80 -0
- package/dist/machines/dialog/index.d.mts +80 -0
- package/dist/machines/dialog/index.mjs +321 -0
- package/dist/machines/editable/index.cjs +551 -0
- package/dist/machines/editable/index.d.cts +114 -0
- package/dist/machines/editable/index.d.mts +114 -0
- package/dist/machines/editable/index.mjs +547 -0
- package/dist/machines/floating-panel/index.cjs +995 -0
- package/dist/machines/floating-panel/index.d.cts +147 -0
- package/dist/machines/floating-panel/index.d.mts +147 -0
- package/dist/machines/floating-panel/index.mjs +988 -0
- package/dist/machines/hover-card/index.cjs +383 -0
- package/dist/machines/hover-card/index.d.cts +69 -0
- package/dist/machines/hover-card/index.d.mts +69 -0
- package/dist/machines/hover-card/index.mjs +379 -0
- package/dist/machines/image-cropper/index.cjs +1995 -0
- package/dist/machines/image-cropper/index.d.cts +182 -0
- package/dist/machines/image-cropper/index.d.mts +182 -0
- package/dist/machines/image-cropper/index.mjs +1990 -0
- package/dist/machines/listbox/index.cjs +794 -0
- package/dist/machines/listbox/index.d.cts +168 -0
- package/dist/machines/listbox/index.d.mts +168 -0
- package/dist/machines/listbox/index.mjs +782 -0
- package/dist/machines/marquee/index.cjs +395 -0
- package/dist/machines/marquee/index.d.cts +102 -0
- package/dist/machines/marquee/index.d.mts +102 -0
- package/dist/machines/marquee/index.mjs +391 -0
- package/dist/machines/menu/index.cjs +1298 -0
- package/dist/machines/menu/index.d.cts +175 -0
- package/dist/machines/menu/index.d.mts +175 -0
- package/dist/machines/menu/index.mjs +1286 -0
- package/dist/machines/navigation-menu/index.cjs +861 -0
- package/dist/machines/navigation-menu/index.d.cts +127 -0
- package/dist/machines/navigation-menu/index.d.mts +127 -0
- package/dist/machines/navigation-menu/index.mjs +857 -0
- package/dist/machines/number-input/index.cjs +996 -0
- package/dist/machines/number-input/index.d.cts +134 -0
- package/dist/machines/number-input/index.d.mts +134 -0
- package/dist/machines/number-input/index.mjs +991 -0
- package/dist/machines/pagination/index.cjs +419 -0
- package/dist/machines/pagination/index.d.cts +139 -0
- package/dist/machines/pagination/index.d.mts +139 -0
- package/dist/machines/pagination/index.mjs +411 -0
- package/dist/machines/password-input/index.cjs +228 -0
- package/dist/machines/password-input/index.d.cts +71 -0
- package/dist/machines/password-input/index.d.mts +71 -0
- package/dist/machines/password-input/index.mjs +224 -0
- package/dist/machines/pin-input/index.cjs +523 -0
- package/dist/machines/pin-input/index.d.cts +105 -0
- package/dist/machines/pin-input/index.d.mts +105 -0
- package/dist/machines/pin-input/index.mjs +519 -0
- package/dist/machines/popover/index.cjs +430 -0
- package/dist/machines/popover/index.d.cts +88 -0
- package/dist/machines/popover/index.d.mts +88 -0
- package/dist/machines/popover/index.mjs +426 -0
- package/dist/machines/presence/index.cjs +192 -0
- package/dist/machines/presence/index.d.cts +44 -0
- package/dist/machines/presence/index.d.mts +44 -0
- package/dist/machines/presence/index.mjs +190 -0
- package/dist/machines/progress/index.cjs +288 -0
- package/dist/machines/progress/index.d.cts +96 -0
- package/dist/machines/progress/index.d.mts +96 -0
- package/dist/machines/progress/index.mjs +284 -0
- package/dist/machines/qr-code/index.cjs +172 -0
- package/dist/machines/qr-code/index.d.cts +70 -0
- package/dist/machines/qr-code/index.d.mts +70 -0
- package/dist/machines/qr-code/index.mjs +167 -0
- package/dist/machines/radio-group/index.cjs +436 -0
- package/dist/machines/radio-group/index.d.cts +106 -0
- package/dist/machines/radio-group/index.d.mts +106 -0
- package/dist/machines/radio-group/index.mjs +430 -0
- package/dist/machines/rating-group/index.cjs +405 -0
- package/dist/machines/rating-group/index.d.cts +101 -0
- package/dist/machines/rating-group/index.d.mts +101 -0
- package/dist/machines/rating-group/index.mjs +399 -0
- package/dist/machines/scroll-area/index.cjs +857 -0
- package/dist/machines/scroll-area/index.d.cts +159 -0
- package/dist/machines/scroll-area/index.d.mts +159 -0
- package/dist/machines/scroll-area/index.mjs +853 -0
- package/dist/machines/select/index.cjs +1165 -0
- package/dist/machines/select/index.d.cts +183 -0
- package/dist/machines/select/index.d.mts +183 -0
- package/dist/machines/select/index.mjs +1154 -0
- package/dist/machines/signature-pad/index.cjs +334 -0
- package/dist/machines/signature-pad/index.d.cts +108 -0
- package/dist/machines/signature-pad/index.d.mts +108 -0
- package/dist/machines/signature-pad/index.mjs +328 -0
- package/dist/machines/slider/index.cjs +957 -0
- package/dist/machines/slider/index.d.cts +149 -0
- package/dist/machines/slider/index.d.mts +149 -0
- package/dist/machines/slider/index.mjs +949 -0
- package/dist/machines/splitter/index.cjs +1112 -0
- package/dist/machines/splitter/index.d.cts +155 -0
- package/dist/machines/splitter/index.d.mts +155 -0
- package/dist/machines/splitter/index.mjs +1103 -0
- package/dist/machines/steps/index.cjs +289 -0
- package/dist/machines/steps/index.d.cts +97 -0
- package/dist/machines/steps/index.d.mts +97 -0
- package/dist/machines/steps/index.mjs +285 -0
- package/dist/machines/switch/index.cjs +305 -0
- package/dist/machines/switch/index.d.cts +80 -0
- package/dist/machines/switch/index.d.mts +80 -0
- package/dist/machines/switch/index.mjs +301 -0
- package/dist/machines/tabs/index.cjs +508 -0
- package/dist/machines/tabs/index.d.cts +111 -0
- package/dist/machines/tabs/index.d.mts +111 -0
- package/dist/machines/tabs/index.mjs +500 -0
- package/dist/machines/tags-input/index.cjs +1127 -0
- package/dist/machines/tags-input/index.d.cts +179 -0
- package/dist/machines/tags-input/index.d.mts +179 -0
- package/dist/machines/tags-input/index.mjs +1121 -0
- package/dist/machines/timer/index.cjs +329 -0
- package/dist/machines/timer/index.d.cts +98 -0
- package/dist/machines/timer/index.d.mts +98 -0
- package/dist/machines/timer/index.mjs +324 -0
- package/dist/machines/toast/index.cjs +1155 -0
- package/dist/machines/toast/index.d.cts +195 -0
- package/dist/machines/toast/index.d.mts +195 -0
- package/dist/machines/toast/index.mjs +1151 -0
- package/dist/machines/toggle/index.cjs +103 -0
- package/dist/machines/toggle/index.d.cts +46 -0
- package/dist/machines/toggle/index.d.mts +46 -0
- package/dist/machines/toggle/index.mjs +99 -0
- package/dist/machines/toggle-group/index.cjs +328 -0
- package/dist/machines/toggle-group/index.d.cts +81 -0
- package/dist/machines/toggle-group/index.d.mts +81 -0
- package/dist/machines/toggle-group/index.mjs +322 -0
- package/dist/machines/tooltip/index.cjs +516 -0
- package/dist/machines/tooltip/index.d.cts +71 -0
- package/dist/machines/tooltip/index.d.mts +71 -0
- package/dist/machines/tooltip/index.mjs +512 -0
- package/dist/machines/tour/index.cjs +1108 -0
- package/dist/machines/tour/index.d.cts +206 -0
- package/dist/machines/tour/index.d.mts +206 -0
- package/dist/machines/tour/index.mjs +1101 -0
- package/dist/machines/tree-view/index.cjs +1271 -0
- package/dist/machines/tree-view/index.d.cts +215 -0
- package/dist/machines/tree-view/index.d.mts +215 -0
- package/dist/machines/tree-view/index.mjs +1263 -0
- package/dist/node-BctU8GXk.d.mts +24 -0
- package/dist/node-CSsuPZVZ.d.cts +24 -0
- package/dist/popper-BPJeAtcA.mjs +349 -0
- package/dist/popper-D0FAW_p7.cjs +373 -0
- package/dist/popper.cjs +8 -0
- package/dist/popper.d.cts +74 -0
- package/dist/popper.d.mts +2 -0
- package/dist/popper.mjs +5 -0
- package/dist/raf-BnlYUlDi.d.mts +15 -0
- package/dist/raf-Cd2FGy0z.d.cts +15 -0
- package/dist/rect-utils-0ellN0a_.mjs +854 -0
- package/dist/rect-utils-DKLRhP8G.cjs +1147 -0
- package/dist/rect-utils.cjs +51 -0
- package/dist/rect-utils.d.cts +198 -0
- package/dist/rect-utils.d.mts +198 -0
- package/dist/rect-utils.mjs +3 -0
- package/dist/remove-scroll-Lrfv79X_.mjs +58 -0
- package/dist/remove-scroll-Uvzg1L9r.cjs +63 -0
- package/dist/remove-scroll.cjs +0 -0
- package/dist/remove-scroll.d.cts +1 -0
- package/dist/remove-scroll.d.mts +1 -0
- package/dist/remove-scroll.mjs +1 -0
- package/dist/scroll-snap-CrTmQRzA.mjs +152 -0
- package/dist/scroll-snap-zyiZLv7W.cjs +175 -0
- package/dist/scroll-snap.cjs +7 -0
- package/dist/scroll-snap.d.cts +14 -0
- package/dist/scroll-snap.d.mts +14 -0
- package/dist/scroll-snap.mjs +4 -0
- package/dist/selection-BIhSzkF7.d.mts +50 -0
- package/dist/selection-CS1GBp8e.d.cts +50 -0
- package/dist/store-BZcXv49B.cjs +305 -0
- package/dist/store-DEojWy9H.mjs +263 -0
- package/dist/store.cjs +9 -0
- package/dist/store.d.cts +26 -0
- package/dist/store.d.mts +26 -0
- package/dist/store.mjs +3 -0
- package/dist/stringify-state.cjs +49 -0
- package/dist/stringify-state.d.cts +8 -0
- package/dist/stringify-state.d.mts +8 -0
- package/dist/stringify-state.mjs +46 -0
- package/dist/tree-collection-BwU5WhGQ.d.mts +78 -0
- package/dist/tree-collection-DP_eznnI.d.cts +78 -0
- package/dist/typeahead-BdNwVP09.d.cts +45 -0
- package/dist/typeahead-XN6lZ7G9.d.mts +45 -0
- package/dist/types-BivBkYg9.d.cts +57 -0
- package/dist/types-Bl_6JtPQ.d.mts +57 -0
- package/dist/types-CPUMVt7c.d.mts +54 -0
- package/dist/types-CT_W6HWr.d.cts +54 -0
- package/dist/types-DDTcG99l.d.mts +201 -0
- package/dist/types-DejIu60O.d.cts +201 -0
- package/dist/types-DiIdKZ3K.d.cts +45 -0
- package/dist/types-GxLIgJib.d.cts +17 -0
- package/dist/types.cjs +15 -0
- package/dist/types.d.cts +2 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +14 -0
- package/dist/utils-BZyrxWWR.mjs +525 -0
- package/dist/utils-_6frwjgJ.cjs +1040 -0
- package/dist/utils.cjs +88 -0
- package/dist/utils.d.cts +144 -0
- package/dist/utils.d.mts +144 -0
- package/dist/utils.mjs +3 -0
- package/dist/wait-for-CMjPsqWk.d.cts +10 -0
- package/dist/wait-for-D2nkdD4z.d.mts +10 -0
- package/package.json +399 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { n as AnatomyInstance } from "../../create-anatomy-B3XYc-qG.mjs";
|
|
2
|
+
import { p as Machine, u as EventObject, y as Service } from "../../types-DDTcG99l.mjs";
|
|
3
|
+
import { b as NormalizeProps, g as RequiredBy, r as DirectionProperty, t as CommonProperties, x as PropTypes } from "../../index-C0MKXQmE.mjs";
|
|
4
|
+
import { c as PointerDownOutsideEvent, i as InteractOutsideHandlers, n as FocusOutsideEvent, r as InteractOutsideEvent } from "../../index-BkzYij2j.mjs";
|
|
5
|
+
|
|
6
|
+
//#region src/machines/editable/editable.anatomy.d.ts
|
|
7
|
+
declare const anatomy: AnatomyInstance<"root" | "area" | "input" | "label" | "control" | "preview" | "editTrigger" | "submitTrigger" | "cancelTrigger">;
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/machines/editable/editable.types.d.ts
|
|
10
|
+
interface ValueChangeDetails {
|
|
11
|
+
value: string;
|
|
12
|
+
}
|
|
13
|
+
interface EditChangeDetails {
|
|
14
|
+
edit: boolean;
|
|
15
|
+
}
|
|
16
|
+
type ActivationMode = "focus" | "dblclick" | "click" | "none";
|
|
17
|
+
type SubmitMode = "enter" | "blur" | "both" | "none";
|
|
18
|
+
type IntlTranslations = {
|
|
19
|
+
edit: string;
|
|
20
|
+
submit: string;
|
|
21
|
+
cancel: string;
|
|
22
|
+
input: string;
|
|
23
|
+
};
|
|
24
|
+
type ElementIds = Partial<{
|
|
25
|
+
root: string;
|
|
26
|
+
area: string;
|
|
27
|
+
label: string;
|
|
28
|
+
preview: string;
|
|
29
|
+
input: string;
|
|
30
|
+
control: string;
|
|
31
|
+
submitTrigger: string;
|
|
32
|
+
cancelTrigger: string;
|
|
33
|
+
editTrigger: string;
|
|
34
|
+
}>;
|
|
35
|
+
interface EditableProps extends DirectionProperty, CommonProperties, InteractOutsideHandlers {
|
|
36
|
+
ids?: ElementIds | undefined;
|
|
37
|
+
invalid?: boolean | undefined;
|
|
38
|
+
name?: string | undefined;
|
|
39
|
+
form?: string | undefined;
|
|
40
|
+
autoResize?: boolean | undefined;
|
|
41
|
+
activationMode?: ActivationMode | undefined;
|
|
42
|
+
submitMode?: SubmitMode | undefined;
|
|
43
|
+
selectOnFocus?: boolean | undefined;
|
|
44
|
+
edit?: boolean | undefined;
|
|
45
|
+
defaultEdit?: boolean | undefined;
|
|
46
|
+
onEditChange?: ((details: EditChangeDetails) => void) | undefined;
|
|
47
|
+
maxLength?: number | undefined;
|
|
48
|
+
disabled?: boolean | undefined;
|
|
49
|
+
readOnly?: boolean | undefined;
|
|
50
|
+
required?: boolean | undefined;
|
|
51
|
+
placeholder?: string | {
|
|
52
|
+
edit: string;
|
|
53
|
+
preview: string;
|
|
54
|
+
} | undefined;
|
|
55
|
+
translations?: IntlTranslations | undefined;
|
|
56
|
+
finalFocusEl?: (() => HTMLElement | null) | undefined;
|
|
57
|
+
value?: string | undefined;
|
|
58
|
+
defaultValue?: string | undefined;
|
|
59
|
+
onValueChange?: ((details: ValueChangeDetails) => void) | undefined;
|
|
60
|
+
onValueRevert?: ((details: ValueChangeDetails) => void) | undefined;
|
|
61
|
+
onValueCommit?: ((details: ValueChangeDetails) => void) | undefined;
|
|
62
|
+
}
|
|
63
|
+
type PropsWithDefault = "activationMode" | "submitMode" | "selectOnFocus" | "translations";
|
|
64
|
+
interface EditableSchema {
|
|
65
|
+
props: RequiredBy<EditableProps, PropsWithDefault>;
|
|
66
|
+
state: "edit" | "preview";
|
|
67
|
+
context: {
|
|
68
|
+
value: string;
|
|
69
|
+
previousValue: string;
|
|
70
|
+
};
|
|
71
|
+
computed: {
|
|
72
|
+
isInteractive: boolean;
|
|
73
|
+
submitOnEnter: boolean;
|
|
74
|
+
submitOnBlur: boolean;
|
|
75
|
+
};
|
|
76
|
+
action: string;
|
|
77
|
+
effect: string;
|
|
78
|
+
event: EventObject;
|
|
79
|
+
guard: string;
|
|
80
|
+
}
|
|
81
|
+
type EditableService = Service<EditableSchema>;
|
|
82
|
+
type EditableMachine = Machine<EditableSchema>;
|
|
83
|
+
interface EditableApi<T extends PropTypes = PropTypes> {
|
|
84
|
+
editing: boolean;
|
|
85
|
+
empty: boolean;
|
|
86
|
+
value: string;
|
|
87
|
+
valueText: string;
|
|
88
|
+
setValue: (value: string) => void;
|
|
89
|
+
clearValue: VoidFunction;
|
|
90
|
+
edit: VoidFunction;
|
|
91
|
+
cancel: VoidFunction;
|
|
92
|
+
submit: VoidFunction;
|
|
93
|
+
getRootProps: () => T["element"];
|
|
94
|
+
getAreaProps: () => T["element"];
|
|
95
|
+
getLabelProps: () => T["label"];
|
|
96
|
+
getInputProps: () => T["input"];
|
|
97
|
+
getPreviewProps: () => T["element"];
|
|
98
|
+
getEditTriggerProps: () => T["button"];
|
|
99
|
+
getControlProps: () => T["element"];
|
|
100
|
+
getSubmitTriggerProps: () => T["button"];
|
|
101
|
+
getCancelTriggerProps: () => T["button"];
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/machines/editable/editable.connect.d.ts
|
|
105
|
+
declare function connect<T extends PropTypes>(service: Service<EditableSchema>, normalize: NormalizeProps<T>): EditableApi<T>;
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/machines/editable/editable.machine.d.ts
|
|
108
|
+
declare const machine: Machine<EditableSchema>;
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region src/machines/editable/editable.props.d.ts
|
|
111
|
+
declare const props: (keyof EditableProps)[];
|
|
112
|
+
declare const splitProps: <Props extends Partial<EditableProps>>(props: Props) => [Partial<EditableProps>, Omit<Props, keyof EditableProps>];
|
|
113
|
+
//#endregion
|
|
114
|
+
export { type ActivationMode, type EditableApi as Api, type EditChangeDetails, type ElementIds, type FocusOutsideEvent, type InteractOutsideEvent, type IntlTranslations, type EditableMachine as Machine, type PointerDownOutsideEvent, type EditableProps as Props, type EditableService as Service, type SubmitMode, type ValueChangeDetails, anatomy, connect, machine, props, splitProps };
|
|
@@ -0,0 +1,547 @@
|
|
|
1
|
+
import { t as createAnatomy } from "../../create-anatomy-BbDZbHpC.mjs";
|
|
2
|
+
import { At as isApple, U as raf, Xt as contains, _n as ariaAttr, at as setElementValue, mt as isComposingEvent, vn as dataAttr } from "../../dom-query-DFCRhyj1.mjs";
|
|
3
|
+
import { u as createSplitProps } from "../../utils-BZyrxWWR.mjs";
|
|
4
|
+
import { a as createMachine } from "../../core-DCFNMTZF.mjs";
|
|
5
|
+
import { t as trackInteractOutside } from "../../interact-outside-BplxR9cR.mjs";
|
|
6
|
+
import { t as createProps } from "../../create-props-BnF_vl-E.mjs";
|
|
7
|
+
|
|
8
|
+
//#region src/machines/editable/editable.anatomy.ts
|
|
9
|
+
const anatomy = createAnatomy("editable").parts("root", "area", "label", "preview", "input", "editTrigger", "submitTrigger", "cancelTrigger", "control");
|
|
10
|
+
const parts = anatomy.build();
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/machines/editable/editable.dom.ts
|
|
14
|
+
const getRootId = (ctx) => ctx.ids?.root ?? `editable:${ctx.id}`;
|
|
15
|
+
const getAreaId = (ctx) => ctx.ids?.area ?? `editable:${ctx.id}:area`;
|
|
16
|
+
const getLabelId = (ctx) => ctx.ids?.label ?? `editable:${ctx.id}:label`;
|
|
17
|
+
const getPreviewId = (ctx) => ctx.ids?.preview ?? `editable:${ctx.id}:preview`;
|
|
18
|
+
const getInputId = (ctx) => ctx.ids?.input ?? `editable:${ctx.id}:input`;
|
|
19
|
+
const getControlId = (ctx) => ctx.ids?.control ?? `editable:${ctx.id}:control`;
|
|
20
|
+
const getSubmitTriggerId = (ctx) => ctx.ids?.submitTrigger ?? `editable:${ctx.id}:submit`;
|
|
21
|
+
const getCancelTriggerId = (ctx) => ctx.ids?.cancelTrigger ?? `editable:${ctx.id}:cancel`;
|
|
22
|
+
const getEditTriggerId = (ctx) => ctx.ids?.editTrigger ?? `editable:${ctx.id}:edit`;
|
|
23
|
+
const getInputEl = (ctx) => ctx.getById(getInputId(ctx));
|
|
24
|
+
const getPreviewEl = (ctx) => ctx.getById(getPreviewId(ctx));
|
|
25
|
+
const getSubmitTriggerEl = (ctx) => ctx.getById(getSubmitTriggerId(ctx));
|
|
26
|
+
const getCancelTriggerEl = (ctx) => ctx.getById(getCancelTriggerId(ctx));
|
|
27
|
+
const getEditTriggerEl = (ctx) => ctx.getById(getEditTriggerId(ctx));
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/machines/editable/editable.connect.ts
|
|
31
|
+
function connect(service, normalize) {
|
|
32
|
+
const { state, context, send, prop, scope, computed } = service;
|
|
33
|
+
const disabled = !!prop("disabled");
|
|
34
|
+
const interactive = computed("isInteractive");
|
|
35
|
+
const readOnly = !!prop("readOnly");
|
|
36
|
+
const required = !!prop("required");
|
|
37
|
+
const invalid = !!prop("invalid");
|
|
38
|
+
const autoResize = !!prop("autoResize");
|
|
39
|
+
const translations = prop("translations");
|
|
40
|
+
const editing = state.matches("edit");
|
|
41
|
+
const placeholderProp = prop("placeholder");
|
|
42
|
+
const placeholder = typeof placeholderProp === "string" ? {
|
|
43
|
+
edit: placeholderProp,
|
|
44
|
+
preview: placeholderProp
|
|
45
|
+
} : placeholderProp;
|
|
46
|
+
const value = context.get("value");
|
|
47
|
+
const empty = value.trim() === "";
|
|
48
|
+
const valueText = empty ? placeholder?.preview ?? "" : value;
|
|
49
|
+
return {
|
|
50
|
+
editing,
|
|
51
|
+
empty,
|
|
52
|
+
value,
|
|
53
|
+
valueText,
|
|
54
|
+
setValue(value$1) {
|
|
55
|
+
send({
|
|
56
|
+
type: "VALUE.SET",
|
|
57
|
+
value: value$1,
|
|
58
|
+
src: "setValue"
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
clearValue() {
|
|
62
|
+
send({
|
|
63
|
+
type: "VALUE.SET",
|
|
64
|
+
value: "",
|
|
65
|
+
src: "clearValue"
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
edit() {
|
|
69
|
+
if (!interactive) return;
|
|
70
|
+
send({ type: "EDIT" });
|
|
71
|
+
},
|
|
72
|
+
cancel() {
|
|
73
|
+
if (!interactive) return;
|
|
74
|
+
send({ type: "CANCEL" });
|
|
75
|
+
},
|
|
76
|
+
submit() {
|
|
77
|
+
if (!interactive) return;
|
|
78
|
+
send({ type: "SUBMIT" });
|
|
79
|
+
},
|
|
80
|
+
getRootProps() {
|
|
81
|
+
return normalize.element({
|
|
82
|
+
...parts.root.attrs,
|
|
83
|
+
id: getRootId(scope),
|
|
84
|
+
dir: prop("dir")
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
getAreaProps() {
|
|
88
|
+
return normalize.element({
|
|
89
|
+
...parts.area.attrs,
|
|
90
|
+
id: getAreaId(scope),
|
|
91
|
+
dir: prop("dir"),
|
|
92
|
+
style: autoResize ? { display: "inline-grid" } : void 0,
|
|
93
|
+
"data-focus": dataAttr(editing),
|
|
94
|
+
"data-disabled": dataAttr(disabled),
|
|
95
|
+
"data-placeholder-shown": dataAttr(empty)
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
getLabelProps() {
|
|
99
|
+
return normalize.label({
|
|
100
|
+
...parts.label.attrs,
|
|
101
|
+
id: getLabelId(scope),
|
|
102
|
+
dir: prop("dir"),
|
|
103
|
+
htmlFor: getInputId(scope),
|
|
104
|
+
"data-focus": dataAttr(editing),
|
|
105
|
+
"data-invalid": dataAttr(invalid),
|
|
106
|
+
"data-required": dataAttr(required),
|
|
107
|
+
onClick() {
|
|
108
|
+
if (editing) return;
|
|
109
|
+
getPreviewEl(scope)?.focus({ preventScroll: true });
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
},
|
|
113
|
+
getInputProps() {
|
|
114
|
+
return normalize.input({
|
|
115
|
+
...parts.input.attrs,
|
|
116
|
+
dir: prop("dir"),
|
|
117
|
+
"aria-label": translations?.input,
|
|
118
|
+
name: prop("name"),
|
|
119
|
+
form: prop("form"),
|
|
120
|
+
id: getInputId(scope),
|
|
121
|
+
hidden: autoResize ? void 0 : !editing,
|
|
122
|
+
placeholder: placeholder?.edit,
|
|
123
|
+
maxLength: prop("maxLength"),
|
|
124
|
+
required: prop("required"),
|
|
125
|
+
disabled,
|
|
126
|
+
"data-disabled": dataAttr(disabled),
|
|
127
|
+
readOnly,
|
|
128
|
+
"data-readonly": dataAttr(readOnly),
|
|
129
|
+
"aria-invalid": ariaAttr(invalid),
|
|
130
|
+
"data-invalid": dataAttr(invalid),
|
|
131
|
+
"data-autoresize": dataAttr(autoResize),
|
|
132
|
+
defaultValue: value,
|
|
133
|
+
size: autoResize ? 1 : void 0,
|
|
134
|
+
onChange(event) {
|
|
135
|
+
send({
|
|
136
|
+
type: "VALUE.SET",
|
|
137
|
+
src: "input.change",
|
|
138
|
+
value: event.currentTarget.value
|
|
139
|
+
});
|
|
140
|
+
},
|
|
141
|
+
onKeyDown(event) {
|
|
142
|
+
if (event.defaultPrevented) return;
|
|
143
|
+
if (isComposingEvent(event)) return;
|
|
144
|
+
const exec = {
|
|
145
|
+
Escape() {
|
|
146
|
+
send({ type: "CANCEL" });
|
|
147
|
+
event.preventDefault();
|
|
148
|
+
},
|
|
149
|
+
Enter(event$1) {
|
|
150
|
+
if (!computed("submitOnEnter")) return;
|
|
151
|
+
const { localName } = event$1.currentTarget;
|
|
152
|
+
if (localName === "textarea") {
|
|
153
|
+
if (!(isApple() ? event$1.metaKey : event$1.ctrlKey)) return;
|
|
154
|
+
send({
|
|
155
|
+
type: "SUBMIT",
|
|
156
|
+
src: "keydown.enter"
|
|
157
|
+
});
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
if (localName === "input" && !event$1.shiftKey && !event$1.metaKey) {
|
|
161
|
+
send({
|
|
162
|
+
type: "SUBMIT",
|
|
163
|
+
src: "keydown.enter"
|
|
164
|
+
});
|
|
165
|
+
event$1.preventDefault();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}[event.key];
|
|
169
|
+
if (exec) exec(event);
|
|
170
|
+
},
|
|
171
|
+
style: autoResize ? {
|
|
172
|
+
gridArea: "1 / 1 / auto / auto",
|
|
173
|
+
visibility: !editing ? "hidden" : void 0
|
|
174
|
+
} : void 0
|
|
175
|
+
});
|
|
176
|
+
},
|
|
177
|
+
getPreviewProps() {
|
|
178
|
+
return normalize.element({
|
|
179
|
+
id: getPreviewId(scope),
|
|
180
|
+
...parts.preview.attrs,
|
|
181
|
+
dir: prop("dir"),
|
|
182
|
+
"data-placeholder-shown": dataAttr(empty),
|
|
183
|
+
"aria-readonly": ariaAttr(readOnly),
|
|
184
|
+
"data-readonly": dataAttr(disabled),
|
|
185
|
+
"data-disabled": dataAttr(disabled),
|
|
186
|
+
"aria-disabled": ariaAttr(disabled),
|
|
187
|
+
"aria-invalid": ariaAttr(invalid),
|
|
188
|
+
"data-invalid": dataAttr(invalid),
|
|
189
|
+
"aria-label": translations?.edit,
|
|
190
|
+
"data-autoresize": dataAttr(autoResize),
|
|
191
|
+
children: valueText,
|
|
192
|
+
hidden: autoResize ? void 0 : editing,
|
|
193
|
+
tabIndex: interactive ? 0 : void 0,
|
|
194
|
+
onClick() {
|
|
195
|
+
if (!interactive) return;
|
|
196
|
+
if (prop("activationMode") !== "click") return;
|
|
197
|
+
send({
|
|
198
|
+
type: "EDIT",
|
|
199
|
+
src: "click"
|
|
200
|
+
});
|
|
201
|
+
},
|
|
202
|
+
onFocus() {
|
|
203
|
+
if (!interactive) return;
|
|
204
|
+
if (prop("activationMode") !== "focus") return;
|
|
205
|
+
send({
|
|
206
|
+
type: "EDIT",
|
|
207
|
+
src: "focus"
|
|
208
|
+
});
|
|
209
|
+
},
|
|
210
|
+
onDoubleClick(event) {
|
|
211
|
+
if (event.defaultPrevented) return;
|
|
212
|
+
if (!interactive) return;
|
|
213
|
+
if (prop("activationMode") !== "dblclick") return;
|
|
214
|
+
send({
|
|
215
|
+
type: "EDIT",
|
|
216
|
+
src: "dblclick"
|
|
217
|
+
});
|
|
218
|
+
},
|
|
219
|
+
style: autoResize ? {
|
|
220
|
+
whiteSpace: "pre",
|
|
221
|
+
gridArea: "1 / 1 / auto / auto",
|
|
222
|
+
visibility: editing ? "hidden" : void 0,
|
|
223
|
+
overflow: "hidden",
|
|
224
|
+
textOverflow: "ellipsis"
|
|
225
|
+
} : void 0
|
|
226
|
+
});
|
|
227
|
+
},
|
|
228
|
+
getEditTriggerProps() {
|
|
229
|
+
return normalize.button({
|
|
230
|
+
...parts.editTrigger.attrs,
|
|
231
|
+
id: getEditTriggerId(scope),
|
|
232
|
+
dir: prop("dir"),
|
|
233
|
+
"aria-label": translations?.edit,
|
|
234
|
+
hidden: editing,
|
|
235
|
+
type: "button",
|
|
236
|
+
disabled,
|
|
237
|
+
onClick(event) {
|
|
238
|
+
if (event.defaultPrevented) return;
|
|
239
|
+
if (!interactive) return;
|
|
240
|
+
send({
|
|
241
|
+
type: "EDIT",
|
|
242
|
+
src: "edit.click"
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
},
|
|
247
|
+
getControlProps() {
|
|
248
|
+
return normalize.element({
|
|
249
|
+
id: getControlId(scope),
|
|
250
|
+
...parts.control.attrs,
|
|
251
|
+
dir: prop("dir")
|
|
252
|
+
});
|
|
253
|
+
},
|
|
254
|
+
getSubmitTriggerProps() {
|
|
255
|
+
return normalize.button({
|
|
256
|
+
...parts.submitTrigger.attrs,
|
|
257
|
+
dir: prop("dir"),
|
|
258
|
+
id: getSubmitTriggerId(scope),
|
|
259
|
+
"aria-label": translations?.submit,
|
|
260
|
+
hidden: !editing,
|
|
261
|
+
disabled,
|
|
262
|
+
type: "button",
|
|
263
|
+
onClick(event) {
|
|
264
|
+
if (event.defaultPrevented) return;
|
|
265
|
+
if (!interactive) return;
|
|
266
|
+
send({
|
|
267
|
+
type: "SUBMIT",
|
|
268
|
+
src: "submit.click"
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
},
|
|
273
|
+
getCancelTriggerProps() {
|
|
274
|
+
return normalize.button({
|
|
275
|
+
...parts.cancelTrigger.attrs,
|
|
276
|
+
dir: prop("dir"),
|
|
277
|
+
"aria-label": translations?.cancel,
|
|
278
|
+
id: getCancelTriggerId(scope),
|
|
279
|
+
hidden: !editing,
|
|
280
|
+
type: "button",
|
|
281
|
+
disabled,
|
|
282
|
+
onClick(event) {
|
|
283
|
+
if (event.defaultPrevented) return;
|
|
284
|
+
if (!interactive) return;
|
|
285
|
+
send({
|
|
286
|
+
type: "CANCEL",
|
|
287
|
+
src: "cancel.click"
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
//#endregion
|
|
296
|
+
//#region src/machines/editable/editable.machine.ts
|
|
297
|
+
const machine = createMachine({
|
|
298
|
+
props({ props: props$1 }) {
|
|
299
|
+
return {
|
|
300
|
+
activationMode: "focus",
|
|
301
|
+
submitMode: "both",
|
|
302
|
+
defaultValue: "",
|
|
303
|
+
selectOnFocus: true,
|
|
304
|
+
...props$1,
|
|
305
|
+
translations: {
|
|
306
|
+
input: "editable input",
|
|
307
|
+
edit: "edit",
|
|
308
|
+
submit: "submit",
|
|
309
|
+
cancel: "cancel",
|
|
310
|
+
...props$1.translations
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
},
|
|
314
|
+
initialState({ prop }) {
|
|
315
|
+
return prop("edit") || prop("defaultEdit") ? "edit" : "preview";
|
|
316
|
+
},
|
|
317
|
+
entry: ["focusInputIfNeeded"],
|
|
318
|
+
context: ({ bindable, prop }) => {
|
|
319
|
+
return {
|
|
320
|
+
value: bindable(() => ({
|
|
321
|
+
defaultValue: prop("defaultValue"),
|
|
322
|
+
value: prop("value"),
|
|
323
|
+
onChange(value) {
|
|
324
|
+
return prop("onValueChange")?.({ value });
|
|
325
|
+
}
|
|
326
|
+
})),
|
|
327
|
+
previousValue: bindable(() => ({ defaultValue: "" }))
|
|
328
|
+
};
|
|
329
|
+
},
|
|
330
|
+
watch({ track, action, context, prop }) {
|
|
331
|
+
track([() => context.get("value")], () => {
|
|
332
|
+
action(["syncInputValue"]);
|
|
333
|
+
});
|
|
334
|
+
track([() => prop("edit")], () => {
|
|
335
|
+
action(["toggleEditing"]);
|
|
336
|
+
});
|
|
337
|
+
},
|
|
338
|
+
computed: {
|
|
339
|
+
submitOnEnter({ prop }) {
|
|
340
|
+
const submitMode = prop("submitMode");
|
|
341
|
+
return submitMode === "both" || submitMode === "enter";
|
|
342
|
+
},
|
|
343
|
+
submitOnBlur({ prop }) {
|
|
344
|
+
const submitMode = prop("submitMode");
|
|
345
|
+
return submitMode === "both" || submitMode === "blur";
|
|
346
|
+
},
|
|
347
|
+
isInteractive({ prop }) {
|
|
348
|
+
return !(prop("disabled") || prop("readOnly"));
|
|
349
|
+
}
|
|
350
|
+
},
|
|
351
|
+
on: { "VALUE.SET": { actions: ["setValue"] } },
|
|
352
|
+
states: {
|
|
353
|
+
preview: {
|
|
354
|
+
entry: ["blurInput"],
|
|
355
|
+
on: {
|
|
356
|
+
"CONTROLLED.EDIT": {
|
|
357
|
+
target: "edit",
|
|
358
|
+
actions: ["setPreviousValue", "focusInput"]
|
|
359
|
+
},
|
|
360
|
+
EDIT: [{
|
|
361
|
+
guard: "isEditControlled",
|
|
362
|
+
actions: ["invokeOnEdit"]
|
|
363
|
+
}, {
|
|
364
|
+
target: "edit",
|
|
365
|
+
actions: [
|
|
366
|
+
"setPreviousValue",
|
|
367
|
+
"focusInput",
|
|
368
|
+
"invokeOnEdit"
|
|
369
|
+
]
|
|
370
|
+
}]
|
|
371
|
+
}
|
|
372
|
+
},
|
|
373
|
+
edit: {
|
|
374
|
+
effects: ["trackInteractOutside"],
|
|
375
|
+
entry: ["syncInputValue"],
|
|
376
|
+
on: {
|
|
377
|
+
"CONTROLLED.PREVIEW": [{
|
|
378
|
+
guard: "isSubmitEvent",
|
|
379
|
+
target: "preview",
|
|
380
|
+
actions: [
|
|
381
|
+
"setPreviousValue",
|
|
382
|
+
"restoreFocus",
|
|
383
|
+
"invokeOnSubmit"
|
|
384
|
+
]
|
|
385
|
+
}, {
|
|
386
|
+
target: "preview",
|
|
387
|
+
actions: [
|
|
388
|
+
"revertValue",
|
|
389
|
+
"restoreFocus",
|
|
390
|
+
"invokeOnCancel"
|
|
391
|
+
]
|
|
392
|
+
}],
|
|
393
|
+
CANCEL: [{
|
|
394
|
+
guard: "isEditControlled",
|
|
395
|
+
actions: ["invokeOnPreview"]
|
|
396
|
+
}, {
|
|
397
|
+
target: "preview",
|
|
398
|
+
actions: [
|
|
399
|
+
"revertValue",
|
|
400
|
+
"restoreFocus",
|
|
401
|
+
"invokeOnCancel",
|
|
402
|
+
"invokeOnPreview"
|
|
403
|
+
]
|
|
404
|
+
}],
|
|
405
|
+
SUBMIT: [{
|
|
406
|
+
guard: "isEditControlled",
|
|
407
|
+
actions: ["invokeOnPreview"]
|
|
408
|
+
}, {
|
|
409
|
+
target: "preview",
|
|
410
|
+
actions: [
|
|
411
|
+
"setPreviousValue",
|
|
412
|
+
"restoreFocus",
|
|
413
|
+
"invokeOnSubmit",
|
|
414
|
+
"invokeOnPreview"
|
|
415
|
+
]
|
|
416
|
+
}]
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
},
|
|
420
|
+
implementations: {
|
|
421
|
+
guards: {
|
|
422
|
+
isEditControlled: ({ prop }) => prop("edit") != void 0,
|
|
423
|
+
isSubmitEvent: ({ event }) => event.previousEvent?.type === "SUBMIT"
|
|
424
|
+
},
|
|
425
|
+
effects: { trackInteractOutside({ send, scope, prop, computed }) {
|
|
426
|
+
return trackInteractOutside(getInputEl(scope), {
|
|
427
|
+
exclude(target) {
|
|
428
|
+
return [getCancelTriggerEl(scope), getSubmitTriggerEl(scope)].some((el) => contains(el, target));
|
|
429
|
+
},
|
|
430
|
+
onFocusOutside: prop("onFocusOutside"),
|
|
431
|
+
onPointerDownOutside: prop("onPointerDownOutside"),
|
|
432
|
+
onInteractOutside(event) {
|
|
433
|
+
prop("onInteractOutside")?.(event);
|
|
434
|
+
if (event.defaultPrevented) return;
|
|
435
|
+
const { focusable } = event.detail;
|
|
436
|
+
send({
|
|
437
|
+
type: computed("submitOnBlur") ? "SUBMIT" : "CANCEL",
|
|
438
|
+
src: "interact-outside",
|
|
439
|
+
focusable
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
} },
|
|
444
|
+
actions: {
|
|
445
|
+
restoreFocus({ event, scope, prop }) {
|
|
446
|
+
if (event.focusable) return;
|
|
447
|
+
raf(() => {
|
|
448
|
+
(prop("finalFocusEl")?.() ?? getEditTriggerEl(scope))?.focus({ preventScroll: true });
|
|
449
|
+
});
|
|
450
|
+
},
|
|
451
|
+
clearValue({ context }) {
|
|
452
|
+
context.set("value", "");
|
|
453
|
+
},
|
|
454
|
+
focusInputIfNeeded({ action, prop }) {
|
|
455
|
+
if (!(prop("edit") || prop("defaultEdit"))) return;
|
|
456
|
+
action(["focusInput"]);
|
|
457
|
+
},
|
|
458
|
+
focusInput({ scope, prop }) {
|
|
459
|
+
raf(() => {
|
|
460
|
+
const inputEl = getInputEl(scope);
|
|
461
|
+
if (!inputEl) return;
|
|
462
|
+
if (prop("selectOnFocus")) inputEl.select();
|
|
463
|
+
else inputEl.focus({ preventScroll: true });
|
|
464
|
+
});
|
|
465
|
+
},
|
|
466
|
+
invokeOnCancel({ prop, context }) {
|
|
467
|
+
const prev = context.get("previousValue");
|
|
468
|
+
prop("onValueRevert")?.({ value: prev });
|
|
469
|
+
},
|
|
470
|
+
invokeOnSubmit({ prop, context }) {
|
|
471
|
+
const value = context.get("value");
|
|
472
|
+
prop("onValueCommit")?.({ value });
|
|
473
|
+
},
|
|
474
|
+
invokeOnEdit({ prop }) {
|
|
475
|
+
prop("onEditChange")?.({ edit: true });
|
|
476
|
+
},
|
|
477
|
+
invokeOnPreview({ prop }) {
|
|
478
|
+
prop("onEditChange")?.({ edit: false });
|
|
479
|
+
},
|
|
480
|
+
toggleEditing({ prop, send, event }) {
|
|
481
|
+
send({
|
|
482
|
+
type: prop("edit") ? "CONTROLLED.EDIT" : "CONTROLLED.PREVIEW",
|
|
483
|
+
previousEvent: event
|
|
484
|
+
});
|
|
485
|
+
},
|
|
486
|
+
syncInputValue({ context, scope }) {
|
|
487
|
+
const inputEl = getInputEl(scope);
|
|
488
|
+
if (!inputEl) return;
|
|
489
|
+
setElementValue(inputEl, context.get("value"));
|
|
490
|
+
},
|
|
491
|
+
setValue({ context, prop, event }) {
|
|
492
|
+
const max = prop("maxLength");
|
|
493
|
+
const value = max != null ? event.value.slice(0, max) : event.value;
|
|
494
|
+
context.set("value", value);
|
|
495
|
+
},
|
|
496
|
+
setPreviousValue({ context }) {
|
|
497
|
+
context.set("previousValue", context.get("value"));
|
|
498
|
+
},
|
|
499
|
+
revertValue({ context }) {
|
|
500
|
+
const value = context.get("previousValue");
|
|
501
|
+
if (!value) return;
|
|
502
|
+
context.set("value", value);
|
|
503
|
+
},
|
|
504
|
+
blurInput({ scope }) {
|
|
505
|
+
getInputEl(scope)?.blur();
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
//#endregion
|
|
512
|
+
//#region src/machines/editable/editable.props.ts
|
|
513
|
+
const props = createProps()([
|
|
514
|
+
"activationMode",
|
|
515
|
+
"autoResize",
|
|
516
|
+
"dir",
|
|
517
|
+
"disabled",
|
|
518
|
+
"finalFocusEl",
|
|
519
|
+
"form",
|
|
520
|
+
"getRootNode",
|
|
521
|
+
"id",
|
|
522
|
+
"ids",
|
|
523
|
+
"invalid",
|
|
524
|
+
"maxLength",
|
|
525
|
+
"name",
|
|
526
|
+
"onEditChange",
|
|
527
|
+
"onFocusOutside",
|
|
528
|
+
"onInteractOutside",
|
|
529
|
+
"onPointerDownOutside",
|
|
530
|
+
"onValueChange",
|
|
531
|
+
"onValueCommit",
|
|
532
|
+
"onValueRevert",
|
|
533
|
+
"placeholder",
|
|
534
|
+
"readOnly",
|
|
535
|
+
"required",
|
|
536
|
+
"selectOnFocus",
|
|
537
|
+
"edit",
|
|
538
|
+
"defaultEdit",
|
|
539
|
+
"submitMode",
|
|
540
|
+
"translations",
|
|
541
|
+
"defaultValue",
|
|
542
|
+
"value"
|
|
543
|
+
]);
|
|
544
|
+
const splitProps = createSplitProps(props);
|
|
545
|
+
|
|
546
|
+
//#endregion
|
|
547
|
+
export { anatomy, connect, machine, props, splitProps };
|