@epilot/zenith-react 0.2.0-next.3 → 0.2.0-next.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -1
- package/codemods/README.md +182 -0
- package/codemods/format.ts +86 -0
- package/codemods/migrate/base-elements/accordion.ts +132 -0
- package/codemods/migrate/base-elements/alert.ts +81 -0
- package/codemods/migrate/base-elements/avatar.ts +116 -0
- package/codemods/migrate/base-elements/button.ts +188 -0
- package/codemods/migrate/base-elements/checkbox.ts +17 -0
- package/codemods/migrate/base-elements/chip.ts +87 -0
- package/codemods/migrate/base-elements/chip360.ts +162 -0
- package/codemods/migrate/base-elements/circular-progress.ts +73 -0
- package/codemods/migrate/base-elements/dialog.ts +323 -0
- package/codemods/migrate/base-elements/divider.ts +61 -0
- package/codemods/migrate/base-elements/feedback-message.ts +95 -0
- package/codemods/migrate/base-elements/icon-button.ts +203 -0
- package/codemods/migrate/base-elements/index.ts +55 -0
- package/codemods/migrate/base-elements/mui-props.ts +29 -0
- package/codemods/migrate/base-elements/notification.ts +98 -0
- package/codemods/migrate/base-elements/paper.ts +78 -0
- package/codemods/migrate/base-elements/select.ts +328 -0
- package/codemods/migrate/base-elements/shared.ts +910 -0
- package/codemods/migrate/base-elements/skeleton.ts +83 -0
- package/codemods/migrate/base-elements/switch.ts +19 -0
- package/codemods/migrate/base-elements/tabs.ts +222 -0
- package/codemods/migrate/base-elements/text-field.ts +425 -0
- package/codemods/migrate/base-elements/toggle-button.ts +185 -0
- package/codemods/migrate/base-elements/tooltip.ts +231 -0
- package/codemods/migrate/base-elements/typography.ts +247 -0
- package/codemods/migrate/base-elements/unsupported.ts +277 -0
- package/codemods/migrate/from-base-elements.ts +26 -0
- package/codemods/migrate/from-volt.ts +26 -0
- package/codemods/migrate/lib/imports.ts +399 -0
- package/codemods/migrate/lib/jsx.ts +313 -0
- package/codemods/migrate/lib/run-migration.ts +528 -0
- package/codemods/migrate/lib/source.ts +6 -0
- package/codemods/migrate/lib/todo.ts +107 -0
- package/codemods/migrate/lib/types.ts +114 -0
- package/codemods/migrate/volt/class-helpers.ts +37 -0
- package/codemods/migrate/volt/index.ts +18 -0
- package/codemods/migrate/volt/pagination.ts +26 -0
- package/codemods/migrate/volt/same-name.ts +293 -0
- package/codemods/migrate/volt/stylesheets.ts +18 -0
- package/codemods/migrate/volt/tanstack-types.ts +20 -0
- package/codemods/radix-to-base-ui.ts +677 -0
- package/dist/_virtual/_zenith-runtime-family_accordion.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_accordion.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_alert-dialog.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_alert-dialog.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_avatar.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_avatar.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_button.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_button.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_checkbox.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_checkbox.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_csp-provider.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_csp-provider.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_dialog.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_dialog.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_direction-provider.js +8 -0
- package/dist/_virtual/_zenith-runtime-family_direction-provider.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_menu.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_menu.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_merge-props.js +11 -0
- package/dist/_virtual/_zenith-runtime-family_merge-props.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_popover.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_popover.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_radio-group.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_radio-group.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_radio.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_radio.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_scroll-area.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_scroll-area.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_select.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_select.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_separator.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_separator.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_switch.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_switch.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_tabs.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_tabs.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_toast.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_toast.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_toggle-group.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_toggle-group.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_toggle.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_toggle.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_tooltip.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_tooltip.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_use-render.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_use-render.js.map +1 -0
- package/dist/components/accordion/accordion.js +179 -96
- package/dist/components/accordion/accordion.js.map +1 -1
- package/dist/components/alert-dialog/alert-dialog.js +243 -206
- package/dist/components/alert-dialog/alert-dialog.js.map +1 -1
- package/dist/components/avatar/avatar.js +94 -82
- package/dist/components/avatar/avatar.js.map +1 -1
- package/dist/components/badge/badge.js +11 -11
- package/dist/components/breadcrumb/breadcrumb.js +69 -70
- package/dist/components/breadcrumb/breadcrumb.js.map +1 -1
- package/dist/components/button/button.js +119 -102
- package/dist/components/button/button.js.map +1 -1
- package/dist/components/checkbox/checkbox.js +68 -51
- package/dist/components/checkbox/checkbox.js.map +1 -1
- package/dist/components/date-range-picker/date-range-picker.js +100 -90
- package/dist/components/date-range-picker/date-range-picker.js.map +1 -1
- package/dist/components/date-time-picker/date-time-picker-input.js +118 -108
- package/dist/components/date-time-picker/date-time-picker-input.js.map +1 -1
- package/dist/components/date-time-picker/date-time-picker-panel.js +91 -94
- package/dist/components/date-time-picker/date-time-picker-panel.js.map +1 -1
- package/dist/components/dialog/dialog.js +238 -228
- package/dist/components/dialog/dialog.js.map +1 -1
- package/dist/components/drawer/drawer.js +259 -321
- package/dist/components/drawer/drawer.js.map +1 -1
- package/dist/components/dropdown-menu/dropdown-menu.js +533 -279
- package/dist/components/dropdown-menu/dropdown-menu.js.map +1 -1
- package/dist/components/field/field-combobox.js +205 -186
- package/dist/components/field/field-combobox.js.map +1 -1
- package/dist/components/field/field-select.js +37 -22
- package/dist/components/field/field-select.js.map +1 -1
- package/dist/components/list/list-sortable.js +104 -0
- package/dist/components/list/list-sortable.js.map +1 -0
- package/dist/components/list/list.js +246 -324
- package/dist/components/list/list.js.map +1 -1
- package/dist/components/option-card/option-card.js +121 -117
- package/dist/components/option-card/option-card.js.map +1 -1
- package/dist/components/pill/pill.js +7 -7
- package/dist/components/popover/popover.js +223 -127
- package/dist/components/popover/popover.js.map +1 -1
- package/dist/components/radio/radio-group-base.js +54 -0
- package/dist/components/radio/radio-group-base.js.map +1 -0
- package/dist/components/radio/radio.js +71 -60
- package/dist/components/radio/radio.js.map +1 -1
- package/dist/components/scroll-area/scroll-area.js +142 -108
- package/dist/components/scroll-area/scroll-area.js.map +1 -1
- package/dist/components/scroll-overflow/scroll-overflow.js +156 -127
- package/dist/components/scroll-overflow/scroll-overflow.js.map +1 -1
- package/dist/components/segmented-control/segmented-control.js +93 -81
- package/dist/components/segmented-control/segmented-control.js.map +1 -1
- package/dist/components/select/select.js +485 -310
- package/dist/components/select/select.js.map +1 -1
- package/dist/components/separator/separator.js.map +1 -1
- package/dist/components/slot/compose-as-child.js +15 -12
- package/dist/components/slot/compose-as-child.js.map +1 -1
- package/dist/components/switch/switch.js +75 -68
- package/dist/components/switch/switch.js.map +1 -1
- package/dist/components/table/table-pagination.js +212 -175
- package/dist/components/table/table-pagination.js.map +1 -1
- package/dist/components/tabs/tabs.js +193 -190
- package/dist/components/tabs/tabs.js.map +1 -1
- package/dist/components/toast/toast.js +610 -148
- package/dist/components/toast/toast.js.map +1 -1
- package/dist/components/toggle/toggle-group.js +143 -32
- package/dist/components/toggle/toggle-group.js.map +1 -1
- package/dist/components/toggle/toggle.js +82 -49
- package/dist/components/toggle/toggle.js.map +1 -1
- package/dist/components/tooltip/tooltip.js +298 -138
- package/dist/components/tooltip/tooltip.js.map +1 -1
- package/dist/index.d.ts +2336 -2130
- package/dist/index.js +24 -23
- package/dist/list/sortable/index.d.ts +29 -0
- package/dist/list/sortable/index.js +5 -0
- package/dist/{_virtual → list/sortable}/index.js.map +1 -1
- package/dist/packages/tokens/dist/delivery/index.js +10 -10
- package/dist/packages/tokens/dist/delivery/index.js.map +1 -1
- package/dist/packages/tokens/dist/generated/core.generated.js +6 -15
- package/dist/packages/tokens/dist/generated/core.generated.js.map +1 -1
- package/dist/packages/tokens/dist/generated/palette.generated.js +4 -5
- package/dist/packages/tokens/dist/generated/palette.generated.js.map +1 -1
- package/dist/packages/tokens/dist/generated/palette.meta.generated.js +5 -0
- package/dist/packages/tokens/dist/generated/palette.meta.generated.js.map +1 -0
- package/dist/packages/tokens/dist/install.js +40 -17
- package/dist/packages/tokens/dist/install.js.map +1 -1
- package/dist/renderer/runtime-contract.generated.js +8 -0
- package/dist/renderer/runtime-contract.generated.js.map +1 -0
- package/dist/renderer/served.js +39 -0
- package/dist/renderer/served.js.map +1 -0
- package/dist/tokens/core.meta.generated.js +2 -2
- package/dist/tokens/core.meta.generated.js.map +1 -1
- package/dist/tokens/index.d.ts +1028 -1028
- package/dist/tokens/index.js +863 -863
- package/dist/tokens/index.js.map +1 -1
- package/dist/tokens/palette.meta.generated.js +5 -0
- package/dist/tokens/palette.meta.generated.js.map +1 -0
- package/dist/tokens.json +1 -1
- package/dist/vendor/.bun/@radix-ui_react-dialog@1.1.15_2b23df507bdda662/vendor/@radix-ui/react-dialog/dist/index.js +57 -62
- package/dist/vendor/.bun/@radix-ui_react-dialog@1.1.15_2b23df507bdda662/vendor/@radix-ui/react-dialog/dist/index.js.map +1 -1
- package/dist/vendor/.bun/@radix-ui_react-slot@1.2.3_0ac650c021fb1b59/vendor/@radix-ui/react-slot/dist/index.js +32 -38
- package/dist/vendor/.bun/@radix-ui_react-slot@1.2.3_0ac650c021fb1b59/vendor/@radix-ui/react-slot/dist/index.js.map +1 -1
- package/package.json +29 -21
- package/scripts/migration-diagnostics-core.mjs +302 -10
- package/scripts/migration-diagnostics.mjs +31 -8
- package/scripts/migration-sweep.mjs +10 -10
- package/testing/setup.cjs +87 -0
- package/dist/_virtual/index.js +0 -6
- package/dist/_virtual/index2.js +0 -5
- package/dist/_virtual/index2.js.map +0 -1
- package/dist/_virtual/use-sync-external-store-shim.development.js +0 -5
- package/dist/_virtual/use-sync-external-store-shim.development.js.map +0 -1
- package/dist/_virtual/use-sync-external-store-shim.production.js +0 -5
- package/dist/_virtual/use-sync-external-store-shim.production.js.map +0 -1
- package/dist/tokens/palette.generated.js +0 -5
- package/dist/tokens/palette.generated.js.map +0 -1
- package/dist/vendor/.bun/@floating-ui_core@1.8.0/vendor/@floating-ui/core/dist/floating-ui.core.js +0 -512
- package/dist/vendor/.bun/@floating-ui_core@1.8.0/vendor/@floating-ui/core/dist/floating-ui.core.js.map +0 -1
- package/dist/vendor/.bun/@floating-ui_dom@1.8.0/vendor/@floating-ui/dom/dist/floating-ui.dom.js +0 -396
- package/dist/vendor/.bun/@floating-ui_dom@1.8.0/vendor/@floating-ui/dom/dist/floating-ui.dom.js.map +0 -1
- package/dist/vendor/.bun/@floating-ui_react-dom@2.1.9_6f4b9a1cfb20c0ae/vendor/@floating-ui/react-dom/dist/floating-ui.react-dom.js +0 -233
- package/dist/vendor/.bun/@floating-ui_react-dom@2.1.9_6f4b9a1cfb20c0ae/vendor/@floating-ui/react-dom/dist/floating-ui.react-dom.js.map +0 -1
- package/dist/vendor/.bun/@floating-ui_utils@0.2.12/vendor/@floating-ui/utils/dist/floating-ui.utils.dom.js +0 -137
- package/dist/vendor/.bun/@floating-ui_utils@0.2.12/vendor/@floating-ui/utils/dist/floating-ui.utils.dom.js.map +0 -1
- package/dist/vendor/.bun/@floating-ui_utils@0.2.12/vendor/@floating-ui/utils/dist/floating-ui.utils.js +0 -129
- package/dist/vendor/.bun/@floating-ui_utils@0.2.12/vendor/@floating-ui/utils/dist/floating-ui.utils.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_number@1.1.1/vendor/@radix-ui/number/dist/index.js +0 -7
- package/dist/vendor/.bun/@radix-ui_number@1.1.1/vendor/@radix-ui/number/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-accordion@1.2.12_2b23df507bdda662/vendor/@radix-ui/react-accordion/dist/index.js +0 -240
- package/dist/vendor/.bun/@radix-ui_react-accordion@1.2.12_2b23df507bdda662/vendor/@radix-ui/react-accordion/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-alert-dialog@1.1.15_2b23df507bdda662/vendor/@radix-ui/react-alert-dialog/dist/index.js +0 -128
- package/dist/vendor/.bun/@radix-ui_react-alert-dialog@1.1.15_2b23df507bdda662/vendor/@radix-ui/react-alert-dialog/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-arrow@1.1.7_2b23df507bdda662/vendor/@radix-ui/react-arrow/dist/index.js +0 -25
- package/dist/vendor/.bun/@radix-ui_react-arrow@1.1.7_2b23df507bdda662/vendor/@radix-ui/react-arrow/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-avatar@1.1.10_2b23df507bdda662/vendor/@radix-ui/react-avatar/dist/index.js +0 -76
- package/dist/vendor/.bun/@radix-ui_react-avatar@1.1.10_2b23df507bdda662/vendor/@radix-ui/react-avatar/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-checkbox@1.3.3_2b23df507bdda662/vendor/@radix-ui/react-checkbox/dist/index.js +0 -252
- package/dist/vendor/.bun/@radix-ui_react-checkbox@1.3.3_2b23df507bdda662/vendor/@radix-ui/react-checkbox/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-collapsible@1.1.12_2b23df507bdda662/vendor/@radix-ui/react-collapsible/dist/index.js +0 -121
- package/dist/vendor/.bun/@radix-ui_react-collapsible@1.1.12_2b23df507bdda662/vendor/@radix-ui/react-collapsible/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-collection@1.1.7_2b23df507bdda662/vendor/@radix-ui/react-collection/dist/index.js +0 -49
- package/dist/vendor/.bun/@radix-ui_react-collection@1.1.7_2b23df507bdda662/vendor/@radix-ui/react-collection/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-direction@1.1.1_0ac650c021fb1b59/vendor/@radix-ui/react-direction/dist/index.js +0 -11
- package/dist/vendor/.bun/@radix-ui_react-direction@1.1.1_0ac650c021fb1b59/vendor/@radix-ui/react-direction/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-dropdown-menu@2.1.16_2b23df507bdda662/vendor/@radix-ui/react-dropdown-menu/dist/index.js +0 -228
- package/dist/vendor/.bun/@radix-ui_react-dropdown-menu@2.1.16_2b23df507bdda662/vendor/@radix-ui/react-dropdown-menu/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-menu@2.1.16_2b23df507bdda662/vendor/@radix-ui/react-menu/dist/index.js +0 -653
- package/dist/vendor/.bun/@radix-ui_react-menu@2.1.16_2b23df507bdda662/vendor/@radix-ui/react-menu/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-popover@1.1.15_2b23df507bdda662/vendor/@radix-ui/react-popover/dist/index.js +0 -244
- package/dist/vendor/.bun/@radix-ui_react-popover@1.1.15_2b23df507bdda662/vendor/@radix-ui/react-popover/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-popper@1.2.8_2b23df507bdda662/vendor/@radix-ui/react-popper/dist/index.js +0 -222
- package/dist/vendor/.bun/@radix-ui_react-popper@1.2.8_2b23df507bdda662/vendor/@radix-ui/react-popper/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-radio-group@1.3.8_2b23df507bdda662/vendor/@radix-ui/react-radio-group/dist/index.js +0 -239
- package/dist/vendor/.bun/@radix-ui_react-radio-group@1.3.8_2b23df507bdda662/vendor/@radix-ui/react-radio-group/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-roving-focus@1.1.11_2b23df507bdda662/vendor/@radix-ui/react-roving-focus/dist/index.js +0 -184
- package/dist/vendor/.bun/@radix-ui_react-roving-focus@1.1.11_2b23df507bdda662/vendor/@radix-ui/react-roving-focus/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-scroll-area@1.2.10_2b23df507bdda662/vendor/@radix-ui/react-scroll-area/dist/index.js +0 -535
- package/dist/vendor/.bun/@radix-ui_react-scroll-area@1.2.10_2b23df507bdda662/vendor/@radix-ui/react-scroll-area/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-select@2.2.6_2b23df507bdda662/vendor/@radix-ui/react-select/dist/index.js +0 -863
- package/dist/vendor/.bun/@radix-ui_react-select@2.2.6_2b23df507bdda662/vendor/@radix-ui/react-select/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-slot@1.2.4_0ac650c021fb1b59/vendor/@radix-ui/react-slot/dist/index.js +0 -63
- package/dist/vendor/.bun/@radix-ui_react-slot@1.2.4_0ac650c021fb1b59/vendor/@radix-ui/react-slot/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-switch@1.2.6_2b23df507bdda662/vendor/@radix-ui/react-switch/dist/index.js +0 -133
- package/dist/vendor/.bun/@radix-ui_react-switch@1.2.6_2b23df507bdda662/vendor/@radix-ui/react-switch/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-tabs@1.1.13_2b23df507bdda662/vendor/@radix-ui/react-tabs/dist/index.js +0 -164
- package/dist/vendor/.bun/@radix-ui_react-tabs@1.1.13_2b23df507bdda662/vendor/@radix-ui/react-tabs/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-toggle-group@1.1.11_2b23df507bdda662/vendor/@radix-ui/react-toggle-group/dist/index.js +0 -138
- package/dist/vendor/.bun/@radix-ui_react-toggle-group@1.1.11_2b23df507bdda662/vendor/@radix-ui/react-toggle-group/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-toggle@1.1.10_2b23df507bdda662/vendor/@radix-ui/react-toggle/dist/index.js +0 -34
- package/dist/vendor/.bun/@radix-ui_react-toggle@1.1.10_2b23df507bdda662/vendor/@radix-ui/react-toggle/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-tooltip@1.2.8_2b23df507bdda662/vendor/@radix-ui/react-tooltip/dist/index.js +0 -340
- package/dist/vendor/.bun/@radix-ui_react-tooltip@1.2.8_2b23df507bdda662/vendor/@radix-ui/react-tooltip/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-use-is-hydrated@0.1.0_0ac650c021fb1b59/vendor/@radix-ui/react-use-is-hydrated/dist/index.js +0 -16
- package/dist/vendor/.bun/@radix-ui_react-use-is-hydrated@0.1.0_0ac650c021fb1b59/vendor/@radix-ui/react-use-is-hydrated/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-use-previous@1.1.1_0ac650c021fb1b59/vendor/@radix-ui/react-use-previous/dist/index.js +0 -9
- package/dist/vendor/.bun/@radix-ui_react-use-previous@1.1.1_0ac650c021fb1b59/vendor/@radix-ui/react-use-previous/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-use-size@1.1.1_0ac650c021fb1b59/vendor/@radix-ui/react-use-size/dist/index.js +0 -28
- package/dist/vendor/.bun/@radix-ui_react-use-size@1.1.1_0ac650c021fb1b59/vendor/@radix-ui/react-use-size/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-visually-hidden@1.2.3_2b23df507bdda662/vendor/@radix-ui/react-visually-hidden/dist/index.js +0 -33
- package/dist/vendor/.bun/@radix-ui_react-visually-hidden@1.2.3_2b23df507bdda662/vendor/@radix-ui/react-visually-hidden/dist/index.js.map +0 -1
- package/dist/vendor/.bun/sonner@2.0.7_6f4b9a1cfb20c0ae/vendor/sonner/dist/index.js +0 -747
- package/dist/vendor/.bun/sonner@2.0.7_6f4b9a1cfb20c0ae/vendor/sonner/dist/index.js.map +0 -1
- package/dist/vendor/.bun/use-sync-external-store@1.7.0_62547eec5a2188e3/vendor/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +0 -68
- package/dist/vendor/.bun/use-sync-external-store@1.7.0_62547eec5a2188e3/vendor/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +0 -1
- package/dist/vendor/.bun/use-sync-external-store@1.7.0_62547eec5a2188e3/vendor/use-sync-external-store/cjs/use-sync-external-store-shim.production.js +0 -56
- package/dist/vendor/.bun/use-sync-external-store@1.7.0_62547eec5a2188e3/vendor/use-sync-external-store/cjs/use-sync-external-store-shim.production.js.map +0 -1
- package/dist/vendor/.bun/use-sync-external-store@1.7.0_62547eec5a2188e3/vendor/use-sync-external-store/shim/index.js +0 -11
- package/dist/vendor/.bun/use-sync-external-store@1.7.0_62547eec5a2188e3/vendor/use-sync-external-store/shim/index.js.map +0 -1
|
@@ -0,0 +1,677 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zenith: Radix → Base UI consumer codemod, one transform for every family whose Base UI port
|
|
3
|
+
* changed the public API (DECISIONS.md D12: only overlay dismissal interceptors left the surface).
|
|
4
|
+
*
|
|
5
|
+
* bunx jscodeshift@17.3.0 --parser=tsx -t node_modules/@epilot/zenith-react/codemods/radix-to-base-ui.ts <paths>
|
|
6
|
+
*
|
|
7
|
+
* Rules:
|
|
8
|
+
* 1. The dismissal interceptors Radix took on an overlay's content part (`OVERLAYS` below lists
|
|
9
|
+
* which, per part) move into the enclosing root's `onOpenChange`, keyed on Base UI's
|
|
10
|
+
* `eventDetails.reason`. A handler that calls `preventDefault()` keeps the overlay open via
|
|
11
|
+
* `eventDetails.cancel()`, as it did under Radix. Radix's AlertDialogContent never let an outside
|
|
12
|
+
* press through, and its Select and Tooltip content never took the focus and interact handlers,
|
|
13
|
+
* so those parts list fewer props. FieldComboboxContent takes PopoverContent's props, so the
|
|
14
|
+
* same rule moves them to the enclosing FieldCombobox.
|
|
15
|
+
* 2. A DropdownMenu item's `onSelect` that calls `preventDefault()` to keep the menu open is
|
|
16
|
+
* reported: the menu closes regardless under Base UI, and the place to cancel it is the root's
|
|
17
|
+
* `onOpenChange` (`eventDetails.reason === "item-press"`), which needs to know which item was
|
|
18
|
+
* chosen.
|
|
19
|
+
* 3. Anything it cannot rewrite safely gets a `TODO(zenith-base-ui)` comment and is reported.
|
|
20
|
+
*
|
|
21
|
+
* Every other prop (`forceMount`, `loop`, `onCloseAutoFocus`, `sticky`, `position` and the other
|
|
22
|
+
* placement props, `value=""` for no selection) stays as it is: the wrappers still take them and
|
|
23
|
+
* translate them for Base UI.
|
|
24
|
+
*/
|
|
25
|
+
import { existsSync, readFileSync, statSync } from "node:fs"
|
|
26
|
+
import { dirname, resolve } from "node:path"
|
|
27
|
+
import type {
|
|
28
|
+
API,
|
|
29
|
+
ArrowFunctionExpression,
|
|
30
|
+
ASTPath,
|
|
31
|
+
BinaryExpression,
|
|
32
|
+
Collection,
|
|
33
|
+
ExpressionStatement,
|
|
34
|
+
FileInfo,
|
|
35
|
+
FunctionExpression,
|
|
36
|
+
IfStatement,
|
|
37
|
+
JSXAttribute,
|
|
38
|
+
JSXElement,
|
|
39
|
+
JSXFragment,
|
|
40
|
+
LogicalExpression,
|
|
41
|
+
Options,
|
|
42
|
+
VariableDeclaration,
|
|
43
|
+
} from "jscodeshift"
|
|
44
|
+
import { formatOutput } from "./format"
|
|
45
|
+
|
|
46
|
+
type J = API["jscodeshift"]
|
|
47
|
+
type Scope = ASTPath["scope"]
|
|
48
|
+
/** Where a reference is looked up: the file's AST, its path (imports resolve against it) and depth. */
|
|
49
|
+
type Lookup = { j: J; root: Collection; path: string; depth: number }
|
|
50
|
+
|
|
51
|
+
const ZENITH = "@epilot/zenith-react"
|
|
52
|
+
|
|
53
|
+
const DISMISS_REASONS: Record<string, string[]> = {
|
|
54
|
+
onEscapeKeyDown: ["escape-key"],
|
|
55
|
+
onPointerDownOutside: ["outside-press"],
|
|
56
|
+
onInteractOutside: ["outside-press", "focus-out"],
|
|
57
|
+
onFocusOutside: ["focus-out"],
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const ALL_DISMISSALS = Object.keys(DISMISS_REASONS)
|
|
61
|
+
|
|
62
|
+
/** Each content part, the root whose `onOpenChange` takes over its handlers, and which it took. */
|
|
63
|
+
const OVERLAYS = [
|
|
64
|
+
{ content: "DialogContent", root: "Dialog", props: ALL_DISMISSALS },
|
|
65
|
+
{
|
|
66
|
+
content: "AlertDialogContent",
|
|
67
|
+
root: "AlertDialog",
|
|
68
|
+
props: ["onEscapeKeyDown", "onFocusOutside"],
|
|
69
|
+
},
|
|
70
|
+
{ content: "DrawerContent", root: "Drawer", props: ALL_DISMISSALS },
|
|
71
|
+
{ content: "PopoverContent", root: "Popover", props: ALL_DISMISSALS },
|
|
72
|
+
{
|
|
73
|
+
content: "FieldComboboxContent",
|
|
74
|
+
root: "FieldCombobox",
|
|
75
|
+
props: ALL_DISMISSALS,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
content: "DropdownMenuContent",
|
|
79
|
+
root: "DropdownMenu",
|
|
80
|
+
props: ALL_DISMISSALS,
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
content: "DropdownMenuSubContent",
|
|
84
|
+
root: "DropdownMenuSub",
|
|
85
|
+
props: ALL_DISMISSALS,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
content: "SelectContent",
|
|
89
|
+
root: "Select",
|
|
90
|
+
props: ["onEscapeKeyDown", "onPointerDownOutside"],
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
content: "TooltipContent",
|
|
94
|
+
root: "Tooltip",
|
|
95
|
+
props: ["onEscapeKeyDown", "onPointerDownOutside"],
|
|
96
|
+
},
|
|
97
|
+
]
|
|
98
|
+
|
|
99
|
+
const MENU_ITEMS = [
|
|
100
|
+
"DropdownMenuItem",
|
|
101
|
+
"DropdownMenuCheckboxItem",
|
|
102
|
+
"DropdownMenuRadioItem",
|
|
103
|
+
]
|
|
104
|
+
|
|
105
|
+
const TODO = "TODO(zenith-base-ui)"
|
|
106
|
+
|
|
107
|
+
export const parser = "tsx"
|
|
108
|
+
|
|
109
|
+
export default async function transform(
|
|
110
|
+
file: FileInfo,
|
|
111
|
+
api: API,
|
|
112
|
+
options: Options
|
|
113
|
+
): Promise<string | undefined> {
|
|
114
|
+
const j = api.jscodeshift
|
|
115
|
+
const root = j(file.source)
|
|
116
|
+
const local = zenithLocalNames(j, root)
|
|
117
|
+
const overlays = OVERLAYS.filter(({ content }) => local[content]).map(
|
|
118
|
+
(overlay) => ({
|
|
119
|
+
...overlay,
|
|
120
|
+
localContent: local[overlay.content],
|
|
121
|
+
localRoot: local[overlay.root],
|
|
122
|
+
})
|
|
123
|
+
)
|
|
124
|
+
const items = new Set(MENU_ITEMS.map((name) => local[name]).filter(Boolean))
|
|
125
|
+
if (overlays.length === 0 && items.size === 0) return undefined
|
|
126
|
+
|
|
127
|
+
let changed = false
|
|
128
|
+
const todos: string[] = []
|
|
129
|
+
|
|
130
|
+
const elementName = (el: JSXElement) => {
|
|
131
|
+
const name = el.openingElement.name
|
|
132
|
+
return name.type === "JSXIdentifier" ? name.name : undefined
|
|
133
|
+
}
|
|
134
|
+
const attrsOf = (el: JSXElement) =>
|
|
135
|
+
el.openingElement.attributes!.filter(
|
|
136
|
+
(a): a is JSXAttribute => a.type === "JSXAttribute"
|
|
137
|
+
)
|
|
138
|
+
const attr = (el: JSXElement, name: string) =>
|
|
139
|
+
attrsOf(el).find((a) => a.name.name === name)
|
|
140
|
+
const removeAttr = (el: JSXElement, node: JSXAttribute) => {
|
|
141
|
+
el.openingElement.attributes = el.openingElement.attributes!.filter(
|
|
142
|
+
(a) => a !== node
|
|
143
|
+
)
|
|
144
|
+
}
|
|
145
|
+
const addTodo = (path: ASTPath<JSXElement>, message: string) => {
|
|
146
|
+
const line = path.node.loc?.start.line
|
|
147
|
+
todos.push(`${file.path}:${line ?? "?"} ${message}`)
|
|
148
|
+
const text = `${TODO}: ${message}`
|
|
149
|
+
// A rerun over already-migrated output reports the place again but does not stack a
|
|
150
|
+
// second copy of the same comment.
|
|
151
|
+
const parent = path.parent?.node as JSXElement | JSXFragment | undefined
|
|
152
|
+
if (parent?.type === "JSXElement" || parent?.type === "JSXFragment") {
|
|
153
|
+
// Among JSX children a bare comment renders as text, so it goes in braces before the element.
|
|
154
|
+
const siblings = parent.children ?? []
|
|
155
|
+
const index = siblings.indexOf(path.node)
|
|
156
|
+
const before = siblings[index - 1]
|
|
157
|
+
const beforeThat = siblings[index - 2]
|
|
158
|
+
if (
|
|
159
|
+
beforeThat?.type === "JSXExpressionContainer" &&
|
|
160
|
+
j(beforeThat).toSource().includes(text)
|
|
161
|
+
)
|
|
162
|
+
return
|
|
163
|
+
const indent =
|
|
164
|
+
before?.type === "JSXText"
|
|
165
|
+
? (/\n([ \t]*)$/.exec(before.value)?.[1] ?? "")
|
|
166
|
+
: ""
|
|
167
|
+
const empty = j.jsxEmptyExpression()
|
|
168
|
+
;(empty as { comments?: unknown[] }).comments = [
|
|
169
|
+
j.commentBlock(` ${text} `, false, true),
|
|
170
|
+
]
|
|
171
|
+
siblings.splice(
|
|
172
|
+
index,
|
|
173
|
+
0,
|
|
174
|
+
j.jsxExpressionContainer(empty),
|
|
175
|
+
j.jsxText(`\n${indent}`)
|
|
176
|
+
)
|
|
177
|
+
return
|
|
178
|
+
}
|
|
179
|
+
// The parser hands a leading comment to the element itself, the transform to its opening tag.
|
|
180
|
+
const existing = [
|
|
181
|
+
...(path.node.comments ?? []),
|
|
182
|
+
...(path.node.openingElement.comments ?? []),
|
|
183
|
+
]
|
|
184
|
+
if (existing.some((c) => String(c.value).includes(text))) return
|
|
185
|
+
const comment = j.commentBlock(` ${text} `, true, false)
|
|
186
|
+
path.node.openingElement.comments = [
|
|
187
|
+
...(path.node.openingElement.comments ?? []),
|
|
188
|
+
comment,
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Rule 1: dismissal interceptors move to the root's onOpenChange.
|
|
193
|
+
for (const overlay of overlays)
|
|
194
|
+
root
|
|
195
|
+
.find(j.JSXElement)
|
|
196
|
+
.filter((p) => elementName(p.node) === overlay.localContent)
|
|
197
|
+
.forEach((contentPath) => {
|
|
198
|
+
const handlers = overlay.props
|
|
199
|
+
.map((prop) => ({ prop, node: attr(contentPath.node, prop) }))
|
|
200
|
+
.filter((h): h is { prop: string; node: JSXAttribute } => !!h.node)
|
|
201
|
+
if (handlers.length === 0) return
|
|
202
|
+
|
|
203
|
+
const rootPath = closestElement(
|
|
204
|
+
contentPath,
|
|
205
|
+
(el) => !!overlay.localRoot && elementName(el) === overlay.localRoot
|
|
206
|
+
)
|
|
207
|
+
const values = handlers.map((h) => h.node.value)
|
|
208
|
+
if (
|
|
209
|
+
!rootPath ||
|
|
210
|
+
values.some((v) => v?.type !== "JSXExpressionContainer")
|
|
211
|
+
) {
|
|
212
|
+
addTodo(
|
|
213
|
+
contentPath,
|
|
214
|
+
`${handlers.map((h) => h.prop).join(", ")} ${handlers.length > 1 ? "are" : "is"} ` +
|
|
215
|
+
`not on ${overlay.content} any more; handle eventDetails.reason in the ${overlay.root}'s onOpenChange`
|
|
216
|
+
)
|
|
217
|
+
return
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// Each handler is evaluated once per dismissal, in Radix's order, on the native event.
|
|
221
|
+
const checks: IfStatement[] = []
|
|
222
|
+
for (const h of handlers) {
|
|
223
|
+
const value = (h.node.value as unknown as { expression: never })
|
|
224
|
+
.expression
|
|
225
|
+
const reasons = DISMISS_REASONS[h.prop]
|
|
226
|
+
const comparisons: Array<BinaryExpression | LogicalExpression> =
|
|
227
|
+
reasons.map((reason) =>
|
|
228
|
+
j.binaryExpression(
|
|
229
|
+
"===",
|
|
230
|
+
j.memberExpression(
|
|
231
|
+
j.identifier("eventDetails"),
|
|
232
|
+
j.identifier("reason")
|
|
233
|
+
),
|
|
234
|
+
j.stringLiteral(reason)
|
|
235
|
+
)
|
|
236
|
+
)
|
|
237
|
+
const test = comparisons.reduce((a, b) =>
|
|
238
|
+
j.logicalExpression("||", a, b)
|
|
239
|
+
)
|
|
240
|
+
const withEvent = handlerTakesEvent(
|
|
241
|
+
{ j, root, path: file.path, depth: 0 },
|
|
242
|
+
contentPath.scope,
|
|
243
|
+
value
|
|
244
|
+
)
|
|
245
|
+
checks.push(
|
|
246
|
+
j.ifStatement(
|
|
247
|
+
test,
|
|
248
|
+
j.expressionStatement(callHandler(j, value, withEvent))
|
|
249
|
+
)
|
|
250
|
+
)
|
|
251
|
+
removeAttr(contentPath.node, h.node)
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const dismissal: Array<VariableDeclaration | IfStatement> = [
|
|
255
|
+
j.variableDeclaration("const", [
|
|
256
|
+
j.variableDeclarator(
|
|
257
|
+
j.identifier("wasPrevented"),
|
|
258
|
+
eventField(j, "defaultPrevented")
|
|
259
|
+
),
|
|
260
|
+
]),
|
|
261
|
+
...checks,
|
|
262
|
+
j.ifStatement(
|
|
263
|
+
j.logicalExpression(
|
|
264
|
+
"&&",
|
|
265
|
+
j.unaryExpression("!", j.identifier("wasPrevented")),
|
|
266
|
+
eventField(j, "defaultPrevented")
|
|
267
|
+
),
|
|
268
|
+
j.returnStatement(
|
|
269
|
+
j.callExpression(
|
|
270
|
+
j.memberExpression(
|
|
271
|
+
j.identifier("eventDetails"),
|
|
272
|
+
j.identifier("cancel")
|
|
273
|
+
),
|
|
274
|
+
[]
|
|
275
|
+
)
|
|
276
|
+
)
|
|
277
|
+
),
|
|
278
|
+
]
|
|
279
|
+
|
|
280
|
+
const rootEl = rootPath.node
|
|
281
|
+
const existing = attr(rootEl, "onOpenChange")
|
|
282
|
+
const expression =
|
|
283
|
+
existing?.value?.type === "JSXExpressionContainer"
|
|
284
|
+
? existing.value.expression
|
|
285
|
+
: undefined
|
|
286
|
+
|
|
287
|
+
let next: ArrowFunctionExpression | FunctionExpression
|
|
288
|
+
if (
|
|
289
|
+
expression &&
|
|
290
|
+
(expression.type === "ArrowFunctionExpression" ||
|
|
291
|
+
expression.type === "FunctionExpression") &&
|
|
292
|
+
expression.params.length <= 1
|
|
293
|
+
) {
|
|
294
|
+
// Reuse the caller's own callback: add the details parameter and prepend the checks.
|
|
295
|
+
next = expression
|
|
296
|
+
if (next.params.length === 0) next.params.push(j.identifier("_open"))
|
|
297
|
+
next.params.push(j.identifier("eventDetails"))
|
|
298
|
+
const body =
|
|
299
|
+
next.body.type === "BlockStatement"
|
|
300
|
+
? next.body.body
|
|
301
|
+
: [j.expressionStatement(next.body)]
|
|
302
|
+
next.body = j.blockStatement([...dismissal, ...body])
|
|
303
|
+
if (next.type === "ArrowFunctionExpression") next.expression = false
|
|
304
|
+
} else {
|
|
305
|
+
const forward: ExpressionStatement[] =
|
|
306
|
+
expression && expression.type !== "JSXEmptyExpression"
|
|
307
|
+
? [
|
|
308
|
+
j.expressionStatement(
|
|
309
|
+
j.optionalCallExpression(
|
|
310
|
+
expression,
|
|
311
|
+
[j.identifier("open")],
|
|
312
|
+
true
|
|
313
|
+
)
|
|
314
|
+
),
|
|
315
|
+
]
|
|
316
|
+
: []
|
|
317
|
+
next = j.arrowFunctionExpression(
|
|
318
|
+
[
|
|
319
|
+
j.identifier(forward.length ? "open" : "_open"),
|
|
320
|
+
j.identifier("eventDetails"),
|
|
321
|
+
],
|
|
322
|
+
j.blockStatement([...dismissal, ...forward])
|
|
323
|
+
)
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
const replacement = j.jsxAttribute(
|
|
327
|
+
j.jsxIdentifier("onOpenChange"),
|
|
328
|
+
j.jsxExpressionContainer(next)
|
|
329
|
+
)
|
|
330
|
+
if (existing) {
|
|
331
|
+
rootEl.openingElement.attributes =
|
|
332
|
+
rootEl.openingElement.attributes!.map((a) =>
|
|
333
|
+
a === existing ? replacement : a
|
|
334
|
+
)
|
|
335
|
+
} else {
|
|
336
|
+
rootEl.openingElement.attributes!.push(replacement)
|
|
337
|
+
}
|
|
338
|
+
changed = true
|
|
339
|
+
})
|
|
340
|
+
|
|
341
|
+
// Rule 2: onSelect can no longer keep the menu open.
|
|
342
|
+
root
|
|
343
|
+
.find(j.JSXElement)
|
|
344
|
+
.filter((p) => items.has(elementName(p.node) ?? ""))
|
|
345
|
+
.forEach((itemPath) => {
|
|
346
|
+
const onSelect = attr(itemPath.node, "onSelect")
|
|
347
|
+
if (!onSelect || !j(onSelect).toSource().includes("preventDefault"))
|
|
348
|
+
return
|
|
349
|
+
addTodo(
|
|
350
|
+
itemPath,
|
|
351
|
+
"onSelect's preventDefault() no longer keeps the menu open; cancel it in the DropdownMenu's onOpenChange when eventDetails.reason is \"item-press\""
|
|
352
|
+
)
|
|
353
|
+
})
|
|
354
|
+
|
|
355
|
+
for (const todo of todos) api.report(todo)
|
|
356
|
+
if (todos.length) changed = true
|
|
357
|
+
|
|
358
|
+
return changed
|
|
359
|
+
? formatOutput(
|
|
360
|
+
root.toSource({ quote: options.quote ?? "single" }),
|
|
361
|
+
file.path
|
|
362
|
+
)
|
|
363
|
+
: undefined
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function zenithLocalNames(j: API["jscodeshift"], root: Collection) {
|
|
367
|
+
const names: Record<string, string> = {}
|
|
368
|
+
root.find(j.ImportDeclaration, { source: { value: ZENITH } }).forEach((p) => {
|
|
369
|
+
for (const s of p.node.specifiers ?? []) {
|
|
370
|
+
if (s.type !== "ImportSpecifier") continue
|
|
371
|
+
names[String(s.imported.name)] = String(s.local?.name ?? s.imported.name)
|
|
372
|
+
}
|
|
373
|
+
})
|
|
374
|
+
return names
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
function closestElement(
|
|
378
|
+
path: ASTPath<JSXElement>,
|
|
379
|
+
match: (el: JSXElement) => boolean
|
|
380
|
+
): ASTPath<JSXElement> | undefined {
|
|
381
|
+
let current = path.parent as ASTPath | null
|
|
382
|
+
while (current) {
|
|
383
|
+
if (
|
|
384
|
+
current.node.type === "JSXElement" &&
|
|
385
|
+
match(current.node as JSXElement)
|
|
386
|
+
) {
|
|
387
|
+
return current as ASTPath<JSXElement>
|
|
388
|
+
}
|
|
389
|
+
current = current.parent
|
|
390
|
+
}
|
|
391
|
+
return undefined
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
function eventField(j: API["jscodeshift"], field: string) {
|
|
395
|
+
return j.memberExpression(
|
|
396
|
+
j.memberExpression(j.identifier("eventDetails"), j.identifier("event")),
|
|
397
|
+
j.identifier(field)
|
|
398
|
+
)
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
function callHandler(j: J, handler: never, withEvent: boolean) {
|
|
402
|
+
const h = handler as { type: string }
|
|
403
|
+
const args = withEvent
|
|
404
|
+
? [j.memberExpression(j.identifier("eventDetails"), j.identifier("event"))]
|
|
405
|
+
: []
|
|
406
|
+
// An inline function is always defined; a reference may be undefined (a conditional handler).
|
|
407
|
+
return h.type === "ArrowFunctionExpression" || h.type === "FunctionExpression"
|
|
408
|
+
? j.callExpression(handler, args)
|
|
409
|
+
: j.optionalCallExpression(handler, args, true)
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* Whether the handler is called with the event. A function that takes no parameter is called
|
|
414
|
+
* without it, so the output typechecks (TS2554): an inline function by its own parameters, a
|
|
415
|
+
* reference by the declaration it resolves to, in this file or in a relative import (a `const`
|
|
416
|
+
* or `function` declaration, `useCallback`, a type annotation, a destructured prop whose type is
|
|
417
|
+
* written in the file). A reference the file cannot explain (a package import, a member
|
|
418
|
+
* expression, a conditional) gets the event: an extra argument is harmless at runtime, and
|
|
419
|
+
* TypeScript reports the rare zero-parameter case.
|
|
420
|
+
*/
|
|
421
|
+
function handlerTakesEvent(
|
|
422
|
+
lookup: Lookup,
|
|
423
|
+
scope: Scope,
|
|
424
|
+
handler: { type: string; params?: unknown[]; name?: string }
|
|
425
|
+
): boolean {
|
|
426
|
+
if (
|
|
427
|
+
handler.type === "ArrowFunctionExpression" ||
|
|
428
|
+
handler.type === "FunctionExpression"
|
|
429
|
+
)
|
|
430
|
+
return (handler.params?.length ?? 0) > 0
|
|
431
|
+
if (handler.type !== "Identifier" || !handler.name) return true
|
|
432
|
+
const arity = referenceArity(lookup, scope, handler.name)
|
|
433
|
+
return arity === undefined || arity > 0
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
const MAX_DEPTH = 8
|
|
437
|
+
|
|
438
|
+
/** The number of parameters `name` is declared with, or undefined when the file does not say. */
|
|
439
|
+
function referenceArity(
|
|
440
|
+
lookup: Lookup,
|
|
441
|
+
scope: Scope,
|
|
442
|
+
name: string
|
|
443
|
+
): number | undefined {
|
|
444
|
+
if (lookup.depth > MAX_DEPTH) return undefined
|
|
445
|
+
const declaring = scope?.lookup(name)
|
|
446
|
+
const [binding] = declaring?.getBindings()[name] ?? []
|
|
447
|
+
return binding ? bindingArity(lookup, binding) : undefined
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
function bindingArity(lookup: Lookup, binding: ASTPath): number | undefined {
|
|
451
|
+
const { j } = lookup
|
|
452
|
+
const id = binding.node
|
|
453
|
+
const parent = binding.parent?.node
|
|
454
|
+
// `const close: () => void = …`, a parameter `close: () => void`
|
|
455
|
+
if (j.Identifier.check(id) && id.typeAnnotation) {
|
|
456
|
+
const arity = typeArity(lookup, id.typeAnnotation.typeAnnotation)
|
|
457
|
+
if (arity !== undefined) return arity
|
|
458
|
+
}
|
|
459
|
+
if (j.VariableDeclarator.check(parent) && binding.name === "id")
|
|
460
|
+
return parent.init
|
|
461
|
+
? expressionArity(lookup, binding.parent.scope, parent.init)
|
|
462
|
+
: undefined
|
|
463
|
+
if (j.FunctionDeclaration.check(parent) && binding.name === "id")
|
|
464
|
+
return parent.params.length
|
|
465
|
+
if (
|
|
466
|
+
j.ImportSpecifier.check(parent) ||
|
|
467
|
+
j.ImportDefaultSpecifier.check(parent)
|
|
468
|
+
) {
|
|
469
|
+
const declaration = binding.parent.parent?.node
|
|
470
|
+
if (!j.ImportDeclaration.check(declaration)) return undefined
|
|
471
|
+
const imported = j.ImportSpecifier.check(parent)
|
|
472
|
+
? String(parent.imported.name)
|
|
473
|
+
: "default"
|
|
474
|
+
return importedArity(lookup, String(declaration.source.value), imported)
|
|
475
|
+
}
|
|
476
|
+
// `({ onClose }: { onClose: () => void }) => …`: the destructured prop's type
|
|
477
|
+
if (
|
|
478
|
+
(j.ObjectProperty.check(parent) || j.Property.check(parent)) &&
|
|
479
|
+
binding.name === "value"
|
|
480
|
+
) {
|
|
481
|
+
const pattern = binding.parent.parent?.node
|
|
482
|
+
const key = parent.key
|
|
483
|
+
const keyName = j.Identifier.check(key)
|
|
484
|
+
? key.name
|
|
485
|
+
: j.StringLiteral.check(key)
|
|
486
|
+
? key.value
|
|
487
|
+
: undefined
|
|
488
|
+
if (
|
|
489
|
+
!j.ObjectPattern.check(pattern) ||
|
|
490
|
+
!pattern.typeAnnotation ||
|
|
491
|
+
keyName === undefined
|
|
492
|
+
)
|
|
493
|
+
return undefined
|
|
494
|
+
const members = typeMembers(lookup, pattern.typeAnnotation.typeAnnotation)
|
|
495
|
+
for (const member of members ?? []) {
|
|
496
|
+
const memberKey = (member as { key?: unknown }).key
|
|
497
|
+
const memberName = j.Identifier.check(memberKey)
|
|
498
|
+
? memberKey.name
|
|
499
|
+
: j.StringLiteral.check(memberKey)
|
|
500
|
+
? memberKey.value
|
|
501
|
+
: undefined
|
|
502
|
+
if (memberName !== keyName) continue
|
|
503
|
+
if (j.TSMethodSignature.check(member)) return member.parameters.length
|
|
504
|
+
if (j.TSPropertySignature.check(member))
|
|
505
|
+
return member.typeAnnotation
|
|
506
|
+
? typeArity(lookup, member.typeAnnotation.typeAnnotation)
|
|
507
|
+
: undefined
|
|
508
|
+
return undefined
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
return undefined
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
function expressionArity(
|
|
515
|
+
lookup: Lookup,
|
|
516
|
+
scope: Scope,
|
|
517
|
+
expression: unknown
|
|
518
|
+
): number | undefined {
|
|
519
|
+
const { j } = lookup
|
|
520
|
+
if (
|
|
521
|
+
j.ArrowFunctionExpression.check(expression) ||
|
|
522
|
+
j.FunctionExpression.check(expression)
|
|
523
|
+
)
|
|
524
|
+
return expression.params.length
|
|
525
|
+
if (j.Identifier.check(expression))
|
|
526
|
+
return referenceArity(
|
|
527
|
+
{ ...lookup, depth: lookup.depth + 1 },
|
|
528
|
+
scope,
|
|
529
|
+
expression.name
|
|
530
|
+
)
|
|
531
|
+
if (j.TSAsExpression.check(expression))
|
|
532
|
+
return (
|
|
533
|
+
typeArity(lookup, expression.typeAnnotation) ??
|
|
534
|
+
expressionArity(lookup, scope, expression.expression)
|
|
535
|
+
)
|
|
536
|
+
if (j.TSNonNullExpression.check(expression))
|
|
537
|
+
return expressionArity(lookup, scope, expression.expression)
|
|
538
|
+
// `useCallback(() => …, [])`: the callback's own parameters
|
|
539
|
+
if (j.CallExpression.check(expression)) {
|
|
540
|
+
const { callee } = expression
|
|
541
|
+
const hook = j.Identifier.check(callee)
|
|
542
|
+
? callee.name
|
|
543
|
+
: j.MemberExpression.check(callee) && j.Identifier.check(callee.property)
|
|
544
|
+
? callee.property.name
|
|
545
|
+
: undefined
|
|
546
|
+
return hook === "useCallback"
|
|
547
|
+
? expressionArity(lookup, scope, expression.arguments[0])
|
|
548
|
+
: undefined
|
|
549
|
+
}
|
|
550
|
+
return undefined
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
/** The parameter count of a function type, through unions with undefined and aliases in the file. */
|
|
554
|
+
function typeArity(lookup: Lookup, type: unknown): number | undefined {
|
|
555
|
+
const { j, root } = lookup
|
|
556
|
+
if (j.TSFunctionType.check(type)) return type.parameters.length
|
|
557
|
+
if (j.TSParenthesizedType.check(type))
|
|
558
|
+
return typeArity(lookup, type.typeAnnotation)
|
|
559
|
+
if (j.TSUnionType.check(type)) {
|
|
560
|
+
const arities = type.types
|
|
561
|
+
.filter(
|
|
562
|
+
(t) => !j.TSUndefinedKeyword.check(t) && !j.TSNullKeyword.check(t)
|
|
563
|
+
)
|
|
564
|
+
.map((t) => typeArity(lookup, t))
|
|
565
|
+
return arities.length && arities.every((a) => a !== undefined)
|
|
566
|
+
? Math.max(...(arities as number[]))
|
|
567
|
+
: undefined
|
|
568
|
+
}
|
|
569
|
+
if (
|
|
570
|
+
j.TSTypeReference.check(type) &&
|
|
571
|
+
j.Identifier.check(type.typeName) &&
|
|
572
|
+
!type.typeParameters &&
|
|
573
|
+
lookup.depth <= MAX_DEPTH
|
|
574
|
+
) {
|
|
575
|
+
const alias = root
|
|
576
|
+
.find(j.TSTypeAliasDeclaration, { id: { name: type.typeName.name } })
|
|
577
|
+
.nodes()[0]
|
|
578
|
+
return alias
|
|
579
|
+
? typeArity({ ...lookup, depth: lookup.depth + 1 }, alias.typeAnnotation)
|
|
580
|
+
: undefined
|
|
581
|
+
}
|
|
582
|
+
return undefined
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
/** The members of an object type written in the file: a literal, an alias, an interface, an intersection. */
|
|
586
|
+
function typeMembers(lookup: Lookup, type: unknown): unknown[] | undefined {
|
|
587
|
+
const { j, root } = lookup
|
|
588
|
+
if (j.TSTypeLiteral.check(type)) return type.members
|
|
589
|
+
if (j.TSParenthesizedType.check(type))
|
|
590
|
+
return typeMembers(lookup, type.typeAnnotation)
|
|
591
|
+
// A member found in one part of an intersection is one of the property's overloads.
|
|
592
|
+
if (j.TSIntersectionType.check(type))
|
|
593
|
+
return type.types.flatMap((t) => typeMembers(lookup, t) ?? [])
|
|
594
|
+
if (
|
|
595
|
+
j.TSTypeReference.check(type) &&
|
|
596
|
+
j.Identifier.check(type.typeName) &&
|
|
597
|
+
!type.typeParameters &&
|
|
598
|
+
lookup.depth <= MAX_DEPTH
|
|
599
|
+
) {
|
|
600
|
+
const name = type.typeName.name
|
|
601
|
+
const deeper = { ...lookup, depth: lookup.depth + 1 }
|
|
602
|
+
const alias = root
|
|
603
|
+
.find(j.TSTypeAliasDeclaration, { id: { name } })
|
|
604
|
+
.nodes()[0]
|
|
605
|
+
if (alias) return typeMembers(deeper, alias.typeAnnotation)
|
|
606
|
+
// An interface's own members; one inherited through `extends` stays unknown.
|
|
607
|
+
const iface = root
|
|
608
|
+
.find(j.TSInterfaceDeclaration, { id: { name } })
|
|
609
|
+
.nodes()[0]
|
|
610
|
+
return iface?.body.body
|
|
611
|
+
}
|
|
612
|
+
return undefined
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
const MODULE_SUFFIXES = [
|
|
616
|
+
"",
|
|
617
|
+
".ts",
|
|
618
|
+
".tsx",
|
|
619
|
+
".js",
|
|
620
|
+
".jsx",
|
|
621
|
+
".mjs",
|
|
622
|
+
"/index.ts",
|
|
623
|
+
"/index.tsx",
|
|
624
|
+
"/index.js",
|
|
625
|
+
]
|
|
626
|
+
|
|
627
|
+
/** The arity of `imported` from a relative module, read from disk; a package import stays unknown. */
|
|
628
|
+
function importedArity(
|
|
629
|
+
lookup: Lookup,
|
|
630
|
+
source: string,
|
|
631
|
+
imported: string
|
|
632
|
+
): number | undefined {
|
|
633
|
+
if (!source.startsWith(".") || lookup.depth > MAX_DEPTH) return undefined
|
|
634
|
+
const base = resolve(dirname(lookup.path), source)
|
|
635
|
+
const file = MODULE_SUFFIXES.map((suffix) => base + suffix).find(
|
|
636
|
+
(candidate) => existsSync(candidate) && statSync(candidate).isFile()
|
|
637
|
+
)
|
|
638
|
+
if (!file) return undefined
|
|
639
|
+
const { j } = lookup
|
|
640
|
+
let root: Collection
|
|
641
|
+
try {
|
|
642
|
+
root = j(readFileSync(file, "utf8"))
|
|
643
|
+
} catch {
|
|
644
|
+
return undefined
|
|
645
|
+
}
|
|
646
|
+
const other: Lookup = { j, root, path: file, depth: lookup.depth + 1 }
|
|
647
|
+
const program = root.find(j.Program).paths()[0]
|
|
648
|
+
const local = (name: string) => referenceArity(other, program.scope, name)
|
|
649
|
+
|
|
650
|
+
if (imported === "default") {
|
|
651
|
+
const declaration = root
|
|
652
|
+
.find(j.ExportDefaultDeclaration)
|
|
653
|
+
.nodes()[0]?.declaration
|
|
654
|
+
if (j.Identifier.check(declaration)) return local(declaration.name)
|
|
655
|
+
if (j.FunctionDeclaration.check(declaration))
|
|
656
|
+
return declaration.params.length
|
|
657
|
+
return expressionArity(other, program.scope, declaration)
|
|
658
|
+
}
|
|
659
|
+
for (const node of root.find(j.ExportNamedDeclaration).nodes()) {
|
|
660
|
+
for (const specifier of node.specifiers ?? []) {
|
|
661
|
+
if (!j.ExportSpecifier.check(specifier)) continue
|
|
662
|
+
if (String(specifier.exported.name) !== imported) continue
|
|
663
|
+
const localName = String(specifier.local?.name ?? specifier.exported.name)
|
|
664
|
+
return node.source
|
|
665
|
+
? importedArity(other, String(node.source.value), localName)
|
|
666
|
+
: local(localName)
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
// `export const close = …` and `export function close() {}` are program-scope bindings.
|
|
670
|
+
const own = local(imported)
|
|
671
|
+
if (own !== undefined) return own
|
|
672
|
+
for (const node of root.find(j.ExportAllDeclaration).nodes()) {
|
|
673
|
+
const through = importedArity(other, String(node.source.value), imported)
|
|
674
|
+
if (through !== undefined) return through
|
|
675
|
+
}
|
|
676
|
+
return undefined
|
|
677
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_zenith-runtime-family_accordion.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { servedFamily as o } from "../renderer/served.js";
|
|
2
|
+
import { alertDialog as r } from "@epilot/zenith-runtime/v1";
|
|
3
|
+
const e = o("alertDialog", r), a = e.AlertDialog;
|
|
4
|
+
export {
|
|
5
|
+
a as AlertDialog
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=_zenith-runtime-family_alert-dialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_zenith-runtime-family_alert-dialog.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|