@teammodlr/ui-kit 2.0.25 → 2.0.27
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/env.d.ts +1 -1
- package/lib/__storybook__/argTypes.d.ts +40 -40
- package/lib/__storybook__/createStory.d.ts +8 -8
- package/lib/__storybook__/index.d.ts +2 -2
- package/lib/components/avatar/Avatar.vue.d.ts +56 -56
- package/lib/components/avatar/style/Avatar.css.d.ts +9 -9
- package/lib/components/avatar/style/index.d.ts +1 -1
- package/lib/components/avatargroup/AvatarGroup.vue.d.ts +49 -49
- package/lib/components/avatargroup/style/AvatarGroup.css.d.ts +2 -2
- package/lib/components/avatargroup/style/index.d.ts +1 -1
- package/lib/components/avatargroup/symbol.d.ts +13 -13
- package/lib/components/badge/Badge.vue.d.ts +30 -30
- package/lib/components/badge/style/Badge.css.d.ts +4 -4
- package/lib/components/badge/style/index.d.ts +1 -1
- package/lib/components/breadcrumb/Breadcrumb.vue.d.ts +34 -34
- package/lib/components/breadcrumb/BreadcrumbItem.vue.d.ts +29 -29
- package/lib/components/breadcrumb/style/Breadcrumb.css.d.ts +4 -4
- package/lib/components/breadcrumb/style/index.d.ts +1 -1
- package/lib/components/breadcrumb/symbol.d.ts +13 -13
- package/lib/components/button/Button.vue.d.ts +141 -141
- package/lib/components/button/style/Button.css.d.ts +25 -25
- package/lib/components/button/style/index.d.ts +1 -1
- package/lib/components/buttongroup/ButtonGroup.vue.d.ts +18 -18
- package/lib/components/buttongroup/style/ButtonGroup.css.d.ts +2 -2
- package/lib/components/buttongroup/style/index.d.ts +1 -1
- package/lib/components/buttongroup/symbol.d.ts +6 -6
- package/lib/components/checkbox/Checkbox.vue.d.ts +94 -94
- package/lib/components/checkbox/style/Checkbox.css.d.ts +16 -16
- package/lib/components/checkbox/style/index.d.ts +1 -1
- package/lib/components/colorpicker/ColorPicker.vue.d.ts +77 -77
- package/lib/components/colorpicker/style/ColorPicker.css.d.ts +10 -10
- package/lib/components/colorpicker/style/index.d.ts +1 -1
- package/lib/components/colorpicker/utils.d.ts +16 -16
- package/lib/components/dropdown/Dropdown.vue.d.ts +122 -122
- package/lib/components/dropdown/DropdownItem.vue.d.ts +78 -78
- package/lib/components/dropdown/DropdownList.vue.d.ts +5 -5
- package/lib/components/dropdown/DropdownSeperator.vue.d.ts +4 -4
- package/lib/components/dropdown/DropdownWrapper.vue.d.ts +2 -2
- package/lib/components/dropdown/hooks.d.ts +2 -2
- package/lib/components/dropdown/style/Dropdown.css.d.ts +6 -6
- package/lib/components/dropdown/style/index.d.ts +1 -1
- package/lib/components/dropdown/symbol.d.ts +6 -6
- package/lib/components/form/Form.vue.d.ts +75 -75
- package/lib/components/form/style/Form.css.d.ts +4 -4
- package/lib/components/form/style/index.d.ts +2 -2
- package/lib/components/form/symbol.d.ts +9 -9
- package/lib/components/image/Image.vue.d.ts +50 -50
- package/lib/components/index.d.ts +41 -40
- package/lib/components/input/Input.vue.d.ts +142 -142
- package/lib/components/input/style/Input.css.d.ts +23 -23
- package/lib/components/input/style/index.d.ts +1 -1
- package/lib/components/link/Link.vue.d.ts +51 -51
- package/lib/components/messageprovider/Message.vue.d.ts +73 -73
- package/lib/components/messageprovider/MessageProvider.vue.d.ts +52 -52
- package/lib/components/messageprovider/style/Message.css.d.ts +12 -12
- package/lib/components/messageprovider/style/index.d.ts +1 -1
- package/lib/components/messageprovider/types.d.ts +29 -29
- package/lib/components/messageprovider/useMessage.d.ts +2 -2
- package/lib/components/modal/Modal.vue.d.ts +52 -52
- package/lib/components/modal/style/Modal.css.d.ts +21 -21
- package/lib/components/modal/style/index.d.ts +1 -1
- package/lib/components/pagination/Pagination.vue.d.ts +84 -84
- package/lib/components/pagination/style/Pagination.css.d.ts +10 -10
- package/lib/components/pagination/style/index.d.ts +1 -1
- package/lib/components/radio/Radio.vue.d.ts +85 -85
- package/lib/components/radio/style/Checkbox.css.d.ts +16 -16
- package/lib/components/radio/style/index.d.ts +1 -1
- package/lib/components/radiobutton/RadioButton.vue.d.ts +98 -98
- package/lib/components/radiobutton/style/RadioButton.css.d.ts +14 -14
- package/lib/components/radiobutton/style/index.d.ts +1 -1
- package/lib/components/radiobuttongroup/RadioButtonGroup.vue.d.ts +48 -48
- package/lib/components/radiobuttongroup/style/RadioButtonGroup.css.d.ts +3 -3
- package/lib/components/radiobuttongroup/style/index.d.ts +1 -1
- package/lib/components/radiobuttongroup/symbol.d.ts +9 -9
- package/lib/components/select/Select.vue.d.ts +194 -194
- package/lib/components/select/style/Select.css.d.ts +31 -31
- package/lib/components/select/style/index.d.ts +1 -1
- package/lib/components/skeleton/Skeleton.vue.d.ts +33 -33
- package/lib/components/skeleton/style/Skeleton.css.d.ts +8 -8
- package/lib/components/skeleton/style/index.d.ts +2 -2
- package/lib/components/slider/Slider.vue.d.ts +32 -32
- package/lib/components/slider/style/Slider.css.d.ts +4 -4
- package/lib/components/slider/style/index.d.ts +1 -1
- package/lib/components/tab/Tab.vue.d.ts +41 -41
- package/lib/components/tab/TabGroup.vue.d.ts +43 -43
- package/lib/components/table/Table.vue.d.ts +62 -62
- package/lib/components/table/TableBody.vue.d.ts +2 -2
- package/lib/components/table/TableCell.vue.d.ts +2 -2
- package/lib/components/table/TableHead.vue.d.ts +30 -30
- package/lib/components/table/TableHeadRow.vue.d.ts +2 -2
- package/lib/components/table/TableRow.vue.d.ts +2 -2
- package/lib/components/table/style/Table.css.d.ts +4 -4
- package/lib/components/table/style/index.d.ts +1 -1
- package/lib/components/table/types/index.d.ts +6 -6
- package/lib/components/tag/Tag.vue.d.ts +44 -44
- package/lib/components/tag/style/Tag.css.d.ts +11 -11
- package/lib/components/tag/style/index.d.ts +1 -1
- package/lib/components/textarea/TextArea.vue.d.ts +137 -137
- package/lib/components/textarea/style/TextArea.css.d.ts +19 -19
- package/lib/components/textarea/style/index.d.ts +1 -1
- package/lib/components/toggle/Toggle.vue.d.ts +85 -0
- package/lib/components/toggle/style/Toggle.css.d.ts +7 -0
- package/lib/components/toggle/style/index.d.ts +1 -0
- package/lib/components/tooltip/Tooltip.vue.d.ts +71 -71
- package/lib/components/tooltip/style/Tooltip.css.d.ts +10 -10
- package/lib/components/tooltip/style/index.d.ts +1 -1
- package/lib/components/transfer/Transfer.vue.d.ts +67 -67
- package/lib/components/transfer/style/Transfer.css.d.ts +7 -7
- package/lib/components/transfer/style/index.d.ts +1 -1
- package/lib/components/virtualscroll/VirtualScroll.vue.d.ts +73 -73
- package/lib/components/virtualscroll/style/VirtualScroll.css.d.ts +1 -1
- package/lib/components/virtualscroll/style/index.d.ts +1 -1
- package/lib/composables/element.d.ts +2 -2
- package/lib/composables/index.d.ts +3 -3
- package/lib/composables/useCachedUid.d.ts +13 -13
- package/lib/composables/useEventListener.d.ts +1 -1
- package/lib/composables/useInput.d.ts +36 -36
- package/lib/composables/useInteractive.d.ts +15 -15
- package/lib/composables/useIsServer.d.ts +1 -1
- package/lib/composables/useMount.d.ts +13 -13
- package/lib/composables/usePopper.d.ts +31 -31
- package/lib/composables/useZIndex.d.ts +8 -8
- package/lib/create.d.ts +9 -9
- package/lib/index.cjs.js +4 -4
- package/lib/index.d.ts +5 -5
- package/lib/index.es.js +1896 -1778
- package/lib/install.d.ts +4 -4
- package/lib/nuxt.js +33 -33
- package/lib/nuxt.plugin.js +8 -8
- package/lib/style.css +1 -1
- package/lib/styles/theme.css.d.ts +167 -167
- package/lib/styles/typography.css.d.ts +22 -22
- package/lib/types/props.d.ts +3 -3
- package/package.json +2 -2
- package/src/__storybook__/argTypes.ts +61 -61
- package/src/__storybook__/createStory.ts +15 -15
- package/src/__storybook__/index.ts +2 -2
- package/src/components/avatar/Avatar.vue +109 -109
- package/src/components/avatar/examples/basic.vue +6 -6
- package/src/components/avatar/examples/custom-size.vue +7 -7
- package/src/components/avatar/examples/index.stories.ts +28 -28
- package/src/components/avatar/examples/index.ts +5 -5
- package/src/components/avatar/examples/sizes.vue +33 -33
- package/src/components/avatar/examples/slots.vue +7 -7
- package/src/components/avatar/examples/variants.vue +18 -18
- package/src/components/avatar/style/Avatar.css.ts +92 -92
- package/src/components/avatar/style/index.ts +1 -1
- package/src/components/avatargroup/AvatarGroup.css +8 -8
- package/src/components/avatargroup/AvatarGroup.vue +71 -71
- package/src/components/avatargroup/examples/basic.vue +37 -37
- package/src/components/avatargroup/examples/index.stories.ts +24 -24
- package/src/components/avatargroup/examples/index.ts +1 -1
- package/src/components/avatargroup/style/AvatarGroup.css.ts +21 -21
- package/src/components/avatargroup/style/index.ts +1 -1
- package/src/components/avatargroup/symbol.ts +16 -16
- package/src/components/badge/Badge.css +128 -128
- package/src/components/badge/Badge.vue +43 -43
- package/src/components/badge/examples/basic.vue +10 -10
- package/src/components/badge/examples/index.stories.ts +21 -21
- package/src/components/badge/examples/index.ts +1 -1
- package/src/components/badge/style/Badge.css.ts +135 -135
- package/src/components/badge/style/index.ts +1 -1
- package/src/components/breadcrumb/Breadcrumb.css +46 -46
- package/src/components/breadcrumb/Breadcrumb.vue +58 -58
- package/src/components/breadcrumb/BreadcrumbItem.vue +72 -72
- package/src/components/breadcrumb/examples/basic.vue +7 -7
- package/src/components/breadcrumb/examples/index.stories.ts +20 -20
- package/src/components/breadcrumb/examples/index.ts +1 -1
- package/src/components/breadcrumb/style/Breadcrumb.css.ts +39 -39
- package/src/components/breadcrumb/symbol.ts +16 -16
- package/src/components/button/Button-old.css +378 -378
- package/src/components/button/Button.vue +203 -203
- package/src/components/button/examples/basic.vue +3 -3
- package/src/components/button/examples/disabled.vue +3 -3
- package/src/components/button/examples/icon-left.vue +12 -12
- package/src/components/button/examples/icon.vue +9 -9
- package/src/components/button/examples/index.stories.ts +35 -35
- package/src/components/button/examples/index.ts +8 -8
- package/src/components/button/examples/rounded.vue +7 -7
- package/src/components/button/examples/size.vue +7 -7
- package/src/components/button/examples/variants-secondary.vue +10 -10
- package/src/components/button/examples/variants.vue +10 -10
- package/src/components/button/style/Button.css.ts +677 -677
- package/src/components/button/style/index.ts +1 -1
- package/src/components/buttongroup/ButtonGroup.vue +36 -36
- package/src/components/buttongroup/examples/basic.vue +9 -9
- package/src/components/buttongroup/examples/icon-group.vue +21 -21
- package/src/components/buttongroup/examples/index.stories.ts +22 -22
- package/src/components/buttongroup/examples/index.ts +2 -2
- package/src/components/buttongroup/style/ButtonGroup.css.ts +39 -39
- package/src/components/buttongroup/style/index.ts +1 -1
- package/src/components/buttongroup/symbol.ts +7 -7
- package/src/components/checkbox/Checkbox.css +185 -185
- package/src/components/checkbox/Checkbox.vue +156 -156
- package/src/components/checkbox/examples/basic.vue +9 -9
- package/src/components/checkbox/examples/index.stories.ts +21 -21
- package/src/components/checkbox/examples/index.ts +3 -3
- package/src/components/checkbox/examples/slot.vue +11 -11
- package/src/components/checkbox/style/Checkbox.css.ts +140 -140
- package/src/components/checkbox/style/index.ts +1 -1
- package/src/components/colorpicker/ColorPicker.vue +324 -324
- package/src/components/colorpicker/examples/basic.vue +2 -2
- package/src/components/colorpicker/examples/index.stories.ts +17 -17
- package/src/components/colorpicker/style/ColorPicker.css.ts +116 -116
- package/src/components/colorpicker/style/index.ts +1 -1
- package/src/components/colorpicker/utils.ts +187 -187
- package/src/components/dropdown/Dropdown.vue +263 -263
- package/src/components/dropdown/DropdownItem.vue +134 -134
- package/src/components/dropdown/DropdownList.vue +20 -20
- package/src/components/dropdown/DropdownSeperator.vue +22 -22
- package/src/components/dropdown/DropdownWrapper.vue +18 -18
- package/src/components/dropdown/examples/basic.vue +73 -73
- package/src/components/dropdown/examples/context.vue +71 -71
- package/src/components/dropdown/examples/index.stories.ts +28 -28
- package/src/components/dropdown/examples/index.ts +3 -3
- package/src/components/dropdown/hooks.ts +30 -30
- package/src/components/dropdown/style/Dropdown.css.ts +54 -54
- package/src/components/dropdown/style/index.ts +1 -1
- package/src/components/dropdown/symbol.ts +7 -7
- package/src/components/form/Form.vue +153 -153
- package/src/components/form/examples/basic.vue +75 -75
- package/src/components/form/examples/index.stories.ts +25 -25
- package/src/components/form/examples/index.ts +1 -1
- package/src/components/form/style/Form.css.ts +22 -22
- package/src/components/form/style/index.ts +1 -1
- package/src/components/form/symbol.ts +10 -10
- package/src/components/image/Image.vue +71 -71
- package/src/components/image/examples/basic.vue +5 -5
- package/src/components/image/examples/index.stories.ts +12 -12
- package/src/components/image/examples/index.ts +1 -1
- package/src/components/index.ts +40 -39
- package/src/components/input/Input.css +173 -173
- package/src/components/input/Input.vue +218 -218
- package/src/components/input/examples/basic.vue +8 -8
- package/src/components/input/examples/index.stories.ts +24 -24
- package/src/components/input/examples/index.ts +4 -4
- package/src/components/input/examples/prefix.vue +9 -9
- package/src/components/input/examples/sizes.vue +9 -9
- package/src/components/input/examples/suffix.vue +9 -9
- package/src/components/input/style/Input.css.ts +221 -221
- package/src/components/input/style/index.ts +1 -1
- package/src/components/link/Link.css +147 -147
- package/src/components/link/Link.vue +53 -53
- package/src/components/link/examples/basic.vue +3 -3
- package/src/components/link/examples/index.stories.ts +20 -20
- package/src/components/link/examples/index.ts +1 -1
- package/src/components/messageprovider/Message.vue +123 -123
- package/src/components/messageprovider/MessageProvider.css +23 -23
- package/src/components/messageprovider/MessageProvider.vue +144 -144
- package/src/components/messageprovider/examples/basic.vue +70 -70
- package/src/components/messageprovider/examples/index.stories.ts +29 -29
- package/src/components/messageprovider/examples/index.ts +2 -2
- package/src/components/messageprovider/examples/update.vue +34 -34
- package/src/components/messageprovider/examples/wrapper.vue +9 -9
- package/src/components/messageprovider/style/Message.css.ts +109 -109
- package/src/components/messageprovider/style/index.ts +1 -1
- package/src/components/messageprovider/types.ts +47 -47
- package/src/components/messageprovider/useMessage.ts +12 -12
- package/src/components/modal/Modal.vue +125 -125
- package/src/components/modal/examples/basic.vue +40 -40
- package/src/components/modal/examples/index.stories.ts +20 -20
- package/src/components/modal/examples/index.ts +2 -2
- package/src/components/modal/examples/modal-form.vue +99 -99
- package/src/components/modal/style/Modal.css.ts +257 -257
- package/src/components/modal/style/index.ts +1 -1
- package/src/components/pagination/Pagination.vue +237 -237
- package/src/components/pagination/examples/basic.vue +17 -17
- package/src/components/pagination/examples/index.stories.ts +14 -14
- package/src/components/pagination/style/Pagination.css.ts +87 -87
- package/src/components/pagination/style/index.ts +1 -1
- package/src/components/radio/Checkbox.css +185 -185
- package/src/components/radio/Radio.vue +137 -137
- package/src/components/radio/examples/basic.vue +9 -9
- package/src/components/radio/examples/index.stories.ts +19 -19
- package/src/components/radio/examples/index.ts +2 -2
- package/src/components/radio/style/Checkbox.css.ts +131 -131
- package/src/components/radio/style/index.ts +1 -1
- package/src/components/radiobutton/RadioButton.vue +131 -131
- package/src/components/radiobutton/style/RadioButton.css.ts +183 -183
- package/src/components/radiobutton/style/index.ts +1 -1
- package/src/components/radiobuttongroup/RadioButtonGroup.vue +74 -74
- package/src/components/radiobuttongroup/examples/basic.vue +16 -16
- package/src/components/radiobuttongroup/examples/index.stories.ts +22 -22
- package/src/components/radiobuttongroup/examples/index.ts +2 -2
- package/src/components/radiobuttongroup/style/RadioButtonGroup.css.ts +36 -36
- package/src/components/radiobuttongroup/symbol.ts +10 -10
- package/src/components/select/Select.vue +569 -569
- package/src/components/select/examples/basic.vue +20 -20
- package/src/components/select/examples/index.stories.ts +22 -22
- package/src/components/select/examples/index.ts +3 -3
- package/src/components/select/examples/multiple.vue +21 -21
- package/src/components/select/examples/searchable.vue +20 -20
- package/src/components/select/style/Select.css.ts +261 -261
- package/src/components/select/style/index.ts +1 -1
- package/src/components/skeleton/Skeleton.css +73 -73
- package/src/components/skeleton/Skeleton.vue +55 -55
- package/src/components/skeleton/examples/basic.vue +3 -3
- package/src/components/skeleton/examples/index.stories.ts +17 -17
- package/src/components/skeleton/examples/index.ts +2 -2
- package/src/components/skeleton/examples/post.vue +8 -8
- package/src/components/skeleton/style/Skeleton.css.ts +56 -56
- package/src/components/skeleton/style/index.ts +1 -1
- package/src/components/slider/Slider.vue +76 -76
- package/src/components/slider/style/Slider.css.ts +42 -42
- package/src/components/slider/style/index.ts +1 -1
- package/src/components/tab/Tab.css +113 -113
- package/src/components/tab/Tab.vue +98 -98
- package/src/components/tab/TabGroup.vue +90 -90
- package/src/components/tab/examples/basic.vue +19 -19
- package/src/components/tab/examples/index.stories.ts +25 -25
- package/src/components/tab/examples/index.ts +2 -2
- package/src/components/tab/examples/vertical.vue +19 -19
- package/src/components/table/Table.vue +119 -119
- package/src/components/table/TableBody.vue +13 -13
- package/src/components/table/TableCell.vue +13 -13
- package/src/components/table/TableHead.vue +46 -46
- package/src/components/table/TableHeadRow.vue +15 -15
- package/src/components/table/TableRow.vue +13 -13
- package/src/components/table/examples/basic.vue +55 -55
- package/src/components/table/examples/empty.vue +44 -44
- package/src/components/table/examples/index.stories.ts +20 -20
- package/src/components/table/examples/index.ts +2 -2
- package/src/components/table/style/Table.css.ts +80 -80
- package/src/components/table/types/index.ts +6 -6
- package/src/components/tag/Tag.vue +66 -66
- package/src/components/tag/examples/basic.vue +5 -5
- package/src/components/tag/examples/index.stories.ts +22 -22
- package/src/components/tag/examples/index.ts +1 -1
- package/src/components/tag/style/Tag.css.ts +79 -79
- package/src/components/tag/style/index.ts +1 -1
- package/src/components/textarea/TextArea.css +173 -173
- package/src/components/textarea/TextArea.vue +181 -181
- package/src/components/textarea/examples/basic.vue +8 -8
- package/src/components/textarea/examples/index.stories.ts +18 -18
- package/src/components/textarea/style/TextArea.css.ts +189 -189
- package/src/components/textarea/style/index.ts +1 -1
- package/src/components/toggle/Toggle.vue +132 -0
- package/src/components/toggle/examples/basic.vue +9 -0
- package/src/components/toggle/examples/index.stories.ts +20 -0
- package/src/components/toggle/examples/index.ts +3 -0
- package/src/components/toggle/examples/slot.vue +11 -0
- package/src/components/toggle/style/Toggle.css.ts +135 -0
- package/src/components/toggle/style/index.ts +1 -0
- package/src/components/tooltip/Tooltip.css +43 -43
- package/src/components/tooltip/Tooltip.vue +118 -118
- package/src/components/tooltip/examples/basic.vue +5 -5
- package/src/components/tooltip/examples/index.stories.ts +22 -22
- package/src/components/tooltip/examples/index.ts +2 -2
- package/src/components/tooltip/examples/placement.vue +9 -9
- package/src/components/tooltip/style/Tooltip.css.ts +91 -91
- package/src/components/tooltip/style/index.ts +1 -1
- package/src/components/transfer/Transfer.vue +143 -143
- package/src/components/transfer/examples/basic.vue +20 -20
- package/src/components/transfer/examples/index.stories.ts +15 -15
- package/src/components/transfer/examples/index.ts +1 -1
- package/src/components/transfer/style/Transfer.css.ts +67 -67
- package/src/components/transfer/style/index.ts +1 -1
- package/src/components/virtualscroll/VirtualScroll.css +13 -13
- package/src/components/virtualscroll/VirtualScroll.vue +166 -166
- package/src/components/virtualscroll/examples/basic.vue +31 -31
- package/src/components/virtualscroll/examples/index.stories.ts +15 -15
- package/src/components/virtualscroll/examples/index.ts +1 -1
- package/src/components/virtualscroll/style/VirtualScroll.css.ts +18 -18
- package/src/components/virtualscroll/style/index.ts +1 -1
- package/src/composables/element.ts +13 -13
- package/src/composables/index.ts +2 -2
- package/src/composables/useCachedUid.ts +48 -48
- package/src/composables/useEventListener.ts +14 -14
- package/src/composables/useInput.ts +129 -129
- package/src/composables/useInteractive.ts +19 -19
- package/src/composables/useIsServer.ts +7 -7
- package/src/composables/useMount.ts +43 -43
- package/src/composables/usePopper.ts +194 -194
- package/src/composables/useZIndex.ts +30 -30
- package/src/create.ts +34 -34
- package/src/css/components.css +16 -15
- package/src/css/index.css +4 -4
- package/src/css/transitions.css +40 -40
- package/src/css/variables.css +80 -80
- package/src/examples/cards/cards.stories.ts +9 -9
- package/src/examples/cards/sidebar.vue +262 -262
- package/src/exports/nuxt.js +33 -33
- package/src/exports/nuxt.plugin.js +8 -8
- package/src/index.ts +7 -7
- package/src/install.ts +8 -8
- package/src/shims-vue.d.ts +6 -6
- package/src/styles/theme.css.ts +170 -170
- package/src/styles/typography.css.ts +91 -91
- package/src/types/props.ts +5 -5
- package/volar.d.ts +16 -16
|
@@ -1,324 +1,324 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div ref="wrapper" class="m-color-picker">
|
|
3
|
-
<div ref="referenceRef"
|
|
4
|
-
@click="isOpen = !isOpen"
|
|
5
|
-
:class="style.reference"
|
|
6
|
-
>
|
|
7
|
-
<div :class="style.referenceColor"
|
|
8
|
-
:style="{ backgroundColor: `rgba(${finalColor.r}, ${finalColor.g}, ${finalColor.b}, ${finalColor.a})` }">
|
|
9
|
-
</div>
|
|
10
|
-
</div>
|
|
11
|
-
<Teleport to="body">
|
|
12
|
-
<div :class="style.container" v-if="isOpen" ref="popper" :style="{zIndex: zIndex}">
|
|
13
|
-
<div ref="picker" @mousedown="handleMouseDown" :class="style.colours"
|
|
14
|
-
:style="`background: rgb(${mainColor.r}, ${mainColor.g}, ${mainColor.b});` ">
|
|
15
|
-
<div :class="style.whiteGradient"></div>
|
|
16
|
-
<div :class="style.blackGradient"></div>
|
|
17
|
-
<div draggable="true" :class="style.sliderThumb" @mousedown="handleMouseDown"
|
|
18
|
-
:style="{ left: `${position.x * 100}%`, top: `${position.y * 100}%` }"></div>
|
|
19
|
-
</div>
|
|
20
|
-
|
|
21
|
-
<div :class="style.colorActions">
|
|
22
|
-
<template v-if="canPickColor">
|
|
23
|
-
<button role="button" :disabled="!canPickColor" :class="style.eyeDrop" @click="openEyeDropper">
|
|
24
|
-
<svg
|
|
25
|
-
width="24"
|
|
26
|
-
height="24"
|
|
27
|
-
viewBox="0 0 24 24"
|
|
28
|
-
fill="none"
|
|
29
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
30
|
-
>
|
|
31
|
-
<path
|
|
32
|
-
d="M20.3847 2.87868C19.2132 1.70711 17.3137 1.70711 16.1421 2.87868L14.0202 5.00052L13.313 4.29332C12.9225 3.9028 12.2894 3.9028 11.8988 4.29332C11.5083 4.68385 11.5083 5.31701 11.8988 5.70754L17.5557 11.3644C17.9462 11.7549 18.5794 11.7549 18.9699 11.3644C19.3604 10.9739 19.3604 10.3407 18.9699 9.95018L18.2629 9.24316L20.3847 7.12132C21.5563 5.94975 21.5563 4.05025 20.3847 2.87868Z"
|
|
33
|
-
fill="currentColor"
|
|
34
|
-
/>
|
|
35
|
-
<path
|
|
36
|
-
fill-rule="evenodd"
|
|
37
|
-
clip-rule="evenodd"
|
|
38
|
-
d="M11.9297 7.09116L4.1515 14.8693C3.22786 15.793 3.03239 17.169 3.5651 18.2842L1.99994 19.8493L3.41415 21.2635L4.97931 19.6984C6.09444 20.2311 7.4705 20.0356 8.39414 19.112L16.1723 11.3338L11.9297 7.09116ZM13.3439 11.3338L11.9297 9.91959L5.56571 16.2835C5.17518 16.6741 5.17518 17.3072 5.56571 17.6978C5.95623 18.0883 6.5894 18.0883 6.97992 17.6978L13.3439 11.3338Z"
|
|
39
|
-
fill="currentColor"
|
|
40
|
-
/>
|
|
41
|
-
</svg>
|
|
42
|
-
</button>
|
|
43
|
-
</template>
|
|
44
|
-
<template v-else>
|
|
45
|
-
<div :class="style.preview">
|
|
46
|
-
<div
|
|
47
|
-
:style="`width: 100%; height: 100%; background-color: rgba(${finalColor.r}, ${finalColor.g}, ${finalColor.b}, ${finalColor.a});`">
|
|
48
|
-
</div>
|
|
49
|
-
</div>
|
|
50
|
-
</template>
|
|
51
|
-
<div style="width: 100%; display: flex; flex-direction: column; gap: 10px;">
|
|
52
|
-
<MSlider v-model="hueSlider"
|
|
53
|
-
background="linear-gradient(to right, #FF0000, #FFFF00, #00FF00, #00FFFF, #0000FF, #FF00FF, #FF0000)">
|
|
54
|
-
</MSlider>
|
|
55
|
-
|
|
56
|
-
<MSlider v-model="opacitySlider"
|
|
57
|
-
:background="`linear-gradient(to right, rgba(${finalColor.r}, ${finalColor.g}, ${finalColor.b}, 0), rgba(${finalColor.r}, ${finalColor.g}, ${finalColor.b}, 1))`">
|
|
58
|
-
</MSlider>
|
|
59
|
-
</div>
|
|
60
|
-
</div>
|
|
61
|
-
|
|
62
|
-
<div
|
|
63
|
-
:class="style.colorActions">
|
|
64
|
-
<template v-if="rgbOrHex">
|
|
65
|
-
<MInput @keyup.enter="updateFromRGB" @blur="updateFromRGB" block ref="rInputElement"
|
|
66
|
-
v-model="rInput"
|
|
67
|
-
name="r" placeholder="R"/>
|
|
68
|
-
<MInput @keyup.enter="updateFromRGB" @blur="updateFromRGB" block ref="gInputElement"
|
|
69
|
-
v-model="gInput"
|
|
70
|
-
name="g" placeholder="G"/>
|
|
71
|
-
<MInput @keyup.enter="updateFromRGB" @blur="updateFromRGB" block ref="bInputElement"
|
|
72
|
-
v-model="bInput"
|
|
73
|
-
name="b" placeholder="B"/>
|
|
74
|
-
<MInput @keyup.enter="updateFromRGB" @blur="updateFromRGB" block ref="aInputElement"
|
|
75
|
-
v-model="aInput"
|
|
76
|
-
name="a" placeholder="A"/>
|
|
77
|
-
</template>
|
|
78
|
-
<template v-else>
|
|
79
|
-
<MInput @keyup.enter="updateFromHex" @blur="updateFromHex" block
|
|
80
|
-
ref="hexInputElement"
|
|
81
|
-
v-model="hexInput" name="hex" placeholder="#00000000"/>
|
|
82
|
-
</template>
|
|
83
|
-
|
|
84
|
-
<MButton icon @click.prevent="rgbOrHex = !rgbOrHex">
|
|
85
|
-
<svg style="width: 18px; height: 18px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"
|
|
86
|
-
fill="currentColor" class="w-5 h-5">
|
|
87
|
-
<path fill-rule="evenodd"
|
|
88
|
-
d="M10 3a.75.75 0 01.55.24l3.25 3.5a.75.75 0 11-1.1 1.02L10 4.852 7.3 7.76a.75.75 0 01-1.1-1.02l3.25-3.5A.75.75 0 0110 3zm-3.76 9.2a.75.75 0 011.06.04l2.7 2.908 2.7-2.908a.75.75 0 111.1 1.02l-3.25 3.5a.75.75 0 01-1.1 0l-3.25-3.5a.75.75 0 01.04-1.06z"
|
|
89
|
-
clip-rule="evenodd"/>
|
|
90
|
-
</svg>
|
|
91
|
-
</MButton>
|
|
92
|
-
</div>
|
|
93
|
-
</div>
|
|
94
|
-
</Teleport>
|
|
95
|
-
</div>
|
|
96
|
-
</template>
|
|
97
|
-
|
|
98
|
-
<script lang="ts">
|
|
99
|
-
import {onClickOutside, useEyeDropper, useMouseInElement, useMousePressed} from '@vueuse/core';
|
|
100
|
-
import {computed, defineComponent, onMounted, type PropType, reactive, ref, toRef, watch} from "vue";
|
|
101
|
-
import * as style from './style';
|
|
102
|
-
import {hexToRGB, type HSV, HSVToRGBA, HueToRGBA, RGBAToHex, RGBToHSV} from './utils';
|
|
103
|
-
import {usePopper} from "../../composables/usePopper";
|
|
104
|
-
import type {Placement} from "@popperjs/core";
|
|
105
|
-
import {useZIndex} from "../../composables/useZIndex";
|
|
106
|
-
import MSlider from "../../components/slider/Slider.vue";
|
|
107
|
-
import MButton from "../../components/button/Button.vue";
|
|
108
|
-
import MInput from "../../components/input/Input.vue";
|
|
109
|
-
|
|
110
|
-
export default defineComponent({
|
|
111
|
-
name: "MColorPicker",
|
|
112
|
-
props: {
|
|
113
|
-
modelValue: {
|
|
114
|
-
type: String,
|
|
115
|
-
default: "#FF00FF"
|
|
116
|
-
},
|
|
117
|
-
transfer: {
|
|
118
|
-
type: Boolean,
|
|
119
|
-
default: false
|
|
120
|
-
},
|
|
121
|
-
placement: {
|
|
122
|
-
type: String as PropType<Placement>,
|
|
123
|
-
default: "bottom-start"
|
|
124
|
-
},
|
|
125
|
-
zIndex: {
|
|
126
|
-
type: Number
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
emits: ['update:modelValue'],
|
|
130
|
-
components: {
|
|
131
|
-
MSlider,
|
|
132
|
-
MInput,
|
|
133
|
-
MButton
|
|
134
|
-
},
|
|
135
|
-
setup(props, {emit}) {
|
|
136
|
-
const {isSupported: canPickColor, open: openEyeDrop, sRGBHex: eyeDropColor} = useEyeDropper();
|
|
137
|
-
const {nextZIndex} = useZIndex();
|
|
138
|
-
const isOpen = ref(false);
|
|
139
|
-
const rgbOrHex = ref<boolean>(false);
|
|
140
|
-
const hexInput = ref("");
|
|
141
|
-
const rInput = ref("");
|
|
142
|
-
const gInput = ref("");
|
|
143
|
-
const bInput = ref("");
|
|
144
|
-
const aInput = ref("");
|
|
145
|
-
|
|
146
|
-
const picker = ref<HTMLElement>();
|
|
147
|
-
const wrapper = ref<HTMLElement>();
|
|
148
|
-
const referenceRef = ref<HTMLElement>();
|
|
149
|
-
const transfer = toRef(props, 'transfer');
|
|
150
|
-
const placement = toRef(props, 'placement');
|
|
151
|
-
const hexInputElement = ref();
|
|
152
|
-
const hueSlider = ref(0);
|
|
153
|
-
const opacitySlider = ref(100);
|
|
154
|
-
const dragging = ref(false);
|
|
155
|
-
const position = reactive({
|
|
156
|
-
x: 0,
|
|
157
|
-
y: 0
|
|
158
|
-
});
|
|
159
|
-
const zIndex = ref(props.zIndex ?? nextZIndex());
|
|
160
|
-
|
|
161
|
-
const {elementX, elementY} = useMouseInElement(picker);
|
|
162
|
-
const {pressed} = useMousePressed();
|
|
163
|
-
const {popper, transferTo, updatePopper} = usePopper({
|
|
164
|
-
reference: referenceRef,
|
|
165
|
-
placement,
|
|
166
|
-
transfer,
|
|
167
|
-
wrapper,
|
|
168
|
-
isDrop: false,
|
|
169
|
-
offset: [-2, 2]
|
|
170
|
-
});
|
|
171
|
-
const brightness = computed(() => {
|
|
172
|
-
return 1 - position.y;
|
|
173
|
-
})
|
|
174
|
-
|
|
175
|
-
const saturation = computed(() => {
|
|
176
|
-
return position.x;
|
|
177
|
-
})
|
|
178
|
-
|
|
179
|
-
const finalColor = computed(() => {
|
|
180
|
-
return HSVToRGBA(hueSlider.value * 3.6, brightness.value, saturation.value, opacitySlider.value / 100);
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
const mainColor = computed(() => {
|
|
184
|
-
return HueToRGBA(hueSlider.value * 3.6, opacitySlider.value / 100);
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
const setInputs = () => {
|
|
188
|
-
hexInput.value = RGBAToHex(finalColor.value.r, finalColor.value.g, finalColor.value.b, finalColor.value.a);
|
|
189
|
-
rInput.value = finalColor.value.r.toString();
|
|
190
|
-
gInput.value = finalColor.value.g.toString();
|
|
191
|
-
bInput.value = finalColor.value.b.toString();
|
|
192
|
-
aInput.value = finalColor.value.a.toFixed(2).toString();
|
|
193
|
-
|
|
194
|
-
emit('update:modelValue', hexInput.value);
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
watch(() => finalColor.value, () => {
|
|
198
|
-
setInputs();
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
const updateFromHSV = (hsv: HSV, alpha: number) => {
|
|
202
|
-
position.x = hsv.s;
|
|
203
|
-
position.y = 1 - hsv.v;
|
|
204
|
-
hueSlider.value = ((1 / 360) * hsv.h) * 100;
|
|
205
|
-
opacitySlider.value = alpha * 100;
|
|
206
|
-
setInputs();
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
const updateFromHex = () => {
|
|
210
|
-
var color = hexToRGB(hexInput.value, finalColor.value.r, finalColor.value.g, finalColor.value.b, finalColor.value.a);
|
|
211
|
-
updateFromHSV(RGBToHSV(color.r, color.g, color.b), color.a);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
const updateFromRGB = () => {
|
|
215
|
-
var red = parseInt(rInput.value);
|
|
216
|
-
if (isNaN(red) || red > 255 || red < 0) {
|
|
217
|
-
red = finalColor.value.r;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
var green = parseInt(gInput.value);
|
|
221
|
-
if (isNaN(green) || green > 255 || green < 0) {
|
|
222
|
-
green = finalColor.value.g;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
var blue = parseInt(bInput.value);
|
|
226
|
-
if (isNaN(blue) || blue > 255 || blue < 0) {
|
|
227
|
-
blue = finalColor.value.b;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
var alpha = parseFloat(aInput.value);
|
|
231
|
-
if (isNaN(alpha) || alpha > 1 || alpha < 0) {
|
|
232
|
-
alpha = finalColor.value.a;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
updateFromHSV(RGBToHSV(red, green, blue), alpha);
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
watch(() => pressed.value, () => {
|
|
239
|
-
if (!pressed.value) {
|
|
240
|
-
dragging.value = false;
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
watch(() => [elementX.value, elementY.value], () => {
|
|
245
|
-
if (!dragging.value) {
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
setThumbPosition();
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
watch(() => props.modelValue, () => {
|
|
253
|
-
hexInput.value = props.modelValue;
|
|
254
|
-
updateFromHex();
|
|
255
|
-
console.log('hi');
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
const setThumbPosition = () => {
|
|
259
|
-
position.x = ((Math.min(Math.max(elementX.value, 0), picker.value?.clientWidth || 0) / (picker.value?.clientWidth || 0)));
|
|
260
|
-
position.y = ((Math.min(Math.max(elementY.value, 0), picker.value?.clientHeight || 0) / (picker.value?.clientHeight || 0)));
|
|
261
|
-
};
|
|
262
|
-
|
|
263
|
-
const handleMouseDown = () => {
|
|
264
|
-
dragging.value = true;
|
|
265
|
-
setThumbPosition();
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
onMounted(() => {
|
|
269
|
-
hexInput.value = props.modelValue;
|
|
270
|
-
updateFromHex();
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
onClickOutside(popper, (e) => {
|
|
274
|
-
isOpen.value = false;
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
watch(() => eyeDropColor.value, () => {
|
|
278
|
-
hexInput.value = eyeDropColor.value;
|
|
279
|
-
updateFromHex();
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
const openEyeDropper = () => {
|
|
283
|
-
try {
|
|
284
|
-
openEyeDrop();
|
|
285
|
-
} catch (e) {
|
|
286
|
-
console.log(e);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
return {
|
|
291
|
-
isOpen,
|
|
292
|
-
popper,
|
|
293
|
-
transferTo,
|
|
294
|
-
wrapper,
|
|
295
|
-
referenceRef,
|
|
296
|
-
updateFromRGB,
|
|
297
|
-
updateFromHex,
|
|
298
|
-
setInputs,
|
|
299
|
-
rgbOrHex,
|
|
300
|
-
hexInputElement,
|
|
301
|
-
hexInput,
|
|
302
|
-
rInput,
|
|
303
|
-
gInput,
|
|
304
|
-
bInput,
|
|
305
|
-
aInput,
|
|
306
|
-
finalColor,
|
|
307
|
-
hueSlider,
|
|
308
|
-
opacitySlider,
|
|
309
|
-
dragging,
|
|
310
|
-
setThumbPosition,
|
|
311
|
-
position,
|
|
312
|
-
elementX,
|
|
313
|
-
pressed,
|
|
314
|
-
handleMouseDown,
|
|
315
|
-
picker,
|
|
316
|
-
style,
|
|
317
|
-
mainColor,
|
|
318
|
-
zIndex,
|
|
319
|
-
canPickColor,
|
|
320
|
-
openEyeDropper
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
})
|
|
324
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<div ref="wrapper" class="m-color-picker">
|
|
3
|
+
<div ref="referenceRef"
|
|
4
|
+
@click="isOpen = !isOpen"
|
|
5
|
+
:class="style.reference"
|
|
6
|
+
>
|
|
7
|
+
<div :class="style.referenceColor"
|
|
8
|
+
:style="{ backgroundColor: `rgba(${finalColor.r}, ${finalColor.g}, ${finalColor.b}, ${finalColor.a})` }">
|
|
9
|
+
</div>
|
|
10
|
+
</div>
|
|
11
|
+
<Teleport to="body">
|
|
12
|
+
<div :class="style.container" v-if="isOpen" ref="popper" :style="{zIndex: zIndex}">
|
|
13
|
+
<div ref="picker" @mousedown="handleMouseDown" :class="style.colours"
|
|
14
|
+
:style="`background: rgb(${mainColor.r}, ${mainColor.g}, ${mainColor.b});` ">
|
|
15
|
+
<div :class="style.whiteGradient"></div>
|
|
16
|
+
<div :class="style.blackGradient"></div>
|
|
17
|
+
<div draggable="true" :class="style.sliderThumb" @mousedown="handleMouseDown"
|
|
18
|
+
:style="{ left: `${position.x * 100}%`, top: `${position.y * 100}%` }"></div>
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
<div :class="style.colorActions">
|
|
22
|
+
<template v-if="canPickColor">
|
|
23
|
+
<button role="button" :disabled="!canPickColor" :class="style.eyeDrop" @click="openEyeDropper">
|
|
24
|
+
<svg
|
|
25
|
+
width="24"
|
|
26
|
+
height="24"
|
|
27
|
+
viewBox="0 0 24 24"
|
|
28
|
+
fill="none"
|
|
29
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
30
|
+
>
|
|
31
|
+
<path
|
|
32
|
+
d="M20.3847 2.87868C19.2132 1.70711 17.3137 1.70711 16.1421 2.87868L14.0202 5.00052L13.313 4.29332C12.9225 3.9028 12.2894 3.9028 11.8988 4.29332C11.5083 4.68385 11.5083 5.31701 11.8988 5.70754L17.5557 11.3644C17.9462 11.7549 18.5794 11.7549 18.9699 11.3644C19.3604 10.9739 19.3604 10.3407 18.9699 9.95018L18.2629 9.24316L20.3847 7.12132C21.5563 5.94975 21.5563 4.05025 20.3847 2.87868Z"
|
|
33
|
+
fill="currentColor"
|
|
34
|
+
/>
|
|
35
|
+
<path
|
|
36
|
+
fill-rule="evenodd"
|
|
37
|
+
clip-rule="evenodd"
|
|
38
|
+
d="M11.9297 7.09116L4.1515 14.8693C3.22786 15.793 3.03239 17.169 3.5651 18.2842L1.99994 19.8493L3.41415 21.2635L4.97931 19.6984C6.09444 20.2311 7.4705 20.0356 8.39414 19.112L16.1723 11.3338L11.9297 7.09116ZM13.3439 11.3338L11.9297 9.91959L5.56571 16.2835C5.17518 16.6741 5.17518 17.3072 5.56571 17.6978C5.95623 18.0883 6.5894 18.0883 6.97992 17.6978L13.3439 11.3338Z"
|
|
39
|
+
fill="currentColor"
|
|
40
|
+
/>
|
|
41
|
+
</svg>
|
|
42
|
+
</button>
|
|
43
|
+
</template>
|
|
44
|
+
<template v-else>
|
|
45
|
+
<div :class="style.preview">
|
|
46
|
+
<div
|
|
47
|
+
:style="`width: 100%; height: 100%; background-color: rgba(${finalColor.r}, ${finalColor.g}, ${finalColor.b}, ${finalColor.a});`">
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
</template>
|
|
51
|
+
<div style="width: 100%; display: flex; flex-direction: column; gap: 10px;">
|
|
52
|
+
<MSlider v-model="hueSlider"
|
|
53
|
+
background="linear-gradient(to right, #FF0000, #FFFF00, #00FF00, #00FFFF, #0000FF, #FF00FF, #FF0000)">
|
|
54
|
+
</MSlider>
|
|
55
|
+
|
|
56
|
+
<MSlider v-model="opacitySlider"
|
|
57
|
+
:background="`linear-gradient(to right, rgba(${finalColor.r}, ${finalColor.g}, ${finalColor.b}, 0), rgba(${finalColor.r}, ${finalColor.g}, ${finalColor.b}, 1))`">
|
|
58
|
+
</MSlider>
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
|
|
62
|
+
<div
|
|
63
|
+
:class="style.colorActions">
|
|
64
|
+
<template v-if="rgbOrHex">
|
|
65
|
+
<MInput @keyup.enter="updateFromRGB" @blur="updateFromRGB" block ref="rInputElement"
|
|
66
|
+
v-model="rInput"
|
|
67
|
+
name="r" placeholder="R"/>
|
|
68
|
+
<MInput @keyup.enter="updateFromRGB" @blur="updateFromRGB" block ref="gInputElement"
|
|
69
|
+
v-model="gInput"
|
|
70
|
+
name="g" placeholder="G"/>
|
|
71
|
+
<MInput @keyup.enter="updateFromRGB" @blur="updateFromRGB" block ref="bInputElement"
|
|
72
|
+
v-model="bInput"
|
|
73
|
+
name="b" placeholder="B"/>
|
|
74
|
+
<MInput @keyup.enter="updateFromRGB" @blur="updateFromRGB" block ref="aInputElement"
|
|
75
|
+
v-model="aInput"
|
|
76
|
+
name="a" placeholder="A"/>
|
|
77
|
+
</template>
|
|
78
|
+
<template v-else>
|
|
79
|
+
<MInput @keyup.enter="updateFromHex" @blur="updateFromHex" block
|
|
80
|
+
ref="hexInputElement"
|
|
81
|
+
v-model="hexInput" name="hex" placeholder="#00000000"/>
|
|
82
|
+
</template>
|
|
83
|
+
|
|
84
|
+
<MButton icon @click.prevent="rgbOrHex = !rgbOrHex">
|
|
85
|
+
<svg style="width: 18px; height: 18px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"
|
|
86
|
+
fill="currentColor" class="w-5 h-5">
|
|
87
|
+
<path fill-rule="evenodd"
|
|
88
|
+
d="M10 3a.75.75 0 01.55.24l3.25 3.5a.75.75 0 11-1.1 1.02L10 4.852 7.3 7.76a.75.75 0 01-1.1-1.02l3.25-3.5A.75.75 0 0110 3zm-3.76 9.2a.75.75 0 011.06.04l2.7 2.908 2.7-2.908a.75.75 0 111.1 1.02l-3.25 3.5a.75.75 0 01-1.1 0l-3.25-3.5a.75.75 0 01.04-1.06z"
|
|
89
|
+
clip-rule="evenodd"/>
|
|
90
|
+
</svg>
|
|
91
|
+
</MButton>
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
</Teleport>
|
|
95
|
+
</div>
|
|
96
|
+
</template>
|
|
97
|
+
|
|
98
|
+
<script lang="ts">
|
|
99
|
+
import {onClickOutside, useEyeDropper, useMouseInElement, useMousePressed} from '@vueuse/core';
|
|
100
|
+
import {computed, defineComponent, onMounted, type PropType, reactive, ref, toRef, watch} from "vue";
|
|
101
|
+
import * as style from './style';
|
|
102
|
+
import {hexToRGB, type HSV, HSVToRGBA, HueToRGBA, RGBAToHex, RGBToHSV} from './utils';
|
|
103
|
+
import {usePopper} from "../../composables/usePopper";
|
|
104
|
+
import type {Placement} from "@popperjs/core";
|
|
105
|
+
import {useZIndex} from "../../composables/useZIndex";
|
|
106
|
+
import MSlider from "../../components/slider/Slider.vue";
|
|
107
|
+
import MButton from "../../components/button/Button.vue";
|
|
108
|
+
import MInput from "../../components/input/Input.vue";
|
|
109
|
+
|
|
110
|
+
export default defineComponent({
|
|
111
|
+
name: "MColorPicker",
|
|
112
|
+
props: {
|
|
113
|
+
modelValue: {
|
|
114
|
+
type: String,
|
|
115
|
+
default: "#FF00FF"
|
|
116
|
+
},
|
|
117
|
+
transfer: {
|
|
118
|
+
type: Boolean,
|
|
119
|
+
default: false
|
|
120
|
+
},
|
|
121
|
+
placement: {
|
|
122
|
+
type: String as PropType<Placement>,
|
|
123
|
+
default: "bottom-start"
|
|
124
|
+
},
|
|
125
|
+
zIndex: {
|
|
126
|
+
type: Number
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
emits: ['update:modelValue'],
|
|
130
|
+
components: {
|
|
131
|
+
MSlider,
|
|
132
|
+
MInput,
|
|
133
|
+
MButton
|
|
134
|
+
},
|
|
135
|
+
setup(props, {emit}) {
|
|
136
|
+
const {isSupported: canPickColor, open: openEyeDrop, sRGBHex: eyeDropColor} = useEyeDropper();
|
|
137
|
+
const {nextZIndex} = useZIndex();
|
|
138
|
+
const isOpen = ref(false);
|
|
139
|
+
const rgbOrHex = ref<boolean>(false);
|
|
140
|
+
const hexInput = ref("");
|
|
141
|
+
const rInput = ref("");
|
|
142
|
+
const gInput = ref("");
|
|
143
|
+
const bInput = ref("");
|
|
144
|
+
const aInput = ref("");
|
|
145
|
+
|
|
146
|
+
const picker = ref<HTMLElement>();
|
|
147
|
+
const wrapper = ref<HTMLElement>();
|
|
148
|
+
const referenceRef = ref<HTMLElement>();
|
|
149
|
+
const transfer = toRef(props, 'transfer');
|
|
150
|
+
const placement = toRef(props, 'placement');
|
|
151
|
+
const hexInputElement = ref();
|
|
152
|
+
const hueSlider = ref(0);
|
|
153
|
+
const opacitySlider = ref(100);
|
|
154
|
+
const dragging = ref(false);
|
|
155
|
+
const position = reactive({
|
|
156
|
+
x: 0,
|
|
157
|
+
y: 0
|
|
158
|
+
});
|
|
159
|
+
const zIndex = ref(props.zIndex ?? nextZIndex());
|
|
160
|
+
|
|
161
|
+
const {elementX, elementY} = useMouseInElement(picker);
|
|
162
|
+
const {pressed} = useMousePressed();
|
|
163
|
+
const {popper, transferTo, updatePopper} = usePopper({
|
|
164
|
+
reference: referenceRef,
|
|
165
|
+
placement,
|
|
166
|
+
transfer,
|
|
167
|
+
wrapper,
|
|
168
|
+
isDrop: false,
|
|
169
|
+
offset: [-2, 2]
|
|
170
|
+
});
|
|
171
|
+
const brightness = computed(() => {
|
|
172
|
+
return 1 - position.y;
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
const saturation = computed(() => {
|
|
176
|
+
return position.x;
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
const finalColor = computed(() => {
|
|
180
|
+
return HSVToRGBA(hueSlider.value * 3.6, brightness.value, saturation.value, opacitySlider.value / 100);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
const mainColor = computed(() => {
|
|
184
|
+
return HueToRGBA(hueSlider.value * 3.6, opacitySlider.value / 100);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
const setInputs = () => {
|
|
188
|
+
hexInput.value = RGBAToHex(finalColor.value.r, finalColor.value.g, finalColor.value.b, finalColor.value.a);
|
|
189
|
+
rInput.value = finalColor.value.r.toString();
|
|
190
|
+
gInput.value = finalColor.value.g.toString();
|
|
191
|
+
bInput.value = finalColor.value.b.toString();
|
|
192
|
+
aInput.value = finalColor.value.a.toFixed(2).toString();
|
|
193
|
+
|
|
194
|
+
emit('update:modelValue', hexInput.value);
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
watch(() => finalColor.value, () => {
|
|
198
|
+
setInputs();
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
const updateFromHSV = (hsv: HSV, alpha: number) => {
|
|
202
|
+
position.x = hsv.s;
|
|
203
|
+
position.y = 1 - hsv.v;
|
|
204
|
+
hueSlider.value = ((1 / 360) * hsv.h) * 100;
|
|
205
|
+
opacitySlider.value = alpha * 100;
|
|
206
|
+
setInputs();
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const updateFromHex = () => {
|
|
210
|
+
var color = hexToRGB(hexInput.value, finalColor.value.r, finalColor.value.g, finalColor.value.b, finalColor.value.a);
|
|
211
|
+
updateFromHSV(RGBToHSV(color.r, color.g, color.b), color.a);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const updateFromRGB = () => {
|
|
215
|
+
var red = parseInt(rInput.value);
|
|
216
|
+
if (isNaN(red) || red > 255 || red < 0) {
|
|
217
|
+
red = finalColor.value.r;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
var green = parseInt(gInput.value);
|
|
221
|
+
if (isNaN(green) || green > 255 || green < 0) {
|
|
222
|
+
green = finalColor.value.g;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
var blue = parseInt(bInput.value);
|
|
226
|
+
if (isNaN(blue) || blue > 255 || blue < 0) {
|
|
227
|
+
blue = finalColor.value.b;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
var alpha = parseFloat(aInput.value);
|
|
231
|
+
if (isNaN(alpha) || alpha > 1 || alpha < 0) {
|
|
232
|
+
alpha = finalColor.value.a;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
updateFromHSV(RGBToHSV(red, green, blue), alpha);
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
watch(() => pressed.value, () => {
|
|
239
|
+
if (!pressed.value) {
|
|
240
|
+
dragging.value = false;
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
watch(() => [elementX.value, elementY.value], () => {
|
|
245
|
+
if (!dragging.value) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
setThumbPosition();
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
watch(() => props.modelValue, () => {
|
|
253
|
+
hexInput.value = props.modelValue;
|
|
254
|
+
updateFromHex();
|
|
255
|
+
console.log('hi');
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
const setThumbPosition = () => {
|
|
259
|
+
position.x = ((Math.min(Math.max(elementX.value, 0), picker.value?.clientWidth || 0) / (picker.value?.clientWidth || 0)));
|
|
260
|
+
position.y = ((Math.min(Math.max(elementY.value, 0), picker.value?.clientHeight || 0) / (picker.value?.clientHeight || 0)));
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
const handleMouseDown = () => {
|
|
264
|
+
dragging.value = true;
|
|
265
|
+
setThumbPosition();
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
onMounted(() => {
|
|
269
|
+
hexInput.value = props.modelValue;
|
|
270
|
+
updateFromHex();
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
onClickOutside(popper, (e) => {
|
|
274
|
+
isOpen.value = false;
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
watch(() => eyeDropColor.value, () => {
|
|
278
|
+
hexInput.value = eyeDropColor.value;
|
|
279
|
+
updateFromHex();
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
const openEyeDropper = () => {
|
|
283
|
+
try {
|
|
284
|
+
openEyeDrop();
|
|
285
|
+
} catch (e) {
|
|
286
|
+
console.log(e);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
return {
|
|
291
|
+
isOpen,
|
|
292
|
+
popper,
|
|
293
|
+
transferTo,
|
|
294
|
+
wrapper,
|
|
295
|
+
referenceRef,
|
|
296
|
+
updateFromRGB,
|
|
297
|
+
updateFromHex,
|
|
298
|
+
setInputs,
|
|
299
|
+
rgbOrHex,
|
|
300
|
+
hexInputElement,
|
|
301
|
+
hexInput,
|
|
302
|
+
rInput,
|
|
303
|
+
gInput,
|
|
304
|
+
bInput,
|
|
305
|
+
aInput,
|
|
306
|
+
finalColor,
|
|
307
|
+
hueSlider,
|
|
308
|
+
opacitySlider,
|
|
309
|
+
dragging,
|
|
310
|
+
setThumbPosition,
|
|
311
|
+
position,
|
|
312
|
+
elementX,
|
|
313
|
+
pressed,
|
|
314
|
+
handleMouseDown,
|
|
315
|
+
picker,
|
|
316
|
+
style,
|
|
317
|
+
mainColor,
|
|
318
|
+
zIndex,
|
|
319
|
+
canPickColor,
|
|
320
|
+
openEyeDropper
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
})
|
|
324
|
+
</script>
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<MColorPicker />
|
|
1
|
+
<template>
|
|
2
|
+
<MColorPicker />
|
|
3
3
|
</template>
|