@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,231 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tooltip → Tooltip + TooltipTrigger asChild + TooltipContent.
|
|
3
|
+
*
|
|
4
|
+
* - The one child becomes the trigger; `title` becomes the content.
|
|
5
|
+
* - `placement` → `side` + `align`. MUI's default is bottom and Radix's is top, so `side` is
|
|
6
|
+
* always written.
|
|
7
|
+
* - `enterDelay` → `delayDuration`; `open` stays on the root. Props MUI forwarded to the child
|
|
8
|
+
* (`className`, `data-*`, `aria-*`) go on the trigger, which merges them into the child.
|
|
9
|
+
* - `arrow`, `interactive` and base-elements' `mode` are theming or Radix's default: dropped.
|
|
10
|
+
* Other MUI-only props are dropped and reported.
|
|
11
|
+
* - Radix throws without a TooltipProvider above the tooltip, so the first tooltip of a file
|
|
12
|
+
* carries a one-time reminder. A tooltip around anything but exactly one child stays on
|
|
13
|
+
* base-elements.
|
|
14
|
+
*/
|
|
15
|
+
import type {
|
|
16
|
+
ASTPath,
|
|
17
|
+
JSXAttribute,
|
|
18
|
+
JSXElement,
|
|
19
|
+
JSXSpreadAttribute,
|
|
20
|
+
} from "jscodeshift"
|
|
21
|
+
import type { MigrateContext } from "../lib/types"
|
|
22
|
+
import {
|
|
23
|
+
contentChildren,
|
|
24
|
+
element,
|
|
25
|
+
printAttrs,
|
|
26
|
+
setChildren,
|
|
27
|
+
takeAttrs,
|
|
28
|
+
printAttr,
|
|
29
|
+
reportValueUses,
|
|
30
|
+
} from "./shared"
|
|
31
|
+
|
|
32
|
+
export const handles = ["Tooltip", "TooltipProps"] as const
|
|
33
|
+
|
|
34
|
+
const SILENT = ["arrow", "interactive", "mode", "title", "placement"]
|
|
35
|
+
const REPORTED = [
|
|
36
|
+
"onOpen",
|
|
37
|
+
"onClose",
|
|
38
|
+
"leaveDelay",
|
|
39
|
+
"enterNextDelay",
|
|
40
|
+
"enterTouchDelay",
|
|
41
|
+
"leaveTouchDelay",
|
|
42
|
+
"disableHoverListener",
|
|
43
|
+
"disableFocusListener",
|
|
44
|
+
"disableTouchListener",
|
|
45
|
+
"PopperProps",
|
|
46
|
+
"PopperComponent",
|
|
47
|
+
"TransitionComponent",
|
|
48
|
+
"TransitionProps",
|
|
49
|
+
"classes",
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
export function migrate(ctx: MigrateContext): void {
|
|
53
|
+
const tooltips = ctx.elements("Tooltip").paths()
|
|
54
|
+
const convertible = tooltips.filter((p) => oneChild(p.node))
|
|
55
|
+
const stays = tooltips.filter((p) => !oneChild(p.node))
|
|
56
|
+
for (const path of stays)
|
|
57
|
+
ctx.todo(
|
|
58
|
+
path,
|
|
59
|
+
"Tooltip",
|
|
60
|
+
"stays on base-elements: Zenith's TooltipTrigger needs exactly one child element; wrap the children in one"
|
|
61
|
+
)
|
|
62
|
+
let root = ctx.names.Tooltip ?? "Tooltip"
|
|
63
|
+
const valueUsed = reportValueUses(
|
|
64
|
+
ctx,
|
|
65
|
+
"Tooltip",
|
|
66
|
+
"rebuild it as Tooltip > TooltipTrigger asChild + TooltipContent"
|
|
67
|
+
)
|
|
68
|
+
if (valueUsed && !stays.length) {
|
|
69
|
+
ctx.keep("Tooltip")
|
|
70
|
+
if (convertible.length) root = ctx.ensureZenith("Tooltip")
|
|
71
|
+
} else if (stays.length) {
|
|
72
|
+
ctx.keep(
|
|
73
|
+
"Tooltip",
|
|
74
|
+
"still used where a Tooltip stayed: see the TODOs on those elements"
|
|
75
|
+
)
|
|
76
|
+
if (convertible.length) root = ctx.ensureZenith("Tooltip")
|
|
77
|
+
} else ctx.move("Tooltip")
|
|
78
|
+
ctx.move("TooltipProps")
|
|
79
|
+
|
|
80
|
+
convertible.forEach((path, index) =>
|
|
81
|
+
migrateTooltip(ctx, path, root, index === 0)
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function oneChild(el: JSXElement): boolean {
|
|
86
|
+
const children = contentChildren(el).filter(
|
|
87
|
+
(c) =>
|
|
88
|
+
!(
|
|
89
|
+
c.type === "JSXExpressionContainer" &&
|
|
90
|
+
c.expression.type === "JSXEmptyExpression"
|
|
91
|
+
)
|
|
92
|
+
)
|
|
93
|
+
return (
|
|
94
|
+
children.length === 1 &&
|
|
95
|
+
(children[0].type === "JSXElement" ||
|
|
96
|
+
children[0].type === "JSXExpressionContainer")
|
|
97
|
+
)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function migrateTooltip(
|
|
101
|
+
ctx: MigrateContext,
|
|
102
|
+
path: ASTPath<JSXElement>,
|
|
103
|
+
root: string,
|
|
104
|
+
first: boolean
|
|
105
|
+
): void {
|
|
106
|
+
const { j, jsx } = ctx
|
|
107
|
+
const el = path.node
|
|
108
|
+
const reported: string[] = []
|
|
109
|
+
const content: JSXAttribute[] = []
|
|
110
|
+
|
|
111
|
+
const placement = jsx.attr(el, "placement")
|
|
112
|
+
const value = placement ? jsx.literal(placement) : "bottom"
|
|
113
|
+
if (typeof value === "string") {
|
|
114
|
+
const [side, align] = value.split("-")
|
|
115
|
+
content.push(j.jsxAttribute(j.jsxIdentifier("side"), jsx.str(side)))
|
|
116
|
+
if (align)
|
|
117
|
+
content.push(j.jsxAttribute(j.jsxIdentifier("align"), jsx.str(align)))
|
|
118
|
+
} else
|
|
119
|
+
reported.push(
|
|
120
|
+
`dropped ${printAttr(ctx, placement!)} (TooltipContent side: top | right | bottom | left, align: start | center | end)`
|
|
121
|
+
)
|
|
122
|
+
const title = jsx.attr(el, "title")
|
|
123
|
+
|
|
124
|
+
jsx.renameAttr(el, "enterDelay", "delayDuration")
|
|
125
|
+
const id = jsx.removeAttr(el, "id")
|
|
126
|
+
if (id) content.push(id)
|
|
127
|
+
|
|
128
|
+
const dropped = takeAttrs(ctx, el, REPORTED)
|
|
129
|
+
if (dropped.length)
|
|
130
|
+
reported.push(
|
|
131
|
+
`dropped ${printAttrs(ctx, dropped)} (Tooltip onOpenChange(open) replaces onOpen/onClose; delays live on TooltipProvider)`
|
|
132
|
+
)
|
|
133
|
+
takeAttrs(ctx, el, SILENT)
|
|
134
|
+
|
|
135
|
+
// What MUI spread onto the child goes on the trigger, which merges it into the child.
|
|
136
|
+
const trigger: (JSXAttribute | JSXSpreadAttribute)[] = [
|
|
137
|
+
j.jsxAttribute(j.jsxIdentifier("asChild")),
|
|
138
|
+
]
|
|
139
|
+
const rootAttrs: JSXAttribute[] = []
|
|
140
|
+
for (const a of el.openingElement.attributes ?? []) {
|
|
141
|
+
if (a.type === "JSXSpreadAttribute") trigger.push(a)
|
|
142
|
+
else if (["open", "delayDuration", "key"].includes(jsx.attrName(a)))
|
|
143
|
+
rootAttrs.push(a)
|
|
144
|
+
else trigger.push(a)
|
|
145
|
+
}
|
|
146
|
+
el.openingElement.attributes = rootAttrs
|
|
147
|
+
|
|
148
|
+
const child = contentChildren(el).find(
|
|
149
|
+
(c) =>
|
|
150
|
+
!(
|
|
151
|
+
c.type === "JSXExpressionContainer" &&
|
|
152
|
+
c.expression.type === "JSXEmptyExpression"
|
|
153
|
+
)
|
|
154
|
+
)!
|
|
155
|
+
// An icon button's tooltip text is its only label: base-elements left it unnamed.
|
|
156
|
+
const iconButtons = [
|
|
157
|
+
ctx.names.IconButton,
|
|
158
|
+
ctx.names.ElevatedIconButton,
|
|
159
|
+
].filter(Boolean)
|
|
160
|
+
if (
|
|
161
|
+
title &&
|
|
162
|
+
child.type === "JSXElement" &&
|
|
163
|
+
iconButtons.includes(jsx.tagName(child) ?? "") &&
|
|
164
|
+
!["aria-label", "aria-labelledby", "title"].some((n) => jsx.attr(child, n))
|
|
165
|
+
)
|
|
166
|
+
child.openingElement.attributes = [
|
|
167
|
+
...(child.openingElement.attributes ?? []),
|
|
168
|
+
j.jsxAttribute(j.jsxIdentifier("aria-label"), title.value),
|
|
169
|
+
]
|
|
170
|
+
const triggerEl = element(j, ctx.ensureZenith("TooltipTrigger"), trigger, [
|
|
171
|
+
j.jsxText("\n"),
|
|
172
|
+
child,
|
|
173
|
+
j.jsxText("\n"),
|
|
174
|
+
])
|
|
175
|
+
const contentEl = element(
|
|
176
|
+
j,
|
|
177
|
+
ctx.ensureZenith("TooltipContent"),
|
|
178
|
+
content,
|
|
179
|
+
title ? [jsx.childFromValue(title)] : []
|
|
180
|
+
)
|
|
181
|
+
jsx.rename(el, root)
|
|
182
|
+
setChildren(j, el, [
|
|
183
|
+
j.jsxText("\n"),
|
|
184
|
+
triggerEl,
|
|
185
|
+
j.jsxText("\n"),
|
|
186
|
+
contentEl,
|
|
187
|
+
j.jsxText("\n"),
|
|
188
|
+
])
|
|
189
|
+
if (!title) reported.push("no title: put the tooltip text in TooltipContent")
|
|
190
|
+
else if (canBeEmpty(title))
|
|
191
|
+
reported.push(
|
|
192
|
+
`${printAttr(ctx, title)} can be empty: MUI hid the tooltip then, Radix shows an empty bubble; render the Tooltip only when there is text`
|
|
193
|
+
)
|
|
194
|
+
if (first)
|
|
195
|
+
reported.push(
|
|
196
|
+
"Zenith's Tooltip throws without a TooltipProvider above it: add one once at the app root if there is none"
|
|
197
|
+
)
|
|
198
|
+
if (reported.length) ctx.todo(path, "Tooltip", reported.join("; "))
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** Whether `title` can evaluate to nothing: `""`, a ternary or `&&` with an empty side. */
|
|
202
|
+
function canBeEmpty(a: JSXAttribute): boolean {
|
|
203
|
+
const v = a.value
|
|
204
|
+
if (v?.type === "StringLiteral" || v?.type === "Literal")
|
|
205
|
+
return String((v as { value: unknown }).value) === ""
|
|
206
|
+
if (v?.type !== "JSXExpressionContainer") return false
|
|
207
|
+
const empty = (e: { type: string; [k: string]: unknown }): boolean => {
|
|
208
|
+
switch (e.type) {
|
|
209
|
+
case "StringLiteral":
|
|
210
|
+
return e.value === ""
|
|
211
|
+
case "TemplateLiteral":
|
|
212
|
+
return (
|
|
213
|
+
(e.expressions as unknown[]).length === 0 &&
|
|
214
|
+
(e.quasis as { value: { cooked: string } }[])[0]?.value.cooked === ""
|
|
215
|
+
)
|
|
216
|
+
case "NullLiteral":
|
|
217
|
+
return true
|
|
218
|
+
case "BooleanLiteral":
|
|
219
|
+
return e.value === false
|
|
220
|
+
case "Identifier":
|
|
221
|
+
return e.name === "undefined"
|
|
222
|
+
case "ConditionalExpression":
|
|
223
|
+
return empty(e.consequent as never) || empty(e.alternate as never)
|
|
224
|
+
case "LogicalExpression":
|
|
225
|
+
return e.operator === "&&" || empty(e.right as never)
|
|
226
|
+
default:
|
|
227
|
+
return false
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return empty(v.expression as never)
|
|
231
|
+
}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typography, H1–H6, DisplayText, LargeText, BodyText, SmallText → Text.
|
|
3
|
+
*
|
|
4
|
+
* Zenith's variants run opposite to HTML headings (title3 is the largest). By the epilot MUI
|
|
5
|
+
* theme's sizes: h1–h4 (96–32px) → title3 (30px), h5 → title2 (24px), h6 → title1 (20px),
|
|
6
|
+
* subtitle1 → heading2 (16px bold), subtitle2 → heading1 (14px bold), body1 (16px) and body2
|
|
7
|
+
* → body2 (14px, Text's default, omitted), caption/overline → body1 (12px).
|
|
8
|
+
* `color="textSecondary"` turns body2/body1 into helper2/helper1 (the gray ink). Text has no
|
|
9
|
+
* other colour variants, so error/primary/secondary (and textSecondary elsewhere) are reported
|
|
10
|
+
* with the token to set.
|
|
11
|
+
*
|
|
12
|
+
* Text renders an inline `<span>`. A heading (H1–H6, an h* variant or component) is reported
|
|
13
|
+
* so it can be wrapped in its `<hN>`; MUI's block element (`<p>`, `<h6>` for subtitles) is
|
|
14
|
+
* reported when the element shares its parent with other content. `customColor`,
|
|
15
|
+
* `gutterBottom`, `paragraph`, `noWrap`, `align` and `display="block"` become inline styles.
|
|
16
|
+
*/
|
|
17
|
+
import type { ASTPath, JSXElement } from "jscodeshift"
|
|
18
|
+
import type { MigrateContext } from "../lib/types"
|
|
19
|
+
import {
|
|
20
|
+
attrExpression,
|
|
21
|
+
contentChildren,
|
|
22
|
+
mapStringExpression,
|
|
23
|
+
parseExpression,
|
|
24
|
+
printAttrs,
|
|
25
|
+
source,
|
|
26
|
+
stringIn,
|
|
27
|
+
takeAttrs,
|
|
28
|
+
printAttr,
|
|
29
|
+
moveElements,
|
|
30
|
+
} from "./shared"
|
|
31
|
+
|
|
32
|
+
const COMPONENTS: Record<string, string> = {
|
|
33
|
+
Typography: "body1",
|
|
34
|
+
H1: "h1",
|
|
35
|
+
H2: "h2",
|
|
36
|
+
H3: "h3",
|
|
37
|
+
H4: "h4",
|
|
38
|
+
H5: "h5",
|
|
39
|
+
H6: "h6",
|
|
40
|
+
DisplayText: "h6",
|
|
41
|
+
LargeText: "body1",
|
|
42
|
+
BodyText: "body2",
|
|
43
|
+
SmallText: "caption",
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const handles = [...Object.keys(COMPONENTS), "TypographyProps"] as const
|
|
47
|
+
|
|
48
|
+
const VARIANTS: Record<string, string> = {
|
|
49
|
+
h1: "title3",
|
|
50
|
+
h2: "title3",
|
|
51
|
+
h3: "title3",
|
|
52
|
+
h4: "title3",
|
|
53
|
+
h5: "title2",
|
|
54
|
+
h6: "title1",
|
|
55
|
+
subtitle1: "heading2",
|
|
56
|
+
subtitle2: "heading1",
|
|
57
|
+
body1: "body2",
|
|
58
|
+
body2: "body2",
|
|
59
|
+
caption: "body1",
|
|
60
|
+
overline: "body1",
|
|
61
|
+
button: "body2",
|
|
62
|
+
}
|
|
63
|
+
const SECONDARY: Record<string, string> = { body2: "helper2", body1: "helper1" }
|
|
64
|
+
/** MUI colours that are Text's own ink anyway. */
|
|
65
|
+
const INK = new Set(["initial", "inherit", "textPrimary"])
|
|
66
|
+
/** The token for a colour Text has no variant for. */
|
|
67
|
+
const COLOR_TOKENS: Record<string, string> = {
|
|
68
|
+
error: "tokens.errorA11",
|
|
69
|
+
primary: "tokens.accentA11",
|
|
70
|
+
secondary: "tokens.accentA11",
|
|
71
|
+
textSecondary: "tokens.grayA11",
|
|
72
|
+
}
|
|
73
|
+
/** MUI variants whose default element is an inline `<span>`, like Text's. */
|
|
74
|
+
const INLINE = new Set(["caption", "overline", "button", "inherit", "srOnly"])
|
|
75
|
+
|
|
76
|
+
export function migrate(ctx: MigrateContext): void {
|
|
77
|
+
for (const name of Object.keys(COMPONENTS)) {
|
|
78
|
+
moveElements(ctx, name, "Text", (path) => migrateText(ctx, path, name))
|
|
79
|
+
}
|
|
80
|
+
ctx.move("TypographyProps", "TextProps")
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function migrateText(
|
|
84
|
+
ctx: MigrateContext,
|
|
85
|
+
path: ASTPath<JSXElement>,
|
|
86
|
+
component: string
|
|
87
|
+
): void {
|
|
88
|
+
const { j, jsx } = ctx
|
|
89
|
+
const el = path.node
|
|
90
|
+
const reported: string[] = []
|
|
91
|
+
const style: [string, string][] = []
|
|
92
|
+
|
|
93
|
+
const variantAttr = jsx.removeAttr(el, "variant")
|
|
94
|
+
const muiVariant = variantAttr
|
|
95
|
+
? jsx.literal(variantAttr)
|
|
96
|
+
: COMPONENTS[component]
|
|
97
|
+
const colorAttr = jsx.removeAttr(el, "color")
|
|
98
|
+
const color = jsx.literal(colorAttr)
|
|
99
|
+
let heading: string | undefined
|
|
100
|
+
if (typeof muiVariant === "string" && muiVariant in VARIANTS) {
|
|
101
|
+
let variant = VARIANTS[muiVariant]
|
|
102
|
+
if (color === "textSecondary" && SECONDARY[variant])
|
|
103
|
+
variant = SECONDARY[variant]
|
|
104
|
+
else if (colorAttr && !INK.has(String(color)))
|
|
105
|
+
reported.push(colorTodo(ctx, colorAttr))
|
|
106
|
+
if (variant !== "body2") jsx.setAttr(el, "variant", variant)
|
|
107
|
+
if (/^h[1-6]$/.test(muiVariant)) heading = muiVariant
|
|
108
|
+
} else {
|
|
109
|
+
const mapped = mapStringExpression(
|
|
110
|
+
j,
|
|
111
|
+
attrExpression(variantAttr),
|
|
112
|
+
(v) => VARIANTS[v],
|
|
113
|
+
(v) => stringIn(ctx, v) as never
|
|
114
|
+
)
|
|
115
|
+
if (mapped) jsx.setAttr(el, "variant", mapped)
|
|
116
|
+
else
|
|
117
|
+
reported.push(
|
|
118
|
+
`dropped ${printAttr(ctx, variantAttr!)} (h1–h4 → title3, h5 → title2, h6 → title1, subtitle1/2 → heading2/1, body1/2 → body2, caption → body1)`
|
|
119
|
+
)
|
|
120
|
+
if (colorAttr && !INK.has(String(color)))
|
|
121
|
+
reported.push(colorTodo(ctx, colorAttr))
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
let inline = typeof muiVariant === "string" && INLINE.has(muiVariant)
|
|
125
|
+
const componentAttr = jsx.removeAttr(el, "component")
|
|
126
|
+
if (componentAttr) {
|
|
127
|
+
// The element MUI rendered, which decides whether there is a heading to keep.
|
|
128
|
+
const tag = jsx.literal(componentAttr)
|
|
129
|
+
const isHeading = typeof tag === "string" && /^h[1-6]$/.test(tag)
|
|
130
|
+
heading = isHeading ? (tag as string) : undefined
|
|
131
|
+
inline = tag === "span"
|
|
132
|
+
if (tag !== "span" && !isHeading)
|
|
133
|
+
reported.push(
|
|
134
|
+
`dropped ${printAttr(ctx, componentAttr)} (Text always renders a <span>; wrap it in the element you need)`
|
|
135
|
+
)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const customColor = jsx.removeAttr(el, "customColor")
|
|
139
|
+
const quoted = (v: string) => source(j, stringIn(ctx, v))
|
|
140
|
+
if (customColor) {
|
|
141
|
+
const value = jsx.literal(customColor)
|
|
142
|
+
style.push([
|
|
143
|
+
"color",
|
|
144
|
+
typeof value === "string"
|
|
145
|
+
? quoted(value)
|
|
146
|
+
: source(j, attrExpression(customColor) as never),
|
|
147
|
+
])
|
|
148
|
+
}
|
|
149
|
+
let block = false
|
|
150
|
+
if (jsx.removeAttr(el, "gutterBottom"))
|
|
151
|
+
style.push(["marginBottom", quoted("0.35em")])
|
|
152
|
+
if (jsx.removeAttr(el, "paragraph")) {
|
|
153
|
+
style.push(["marginBottom", quoted("1rem")])
|
|
154
|
+
block = true
|
|
155
|
+
}
|
|
156
|
+
if (jsx.removeAttr(el, "noWrap")) {
|
|
157
|
+
style.push(
|
|
158
|
+
["overflow", quoted("hidden")],
|
|
159
|
+
["textOverflow", quoted("ellipsis")],
|
|
160
|
+
["whiteSpace", quoted("nowrap")]
|
|
161
|
+
)
|
|
162
|
+
block = true
|
|
163
|
+
}
|
|
164
|
+
const align = jsx.removeAttr(el, "align")
|
|
165
|
+
const alignValue = jsx.literal(align)
|
|
166
|
+
if (typeof alignValue === "string" && alignValue !== "inherit") {
|
|
167
|
+
style.push(["textAlign", quoted(alignValue)])
|
|
168
|
+
block = true
|
|
169
|
+
} else if (align && alignValue !== "inherit")
|
|
170
|
+
reported.push(
|
|
171
|
+
`dropped ${printAttr(ctx, align)} (set textAlign in your styles)`
|
|
172
|
+
)
|
|
173
|
+
const display = jsx.removeAttr(el, "display")
|
|
174
|
+
if (jsx.literal(display) === "block") block = true
|
|
175
|
+
else if (display && jsx.literal(display) !== "initial")
|
|
176
|
+
reported.push(
|
|
177
|
+
`dropped ${printAttr(ctx, display)} (set display in your styles)`
|
|
178
|
+
)
|
|
179
|
+
if (block) style.unshift(["display", quoted("block")])
|
|
180
|
+
if (style.length) applyStyle(ctx, el, style, reported)
|
|
181
|
+
|
|
182
|
+
const unsupported = takeAttrs(ctx, el, ["classes", "variantMapping"])
|
|
183
|
+
if (unsupported.length)
|
|
184
|
+
reported.push(`dropped ${printAttrs(ctx, unsupported)} (MUI-only)`)
|
|
185
|
+
|
|
186
|
+
if (heading) {
|
|
187
|
+
const level = heading.slice(1)
|
|
188
|
+
reported.push(
|
|
189
|
+
`Text renders a <span>: wrap it in <${heading}> (or add role="heading" aria-level={${level}}) to keep the heading`
|
|
190
|
+
)
|
|
191
|
+
} else if (!block && !inline && sharesParent(path))
|
|
192
|
+
reported.push(
|
|
193
|
+
"Text is inline where MUI rendered a block: it now shares a line with its siblings; set display: block or lay the parent out as a column"
|
|
194
|
+
)
|
|
195
|
+
if (reported.length) ctx.todo(path, component, reported.join("; "))
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** Adds `key: value` entries (values are source text) to `style`, creating it when absent. */
|
|
199
|
+
function applyStyle(
|
|
200
|
+
ctx: MigrateContext,
|
|
201
|
+
el: JSXElement,
|
|
202
|
+
entries: [string, string][],
|
|
203
|
+
reported: string[]
|
|
204
|
+
): void {
|
|
205
|
+
const { j, jsx } = ctx
|
|
206
|
+
if (!jsx.attr(el, "style")) {
|
|
207
|
+
const body = entries.map(([k, v]) => `${k}: ${v}`).join(", ")
|
|
208
|
+
jsx.setAttr(el, "style", parseExpression(j, `{ ${body} }`))
|
|
209
|
+
return
|
|
210
|
+
}
|
|
211
|
+
const object = jsx.styleObject(el)
|
|
212
|
+
if (!object) {
|
|
213
|
+
reported.push(
|
|
214
|
+
`add ${entries.map(([k, v]) => `${k}: ${v}`).join(", ")} to its style`
|
|
215
|
+
)
|
|
216
|
+
return
|
|
217
|
+
}
|
|
218
|
+
for (const [k, v] of entries)
|
|
219
|
+
jsx.setObjectKey(object, k, parseExpression(j, v))
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** Whether the element sits among other content in a JSX parent (text or elements). */
|
|
223
|
+
function sharesParent(path: ASTPath<JSXElement>): boolean {
|
|
224
|
+
const parent = path.parent?.node as JSXElement | undefined
|
|
225
|
+
if (
|
|
226
|
+
!parent ||
|
|
227
|
+
(parent.type !== "JSXElement" && parent.type !== "JSXFragment")
|
|
228
|
+
)
|
|
229
|
+
return false
|
|
230
|
+
return contentChildren(parent).some(
|
|
231
|
+
(c) =>
|
|
232
|
+
c !== path.node &&
|
|
233
|
+
!(
|
|
234
|
+
c.type === "JSXExpressionContainer" &&
|
|
235
|
+
c.expression.type === "JSXEmptyExpression"
|
|
236
|
+
)
|
|
237
|
+
)
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function colorTodo(
|
|
241
|
+
ctx: MigrateContext,
|
|
242
|
+
color: NonNullable<ReturnType<MigrateContext["jsx"]["attr"]>>
|
|
243
|
+
): string {
|
|
244
|
+
const value = ctx.jsx.literal(color)
|
|
245
|
+
const token = typeof value === "string" ? COLOR_TOKENS[value] : undefined
|
|
246
|
+
return `dropped ${printAttr(ctx, color)} (Text has no colour variant${token ? `: set color: ${token} in a makeZenithStyles class` : "; set the colour in a makeZenithStyles class with a tokens.* value"})`
|
|
247
|
+
}
|