@epilot/zenith-react 0.2.0-next.3 → 0.2.0-next.4
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 +25 -0
- package/codemods/README.md +168 -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 +20 -0
- package/codemods/migrate/from-volt.ts +20 -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 +389 -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 +87 -77
- package/dist/components/field/field-combobox.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 +83 -53
- 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 +2335 -2129
- 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 +34 -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 +28 -21
- package/scripts/migration-diagnostics-core.mjs +18 -10
- package/scripts/migration-diagnostics.mjs +31 -8
- 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,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry of base-elements rules. One module per component; every module exports `handles` and
|
|
3
|
+
* `migrate` (see `../lib/types.ts`). Order does not matter: each legacy name has exactly one
|
|
4
|
+
* owner, and the runner rejects duplicates.
|
|
5
|
+
*/
|
|
6
|
+
import type { MigrationRule } from "../lib/types"
|
|
7
|
+
import * as accordion from "./accordion"
|
|
8
|
+
import * as alert from "./alert"
|
|
9
|
+
import * as avatar from "./avatar"
|
|
10
|
+
import * as button from "./button"
|
|
11
|
+
import * as checkbox from "./checkbox"
|
|
12
|
+
import * as chip from "./chip"
|
|
13
|
+
import * as chip360 from "./chip360"
|
|
14
|
+
import * as circularProgress from "./circular-progress"
|
|
15
|
+
import * as dialog from "./dialog"
|
|
16
|
+
import * as iconButton from "./icon-button"
|
|
17
|
+
import * as divider from "./divider"
|
|
18
|
+
import * as feedbackMessage from "./feedback-message"
|
|
19
|
+
import * as notification from "./notification"
|
|
20
|
+
import * as paper from "./paper"
|
|
21
|
+
import * as select from "./select"
|
|
22
|
+
import * as skeleton from "./skeleton"
|
|
23
|
+
import * as switchControl from "./switch"
|
|
24
|
+
import * as tabs from "./tabs"
|
|
25
|
+
import * as textField from "./text-field"
|
|
26
|
+
import * as toggleButton from "./toggle-button"
|
|
27
|
+
import * as tooltip from "./tooltip"
|
|
28
|
+
import * as typography from "./typography"
|
|
29
|
+
import * as unsupported from "./unsupported"
|
|
30
|
+
|
|
31
|
+
export const rules: readonly MigrationRule[] = [
|
|
32
|
+
circularProgress,
|
|
33
|
+
divider,
|
|
34
|
+
skeleton,
|
|
35
|
+
avatar,
|
|
36
|
+
paper,
|
|
37
|
+
chip,
|
|
38
|
+
chip360,
|
|
39
|
+
unsupported,
|
|
40
|
+
button,
|
|
41
|
+
dialog,
|
|
42
|
+
textField,
|
|
43
|
+
typography,
|
|
44
|
+
tooltip,
|
|
45
|
+
switchControl,
|
|
46
|
+
checkbox,
|
|
47
|
+
tabs,
|
|
48
|
+
iconButton,
|
|
49
|
+
select,
|
|
50
|
+
alert,
|
|
51
|
+
notification,
|
|
52
|
+
feedbackMessage,
|
|
53
|
+
accordion,
|
|
54
|
+
toggleButton,
|
|
55
|
+
]
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MUI v4 props that every base-elements component accepts and no Zenith component does. A rule
|
|
3
|
+
* drops them from a moved element and reports each with its replacement.
|
|
4
|
+
*/
|
|
5
|
+
import type { ASTPath, JSXElement } from "jscodeshift"
|
|
6
|
+
import type { MigrateContext } from "../lib/types"
|
|
7
|
+
|
|
8
|
+
export const MUI_PROP_HINTS: Record<string, string> = {
|
|
9
|
+
classes: "style the slot with makeZenithStyles and pass className",
|
|
10
|
+
component:
|
|
11
|
+
"the element renders its own tag; wrap it, or use asChild where the part offers it",
|
|
12
|
+
innerRef: "use ref (every Zenith component forwards it)",
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Drops `names` (default: the MUI set) from the element, one TODO per prop found. */
|
|
16
|
+
export function dropWithHint(
|
|
17
|
+
ctx: MigrateContext,
|
|
18
|
+
path: ASTPath<JSXElement>,
|
|
19
|
+
component: string,
|
|
20
|
+
hints: Record<string, string> = MUI_PROP_HINTS
|
|
21
|
+
): void {
|
|
22
|
+
for (const [name, hint] of Object.entries(hints)) {
|
|
23
|
+
const attr = ctx.jsx.attr(path.node, name)
|
|
24
|
+
if (!attr) continue
|
|
25
|
+
const printed = ctx.jsx.print(attr)
|
|
26
|
+
ctx.jsx.removeAttr(path.node, name)
|
|
27
|
+
ctx.todo(path, component, `dropped ${printed}: ${hint}`)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notification, InfoNotification, ErrorNotification, SuccessNotification → Callout.
|
|
3
|
+
*
|
|
4
|
+
* - `title` → `CalloutTitle`; `message` and the children → `CalloutDescription`.
|
|
5
|
+
* - `severity` → `variant` (error → destructive; Notification's default info is Callout's too).
|
|
6
|
+
* The Info/Error/Success variants fix it and hide the icon, as they did.
|
|
7
|
+
* - `visible` (default false: the notification collapsed) → rendered when it is set,
|
|
8
|
+
* `{visible && <Callout …>}`; an absent `visible` is reported, since MUI rendered nothing.
|
|
9
|
+
* - `onClose` → `dismissible onDismiss`.
|
|
10
|
+
*/
|
|
11
|
+
import type { ASTPath, JSXElement } from "jscodeshift"
|
|
12
|
+
import type { MigrateContext } from "../lib/types"
|
|
13
|
+
import {
|
|
14
|
+
SEVERITY,
|
|
15
|
+
attrValue,
|
|
16
|
+
fillCallout,
|
|
17
|
+
isTrue,
|
|
18
|
+
mapAttr,
|
|
19
|
+
printAttrs,
|
|
20
|
+
renderWhen,
|
|
21
|
+
takeAttrs,
|
|
22
|
+
moveElements,
|
|
23
|
+
} from "./shared"
|
|
24
|
+
|
|
25
|
+
const FIXED: Record<string, string | undefined> = {
|
|
26
|
+
Notification: undefined,
|
|
27
|
+
InfoNotification: "info",
|
|
28
|
+
ErrorNotification: "destructive",
|
|
29
|
+
SuccessNotification: "success",
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const handles = [...Object.keys(FIXED), "BaseNotificationProps"] as const
|
|
33
|
+
|
|
34
|
+
export function migrate(ctx: MigrateContext): void {
|
|
35
|
+
for (const name of Object.keys(FIXED)) {
|
|
36
|
+
moveElements(ctx, name, "Callout", (path) =>
|
|
37
|
+
migrateNotification(ctx, path, name)
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
ctx.move("BaseNotificationProps", "CalloutProps")
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function migrateNotification(
|
|
44
|
+
ctx: MigrateContext,
|
|
45
|
+
path: ASTPath<JSXElement>,
|
|
46
|
+
component: string
|
|
47
|
+
): void {
|
|
48
|
+
const { j, jsx } = ctx
|
|
49
|
+
const el = path.node
|
|
50
|
+
const reported: string[] = []
|
|
51
|
+
|
|
52
|
+
const fixed = FIXED[component]
|
|
53
|
+
if (fixed) {
|
|
54
|
+
jsx.removeAttr(el, "severity")
|
|
55
|
+
if (fixed !== "info") jsx.setAttr(el, "variant", fixed)
|
|
56
|
+
jsx.setAttr(el, "hideIcon", null)
|
|
57
|
+
} else if (
|
|
58
|
+
!mapAttr(ctx, el, "severity", SEVERITY, {
|
|
59
|
+
rename: "variant",
|
|
60
|
+
fallback: "info",
|
|
61
|
+
})
|
|
62
|
+
)
|
|
63
|
+
reported.push(
|
|
64
|
+
`dropped ${printAttrs(ctx, takeAttrs(ctx, el, ["severity"]))} (variant: success | info | warning | destructive)`
|
|
65
|
+
)
|
|
66
|
+
takeAttrs(ctx, el, ["color", "elevation"])
|
|
67
|
+
const unsupported = takeAttrs(ctx, el, [
|
|
68
|
+
"icon",
|
|
69
|
+
"iconMapping",
|
|
70
|
+
"closeText",
|
|
71
|
+
"classes",
|
|
72
|
+
])
|
|
73
|
+
if (unsupported.length)
|
|
74
|
+
reported.push(
|
|
75
|
+
`dropped ${printAttrs(ctx, unsupported)} (no Callout equivalent)`
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
const message = jsx.removeAttr(el, "message")
|
|
79
|
+
reported.push(
|
|
80
|
+
...fillCallout(ctx, el, {
|
|
81
|
+
title: jsx.removeAttr(el, "title"),
|
|
82
|
+
description: [
|
|
83
|
+
...(message ? [jsx.childFromValue(message)] : []),
|
|
84
|
+
...(el.children ?? []),
|
|
85
|
+
],
|
|
86
|
+
onClose: jsx.removeAttr(el, "onClose"),
|
|
87
|
+
})
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
const visible = jsx.removeAttr(el, "visible")
|
|
91
|
+
if (!visible)
|
|
92
|
+
reported.push(
|
|
93
|
+
`${component} without visible rendered nothing (it defaults to false): render the Callout only when it should show`
|
|
94
|
+
)
|
|
95
|
+
if (reported.length) ctx.todo(path, component, reported.join("; "))
|
|
96
|
+
if (visible && !isTrue(ctx, visible))
|
|
97
|
+
renderWhen(j, path, attrValue(j, visible), el)
|
|
98
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paper → Surface. Surface is a role, not an elevation scale: `elevation={0}` and
|
|
3
|
+
* `variant="outlined"` are the flat `kind="section"`, anything raised is `kind="panel"`.
|
|
4
|
+
*/
|
|
5
|
+
import type { MigrateContext } from "../lib/types"
|
|
6
|
+
import { dropWithHint } from "./mui-props"
|
|
7
|
+
|
|
8
|
+
export const handles = ["Paper", "PaperProps"] as const
|
|
9
|
+
|
|
10
|
+
export function migrate(ctx: MigrateContext): void {
|
|
11
|
+
const { jsx } = ctx
|
|
12
|
+
const elements = ctx.elements("Paper")
|
|
13
|
+
ctx.moveElements("Paper", "Surface")
|
|
14
|
+
ctx.move("PaperProps", "SurfaceProps")
|
|
15
|
+
|
|
16
|
+
elements.forEach((path) => {
|
|
17
|
+
const el = path.node
|
|
18
|
+
let kind = "panel"
|
|
19
|
+
|
|
20
|
+
// `variant` decides the kind when present (MUI ignores elevation for an outlined Paper): a
|
|
21
|
+
// literal or a ternary of literals becomes `kind`; anything else is reported.
|
|
22
|
+
let kindFromVariant = false
|
|
23
|
+
const variant = jsx.attr(el, "variant")
|
|
24
|
+
if (variant) {
|
|
25
|
+
const mapped = jsx.mapAttrValue(el, "variant", {
|
|
26
|
+
outlined: "section",
|
|
27
|
+
elevation: "panel",
|
|
28
|
+
})
|
|
29
|
+
if (mapped === "mapped") {
|
|
30
|
+
jsx.renameAttr(el, "variant", "kind")
|
|
31
|
+
kindFromVariant = true
|
|
32
|
+
} else {
|
|
33
|
+
const printed = jsx.print(variant)
|
|
34
|
+
jsx.removeAttr(el, "variant")
|
|
35
|
+
ctx.todo(
|
|
36
|
+
path,
|
|
37
|
+
"Paper",
|
|
38
|
+
`dropped ${printed}: Surface kind is "panel" (raised) or "section" (flat, MUI outlined); pick one`
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const elevation = jsx.attr(el, "elevation")
|
|
43
|
+
if (elevation) {
|
|
44
|
+
const value = jsx.literal(elevation)
|
|
45
|
+
if (typeof value === "number") {
|
|
46
|
+
if (value === 0) kind = "section"
|
|
47
|
+
} else if (!kindFromVariant) {
|
|
48
|
+
ctx.todo(
|
|
49
|
+
path,
|
|
50
|
+
"Paper",
|
|
51
|
+
`dropped ${jsx.print(elevation)}: Surface kind is "panel" (raised) or "section" (flat); pick one`
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
jsx.removeAttr(el, "elevation")
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const square = jsx.attr(el, "square")
|
|
58
|
+
if (square) {
|
|
59
|
+
jsx.removeAttr(el, "square")
|
|
60
|
+
ctx.todo(
|
|
61
|
+
path,
|
|
62
|
+
"Paper",
|
|
63
|
+
"dropped square: Surface uses the token radius; override borderRadius via makeZenithStyles"
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (!kindFromVariant) {
|
|
68
|
+
el.openingElement.attributes = [
|
|
69
|
+
ctx.j.jsxAttribute(ctx.j.jsxIdentifier("kind"), jsx.str(kind)),
|
|
70
|
+
...(el.openingElement.attributes ?? []),
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
dropWithHint(ctx, path, "Paper", {
|
|
74
|
+
classes: "style the Surface with makeZenithStyles and pass className",
|
|
75
|
+
component: "wrap that element with <Surface kind asChild>",
|
|
76
|
+
})
|
|
77
|
+
})
|
|
78
|
+
}
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Select + MenuItem → Select / SelectTrigger / SelectValue / SelectContent / SelectItem.
|
|
3
|
+
*
|
|
4
|
+
* Converted when the children are static: MenuItem elements, or `{list.map(… => <MenuItem>)}`,
|
|
5
|
+
* each with a non-empty string value (Radix reserves "" for "no selection"). Anything else
|
|
6
|
+
* stays on base-elements with a TODO.
|
|
7
|
+
*
|
|
8
|
+
* - `value`, `defaultValue`, `name`, `disabled`, `required`, `open` stay on the root;
|
|
9
|
+
* `onChange={(event) => f(event.target.value)}` → `onValueChange={(value) => f(value)}`.
|
|
10
|
+
* - `placeholder` → `<SelectValue placeholder>`; `id`, `className`, `style`, `data-*` and
|
|
11
|
+
* `aria-*` go on the trigger, which MUI's select box was.
|
|
12
|
+
* - base-elements' `label` → a wrapping `Field` with a `FieldLabel` tied to the trigger's id.
|
|
13
|
+
* - `variant`, `size`, `fullWidth`, `customBackgroundColor` are theming: dropped. `renderValue`,
|
|
14
|
+
* `MenuProps`, `multiple`, `displayEmpty`, `error` and the rest are dropped and reported.
|
|
15
|
+
* - A MenuItem outside a Select (a Menu's) stays on base-elements with a DropdownMenu hint.
|
|
16
|
+
*/
|
|
17
|
+
import type {
|
|
18
|
+
ASTPath,
|
|
19
|
+
JSXAttribute,
|
|
20
|
+
JSXElement,
|
|
21
|
+
JSXSpreadAttribute,
|
|
22
|
+
} from "jscodeshift"
|
|
23
|
+
import type { MigrateContext } from "../lib/types"
|
|
24
|
+
import {
|
|
25
|
+
attrExpression,
|
|
26
|
+
contentChildren,
|
|
27
|
+
element,
|
|
28
|
+
printAttr,
|
|
29
|
+
printAttrs,
|
|
30
|
+
renamedAttr,
|
|
31
|
+
setChildren,
|
|
32
|
+
takeAttrs,
|
|
33
|
+
valueHandler,
|
|
34
|
+
wrapElement,
|
|
35
|
+
type Child,
|
|
36
|
+
reportValueUses,
|
|
37
|
+
} from "./shared"
|
|
38
|
+
|
|
39
|
+
export const handles = [
|
|
40
|
+
"Select",
|
|
41
|
+
"SelectProps",
|
|
42
|
+
"MenuItem",
|
|
43
|
+
"MenuItemProps",
|
|
44
|
+
] as const
|
|
45
|
+
|
|
46
|
+
const ROOT = [
|
|
47
|
+
"value",
|
|
48
|
+
"defaultValue",
|
|
49
|
+
"name",
|
|
50
|
+
"disabled",
|
|
51
|
+
"required",
|
|
52
|
+
"open",
|
|
53
|
+
"key",
|
|
54
|
+
]
|
|
55
|
+
const SILENT = [
|
|
56
|
+
"variant",
|
|
57
|
+
"size",
|
|
58
|
+
"fullWidth",
|
|
59
|
+
"customBackgroundColor",
|
|
60
|
+
"color",
|
|
61
|
+
]
|
|
62
|
+
const TRIGGER = (name: string) =>
|
|
63
|
+
name === "id" ||
|
|
64
|
+
name === "className" ||
|
|
65
|
+
name === "style" ||
|
|
66
|
+
name.startsWith("data-") ||
|
|
67
|
+
name.startsWith("aria-")
|
|
68
|
+
|
|
69
|
+
export function migrate(ctx: MigrateContext): void {
|
|
70
|
+
const { jsx } = ctx
|
|
71
|
+
const itemTag = ctx.names.MenuItem
|
|
72
|
+
const converted = new Set<JSXElement>()
|
|
73
|
+
let keptSelect = false
|
|
74
|
+
|
|
75
|
+
const toConvert: ASTPath<JSXElement>[] = []
|
|
76
|
+
ctx.elements("Select").forEach((path) => {
|
|
77
|
+
const items = itemTag ? menuItems(ctx, path.node, itemTag) : undefined
|
|
78
|
+
const problem = items
|
|
79
|
+
? itemProblem(ctx, items)
|
|
80
|
+
: "its children are not MenuItems"
|
|
81
|
+
if (problem) {
|
|
82
|
+
keptSelect = true
|
|
83
|
+
ctx.todo(
|
|
84
|
+
path,
|
|
85
|
+
"Select",
|
|
86
|
+
`stays on base-elements: ${problem}; rebuild it as Select + SelectTrigger + SelectValue + SelectContent + SelectItem`
|
|
87
|
+
)
|
|
88
|
+
return
|
|
89
|
+
}
|
|
90
|
+
for (const item of items!) converted.add(item)
|
|
91
|
+
toConvert.push(path)
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
let root = ctx.names.Select ?? "Select"
|
|
95
|
+
if (
|
|
96
|
+
reportValueUses(
|
|
97
|
+
ctx,
|
|
98
|
+
"Select",
|
|
99
|
+
"rebuild it as Select > SelectTrigger > SelectValue + SelectContent > SelectItem"
|
|
100
|
+
) &&
|
|
101
|
+
!keptSelect
|
|
102
|
+
) {
|
|
103
|
+
ctx.keep("Select")
|
|
104
|
+
ctx.keep("SelectProps")
|
|
105
|
+
if (toConvert.length) root = ctx.ensureZenith("Select")
|
|
106
|
+
} else if (keptSelect) {
|
|
107
|
+
ctx.keep(
|
|
108
|
+
"Select",
|
|
109
|
+
"still used where a Select stayed: see the TODOs on those elements"
|
|
110
|
+
)
|
|
111
|
+
ctx.keep(
|
|
112
|
+
"SelectProps",
|
|
113
|
+
"type it from Zenith's SelectProps once the Select moves"
|
|
114
|
+
)
|
|
115
|
+
if (toConvert.length) root = ctx.ensureZenith("Select")
|
|
116
|
+
} else {
|
|
117
|
+
ctx.move("Select")
|
|
118
|
+
ctx.move("SelectProps")
|
|
119
|
+
}
|
|
120
|
+
for (const path of toConvert) migrateSelect(ctx, path, root)
|
|
121
|
+
|
|
122
|
+
let keptItem = false
|
|
123
|
+
if (itemTag)
|
|
124
|
+
ctx.elements("MenuItem").forEach((path) => {
|
|
125
|
+
if (!converted.has(path.node)) {
|
|
126
|
+
keptItem = true
|
|
127
|
+
return
|
|
128
|
+
}
|
|
129
|
+
jsx.rename(path.node, ctx.ensureZenith("SelectItem"))
|
|
130
|
+
takeAttrs(ctx, path.node, [
|
|
131
|
+
"dense",
|
|
132
|
+
"disableGutters",
|
|
133
|
+
"button",
|
|
134
|
+
"selected",
|
|
135
|
+
])
|
|
136
|
+
const unsupported = takeAttrs(ctx, path.node, [
|
|
137
|
+
"divider",
|
|
138
|
+
"ListItemClasses",
|
|
139
|
+
"classes",
|
|
140
|
+
"component",
|
|
141
|
+
])
|
|
142
|
+
if (unsupported.length)
|
|
143
|
+
ctx.todo(
|
|
144
|
+
path,
|
|
145
|
+
"MenuItem",
|
|
146
|
+
`dropped ${printAttrs(ctx, unsupported)} (no SelectItem equivalent)`
|
|
147
|
+
)
|
|
148
|
+
})
|
|
149
|
+
if (
|
|
150
|
+
reportValueUses(
|
|
151
|
+
ctx,
|
|
152
|
+
"MenuItem",
|
|
153
|
+
"a select option becomes SelectItem; a menu entry DropdownMenuItem"
|
|
154
|
+
) &&
|
|
155
|
+
!keptItem
|
|
156
|
+
)
|
|
157
|
+
ctx.keep("MenuItem")
|
|
158
|
+
else if (keptItem)
|
|
159
|
+
ctx.keep(
|
|
160
|
+
"MenuItem",
|
|
161
|
+
"still used outside a converted Select: a select option becomes SelectItem inside SelectContent; a menu entry becomes DropdownMenuItem inside DropdownMenuContent"
|
|
162
|
+
)
|
|
163
|
+
else ctx.drop("MenuItem")
|
|
164
|
+
ctx.keep(
|
|
165
|
+
"MenuItemProps",
|
|
166
|
+
"SelectItemProps for a select option, DropdownMenuItemProps for a menu entry"
|
|
167
|
+
)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** The MenuItem elements a Select renders, or `undefined` when its children are anything else. */
|
|
171
|
+
function menuItems(
|
|
172
|
+
ctx: MigrateContext,
|
|
173
|
+
select: JSXElement,
|
|
174
|
+
itemTag: string
|
|
175
|
+
): JSXElement[] | undefined {
|
|
176
|
+
const { j, jsx } = ctx
|
|
177
|
+
const items: JSXElement[] = []
|
|
178
|
+
for (const child of contentChildren(select)) {
|
|
179
|
+
if (child.type === "JSXElement" && jsx.tagName(child) === itemTag) {
|
|
180
|
+
items.push(child)
|
|
181
|
+
continue
|
|
182
|
+
}
|
|
183
|
+
if (child.type === "JSXExpressionContainer") {
|
|
184
|
+
if (child.expression.type === "JSXEmptyExpression") continue
|
|
185
|
+
const call = child.expression
|
|
186
|
+
const isMap =
|
|
187
|
+
call.type === "CallExpression" &&
|
|
188
|
+
call.callee.type === "MemberExpression" &&
|
|
189
|
+
call.callee.property.type === "Identifier" &&
|
|
190
|
+
call.callee.property.name === "map"
|
|
191
|
+
const returned = j(child as never)
|
|
192
|
+
.find(j.JSXElement)
|
|
193
|
+
.filter((p) => jsx.tagName(p.node) === itemTag)
|
|
194
|
+
.nodes()
|
|
195
|
+
if (isMap && returned.length === 1) {
|
|
196
|
+
items.push(returned[0])
|
|
197
|
+
continue
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return undefined
|
|
201
|
+
}
|
|
202
|
+
return items.length ? items : undefined
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** Why the items cannot become SelectItems, if they cannot. */
|
|
206
|
+
function itemProblem(
|
|
207
|
+
ctx: MigrateContext,
|
|
208
|
+
items: JSXElement[]
|
|
209
|
+
): string | undefined {
|
|
210
|
+
for (const item of items) {
|
|
211
|
+
const value = ctx.jsx.attr(item, "value")
|
|
212
|
+
if (!value) return "a MenuItem has no value"
|
|
213
|
+
const literal = ctx.jsx.literal(value)
|
|
214
|
+
if (literal === "")
|
|
215
|
+
return 'a MenuItem has value="" (Radix reserves it for "no selection"; use a sentinel such as "none")'
|
|
216
|
+
if (typeof literal === "number" || typeof literal === "boolean")
|
|
217
|
+
return `a MenuItem has ${printAttr(ctx, value)} (SelectItem values are strings)`
|
|
218
|
+
const expression = attrExpression(value)
|
|
219
|
+
if (
|
|
220
|
+
expression?.type === "NullLiteral" ||
|
|
221
|
+
(expression?.type === "Identifier" && expression.name === "undefined")
|
|
222
|
+
)
|
|
223
|
+
return `a MenuItem has ${printAttr(ctx, value)} (use a sentinel string such as "none" and map it)`
|
|
224
|
+
}
|
|
225
|
+
return undefined
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function migrateSelect(
|
|
229
|
+
ctx: MigrateContext,
|
|
230
|
+
path: ASTPath<JSXElement>,
|
|
231
|
+
root: string
|
|
232
|
+
): void {
|
|
233
|
+
const { j, jsx } = ctx
|
|
234
|
+
const el = path.node
|
|
235
|
+
const reported: string[] = []
|
|
236
|
+
jsx.rename(el, root)
|
|
237
|
+
|
|
238
|
+
const onChange = jsx.attr(el, "onChange")
|
|
239
|
+
if (onChange) {
|
|
240
|
+
const handler = valueHandler(j, attrExpression(onChange), {
|
|
241
|
+
targetProp: "value",
|
|
242
|
+
valueName: "value",
|
|
243
|
+
})
|
|
244
|
+
jsx.removeAttr(el, "onChange")
|
|
245
|
+
if (handler) jsx.setAttr(el, "onValueChange", handler)
|
|
246
|
+
else
|
|
247
|
+
reported.push(
|
|
248
|
+
`dropped ${printAttr(ctx, onChange)} (onValueChange(value) passes only the value: call your handler with it)`
|
|
249
|
+
)
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
const label = jsx.removeAttr(el, "label")
|
|
253
|
+
const placeholder = jsx.removeAttr(el, "placeholder")
|
|
254
|
+
takeAttrs(ctx, el, SILENT)
|
|
255
|
+
const rootAttrs: (JSXAttribute | JSXSpreadAttribute)[] = []
|
|
256
|
+
const trigger: (JSXAttribute | JSXSpreadAttribute)[] = []
|
|
257
|
+
const dropped: JSXAttribute[] = []
|
|
258
|
+
for (const a of el.openingElement.attributes ?? []) {
|
|
259
|
+
if (a.type === "JSXSpreadAttribute") {
|
|
260
|
+
rootAttrs.push(a)
|
|
261
|
+
reported.push(
|
|
262
|
+
"spread props are MUI SelectProps: keep value/onValueChange/name on Select, styling on SelectTrigger"
|
|
263
|
+
)
|
|
264
|
+
continue
|
|
265
|
+
}
|
|
266
|
+
const name = jsx.attrName(a)
|
|
267
|
+
if (ROOT.includes(name) || name === "onValueChange") rootAttrs.push(a)
|
|
268
|
+
else if (TRIGGER(name)) trigger.push(a)
|
|
269
|
+
else dropped.push(a)
|
|
270
|
+
}
|
|
271
|
+
if (dropped.length)
|
|
272
|
+
reported.push(
|
|
273
|
+
`dropped ${printAttrs(ctx, dropped)} (renderValue → SelectValue children; MenuProps → SelectContent props; multiple has no Select equivalent)`
|
|
274
|
+
)
|
|
275
|
+
el.openingElement.attributes = rootAttrs
|
|
276
|
+
|
|
277
|
+
const value = element(
|
|
278
|
+
j,
|
|
279
|
+
ctx.ensureZenith("SelectValue"),
|
|
280
|
+
placeholder ? [placeholder] : []
|
|
281
|
+
)
|
|
282
|
+
const triggerEl = element(j, ctx.ensureZenith("SelectTrigger"), trigger, [
|
|
283
|
+
j.jsxText("\n"),
|
|
284
|
+
value,
|
|
285
|
+
j.jsxText("\n"),
|
|
286
|
+
])
|
|
287
|
+
const content = element(
|
|
288
|
+
j,
|
|
289
|
+
ctx.ensureZenith("SelectContent"),
|
|
290
|
+
[],
|
|
291
|
+
el.children ?? []
|
|
292
|
+
)
|
|
293
|
+
setChildren(j, el, [
|
|
294
|
+
j.jsxText("\n"),
|
|
295
|
+
triggerEl,
|
|
296
|
+
j.jsxText("\n"),
|
|
297
|
+
content,
|
|
298
|
+
j.jsxText("\n"),
|
|
299
|
+
])
|
|
300
|
+
|
|
301
|
+
let todoPath = path
|
|
302
|
+
if (label) {
|
|
303
|
+
const id = trigger.find(
|
|
304
|
+
(a): a is JSXAttribute =>
|
|
305
|
+
a.type === "JSXAttribute" && jsx.attrName(a) === "id"
|
|
306
|
+
)
|
|
307
|
+
const labelEl = element(
|
|
308
|
+
j,
|
|
309
|
+
ctx.ensureZenith("FieldLabel"),
|
|
310
|
+
id ? [renamedAttr(j, id, "htmlFor")] : [],
|
|
311
|
+
[jsx.childFromValue(label)]
|
|
312
|
+
)
|
|
313
|
+
const nl = (): Child => j.jsxText("\n")
|
|
314
|
+
todoPath = wrapElement(
|
|
315
|
+
j,
|
|
316
|
+
path,
|
|
317
|
+
ctx.ensureZenith("Field"),
|
|
318
|
+
[],
|
|
319
|
+
[nl(), labelEl, nl()],
|
|
320
|
+
[nl()]
|
|
321
|
+
)
|
|
322
|
+
if (!id)
|
|
323
|
+
reported.push(
|
|
324
|
+
"FieldLabel is not tied to the trigger: give SelectTrigger an id and FieldLabel htmlFor"
|
|
325
|
+
)
|
|
326
|
+
}
|
|
327
|
+
if (reported.length) ctx.todo(todoPath, "Select", reported.join("; "))
|
|
328
|
+
}
|