@antify/ui-module 1.6.0 → 1.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.d.mts +182 -51
- package/dist/module.d.ts +182 -51
- package/dist/module.json +1 -1
- package/dist/module.mjs +152 -49
- package/dist/runtime/components/AntAccordion.vue +10 -5
- package/dist/runtime/components/AntAccordionItem.vue +19 -7
- package/dist/runtime/components/AntAlert.vue +27 -27
- package/dist/runtime/components/AntCard.vue +34 -0
- package/dist/runtime/components/AntDropdown.vue +2 -2
- package/dist/runtime/components/AntIcon.vue +21 -16
- package/dist/runtime/components/AntKeycap.vue +26 -5
- package/dist/runtime/components/AntListGroupItem.vue +24 -28
- package/dist/runtime/components/AntModal.vue +5 -5
- package/dist/runtime/components/AntPagination.vue +45 -45
- package/dist/runtime/components/AntPopover.vue +3 -3
- package/dist/runtime/components/AntSpinner.vue +56 -50
- package/dist/runtime/components/AntTag.vue +75 -40
- package/dist/runtime/components/AntToast.vue +40 -31
- package/dist/runtime/components/AntToaster.vue +14 -9
- package/dist/runtime/components/AntTooltip.vue +75 -69
- package/dist/runtime/components/__stories/AntAccordion.stories.mjs +3 -2
- package/dist/runtime/components/__stories/AntAlert.stories.mjs +3 -3
- package/dist/runtime/components/__stories/AntCard.stories.d.ts +7 -0
- package/dist/runtime/components/__stories/AntCard.stories.mjs +87 -0
- package/dist/runtime/components/__stories/AntIcon.stories.mjs +7 -4
- package/dist/runtime/components/__stories/AntKeycap.stories.mjs +8 -1
- package/dist/runtime/components/__stories/AntListGroupItem.stories.mjs +3 -3
- package/dist/runtime/components/__stories/AntModal.stories.mjs +2 -2
- package/dist/runtime/components/__stories/AntSpinner.stories.mjs +7 -7
- package/dist/runtime/components/__stories/AntTag.stories.mjs +5 -6
- package/dist/runtime/components/__stories/AntToast.stories.mjs +3 -3
- package/dist/runtime/components/__stories/AntToaster.stories.d.ts +2 -2
- package/dist/runtime/components/__stories/AntToaster.stories.mjs +4 -4
- package/dist/runtime/components/__stories/AntTooltip.stories.d.ts +5 -0
- package/dist/runtime/components/__stories/AntTooltip.stories.mjs +35 -11
- package/dist/runtime/components/__types/AntIcon.types.d.ts +5 -3
- package/dist/runtime/components/__types/AntIcon.types.mjs +5 -3
- package/dist/runtime/components/__types/AntKeycap.types.d.ts +4 -0
- package/dist/runtime/components/__types/AntKeycap.types.mjs +5 -0
- package/dist/runtime/components/__types/AntListGroupItem.types.d.ts +9 -0
- package/dist/runtime/components/__types/AntListGroupItem.types.mjs +10 -0
- package/dist/runtime/components/__types/AntSpinner.types.d.ts +10 -0
- package/dist/runtime/components/__types/AntSpinner.types.mjs +11 -0
- package/dist/runtime/components/__types/AntTag.types.d.ts +17 -0
- package/dist/runtime/components/__types/AntTag.types.mjs +19 -0
- package/dist/runtime/components/__types/AntToaster.types.d.ts +2 -2
- package/dist/runtime/components/__types/index.d.ts +6 -1
- package/dist/runtime/components/__types/index.mjs +6 -1
- package/dist/runtime/components/buttons/AntActionButton.vue +26 -23
- package/dist/runtime/components/buttons/AntButton.vue +85 -75
- package/dist/runtime/components/buttons/AntCreateButton.vue +2 -2
- package/dist/runtime/components/buttons/AntDeleteButton.vue +2 -2
- package/dist/runtime/components/buttons/AntDuplicateButton.vue +2 -2
- package/dist/runtime/components/buttons/AntEditButton.vue +2 -2
- package/dist/runtime/components/buttons/AntSaveAndNewButton.vue +14 -13
- package/dist/runtime/components/buttons/AntSaveButton.vue +13 -12
- package/dist/runtime/components/buttons/__stories/AntActionButton.stories.mjs +15 -11
- package/dist/runtime/components/buttons/__stories/AntButton.stories.mjs +39 -36
- package/dist/runtime/components/buttons/__stories/AntCreateButton.stories.mjs +1 -1
- package/dist/runtime/components/buttons/__stories/AntDeleteButton.stories.mjs +1 -1
- package/dist/runtime/components/buttons/__stories/AntDuplicateButton.stories.mjs +1 -1
- package/dist/runtime/components/buttons/__stories/AntEditButton.stories.mjs +1 -1
- package/dist/runtime/components/buttons/__stories/AntSaveAndNewButton.stories.mjs +1 -1
- package/dist/runtime/components/buttons/__stories/AntSaveButton.stories.mjs +1 -1
- package/dist/runtime/components/buttons/__types/index.d.ts +1 -1
- package/dist/runtime/components/buttons/__types/index.mjs +1 -1
- package/dist/runtime/components/crud/AntCrudDetailActions.vue +2 -2
- package/dist/runtime/components/crud/AntCrudDetailNav.vue +10 -3
- package/dist/runtime/components/crud/AntCrudTableFilter.vue +14 -14
- package/dist/runtime/components/crud/AntCrudTableNav.vue +27 -27
- package/dist/runtime/components/crud/__stories/AntCrud.stories.mjs +1 -1
- package/dist/runtime/components/dialogs/AntDeleteDialog.vue +3 -3
- package/dist/runtime/components/dialogs/AntDialog.vue +23 -23
- package/dist/runtime/components/dialogs/__stories/AndDeleteDialog.stories.mjs +3 -1
- package/dist/runtime/components/dialogs/__stories/AntDialog.stories.mjs +4 -4
- package/dist/runtime/components/forms/AntField.vue +123 -0
- package/dist/runtime/components/forms/AntFormGroupLabel.vue +5 -0
- package/dist/runtime/components/{form/Elements → forms}/__stories/AntField.stories.mjs +15 -15
- package/dist/runtime/components/{form → forms}/__stories/AntFormGroup.stories.mjs +3 -3
- package/dist/runtime/components/{form → forms}/__stories/AntFormGroupLabel.stories.mjs +1 -1
- package/dist/runtime/components/index.d.ts +46 -6
- package/dist/runtime/components/index.mjs +90 -7
- package/dist/runtime/components/inputs/AntCheckbox.vue +183 -0
- package/dist/runtime/components/inputs/AntCheckboxGroup.vue +117 -0
- package/dist/runtime/components/inputs/AntDateInput.vue +97 -0
- package/{src/runtime/components/form → dist/runtime/components/inputs}/AntNumberInput.vue +28 -50
- package/dist/runtime/components/inputs/AntPasswordInput.vue +107 -0
- package/dist/runtime/components/inputs/AntRadio.vue +192 -0
- package/dist/runtime/components/inputs/AntRadioGroup.vue +116 -0
- package/dist/runtime/components/inputs/AntRangeSlider.vue +101 -0
- package/{src/runtime/components/form → dist/runtime/components/inputs}/AntSearch.vue +17 -21
- package/dist/runtime/components/{form → inputs}/AntSelect.vue +68 -60
- package/dist/runtime/components/inputs/AntSwitch.vue +192 -0
- package/dist/runtime/components/inputs/AntSwitcher.vue +196 -0
- package/{src/runtime/components/form → dist/runtime/components/inputs}/AntTagInput.vue +94 -69
- package/dist/runtime/components/inputs/AntTextInput.vue +72 -0
- package/dist/runtime/components/{form → inputs}/AntTextarea.vue +53 -41
- package/dist/runtime/components/{form → inputs}/AntUnitInput.vue +17 -23
- package/dist/runtime/components/inputs/Elements/AntBaseInput.vue +256 -0
- package/dist/runtime/components/{form → inputs}/Elements/AntDropDown.vue +29 -30
- package/dist/runtime/components/{form → inputs}/Elements/AntInputDescription.vue +17 -14
- package/dist/runtime/components/inputs/Elements/AntInputLabel.vue +65 -0
- package/dist/runtime/components/inputs/Elements/AntInputLimiter.vue +58 -0
- package/dist/runtime/components/{form → inputs}/Elements/__stories/AntBaseInput.stories.d.ts +2 -0
- package/dist/runtime/components/inputs/Elements/__stories/AntBaseInput.stories.mjs +234 -0
- package/dist/runtime/components/{form → inputs}/Elements/__stories/AntInputDescription.stories.mjs +5 -5
- package/dist/runtime/components/{form → inputs}/Elements/__stories/AntInputLabel.stories.mjs +3 -3
- package/dist/runtime/components/{form → inputs}/Elements/__stories/AntInputLimiter.stories.mjs +5 -5
- package/dist/runtime/components/inputs/Elements/__types/index.d.ts +1 -0
- package/dist/runtime/components/inputs/Elements/__types/index.mjs +1 -0
- package/dist/runtime/components/{form → inputs}/Elements/index.d.ts +1 -1
- package/dist/runtime/components/{form → inputs}/Elements/index.mjs +1 -1
- package/dist/runtime/components/inputs/__stories/AntCheckbox.stories.mjs +341 -0
- package/dist/runtime/components/{form/AntCheckboxWidget → inputs}/__stories/AntCheckboxGroup.stories.mjs +23 -34
- package/dist/runtime/components/inputs/__stories/AntDateInput.stories.d.ts +8 -0
- package/dist/runtime/components/inputs/__stories/AntDateInput.stories.mjs +193 -0
- package/dist/runtime/components/{form → inputs}/__stories/AntNumberInput.stories.d.ts +2 -1
- package/dist/runtime/components/inputs/__stories/AntNumberInput.stories.mjs +106 -0
- package/dist/runtime/components/inputs/__stories/AntPasswordInput.stories.d.ts +8 -0
- package/dist/runtime/components/inputs/__stories/AntPasswordInput.stories.mjs +156 -0
- package/dist/runtime/components/{form/AntRadioWidget → inputs}/__stories/AntRadioGroup.stories.d.ts +1 -1
- package/dist/runtime/components/inputs/__stories/AntRadioGroup.stories.mjs +243 -0
- package/dist/runtime/components/inputs/__stories/AntRangeSlider.stories.d.ts +7 -0
- package/dist/runtime/components/inputs/__stories/AntRangeSlider.stories.mjs +67 -0
- package/dist/runtime/components/{form → inputs}/__stories/AntSearch.stories.d.ts +1 -0
- package/dist/runtime/components/inputs/__stories/AntSearch.stories.mjs +103 -0
- package/dist/runtime/components/{form → inputs}/__stories/AntSelect.stories.mjs +78 -46
- package/dist/runtime/components/{form → inputs}/__stories/AntSwitch.stories.d.ts +1 -1
- package/dist/runtime/components/inputs/__stories/AntSwitch.stories.mjs +344 -0
- package/dist/runtime/components/{form → inputs}/__stories/AntSwitcher.stories.d.ts +1 -1
- package/dist/runtime/components/inputs/__stories/AntSwitcher.stories.mjs +235 -0
- package/dist/runtime/components/{form → inputs}/__stories/AntTagInput.stories.d.ts +3 -3
- package/dist/runtime/components/inputs/__stories/AntTagInput.stories.mjs +228 -0
- package/dist/runtime/components/{form → inputs}/__stories/AntTextInput.stories.d.ts +2 -0
- package/dist/runtime/components/inputs/__stories/AntTextInput.stories.mjs +225 -0
- package/dist/runtime/components/{form → inputs}/__stories/AntTextarea.stories.d.ts +1 -0
- package/dist/runtime/components/{form → inputs}/__stories/AntTextarea.stories.mjs +44 -31
- package/dist/runtime/components/{form → inputs}/__stories/AntUnitInput.stories.d.ts +1 -0
- package/dist/runtime/components/{form → inputs}/__stories/AntUnitInput.stories.mjs +49 -17
- package/dist/runtime/components/{form/AntCheckboxWidget/__types/AntCheckbox.d.ts → inputs/__types/AntCheckbox.types.d.ts} +4 -0
- package/dist/runtime/components/inputs/__types/AntCheckbox.types.mjs +5 -0
- package/dist/runtime/components/inputs/__types/AntDateInput.types.d.ts +7 -0
- package/dist/runtime/components/inputs/__types/AntDateInput.types.mjs +8 -0
- package/dist/runtime/components/inputs/__types/AntRadio.types.d.ts +13 -0
- package/dist/runtime/components/inputs/__types/AntRadio.types.mjs +5 -0
- package/dist/runtime/components/inputs/__types/AntTagInput.types.d.ts +5 -0
- package/dist/runtime/components/inputs/__types/AntTagInput.types.mjs +6 -0
- package/dist/runtime/components/{form/__types/AntTextInput.type.d.ts → inputs/__types/AntTextInput.types.d.ts} +0 -1
- package/dist/runtime/components/{form/__types/AntTextInput.type.mjs → inputs/__types/AntTextInput.types.mjs} +0 -1
- package/dist/runtime/components/inputs/__types/index.d.ts +7 -0
- package/dist/runtime/components/inputs/__types/index.mjs +7 -0
- package/dist/runtime/components/layouts/AntNavLeftLayout.vue +3 -3
- package/dist/runtime/components/navbar/AntNavbar.vue +10 -10
- package/dist/runtime/components/navbar/AntNavbarItem.vue +5 -5
- package/dist/runtime/components/navbar/__types/{NavbarItem.d.ts → NavbarItem.types.d.ts} +2 -2
- package/dist/runtime/components/navbar/__types/index.d.ts +1 -0
- package/dist/runtime/components/navbar/__types/index.mjs +1 -0
- package/dist/runtime/components/table/AntTable.vue +10 -6
- package/dist/runtime/components/table/AntTableSortButton.vue +37 -27
- package/dist/runtime/components/table/AntTd.vue +21 -10
- package/dist/runtime/components/table/AntTh.vue +21 -14
- package/dist/runtime/components/table/__stories/AntTable.stories.mjs +35 -36
- package/dist/runtime/components/table/__types/{TableHeader.type.d.ts → TableHeader.types.d.ts} +5 -0
- package/dist/runtime/components/table/__types/{TableHeader.type.mjs → TableHeader.types.mjs} +6 -0
- package/dist/runtime/components/table/__types/index.d.ts +1 -0
- package/dist/runtime/components/table/__types/index.mjs +1 -0
- package/dist/runtime/components/tabs/AntTabItem.vue +34 -34
- package/dist/runtime/components/tabs/__stories/AntTabItem.stories.mjs +4 -4
- package/dist/runtime/components/tabs/__stories/AntTabs.stories.mjs +3 -3
- package/dist/runtime/components/tabs/__types/AntTabItem.types.d.ts +2 -2
- package/dist/runtime/components/tabs/__types/AntTabItem.types.mjs +6 -6
- package/dist/runtime/components/tabs/__types/index.d.ts +1 -0
- package/dist/runtime/components/tabs/__types/index.mjs +1 -0
- package/dist/runtime/composables/useUi.d.ts +6 -6
- package/dist/runtime/composables/useUi.mjs +8 -8
- package/dist/runtime/enums/Size.enum.d.ts +4 -1
- package/dist/runtime/enums/Size.enum.mjs +4 -1
- package/dist/runtime/enums/{ColorType.enum.d.ts → State.enum.d.ts} +2 -2
- package/dist/runtime/enums/State.enum.mjs +18 -0
- package/dist/runtime/enums/index.d.ts +2 -1
- package/dist/runtime/enums/index.mjs +2 -1
- package/dist/runtime/plugins/toaster.d.ts +2 -2
- package/dist/runtime/plugins/toaster.mjs +5 -5
- package/dist/runtime/plugins/ui-module.mjs +1 -1
- package/dist/runtime/tailwind.config.d.ts +1 -181
- package/dist/runtime/tailwind.config.mjs +3 -0
- package/dist/runtime/types.d.ts +5 -4
- package/dist/runtime/types.mjs +5 -4
- package/dist/types.d.mts +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
- package/src/runtime/components/AntAccordion.vue +10 -5
- package/src/runtime/components/AntAccordionItem.vue +19 -7
- package/src/runtime/components/AntAlert.vue +27 -27
- package/src/runtime/components/AntCard.vue +34 -0
- package/src/runtime/components/AntDropdown.vue +2 -2
- package/src/runtime/components/AntIcon.vue +21 -16
- package/src/runtime/components/AntKeycap.vue +26 -5
- package/src/runtime/components/AntListGroupItem.vue +24 -28
- package/src/runtime/components/AntModal.vue +5 -5
- package/src/runtime/components/AntPagination.vue +45 -45
- package/src/runtime/components/AntPopover.vue +3 -3
- package/src/runtime/components/AntSpinner.vue +56 -50
- package/src/runtime/components/AntTag.vue +75 -40
- package/src/runtime/components/AntToast.vue +40 -31
- package/src/runtime/components/AntToaster.vue +16 -17
- package/src/runtime/components/AntTooltip.vue +75 -69
- package/src/runtime/components/buttons/AntActionButton.vue +26 -23
- package/src/runtime/components/buttons/AntButton.vue +85 -75
- package/src/runtime/components/buttons/AntCreateButton.vue +2 -2
- package/src/runtime/components/buttons/AntDeleteButton.vue +2 -2
- package/src/runtime/components/buttons/AntDuplicateButton.vue +2 -2
- package/src/runtime/components/buttons/AntEditButton.vue +2 -2
- package/src/runtime/components/buttons/AntSaveAndNewButton.vue +14 -13
- package/src/runtime/components/buttons/AntSaveButton.vue +13 -12
- package/src/runtime/components/crud/AntCrudDetailActions.vue +2 -2
- package/src/runtime/components/crud/AntCrudDetailNav.vue +10 -3
- package/src/runtime/components/crud/AntCrudTableFilter.vue +14 -14
- package/src/runtime/components/crud/AntCrudTableNav.vue +27 -27
- package/src/runtime/components/dialogs/AntDeleteDialog.vue +3 -3
- package/src/runtime/components/dialogs/AntDialog.vue +23 -23
- package/src/runtime/components/forms/AntField.vue +123 -0
- package/src/runtime/components/forms/AntFormGroupLabel.vue +5 -0
- package/src/runtime/components/inputs/AntCheckbox.vue +202 -0
- package/src/runtime/components/inputs/AntCheckboxGroup.vue +117 -0
- package/src/runtime/components/inputs/AntDateInput.vue +97 -0
- package/{dist/runtime/components/form → src/runtime/components/inputs}/AntNumberInput.vue +28 -50
- package/src/runtime/components/inputs/AntPasswordInput.vue +107 -0
- package/src/runtime/components/inputs/AntRadio.vue +200 -0
- package/src/runtime/components/inputs/AntRadioGroup.vue +116 -0
- package/src/runtime/components/inputs/AntRangeSlider.vue +121 -0
- package/{dist/runtime/components/form → src/runtime/components/inputs}/AntSearch.vue +17 -21
- package/src/runtime/components/{form → inputs}/AntSelect.vue +68 -60
- package/src/runtime/components/inputs/AntSwitch.vue +192 -0
- package/src/runtime/components/inputs/AntSwitcher.vue +196 -0
- package/{dist/runtime/components/form → src/runtime/components/inputs}/AntTagInput.vue +94 -69
- package/src/runtime/components/inputs/AntTextInput.vue +72 -0
- package/src/runtime/components/{form → inputs}/AntTextarea.vue +53 -41
- package/src/runtime/components/{form → inputs}/AntUnitInput.vue +17 -23
- package/src/runtime/components/inputs/Elements/AntBaseInput.vue +304 -0
- package/src/runtime/components/{form → inputs}/Elements/AntDropDown.vue +29 -30
- package/src/runtime/components/{form → inputs}/Elements/AntInputDescription.vue +17 -14
- package/src/runtime/components/inputs/Elements/AntInputLabel.vue +65 -0
- package/src/runtime/components/inputs/Elements/AntInputLimiter.vue +58 -0
- package/src/runtime/components/layouts/AntNavLeftLayout.vue +3 -3
- package/src/runtime/components/navbar/AntNavbar.vue +10 -10
- package/src/runtime/components/navbar/AntNavbarItem.vue +5 -5
- package/src/runtime/components/table/AntTable.vue +10 -6
- package/src/runtime/components/table/AntTableSortButton.vue +37 -27
- package/src/runtime/components/table/AntTd.vue +21 -10
- package/src/runtime/components/table/AntTh.vue +21 -14
- package/src/runtime/components/tabs/AntTabItem.vue +34 -34
- package/dist/runtime/components/form/AntCheckboxWidget/AntCheckbox.vue +0 -144
- package/dist/runtime/components/form/AntCheckboxWidget/AntCheckboxGroup.vue +0 -91
- package/dist/runtime/components/form/AntCheckboxWidget/__stories/AntCheckbox.stories.mjs +0 -289
- package/dist/runtime/components/form/AntFormGroupLabel.vue +0 -5
- package/dist/runtime/components/form/AntRadioWidget/AntRadio.vue +0 -139
- package/dist/runtime/components/form/AntRadioWidget/AntRadioGroup.vue +0 -80
- package/dist/runtime/components/form/AntRadioWidget/__stories/AntRadio.stories.d.ts +0 -8
- package/dist/runtime/components/form/AntRadioWidget/__stories/AntRadio.stories.mjs +0 -79
- package/dist/runtime/components/form/AntRadioWidget/__stories/AntRadioGroup.stories.mjs +0 -125
- package/dist/runtime/components/form/AntRadioWidget/__types/AntRadio.type.d.ts +0 -9
- package/dist/runtime/components/form/AntRangeSlider.vue +0 -81
- package/dist/runtime/components/form/AntSwitch.vue +0 -153
- package/dist/runtime/components/form/AntSwitcher.vue +0 -184
- package/dist/runtime/components/form/AntTextInput.vue +0 -73
- package/dist/runtime/components/form/Elements/AntBaseInput.vue +0 -220
- package/dist/runtime/components/form/Elements/AntField.vue +0 -105
- package/dist/runtime/components/form/Elements/AntInputLabel.vue +0 -55
- package/dist/runtime/components/form/Elements/AntInputLimiter.vue +0 -55
- package/dist/runtime/components/form/Elements/__stories/AntBaseInput.stories.mjs +0 -171
- package/dist/runtime/components/form/Elements/__types/index.d.ts +0 -1
- package/dist/runtime/components/form/Elements/__types/index.mjs +0 -1
- package/dist/runtime/components/form/__stories/AntNumberInput.stories.mjs +0 -74
- package/dist/runtime/components/form/__stories/AntRangeSlider.stories.d.ts +0 -6
- package/dist/runtime/components/form/__stories/AntRangeSlider.stories.mjs +0 -40
- package/dist/runtime/components/form/__stories/AntSearch.stories.mjs +0 -43
- package/dist/runtime/components/form/__stories/AntSwitch.stories.mjs +0 -218
- package/dist/runtime/components/form/__stories/AntSwitcher.stories.mjs +0 -228
- package/dist/runtime/components/form/__stories/AntTagInput.stories.mjs +0 -106
- package/dist/runtime/components/form/__stories/AntTextInput.stories.mjs +0 -68
- package/dist/runtime/components/form/__types/AntSwitcher.type.mjs +0 -0
- package/dist/runtime/components/form/__types/index.d.ts +0 -3
- package/dist/runtime/components/form/__types/index.mjs +0 -3
- package/dist/runtime/components/form/index.d.ts +0 -12
- package/dist/runtime/components/form/index.mjs +0 -24
- package/dist/runtime/components/navbar/__types/NavbarItem.mjs +0 -0
- package/dist/runtime/enums/ColorType.enum.mjs +0 -18
- package/dist/runtime/types/AntListGroupItem.type.d.ts +0 -11
- package/dist/runtime/types/AntListGroupItem.type.mjs +0 -12
- package/dist/runtime/types/AntTag.type.d.ts +0 -7
- package/dist/runtime/types/AntTag.type.mjs +0 -8
- package/dist/runtime/types/Checkbox.type.d.ts +0 -8
- package/dist/runtime/types/Checkbox.type.mjs +0 -0
- package/dist/runtime/types/NavItem.type.d.ts +0 -9
- package/dist/runtime/types/NavItem.type.mjs +0 -0
- package/dist/runtime/types/RadioButton.type.d.ts +0 -5
- package/dist/runtime/types/RadioButton.type.mjs +0 -0
- package/dist/runtime/types/Tabs.type.d.ts +0 -6
- package/dist/runtime/types/Tabs.type.mjs +0 -0
- package/dist/runtime/types/Toaster.type.d.ts +0 -6
- package/dist/runtime/types/Toaster.type.mjs +0 -0
- package/dist/runtime/types/index.d.ts +0 -7
- package/dist/runtime/types/index.mjs +0 -7
- package/src/runtime/components/form/AntCheckboxWidget/AntCheckbox.vue +0 -166
- package/src/runtime/components/form/AntCheckboxWidget/AntCheckboxGroup.vue +0 -91
- package/src/runtime/components/form/AntFormGroupLabel.vue +0 -5
- package/src/runtime/components/form/AntRadioWidget/AntRadio.vue +0 -164
- package/src/runtime/components/form/AntRadioWidget/AntRadioGroup.vue +0 -80
- package/src/runtime/components/form/AntRangeSlider.vue +0 -101
- package/src/runtime/components/form/AntSwitch.vue +0 -153
- package/src/runtime/components/form/AntSwitcher.vue +0 -200
- package/src/runtime/components/form/AntTextInput.vue +0 -73
- package/src/runtime/components/form/Elements/AntBaseInput.vue +0 -251
- package/src/runtime/components/form/Elements/AntField.vue +0 -105
- package/src/runtime/components/form/Elements/AntInputLabel.vue +0 -55
- package/src/runtime/components/form/Elements/AntInputLimiter.vue +0 -55
- /package/dist/runtime/components/__types/{Accordion.types.d.ts → AntAccordion.types.d.ts} +0 -0
- /package/dist/runtime/components/__types/{Accordion.types.mjs → AntAccordion.types.mjs} +0 -0
- /package/dist/runtime/components/buttons/__types/{AntButton.type.d.ts → AntButton.types.d.ts} +0 -0
- /package/dist/runtime/components/buttons/__types/{AntButton.type.mjs → AntButton.types.mjs} +0 -0
- /package/dist/runtime/components/{form → forms}/AntFormGroup.vue +0 -0
- /package/dist/runtime/components/{form/Elements → forms}/__stories/AntField.stories.d.ts +0 -0
- /package/dist/runtime/components/{form → forms}/__stories/AntFormGroup.stories.d.ts +0 -0
- /package/dist/runtime/components/{form → forms}/__stories/AntFormGroupLabel.stories.d.ts +0 -0
- /package/dist/runtime/components/{form → inputs}/AntRichTextEditor.vue +0 -0
- /package/dist/runtime/components/{form → inputs}/Elements/__stories/AntInputDescription.stories.d.ts +0 -0
- /package/dist/runtime/components/{form → inputs}/Elements/__stories/AntInputLabel.stories.d.ts +0 -0
- /package/dist/runtime/components/{form → inputs}/Elements/__stories/AntInputLimiter.stories.d.ts +0 -0
- /package/dist/runtime/components/{form/Elements/__types/AntBaseInput.type.d.ts → inputs/Elements/__types/AntBaseInput.types.d.ts} +0 -0
- /package/dist/runtime/components/{form/Elements/__types/AntBaseInput.type.mjs → inputs/Elements/__types/AntBaseInput.types.mjs} +0 -0
- /package/dist/runtime/components/{form/AntCheckboxWidget → inputs}/__stories/AntCheckbox.stories.d.ts +0 -0
- /package/dist/runtime/components/{form/AntCheckboxWidget → inputs}/__stories/AntCheckboxGroup.stories.d.ts +0 -0
- /package/dist/runtime/components/{form → inputs}/__stories/AntRichTextEditor.stories-old.d.ts +0 -0
- /package/dist/runtime/components/{form → inputs}/__stories/AntRichTextEditor.stories-old.mjs +0 -0
- /package/dist/runtime/components/{form → inputs}/__stories/AntSelect.stories.d.ts +0 -0
- /package/dist/runtime/components/{form/__types/AntSelect.type.d.ts → inputs/__types/AntSelect.types.d.ts} +0 -0
- /package/dist/runtime/components/{form/AntCheckboxWidget/__types/AntCheckbox.mjs → inputs/__types/AntSelect.types.mjs} +0 -0
- /package/dist/runtime/components/{form/__types/AntSwitcher.type.d.ts → inputs/__types/AntSwitcher.types.d.ts} +0 -0
- /package/dist/runtime/components/{form/AntRadioWidget/__types/AntRadio.type.mjs → inputs/__types/AntSwitcher.types.mjs} +0 -0
- /package/dist/runtime/components/{form/__types/AntSelect.type.mjs → navbar/__types/NavbarItem.types.mjs} +0 -0
- /package/src/runtime/components/{form → forms}/AntFormGroup.vue +0 -0
- /package/src/runtime/components/{form → inputs}/AntRichTextEditor.vue +0 -0
|
@@ -12,11 +12,10 @@
|
|
|
12
12
|
* Fix overflow bug (See Ellipsis Text story)
|
|
13
13
|
* TODO:: if the dropdown is open and the user types something, the element with a matching value should be focused.
|
|
14
14
|
*/
|
|
15
|
-
import AntField from '
|
|
16
|
-
import {type SelectOption} from './__types/AntSelect.
|
|
17
|
-
import {computed, onMounted, ref} from 'vue';
|
|
15
|
+
import AntField from '../forms/AntField.vue';
|
|
16
|
+
import {type SelectOption} from './__types/AntSelect.types';
|
|
17
|
+
import {computed, onMounted, ref, watch} from 'vue';
|
|
18
18
|
import {Size} from '../../enums/Size.enum';
|
|
19
|
-
import {FieldValidator} from '@antify/validate';
|
|
20
19
|
import {handleEnumValidation} from '../../handler';
|
|
21
20
|
import {Grouped} from '../../enums/Grouped.enum';
|
|
22
21
|
import AntIcon from '../AntIcon.vue';
|
|
@@ -24,11 +23,12 @@ import {faChevronDown, faChevronUp, faMultiply} from '@fortawesome/free-solid-sv
|
|
|
24
23
|
import AntSkeleton from '../AntSkeleton.vue';
|
|
25
24
|
import {vOnClickOutside} from '@vueuse/components';
|
|
26
25
|
import AntButton from '../buttons/AntButton.vue';
|
|
27
|
-
import {
|
|
26
|
+
import {State, InputState} from '../../enums';
|
|
28
27
|
import {IconSize} from '../__types';
|
|
29
28
|
import AntDropDown from './Elements/AntDropDown.vue';
|
|
30
29
|
|
|
31
30
|
defineOptions({ inheritAttrs: false });
|
|
31
|
+
|
|
32
32
|
const props = withDefaults(
|
|
33
33
|
defineProps<{
|
|
34
34
|
modelValue: string | number | null;
|
|
@@ -37,55 +37,55 @@ const props = withDefaults(
|
|
|
37
37
|
description?: string;
|
|
38
38
|
placeholder?: string;
|
|
39
39
|
size?: Size;
|
|
40
|
-
|
|
40
|
+
state?: InputState;
|
|
41
41
|
disabled?: boolean;
|
|
42
42
|
skeleton?: boolean;
|
|
43
|
-
validator?: FieldValidator;
|
|
44
43
|
nullable?: boolean;
|
|
45
44
|
grouped?: Grouped;
|
|
46
45
|
name?: string;
|
|
47
46
|
wrapperClass?: string | Record<string, boolean>;
|
|
48
47
|
expanded?: boolean;
|
|
48
|
+
messages?: string[]
|
|
49
49
|
}>(), {
|
|
50
|
-
|
|
50
|
+
state: InputState.base,
|
|
51
51
|
grouped: Grouped.none,
|
|
52
52
|
size: Size.md,
|
|
53
53
|
disabled: false,
|
|
54
54
|
skeleton: false,
|
|
55
55
|
nullable: false,
|
|
56
|
-
expanded: true
|
|
56
|
+
expanded: true,
|
|
57
|
+
messages: () => []
|
|
57
58
|
}
|
|
58
59
|
);
|
|
59
|
-
const emit = defineEmits(['update:modelValue']);
|
|
60
|
+
const emit = defineEmits(['update:modelValue', 'blur', 'validate']);
|
|
60
61
|
const isOpen = ref(false);
|
|
61
62
|
const _modelValue = computed({
|
|
62
63
|
get: () => props.modelValue,
|
|
63
64
|
set: (val: string | number | null) => {
|
|
64
|
-
props.validator?.validate(val);
|
|
65
65
|
emit('update:modelValue', val);
|
|
66
66
|
},
|
|
67
67
|
});
|
|
68
68
|
const valueLabel = computed(() => props.options.find(option => option.value === _modelValue.value)?.label || null);
|
|
69
69
|
const inputClasses = computed(() => {
|
|
70
|
-
const variants: Record<
|
|
71
|
-
[
|
|
72
|
-
[
|
|
73
|
-
[
|
|
74
|
-
[
|
|
75
|
-
[
|
|
70
|
+
const variants: Record<InputState, string> = {
|
|
71
|
+
[InputState.base]: 'outline-neutral-300 bg-white focus:ring-primary-200',
|
|
72
|
+
[InputState.success]: 'outline-success-500 bg-success-100 focus:ring-success-200',
|
|
73
|
+
[InputState.info]: 'outline-info-500 bg-info-100 focus:ring-info-200',
|
|
74
|
+
[InputState.warning]: 'outline-warning-500 bg-warning-100 focus:ring-warning-200',
|
|
75
|
+
[InputState.danger]: 'outline-danger-500 bg-danger-100 focus:ring-danger-200',
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
return {
|
|
79
79
|
'flex items-center transition-colors border-none outline relative focus:z-10': true,
|
|
80
80
|
'outline-offset-[-1px] outline-1 focus:outline-offset-[-1px] focus:outline-1': true,
|
|
81
|
-
[variants[
|
|
81
|
+
[variants[props.state]]: true,
|
|
82
82
|
// Skeleton
|
|
83
83
|
'invisible': props.skeleton,
|
|
84
84
|
// Disabled
|
|
85
85
|
'disabled:opacity-50 disabled:cursor-not-allowed': true,
|
|
86
86
|
// Size
|
|
87
|
-
'focus:ring-2 p-1.5 gap-1.5 text-
|
|
88
|
-
'focus:ring-4 p-2
|
|
87
|
+
'focus:ring-2 p-1.5 gap-1.5 text-sm': props.size === Size.sm,
|
|
88
|
+
'focus:ring-4 p-2 gap-2 text-sm': props.size === Size.md,
|
|
89
89
|
// Grouped
|
|
90
90
|
'rounded-tl-md rounded-bl-md rounded-tr-none rounded-br-none': props.grouped === Grouped.left,
|
|
91
91
|
'rounded-tl-none rounded-bl-none rounded-tr-md rounded-br-md': props.grouped === Grouped.right,
|
|
@@ -100,44 +100,30 @@ const inputClasses = computed(() => {
|
|
|
100
100
|
};
|
|
101
101
|
});
|
|
102
102
|
const placeholderClasses = computed(() => {
|
|
103
|
-
const variants: Record<
|
|
104
|
-
[
|
|
105
|
-
[
|
|
106
|
-
[
|
|
107
|
-
[
|
|
108
|
-
[
|
|
103
|
+
const variants: Record<InputState, string> = {
|
|
104
|
+
[InputState.base]: 'text-neutral-500',
|
|
105
|
+
[InputState.success]: 'text-success-700',
|
|
106
|
+
[InputState.info]: 'text-info-700',
|
|
107
|
+
[InputState.warning]: 'text-warning-700',
|
|
108
|
+
[InputState.danger]: 'text-danger-700',
|
|
109
109
|
};
|
|
110
110
|
|
|
111
111
|
return {
|
|
112
112
|
'select-none text-ellipsis overflow-hidden whitespace-nowrap w-full': true,
|
|
113
|
-
[variants[
|
|
114
|
-
};
|
|
115
|
-
});
|
|
116
|
-
const inputValueClasses = computed(() => {
|
|
117
|
-
const variants: Record<InputColorType, string> = {
|
|
118
|
-
[InputColorType.base]: 'text-for-white-bg-font',
|
|
119
|
-
[InputColorType.success]: 'text-success-100-font',
|
|
120
|
-
[InputColorType.info]: 'text-info-100-font',
|
|
121
|
-
[InputColorType.warning]: 'text-warning-100-font',
|
|
122
|
-
[InputColorType.danger]: 'text-danger-100-font',
|
|
123
|
-
};
|
|
124
|
-
return {
|
|
125
|
-
'select-none text-ellipsis overflow-hidden whitespace-nowrap w-full': true,
|
|
126
|
-
[variants[_colorType.value]]: true,
|
|
113
|
+
[variants[props.state]]: true,
|
|
127
114
|
};
|
|
128
115
|
});
|
|
129
116
|
const arrowClasses = computed(() => {
|
|
130
|
-
const variants: Record<
|
|
131
|
-
[
|
|
132
|
-
[
|
|
133
|
-
[
|
|
134
|
-
[
|
|
135
|
-
[
|
|
117
|
+
const variants: Record<InputState, string> = {
|
|
118
|
+
[InputState.base]: 'text-for-white-bg-font',
|
|
119
|
+
[InputState.success]: 'text-success-100-font',
|
|
120
|
+
[InputState.info]: 'text-info-100-font',
|
|
121
|
+
[InputState.warning]: 'text-warning-100-font',
|
|
122
|
+
[InputState.danger]: 'text-danger-100-font',
|
|
136
123
|
};
|
|
137
124
|
|
|
138
|
-
return {[variants[
|
|
125
|
+
return {[variants[props.state]]: true};
|
|
139
126
|
});
|
|
140
|
-
const _colorType = computed(() => props.validator?.hasErrors() ? InputColorType.danger : props.colorType);
|
|
141
127
|
const skeletonGrouped = computed(() => {
|
|
142
128
|
if (!props.nullable || (props.nullable && _modelValue.value === null)) {
|
|
143
129
|
return props.grouped;
|
|
@@ -157,14 +143,35 @@ const dropDownFocused = ref(null);
|
|
|
157
143
|
|
|
158
144
|
onMounted(() => {
|
|
159
145
|
handleEnumValidation(props.size, Size, 'size');
|
|
160
|
-
handleEnumValidation(props.
|
|
146
|
+
handleEnumValidation(props.state, InputState, 'state');
|
|
161
147
|
handleEnumValidation(props.grouped, Grouped, 'grouped');
|
|
162
148
|
|
|
163
|
-
props.validator?.validate(_modelValue.value);
|
|
164
|
-
|
|
165
149
|
focusedDropDownItem.value = _modelValue.value;
|
|
150
|
+
|
|
151
|
+
if (!props.skeleton && props.modelValue !== null) {
|
|
152
|
+
emit('validate', props.modelValue);
|
|
153
|
+
}
|
|
166
154
|
});
|
|
167
155
|
|
|
156
|
+
/**
|
|
157
|
+
* Validate default value if given after delayed data fetching.
|
|
158
|
+
*/
|
|
159
|
+
watch(() => props.skeleton, (val) => {
|
|
160
|
+
if (!val && props.modelValue !== null) {
|
|
161
|
+
emit('validate', props.modelValue);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
watch(_modelValue, () => {
|
|
165
|
+
if (props.messages.length > 0) {
|
|
166
|
+
emit('validate', props.modelValue);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
function onBlur(e: FocusEvent) {
|
|
171
|
+
emit('validate', props.modelValue);
|
|
172
|
+
emit('blur', e);
|
|
173
|
+
}
|
|
174
|
+
|
|
168
175
|
function onClickOutside() {
|
|
169
176
|
if (!isOpen.value) {
|
|
170
177
|
return;
|
|
@@ -182,7 +189,7 @@ function onClickSelectInput(e: MouseEvent) {
|
|
|
182
189
|
}
|
|
183
190
|
|
|
184
191
|
if (isOpen.value) {
|
|
185
|
-
inputRef.value?.focus()
|
|
192
|
+
inputRef.value?.focus();
|
|
186
193
|
}
|
|
187
194
|
|
|
188
195
|
isOpen.value = !isOpen.value;
|
|
@@ -200,10 +207,10 @@ function onClickRemoveButton() {
|
|
|
200
207
|
:size="size"
|
|
201
208
|
:skeleton="skeleton"
|
|
202
209
|
:description="description"
|
|
203
|
-
:
|
|
204
|
-
:validator="validator"
|
|
210
|
+
:state="state"
|
|
205
211
|
:class="wrapperClass"
|
|
206
212
|
:expanded="expanded"
|
|
213
|
+
:messages="messages"
|
|
207
214
|
label-for="noop"
|
|
208
215
|
data-e2e="select"
|
|
209
216
|
@click-label="() => inputRef?.focus()"
|
|
@@ -237,6 +244,7 @@ function onClickRemoveButton() {
|
|
|
237
244
|
v-bind="$attrs"
|
|
238
245
|
@mousedown="onClickSelectInput"
|
|
239
246
|
@click="inputRef?.focus()"
|
|
247
|
+
@blur="onBlur"
|
|
240
248
|
>
|
|
241
249
|
<div
|
|
242
250
|
v-if="_modelValue === null && placeholder !== undefined"
|
|
@@ -254,7 +262,7 @@ function onClickRemoveButton() {
|
|
|
254
262
|
|
|
255
263
|
<div
|
|
256
264
|
v-else
|
|
257
|
-
|
|
265
|
+
class="select-none text-ellipsis overflow-hidden whitespace-nowrap w-full text-black"
|
|
258
266
|
>
|
|
259
267
|
{{ valueLabel }}
|
|
260
268
|
</div>
|
|
@@ -262,14 +270,14 @@ function onClickRemoveButton() {
|
|
|
262
270
|
<AntIcon
|
|
263
271
|
v-if="isOpen"
|
|
264
272
|
:icon="faChevronUp"
|
|
265
|
-
:size="
|
|
273
|
+
:size="IconSize.sm"
|
|
266
274
|
:class="arrowClasses"
|
|
267
275
|
/>
|
|
268
276
|
|
|
269
277
|
<AntIcon
|
|
270
278
|
v-else
|
|
271
279
|
:icon="faChevronDown"
|
|
272
|
-
:size="
|
|
280
|
+
:size="IconSize.sm"
|
|
273
281
|
:class="arrowClasses"
|
|
274
282
|
/>
|
|
275
283
|
</div>
|
|
@@ -283,8 +291,8 @@ function onClickRemoveButton() {
|
|
|
283
291
|
:options="options"
|
|
284
292
|
:input-ref="inputRef"
|
|
285
293
|
:size="size"
|
|
286
|
-
:
|
|
287
|
-
close-on-enter
|
|
294
|
+
:state="state"
|
|
295
|
+
:close-on-enter="true"
|
|
288
296
|
@select-element="(e) => _modelValue = e"
|
|
289
297
|
/>
|
|
290
298
|
</div>
|
|
@@ -292,7 +300,7 @@ function onClickRemoveButton() {
|
|
|
292
300
|
<AntButton
|
|
293
301
|
v-if="nullable && _modelValue !== null"
|
|
294
302
|
:icon-left="faMultiply"
|
|
295
|
-
:
|
|
303
|
+
:state="state as unknown as State"
|
|
296
304
|
:grouped="[Grouped.left, Grouped.center].some(item => item === grouped) ? Grouped.center : Grouped.right"
|
|
297
305
|
:size="size"
|
|
298
306
|
:skeleton="skeleton"
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import AntField from '../forms/AntField.vue';
|
|
3
|
+
import {computed, onMounted, watch} from 'vue';
|
|
4
|
+
import AntSkeleton from '../AntSkeleton.vue';
|
|
5
|
+
import {InputState, Size} from '../../enums';
|
|
6
|
+
import {hasSlotContent} from '../../utils';
|
|
7
|
+
|
|
8
|
+
const emit = defineEmits(['update:modelValue', 'input', 'blur', 'validate']);
|
|
9
|
+
const props = withDefaults(defineProps<{
|
|
10
|
+
modelValue: boolean | null;
|
|
11
|
+
label?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
skeleton?: boolean;
|
|
14
|
+
readonly?: boolean;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
size?: Size;
|
|
17
|
+
state?: InputState
|
|
18
|
+
messages?: string[]
|
|
19
|
+
}>(), {
|
|
20
|
+
size: Size.md,
|
|
21
|
+
state: InputState.base,
|
|
22
|
+
messages: () => []
|
|
23
|
+
});
|
|
24
|
+
const _value = computed({
|
|
25
|
+
get: () => props.modelValue,
|
|
26
|
+
set: (val: boolean | null) => {
|
|
27
|
+
emit('update:modelValue', val);
|
|
28
|
+
emit('input', val);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const hasInputState = computed(() => props.skeleton || props.readonly || props.disabled);
|
|
32
|
+
const buttonClasses = computed(() => {
|
|
33
|
+
const classes: { [key: string]: boolean } = {
|
|
34
|
+
'relative inline-flex flex-shrink-0': true,
|
|
35
|
+
'focus:outline-none': true,
|
|
36
|
+
'rounded-full ease-in-out duration-200': true,
|
|
37
|
+
'focus-within:ring-4': !hasInputState.value && (props.size === Size.lg || props.size === Size.md),
|
|
38
|
+
'focus-within:ring-2': !hasInputState.value && (props.size === Size.sm || props.size === Size.xs || props.size === Size.xs2),
|
|
39
|
+
'h-5 w-9': props.size === Size.lg || props.size === Size.md || props.size === Size.sm,
|
|
40
|
+
'h-4 w-[30px]': props.size === Size.xs || props.size === Size.xs2,
|
|
41
|
+
'bg-neutral-300': !_value.value,
|
|
42
|
+
'invisible': props.skeleton,
|
|
43
|
+
// Disabled
|
|
44
|
+
'opacity-50 cursor-not-allowed': props.disabled,
|
|
45
|
+
'cursor-default': props.readonly
|
|
46
|
+
};
|
|
47
|
+
const colorVariant = {
|
|
48
|
+
[InputState.base]: 'focus-within:ring-primary-200',
|
|
49
|
+
[InputState.danger]: 'focus-within:ring-danger-200 outline outline-1 -outline-offset-1 outline-danger-500',
|
|
50
|
+
[InputState.info]: 'focus-within:ring-info-200 outline outline-1 -outline-offset-1 outline-info-500',
|
|
51
|
+
[InputState.success]: 'focus-within:ring-success-200 outline outline-1 -outline-offset-1 outline-success-500',
|
|
52
|
+
[InputState.warning]: 'focus-within:ring-warning-200 outline outline-1 -outline-offset-1 outline-warning-500',
|
|
53
|
+
};
|
|
54
|
+
const activeColorVariant = {
|
|
55
|
+
[InputState.base]: 'bg-primary-500',
|
|
56
|
+
[InputState.danger]: 'bg-danger-500',
|
|
57
|
+
[InputState.info]: 'bg-info-500',
|
|
58
|
+
[InputState.success]: 'bg-success-500',
|
|
59
|
+
[InputState.warning]: 'bg-warning-500',
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
classes[colorVariant[props.state]] = !hasInputState.value;
|
|
63
|
+
classes[activeColorVariant[props.state]] = !!_value.value;
|
|
64
|
+
|
|
65
|
+
return classes;
|
|
66
|
+
});
|
|
67
|
+
const ballClasses = computed(() => ({
|
|
68
|
+
'pointer-events-none inline-block rounded-full bg-neutral-100 shadow transform ring-0 transition ease-in-out duration-200': true,
|
|
69
|
+
'h-4 w-4 translate-y-0.5': props.size === Size.lg || props.size === Size.md || props.size === Size.sm,
|
|
70
|
+
'translate-x-[1.125rem]': _value.value && (props.size === Size.lg || props.size === Size.md || props.size === Size.sm),
|
|
71
|
+
'translate-x-0.5': !_value.value && (props.size === Size.lg || props.size === Size.md || props.size === Size.sm),
|
|
72
|
+
'h-3.5 w-3.5 translate-y-[1px]': props.size === Size.xs || props.size === Size.xs2,
|
|
73
|
+
'translate-x-[.925rem]': _value.value && (props.size === Size.xs || props.size === Size.xs2),
|
|
74
|
+
'translate-x-[1px]': !_value.value && (props.size === Size.xs || props.size === Size.xs2),
|
|
75
|
+
'invisible': props.skeleton
|
|
76
|
+
}));
|
|
77
|
+
const valueClasses = computed(() => ({
|
|
78
|
+
'text-for-white-bg-font': true,
|
|
79
|
+
'text-sm': props.size === Size.lg || props.size === Size.md || props.size === Size.sm,
|
|
80
|
+
'text-xs': props.size === Size.xs || props.size === Size.xs2,
|
|
81
|
+
'opacity-50 cursor-not-allowed': props.disabled,
|
|
82
|
+
'cursor-pointer': !hasInputState.value,
|
|
83
|
+
}));
|
|
84
|
+
const fieldSize = computed(() => {
|
|
85
|
+
if (props.size === Size.lg) {
|
|
86
|
+
return Size.lg;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (props.size === Size.md) {
|
|
90
|
+
return Size.md;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (props.size === Size.sm) {
|
|
94
|
+
return Size.sm;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (props.size === Size.xs) {
|
|
98
|
+
return Size.xs;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return Size.xs2;
|
|
102
|
+
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Validations
|
|
107
|
+
*/
|
|
108
|
+
watch(() => props.skeleton, (val) => {
|
|
109
|
+
if (!val && props.modelValue !== null) {
|
|
110
|
+
emit('validate', props.modelValue);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
watch(_value, () => {
|
|
114
|
+
if (props.messages.length > 0) {
|
|
115
|
+
emit('validate', props.modelValue);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
onMounted(() => {
|
|
119
|
+
if (!props.skeleton && props.modelValue !== null) {
|
|
120
|
+
emit('validate', props.modelValue);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
function changeValue() {
|
|
125
|
+
if (!hasInputState.value) {
|
|
126
|
+
_value.value = !_value.value;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function onBlur(e: FocusEvent) {
|
|
131
|
+
emit('validate', props.modelValue);
|
|
132
|
+
emit('blur', e);
|
|
133
|
+
}
|
|
134
|
+
</script>
|
|
135
|
+
|
|
136
|
+
<template>
|
|
137
|
+
<AntField
|
|
138
|
+
:label="label"
|
|
139
|
+
:size="fieldSize"
|
|
140
|
+
:description="description"
|
|
141
|
+
:skeleton="skeleton"
|
|
142
|
+
:state="state"
|
|
143
|
+
:messages="messages"
|
|
144
|
+
:expanded="false"
|
|
145
|
+
>
|
|
146
|
+
<div class="relative w-fit flex items-center gap-1.5">
|
|
147
|
+
<div class="relative w-fit flex items-center">
|
|
148
|
+
<button
|
|
149
|
+
v-bind="$attrs"
|
|
150
|
+
type="button"
|
|
151
|
+
:class="buttonClasses"
|
|
152
|
+
role="switch"
|
|
153
|
+
:aria-checked="!!_value"
|
|
154
|
+
:disabled="disabled"
|
|
155
|
+
:tabindex="hasInputState ? -1 : 0"
|
|
156
|
+
@click="changeValue"
|
|
157
|
+
@blur="onBlur"
|
|
158
|
+
>
|
|
159
|
+
<span
|
|
160
|
+
aria-hidden="true"
|
|
161
|
+
:class="ballClasses"
|
|
162
|
+
>
|
|
163
|
+
<slot name="icon" />
|
|
164
|
+
</span>
|
|
165
|
+
</button>
|
|
166
|
+
|
|
167
|
+
<AntSkeleton
|
|
168
|
+
v-if="skeleton"
|
|
169
|
+
absolute
|
|
170
|
+
rounded-full
|
|
171
|
+
/>
|
|
172
|
+
</div>
|
|
173
|
+
|
|
174
|
+
<div
|
|
175
|
+
v-if="hasSlotContent($slots['default'])"
|
|
176
|
+
class="relative flex items-center"
|
|
177
|
+
:class="props.size === Size.lg || props.size === Size.md ||props.size === Size.sm ? 'h-5' : 'h-4'"
|
|
178
|
+
>
|
|
179
|
+
<span :class="valueClasses">
|
|
180
|
+
<slot />
|
|
181
|
+
</span>
|
|
182
|
+
|
|
183
|
+
<AntSkeleton
|
|
184
|
+
v-if="skeleton"
|
|
185
|
+
absolute
|
|
186
|
+
rounded
|
|
187
|
+
class="l-1.5"
|
|
188
|
+
/>
|
|
189
|
+
</div>
|
|
190
|
+
</div>
|
|
191
|
+
</AntField>
|
|
192
|
+
</template>
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import AntField from '../forms/AntField.vue';
|
|
3
|
+
import AntButton from '../buttons/AntButton.vue';
|
|
4
|
+
import {faChevronLeft, faChevronRight} from '@fortawesome/free-solid-svg-icons';
|
|
5
|
+
import AntSkeleton from '../AntSkeleton.vue';
|
|
6
|
+
import {type SwitcherOption} from './__types/AntSwitcher.types';
|
|
7
|
+
import {State, Grouped, InputState, Size} from '../../enums';
|
|
8
|
+
import {computed, onMounted, watch} from 'vue';
|
|
9
|
+
|
|
10
|
+
const emit = defineEmits(['update:modelValue', 'validate', 'blur']);
|
|
11
|
+
const props = withDefaults(defineProps<{
|
|
12
|
+
modelValue: string | null;
|
|
13
|
+
options: string[] | SwitcherOption[];
|
|
14
|
+
label?: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
skeleton?: boolean;
|
|
17
|
+
readonly?: boolean;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
state?: InputState;
|
|
20
|
+
size?: Size,
|
|
21
|
+
messages?: string[];
|
|
22
|
+
}>(), {
|
|
23
|
+
state: InputState.base,
|
|
24
|
+
size: Size.md,
|
|
25
|
+
messages: () => []
|
|
26
|
+
});
|
|
27
|
+
const _value = computed({
|
|
28
|
+
get() {
|
|
29
|
+
const found = props.options.find((option: string | SwitcherOption) =>
|
|
30
|
+
typeof option === 'string' ? option === props.modelValue : option.value === props.modelValue);
|
|
31
|
+
|
|
32
|
+
if (!found) {
|
|
33
|
+
return props.options[0];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return found;
|
|
37
|
+
},
|
|
38
|
+
set(val: string | SwitcherOption) {
|
|
39
|
+
emit('update:modelValue', typeof val === 'string' ? val : val.value);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
const hasInputState = computed(() => props.skeleton || props.readonly || props.disabled);
|
|
43
|
+
const containerClasses = computed(() => {
|
|
44
|
+
const classes: { [key: string]: boolean } = {
|
|
45
|
+
'flex relative ring-primary/25 rounded-md outline-none': true,
|
|
46
|
+
'focus-within:ring-2': (props.size === Size.xs2 || props.size === Size.xs || props.size === Size.sm) && !hasInputState.value,
|
|
47
|
+
'focus-within:ring-4': (props.size === Size.md || props.size === Size.lg) && !hasInputState.value,
|
|
48
|
+
};
|
|
49
|
+
const colorVariant = {
|
|
50
|
+
[InputState.base]: 'focus-within:ring-primary-200',
|
|
51
|
+
[InputState.danger]: 'focus-within:ring-danger-200',
|
|
52
|
+
[InputState.info]: 'focus-within:ring-info-200',
|
|
53
|
+
[InputState.success]: 'focus-within:ring-success-200',
|
|
54
|
+
[InputState.warning]: 'focus-within:ring-warning-200',
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
classes[colorVariant[props.state]] = true;
|
|
58
|
+
|
|
59
|
+
return classes;
|
|
60
|
+
});
|
|
61
|
+
const itemClasses = computed(() => {
|
|
62
|
+
const classes: { [key: string]: boolean } = {
|
|
63
|
+
'grow text-center text-black relative outline outline-1 -outline-offset-1': true,
|
|
64
|
+
'p-1 text-xs ': props.size === Size.xs2,
|
|
65
|
+
'p-1.5 text-xs ': props.size === Size.xs,
|
|
66
|
+
'p-1.5 text-sm ': props.size === Size.sm,
|
|
67
|
+
'p-2 text-sm ': props.size === Size.md,
|
|
68
|
+
'p-2.5 text-sm ': props.size === Size.lg,
|
|
69
|
+
'invisible': props.skeleton,
|
|
70
|
+
'opacity-50 cursor-not-allowed': props.disabled,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const colorVariant = {
|
|
74
|
+
[InputState.danger]: 'outline-danger-500 bg-danger-100',
|
|
75
|
+
[InputState.base]: 'outline-neutral-300 bg-white',
|
|
76
|
+
[InputState.info]: 'outline-info-500 bg-info-100',
|
|
77
|
+
[InputState.success]: 'outline-success-500 bg-success-100',
|
|
78
|
+
[InputState.warning]: 'outline-warning-500 bg-warning-100',
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
classes[colorVariant[props.state]] = true;
|
|
82
|
+
|
|
83
|
+
return classes;
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Validate default value if given after delayed data fetching.
|
|
88
|
+
*/
|
|
89
|
+
watch(() => props.skeleton, (val) => {
|
|
90
|
+
if (!val && props.modelValue !== null) {
|
|
91
|
+
emit('validate', props.modelValue);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
watch(_value, () => {
|
|
95
|
+
if (props.messages.length > 0) {
|
|
96
|
+
emit('validate', props.modelValue);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
function onBlur(e: FocusEvent) {
|
|
101
|
+
emit('validate', props.modelValue);
|
|
102
|
+
emit('blur', e);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function prevOption() {
|
|
106
|
+
if (props.readonly || props.disabled) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const index = props.options.findIndex((option) => option === _value.value);
|
|
111
|
+
|
|
112
|
+
if (index !== -1 && props.options[index - 1]) {
|
|
113
|
+
_value.value = props.options[index - 1];
|
|
114
|
+
} else {
|
|
115
|
+
_value.value = props.options[props.options.length - 1];
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function nextOption() {
|
|
120
|
+
if (props.readonly || props.disabled) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const index = props.options.findIndex((option) => option === _value.value);
|
|
125
|
+
|
|
126
|
+
if (index !== -1 && props.options[index + 1]) {
|
|
127
|
+
_value.value = props.options[index + 1];
|
|
128
|
+
} else {
|
|
129
|
+
_value.value = props.options[0];
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
onMounted(() => {
|
|
134
|
+
if (!props.skeleton && props.modelValue !== null) {
|
|
135
|
+
emit('validate', props.modelValue);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
</script>
|
|
139
|
+
|
|
140
|
+
<template>
|
|
141
|
+
<AntField
|
|
142
|
+
:label="label"
|
|
143
|
+
:size="size"
|
|
144
|
+
:skeleton="skeleton"
|
|
145
|
+
:description="description"
|
|
146
|
+
:state="state"
|
|
147
|
+
:messages="messages"
|
|
148
|
+
label-for="noop"
|
|
149
|
+
>
|
|
150
|
+
<div
|
|
151
|
+
:class="containerClasses"
|
|
152
|
+
tabindex="0"
|
|
153
|
+
@blur="onBlur"
|
|
154
|
+
@keydown.left.prevent="prevOption()"
|
|
155
|
+
@keydown.right.prevent="nextOption()"
|
|
156
|
+
>
|
|
157
|
+
<AntButton
|
|
158
|
+
:icon-left="faChevronLeft"
|
|
159
|
+
:grouped="Grouped.left"
|
|
160
|
+
:no-focus="true"
|
|
161
|
+
:state="state as unknown as State"
|
|
162
|
+
:size="size"
|
|
163
|
+
:skeleton="skeleton"
|
|
164
|
+
:readonly="readonly"
|
|
165
|
+
:disabled="disabled"
|
|
166
|
+
@click="prevOption"
|
|
167
|
+
@blur="onBlur"
|
|
168
|
+
/>
|
|
169
|
+
<div class="grow relative">
|
|
170
|
+
<div :class="itemClasses">
|
|
171
|
+
{{ typeof _value === 'string' ? _value : _value.label }}
|
|
172
|
+
</div>
|
|
173
|
+
|
|
174
|
+
<AntSkeleton
|
|
175
|
+
v-if="skeleton"
|
|
176
|
+
absolute
|
|
177
|
+
:grouped="Grouped.center"
|
|
178
|
+
rounded
|
|
179
|
+
/>
|
|
180
|
+
</div>
|
|
181
|
+
|
|
182
|
+
<AntButton
|
|
183
|
+
:icon-left="faChevronRight"
|
|
184
|
+
:grouped="Grouped.right"
|
|
185
|
+
:no-focus="true"
|
|
186
|
+
:state="state as unknown as State"
|
|
187
|
+
:size="size"
|
|
188
|
+
:skeleton="skeleton"
|
|
189
|
+
:readonly="readonly"
|
|
190
|
+
:disabled="disabled"
|
|
191
|
+
@click="nextOption"
|
|
192
|
+
@blur="onBlur"
|
|
193
|
+
/>
|
|
194
|
+
</div>
|
|
195
|
+
</AntField>
|
|
196
|
+
</template>
|