primevue 3.15.0 → 3.16.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/autocomplete/AutoComplete.d.ts +182 -38
- package/autocomplete/AutoComplete.vue +636 -342
- package/autocomplete/autocomplete.cjs.js +745 -416
- package/autocomplete/autocomplete.cjs.min.js +1 -1
- package/autocomplete/autocomplete.esm.js +747 -418
- package/autocomplete/autocomplete.esm.min.js +1 -1
- package/autocomplete/autocomplete.js +745 -416
- package/autocomplete/autocomplete.min.js +1 -1
- package/button/Button.vue +4 -1
- package/button/button.cjs.js +5 -1
- package/button/button.cjs.min.js +1 -1
- package/button/button.esm.js +5 -1
- package/button/button.esm.min.js +1 -1
- package/button/button.js +5 -1
- package/button/button.min.js +1 -1
- package/calendar/Calendar.d.ts +51 -12
- package/calendar/Calendar.vue +259 -114
- package/calendar/calendar.cjs.js +414 -220
- package/calendar/calendar.cjs.min.js +1 -1
- package/calendar/calendar.esm.js +415 -221
- package/calendar/calendar.esm.min.js +1 -1
- package/calendar/calendar.js +414 -220
- package/calendar/calendar.min.js +1 -1
- package/carousel/Carousel.vue +25 -0
- package/carousel/carousel.cjs.js +25 -0
- package/carousel/carousel.cjs.min.js +1 -1
- package/carousel/carousel.esm.js +25 -0
- package/carousel/carousel.esm.min.js +1 -1
- package/carousel/carousel.js +25 -0
- package/carousel/carousel.min.js +1 -1
- package/cascadeselect/CascadeSelect.d.ts +97 -17
- package/cascadeselect/CascadeSelect.vue +560 -135
- package/cascadeselect/CascadeSelectSub.vue +48 -129
- package/cascadeselect/cascadeselect.cjs.js +670 -306
- package/cascadeselect/cascadeselect.cjs.min.js +1 -1
- package/cascadeselect/cascadeselect.esm.js +672 -308
- package/cascadeselect/cascadeselect.esm.min.js +1 -1
- package/cascadeselect/cascadeselect.js +670 -306
- package/cascadeselect/cascadeselect.min.js +1 -1
- package/checkbox/Checkbox.d.ts +40 -4
- package/checkbox/Checkbox.vue +50 -13
- package/checkbox/checkbox.cjs.js +64 -23
- package/checkbox/checkbox.cjs.min.js +1 -1
- package/checkbox/checkbox.esm.js +65 -24
- package/checkbox/checkbox.esm.min.js +1 -1
- package/checkbox/checkbox.js +64 -23
- package/checkbox/checkbox.min.js +1 -1
- package/chips/Chips.d.ts +36 -12
- package/chips/Chips.vue +116 -22
- package/chips/chips.cjs.js +149 -37
- package/chips/chips.cjs.min.js +1 -1
- package/chips/chips.esm.js +150 -38
- package/chips/chips.esm.min.js +1 -1
- package/chips/chips.js +150 -39
- package/chips/chips.min.js +1 -1
- package/colorpicker/ColorPicker.d.ts +3 -6
- package/colorpicker/ColorPicker.vue +1 -5
- package/colorpicker/colorpicker.cjs.js +2 -7
- package/colorpicker/colorpicker.cjs.min.js +1 -1
- package/colorpicker/colorpicker.esm.js +2 -7
- package/colorpicker/colorpicker.esm.min.js +1 -1
- package/colorpicker/colorpicker.js +2 -7
- package/colorpicker/colorpicker.min.js +1 -1
- package/column/Column.d.ts +4 -0
- package/column/Column.vue +4 -0
- package/column/column.cjs.js +4 -0
- package/column/column.cjs.min.js +1 -1
- package/column/column.esm.js +4 -0
- package/column/column.esm.min.js +1 -1
- package/column/column.js +4 -0
- package/column/column.min.js +1 -1
- package/config/PrimeVue.d.ts +42 -0
- package/config/config.cjs.js +35 -4
- package/config/config.cjs.min.js +1 -1
- package/config/config.esm.js +35 -4
- package/config/config.esm.min.js +1 -1
- package/config/config.js +35 -4
- package/config/config.min.js +1 -1
- package/confirmdialog/ConfirmDialog.vue +4 -1
- package/confirmdialog/confirmdialog.cjs.js +6 -2
- package/confirmdialog/confirmdialog.cjs.min.js +1 -1
- package/confirmdialog/confirmdialog.esm.js +6 -2
- package/confirmdialog/confirmdialog.esm.min.js +1 -1
- package/confirmdialog/confirmdialog.js +6 -2
- package/confirmdialog/confirmdialog.min.js +1 -1
- package/contextmenu/ContextMenu.d.ts +1 -1
- package/contextmenu/ContextMenuSub.vue +3 -3
- package/contextmenu/contextmenu.cjs.js +14 -8
- package/contextmenu/contextmenu.cjs.min.js +1 -1
- package/contextmenu/contextmenu.esm.js +15 -9
- package/contextmenu/contextmenu.esm.min.js +1 -1
- package/contextmenu/contextmenu.js +14 -8
- package/contextmenu/contextmenu.min.js +1 -1
- package/core/core.js +1128 -772
- package/core/core.min.js +12 -12
- package/datatable/BodyCell.vue +11 -2
- package/datatable/DataTable.vue +23 -2
- package/datatable/datatable.cjs.js +34 -4
- package/datatable/datatable.cjs.min.js +1 -1
- package/datatable/datatable.esm.js +34 -4
- package/datatable/datatable.esm.min.js +1 -1
- package/datatable/datatable.js +34 -4
- package/datatable/datatable.min.js +1 -1
- package/dialog/Dialog.d.ts +5 -1
- package/dropdown/Dropdown.d.ts +92 -38
- package/dropdown/Dropdown.vue +538 -399
- package/dropdown/dropdown.cjs.js +657 -486
- package/dropdown/dropdown.cjs.min.js +1 -1
- package/dropdown/dropdown.esm.js +659 -488
- package/dropdown/dropdown.esm.min.js +1 -1
- package/dropdown/dropdown.js +657 -486
- package/dropdown/dropdown.min.js +1 -1
- package/editor/Editor.d.ts +32 -0
- package/editor/Editor.vue +15 -1
- package/editor/editor.cjs.js +15 -1
- package/editor/editor.cjs.min.js +1 -1
- package/editor/editor.esm.js +15 -1
- package/editor/editor.esm.min.js +1 -1
- package/editor/editor.js +15 -1
- package/editor/editor.min.js +1 -1
- package/inputmask/InputMask.vue +9 -6
- package/inputmask/inputmask.cjs.js +14 -6
- package/inputmask/inputmask.cjs.min.js +1 -1
- package/inputmask/inputmask.esm.js +15 -7
- package/inputmask/inputmask.esm.min.js +1 -1
- package/inputmask/inputmask.js +14 -6
- package/inputmask/inputmask.min.js +1 -1
- package/inputnumber/InputNumber.d.ts +31 -7
- package/inputnumber/InputNumber.vue +53 -20
- package/inputnumber/inputnumber.cjs.js +75 -29
- package/inputnumber/inputnumber.cjs.min.js +1 -1
- package/inputnumber/inputnumber.esm.js +76 -30
- package/inputnumber/inputnumber.esm.min.js +1 -1
- package/inputnumber/inputnumber.js +75 -29
- package/inputnumber/inputnumber.min.js +1 -1
- package/inputswitch/InputSwitch.d.ts +24 -8
- package/inputswitch/InputSwitch.vue +27 -12
- package/inputswitch/inputswitch.cjs.js +38 -20
- package/inputswitch/inputswitch.cjs.min.js +1 -1
- package/inputswitch/inputswitch.esm.js +39 -21
- package/inputswitch/inputswitch.esm.min.js +1 -1
- package/inputswitch/inputswitch.js +38 -20
- package/inputswitch/inputswitch.min.js +1 -1
- package/inputtext/InputText.vue +1 -2
- package/inputtext/inputtext.cjs.js +3 -4
- package/inputtext/inputtext.cjs.min.js +1 -1
- package/inputtext/inputtext.esm.js +4 -5
- package/inputtext/inputtext.esm.min.js +1 -1
- package/inputtext/inputtext.js +3 -4
- package/inputtext/inputtext.min.js +1 -1
- package/knob/Knob.d.ts +12 -0
- package/knob/Knob.vue +62 -2
- package/knob/knob.cjs.js +73 -5
- package/knob/knob.cjs.min.js +1 -1
- package/knob/knob.esm.js +73 -5
- package/knob/knob.esm.min.js +1 -1
- package/knob/knob.js +73 -5
- package/knob/knob.min.js +1 -1
- package/listbox/Listbox.d.ts +53 -7
- package/listbox/Listbox.vue +500 -135
- package/listbox/listbox.cjs.js +597 -193
- package/listbox/listbox.cjs.min.js +1 -1
- package/listbox/listbox.esm.js +599 -195
- package/listbox/listbox.esm.min.js +1 -1
- package/listbox/listbox.js +597 -193
- package/listbox/listbox.min.js +1 -1
- package/menu/Menu.d.ts +1 -1
- package/menu/Menuitem.vue +2 -2
- package/menu/menu.cjs.js +12 -6
- package/menu/menu.cjs.min.js +1 -1
- package/menu/menu.esm.js +13 -7
- package/menu/menu.esm.min.js +1 -1
- package/menu/menu.js +12 -6
- package/menu/menu.min.js +1 -1
- package/menubar/MenubarSub.vue +3 -3
- package/menubar/menubar.cjs.js +14 -8
- package/menubar/menubar.cjs.min.js +1 -1
- package/menubar/menubar.esm.js +15 -9
- package/menubar/menubar.esm.min.js +1 -1
- package/menubar/menubar.js +14 -8
- package/menubar/menubar.min.js +1 -1
- package/menuitem/MenuItem.d.ts +1 -1
- package/multiselect/MultiSelect.d.ts +111 -51
- package/multiselect/MultiSelect.vue +629 -338
- package/multiselect/multiselect.cjs.js +748 -428
- package/multiselect/multiselect.cjs.min.js +1 -1
- package/multiselect/multiselect.esm.js +750 -430
- package/multiselect/multiselect.esm.min.js +1 -1
- package/multiselect/multiselect.js +748 -428
- package/multiselect/multiselect.min.js +1 -1
- package/overlaypanel/OverlayPanel.d.ts +1 -1
- package/overlaypanel/OverlayPanel.vue +14 -2
- package/overlaypanel/overlaypanel.cjs.js +14 -2
- package/overlaypanel/overlaypanel.cjs.min.js +1 -1
- package/overlaypanel/overlaypanel.esm.js +14 -2
- package/overlaypanel/overlaypanel.esm.min.js +1 -1
- package/overlaypanel/overlaypanel.js +14 -2
- package/overlaypanel/overlaypanel.min.js +1 -1
- package/package.json +2 -2
- package/paginator/Paginator.d.ts +2 -2
- package/password/Password.d.ts +36 -8
- package/password/Password.vue +50 -14
- package/password/password.cjs.js +69 -24
- package/password/password.cjs.min.js +1 -1
- package/password/password.esm.js +71 -26
- package/password/password.esm.min.js +1 -1
- package/password/password.js +69 -24
- package/password/password.min.js +1 -1
- package/picklist/PickList.d.ts +8 -0
- package/picklist/PickList.vue +10 -2
- package/picklist/picklist.cjs.js +68 -50
- package/picklist/picklist.cjs.min.js +1 -1
- package/picklist/picklist.esm.js +69 -51
- package/picklist/picklist.esm.min.js +1 -1
- package/picklist/picklist.js +68 -50
- package/picklist/picklist.min.js +1 -1
- package/portal/Portal.d.ts +1 -1
- package/radiobutton/RadioButton.d.ts +28 -4
- package/radiobutton/RadioButton.vue +36 -11
- package/radiobutton/radiobutton.cjs.js +49 -23
- package/radiobutton/radiobutton.cjs.min.js +1 -1
- package/radiobutton/radiobutton.esm.js +50 -24
- package/radiobutton/radiobutton.esm.min.js +1 -1
- package/radiobutton/radiobutton.js +49 -23
- package/radiobutton/radiobutton.min.js +1 -1
- package/rating/Rating.d.ts +4 -0
- package/rating/Rating.vue +61 -7
- package/rating/rating.cjs.js +90 -16
- package/rating/rating.cjs.min.js +1 -1
- package/rating/rating.esm.js +91 -17
- package/rating/rating.esm.min.js +1 -1
- package/rating/rating.js +90 -16
- package/rating/rating.min.js +1 -1
- package/resources/primevue.css +8 -0
- package/resources/primevue.min.css +1 -1
- package/resources/themes/arya-blue/theme.css +82 -40
- package/resources/themes/arya-green/theme.css +82 -40
- package/resources/themes/arya-orange/theme.css +82 -40
- package/resources/themes/arya-purple/theme.css +82 -40
- package/resources/themes/bootstrap4-dark-blue/theme.css +82 -40
- package/resources/themes/bootstrap4-dark-purple/theme.css +82 -40
- package/resources/themes/bootstrap4-light-blue/theme.css +82 -40
- package/resources/themes/bootstrap4-light-purple/theme.css +82 -40
- package/resources/themes/fluent-light/theme.css +82 -40
- package/resources/themes/lara-dark-blue/theme.css +82 -40
- package/resources/themes/lara-dark-indigo/theme.css +82 -40
- package/resources/themes/lara-dark-purple/theme.css +82 -40
- package/resources/themes/lara-dark-teal/theme.css +82 -40
- package/resources/themes/lara-light-blue/theme.css +82 -40
- package/resources/themes/lara-light-indigo/theme.css +82 -40
- package/resources/themes/lara-light-purple/theme.css +82 -40
- package/resources/themes/lara-light-teal/theme.css +82 -40
- package/resources/themes/luna-amber/theme.css +82 -40
- package/resources/themes/luna-blue/theme.css +82 -40
- package/resources/themes/luna-green/theme.css +82 -40
- package/resources/themes/luna-pink/theme.css +82 -40
- package/resources/themes/md-dark-deeppurple/theme.css +82 -40
- package/resources/themes/md-dark-indigo/theme.css +82 -40
- package/resources/themes/md-light-deeppurple/theme.css +82 -40
- package/resources/themes/md-light-indigo/theme.css +82 -40
- package/resources/themes/mdc-dark-deeppurple/theme.css +82 -40
- package/resources/themes/mdc-dark-indigo/theme.css +82 -40
- package/resources/themes/mdc-light-deeppurple/theme.css +82 -40
- package/resources/themes/mdc-light-indigo/theme.css +82 -40
- package/resources/themes/nova/theme.css +82 -40
- package/resources/themes/nova-accent/theme.css +82 -40
- package/resources/themes/nova-alt/theme.css +82 -40
- package/resources/themes/nova-vue/theme.css +82 -40
- package/resources/themes/rhea/theme.css +82 -40
- package/resources/themes/saga-blue/theme.css +82 -40
- package/resources/themes/saga-green/theme.css +82 -40
- package/resources/themes/saga-orange/theme.css +82 -40
- package/resources/themes/saga-purple/theme.css +82 -40
- package/resources/themes/tailwind-light/theme.css +82 -40
- package/resources/themes/vela-blue/theme.css +82 -40
- package/resources/themes/vela-green/theme.css +82 -40
- package/resources/themes/vela-orange/theme.css +82 -40
- package/resources/themes/vela-purple/theme.css +82 -40
- package/ripple/ripple.cjs.js +1 -0
- package/ripple/ripple.cjs.min.js +1 -1
- package/ripple/ripple.esm.js +1 -0
- package/ripple/ripple.esm.min.js +1 -1
- package/ripple/ripple.js +1 -0
- package/ripple/ripple.min.js +1 -1
- package/selectbutton/SelectButton.d.ts +6 -2
- package/selectbutton/SelectButton.vue +89 -12
- package/selectbutton/selectbutton.cjs.js +97 -22
- package/selectbutton/selectbutton.cjs.min.js +1 -1
- package/selectbutton/selectbutton.esm.js +99 -24
- package/selectbutton/selectbutton.esm.min.js +1 -1
- package/selectbutton/selectbutton.js +97 -22
- package/selectbutton/selectbutton.min.js +1 -1
- package/slider/Slider.d.ts +9 -1
- package/slider/Slider.vue +50 -34
- package/slider/slider.cjs.js +59 -38
- package/slider/slider.cjs.min.js +1 -1
- package/slider/slider.esm.js +59 -38
- package/slider/slider.esm.min.js +1 -1
- package/slider/slider.js +59 -38
- package/slider/slider.min.js +1 -1
- package/splitbutton/SplitButton.d.ts +1 -1
- package/splitter/Splitter.vue +30 -1
- package/splitter/splitter.cjs.js +30 -1
- package/splitter/splitter.cjs.min.js +1 -1
- package/splitter/splitter.esm.js +30 -1
- package/splitter/splitter.esm.min.js +1 -1
- package/splitter/splitter.js +30 -1
- package/splitter/splitter.min.js +1 -1
- package/textarea/Textarea.vue +1 -2
- package/textarea/textarea.cjs.js +3 -5
- package/textarea/textarea.cjs.min.js +1 -1
- package/textarea/textarea.esm.js +4 -6
- package/textarea/textarea.esm.min.js +1 -1
- package/textarea/textarea.js +3 -5
- package/textarea/textarea.min.js +1 -1
- package/tieredmenu/TieredMenu.d.ts +1 -1
- package/tieredmenu/TieredMenuSub.vue +3 -3
- package/tieredmenu/tieredmenu.cjs.js +14 -8
- package/tieredmenu/tieredmenu.cjs.min.js +1 -1
- package/tieredmenu/tieredmenu.esm.js +15 -9
- package/tieredmenu/tieredmenu.esm.min.js +1 -1
- package/tieredmenu/tieredmenu.js +14 -8
- package/tieredmenu/tieredmenu.min.js +1 -1
- package/timeline/Timeline.d.ts +10 -1
- package/timeline/Timeline.vue +1 -1
- package/timeline/timeline.cjs.js +5 -1
- package/timeline/timeline.cjs.min.js +1 -1
- package/timeline/timeline.esm.js +5 -1
- package/timeline/timeline.esm.min.js +1 -1
- package/timeline/timeline.js +5 -1
- package/timeline/timeline.min.js +1 -1
- package/togglebutton/ToggleButton.d.ts +42 -0
- package/togglebutton/ToggleButton.vue +44 -7
- package/togglebutton/togglebutton.cjs.js +59 -13
- package/togglebutton/togglebutton.cjs.min.js +1 -1
- package/togglebutton/togglebutton.esm.js +60 -14
- package/togglebutton/togglebutton.esm.min.js +1 -1
- package/togglebutton/togglebutton.js +59 -13
- package/togglebutton/togglebutton.min.js +1 -1
- package/tooltip/tooltip.cjs.js +20 -11
- package/tooltip/tooltip.cjs.min.js +1 -1
- package/tooltip/tooltip.esm.js +21 -12
- package/tooltip/tooltip.esm.min.js +1 -1
- package/tooltip/tooltip.js +20 -11
- package/tooltip/tooltip.min.js +1 -1
- package/tree/Tree.vue +5 -1
- package/tree/TreeNode.vue +20 -19
- package/tree/tree.cjs.js +47 -32
- package/tree/tree.cjs.min.js +1 -1
- package/tree/tree.esm.js +47 -32
- package/tree/tree.esm.min.js +1 -1
- package/tree/tree.js +47 -32
- package/tree/tree.min.js +1 -1
- package/treeselect/TreeSelect.d.ts +26 -10
- package/treeselect/TreeSelect.vue +52 -29
- package/treeselect/treeselect.cjs.js +74 -41
- package/treeselect/treeselect.cjs.min.js +1 -1
- package/treeselect/treeselect.esm.js +76 -43
- package/treeselect/treeselect.esm.min.js +1 -1
- package/treeselect/treeselect.js +74 -41
- package/treeselect/treeselect.min.js +1 -1
- package/tristatecheckbox/TriStateCheckbox.d.ts +20 -4
- package/tristatecheckbox/TriStateCheckbox.vue +52 -15
- package/tristatecheckbox/tristatecheckbox.cjs.js +67 -26
- package/tristatecheckbox/tristatecheckbox.cjs.min.js +1 -1
- package/tristatecheckbox/tristatecheckbox.esm.js +68 -27
- package/tristatecheckbox/tristatecheckbox.esm.min.js +1 -1
- package/tristatecheckbox/tristatecheckbox.js +67 -26
- package/tristatecheckbox/tristatecheckbox.min.js +1 -1
- package/utils/Utils.d.ts +3 -2
- package/utils/utils.cjs.js +239 -173
- package/utils/utils.cjs.min.js +1 -1
- package/utils/utils.esm.js +239 -173
- package/utils/utils.esm.min.js +1 -1
- package/utils/utils.js +239 -173
- package/utils/utils.min.js +1 -1
- package/vetur-attributes.json +612 -136
- package/vetur-tags.json +180 -59
- package/virtualscroller/VirtualScroller.d.ts +10 -0
- package/virtualscroller/VirtualScroller.vue +18 -17
- package/virtualscroller/virtualscroller.cjs.js +22 -20
- package/virtualscroller/virtualscroller.cjs.min.js +1 -1
- package/virtualscroller/virtualscroller.esm.js +22 -20
- package/virtualscroller/virtualscroller.esm.min.js +1 -1
- package/virtualscroller/virtualscroller.js +22 -20
- package/virtualscroller/virtualscroller.min.js +1 -1
- package/web-types.json +1745 -338
package/chips/chips.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
this.primevue = this.primevue || {};
|
|
2
|
-
this.primevue.chips = (function (vue) {
|
|
2
|
+
this.primevue.chips = (function (utils, vue) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
5
|
var script = {
|
|
6
6
|
name: 'Chips',
|
|
7
|
-
|
|
8
|
-
emits: ['update:modelValue', 'add', 'remove'],
|
|
7
|
+
emits: ['update:modelValue', 'add', 'remove', 'focus', 'blur'],
|
|
9
8
|
props: {
|
|
10
9
|
modelValue: {
|
|
11
10
|
type: Array,
|
|
@@ -27,13 +26,33 @@ this.primevue.chips = (function (vue) {
|
|
|
27
26
|
type: Boolean,
|
|
28
27
|
default: true
|
|
29
28
|
},
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
placeholder: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: null
|
|
32
|
+
},
|
|
33
|
+
inputId: null,
|
|
34
|
+
inputClass: null,
|
|
35
|
+
inputStyle: null,
|
|
36
|
+
inputProps: null,
|
|
37
|
+
disabled: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: false
|
|
40
|
+
},
|
|
41
|
+
'aria-labelledby': {
|
|
42
|
+
type: String,
|
|
43
|
+
default: null
|
|
44
|
+
},
|
|
45
|
+
'aria-label': {
|
|
46
|
+
type: String,
|
|
47
|
+
default: null
|
|
48
|
+
}
|
|
32
49
|
},
|
|
33
50
|
data() {
|
|
34
51
|
return {
|
|
52
|
+
id: utils.UniqueComponentId(),
|
|
35
53
|
inputValue: null,
|
|
36
|
-
focused: false
|
|
54
|
+
focused: false,
|
|
55
|
+
focusedIndex: null
|
|
37
56
|
};
|
|
38
57
|
},
|
|
39
58
|
methods: {
|
|
@@ -42,37 +61,53 @@ this.primevue.chips = (function (vue) {
|
|
|
42
61
|
},
|
|
43
62
|
onInput(event) {
|
|
44
63
|
this.inputValue = event.target.value;
|
|
64
|
+
this.focusedIndex = null;
|
|
45
65
|
},
|
|
46
|
-
onFocus() {
|
|
66
|
+
onFocus(event) {
|
|
47
67
|
this.focused = true;
|
|
68
|
+
this.focusedIndex = null;
|
|
69
|
+
this.$emit('focus', event);
|
|
48
70
|
},
|
|
49
71
|
onBlur(event) {
|
|
50
72
|
this.focused = false;
|
|
73
|
+
this.focusedIndex = null;
|
|
51
74
|
if (this.addOnBlur) {
|
|
52
75
|
this.addItem(event, event.target.value, false);
|
|
53
76
|
}
|
|
77
|
+
this.$emit('blur', event);
|
|
54
78
|
},
|
|
55
79
|
onKeyDown(event) {
|
|
56
80
|
const inputValue = event.target.value;
|
|
57
81
|
|
|
58
|
-
switch(event.
|
|
59
|
-
|
|
60
|
-
case 8:
|
|
82
|
+
switch(event.code) {
|
|
83
|
+
case 'Backspace':
|
|
61
84
|
if (inputValue.length === 0 && this.modelValue && this.modelValue.length > 0) {
|
|
62
|
-
|
|
85
|
+
if (this.focusedIndex !== null) {
|
|
86
|
+
this.removeItem(event, this.focusedIndex);
|
|
87
|
+
}
|
|
88
|
+
else this.removeItem(event, this.modelValue.length - 1);
|
|
63
89
|
}
|
|
64
90
|
break;
|
|
65
91
|
|
|
66
|
-
|
|
67
|
-
case 13:
|
|
92
|
+
case 'Enter':
|
|
68
93
|
if (inputValue && inputValue.trim().length && !this.maxedOut) {
|
|
69
94
|
this.addItem(event, inputValue, true);
|
|
70
95
|
}
|
|
71
96
|
break;
|
|
72
97
|
|
|
98
|
+
case 'ArrowLeft':
|
|
99
|
+
if (inputValue.length === 0 && this.modelValue && this.modelValue.length > 0) {
|
|
100
|
+
this.$refs.container.focus();
|
|
101
|
+
}
|
|
102
|
+
break;
|
|
103
|
+
|
|
104
|
+
case 'ArrowRight':
|
|
105
|
+
event.stopPropagation();
|
|
106
|
+
break;
|
|
107
|
+
|
|
73
108
|
default:
|
|
74
109
|
if (this.separator) {
|
|
75
|
-
if (this.separator === ',' &&
|
|
110
|
+
if (this.separator === ',' && event.key === ',') {
|
|
76
111
|
this.addItem(event, inputValue, true);
|
|
77
112
|
}
|
|
78
113
|
}
|
|
@@ -91,6 +126,51 @@ this.primevue.chips = (function (vue) {
|
|
|
91
126
|
}
|
|
92
127
|
}
|
|
93
128
|
},
|
|
129
|
+
onContainerFocus() {
|
|
130
|
+
this.focused = true;
|
|
131
|
+
},
|
|
132
|
+
onContainerBlur() {
|
|
133
|
+
this.focusedIndex = -1;
|
|
134
|
+
this.focused = false;
|
|
135
|
+
},
|
|
136
|
+
onContainerKeyDown(event) {
|
|
137
|
+
switch (event.code) {
|
|
138
|
+
case 'ArrowLeft':
|
|
139
|
+
this.onArrowLeftKeyOn(event);
|
|
140
|
+
break;
|
|
141
|
+
|
|
142
|
+
case 'ArrowRight':
|
|
143
|
+
this.onArrowRightKeyOn(event);
|
|
144
|
+
break;
|
|
145
|
+
|
|
146
|
+
case 'Backspace':
|
|
147
|
+
this.onBackspaceKeyOn(event);
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
onArrowLeftKeyOn() {
|
|
152
|
+
if (this.inputValue.length === 0 && this.modelValue && this.modelValue.length > 0) {
|
|
153
|
+
this.focusedIndex = this.focusedIndex === null ? this.modelValue.length - 1 : this.focusedIndex - 1;
|
|
154
|
+
if (this.focusedIndex < 0) this.focusedIndex = 0;
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
onArrowRightKeyOn() {
|
|
158
|
+
if (this.inputValue.length === 0 && this.modelValue && this.modelValue.length > 0) {
|
|
159
|
+
|
|
160
|
+
if (this.focusedIndex === this.modelValue.length - 1) {
|
|
161
|
+
this.focusedIndex = null;
|
|
162
|
+
this.$refs.input.focus();
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
this.focusedIndex++;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
onBackspaceKeyOn(event) {
|
|
170
|
+
if (this.focusedIndex !== null) {
|
|
171
|
+
this.removeItem(event, this.focusedIndex);
|
|
172
|
+
}
|
|
173
|
+
},
|
|
94
174
|
updateModel(event, value, preventDefault) {
|
|
95
175
|
this.$emit('update:modelValue', value);
|
|
96
176
|
this.$emit('add', {
|
|
@@ -114,12 +194,14 @@ this.primevue.chips = (function (vue) {
|
|
|
114
194
|
}
|
|
115
195
|
},
|
|
116
196
|
removeItem(event, index) {
|
|
117
|
-
if (this
|
|
197
|
+
if (this.disabled) {
|
|
118
198
|
return;
|
|
119
199
|
}
|
|
120
200
|
|
|
121
201
|
let values = [...this.modelValue];
|
|
122
202
|
const removedItem = values.splice(index, 1);
|
|
203
|
+
this.focusedIndex = null;
|
|
204
|
+
this.$refs.input.focus();
|
|
123
205
|
this.$emit('update:modelValue', values);
|
|
124
206
|
this.$emit('remove', {
|
|
125
207
|
originalEvent: event,
|
|
@@ -132,57 +214,86 @@ this.primevue.chips = (function (vue) {
|
|
|
132
214
|
return this.max && this.modelValue && this.max === this.modelValue.length;
|
|
133
215
|
},
|
|
134
216
|
containerClass() {
|
|
135
|
-
return ['p-chips p-component p-inputwrapper',
|
|
217
|
+
return ['p-chips p-component p-inputwrapper', {
|
|
218
|
+
'p-disabled': this.disabled,
|
|
219
|
+
'p-focus': this.focused,
|
|
136
220
|
'p-inputwrapper-filled': ((this.modelValue && this.modelValue.length) || (this.inputValue && this.inputValue.length)),
|
|
137
221
|
'p-inputwrapper-focus': this.focused
|
|
138
222
|
}];
|
|
223
|
+
},
|
|
224
|
+
focusedOptionId() {
|
|
225
|
+
return this.focusedIndex !== null ? `${this.id}_chips_item_${this.focusedIndex}` : null;
|
|
139
226
|
}
|
|
140
227
|
}
|
|
141
228
|
};
|
|
142
229
|
|
|
143
|
-
const _hoisted_1 =
|
|
144
|
-
const _hoisted_2 = ["
|
|
145
|
-
const _hoisted_3 = { class: "p-chips-
|
|
146
|
-
const _hoisted_4 = ["
|
|
230
|
+
const _hoisted_1 = ["aria-labelledby", "aria-label", "aria-activedescendant"];
|
|
231
|
+
const _hoisted_2 = ["id", "aria-label", "aria-setsize", "aria-posinset"];
|
|
232
|
+
const _hoisted_3 = { class: "p-chips-token-label" };
|
|
233
|
+
const _hoisted_4 = ["onClick"];
|
|
234
|
+
const _hoisted_5 = {
|
|
235
|
+
class: "p-chips-input-token",
|
|
236
|
+
role: "option"
|
|
237
|
+
};
|
|
238
|
+
const _hoisted_6 = ["id", "disabled", "placeholder"];
|
|
147
239
|
|
|
148
240
|
function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
149
241
|
return (vue.openBlock(), vue.createElementBlock("div", {
|
|
150
|
-
class: vue.normalizeClass($options.containerClass)
|
|
151
|
-
style: vue.normalizeStyle($props.style)
|
|
242
|
+
class: vue.normalizeClass($options.containerClass)
|
|
152
243
|
}, [
|
|
153
244
|
vue.createElementVNode("ul", {
|
|
154
|
-
|
|
155
|
-
|
|
245
|
+
ref: "container",
|
|
246
|
+
class: "p-inputtext p-chips-multiple-container",
|
|
247
|
+
tabindex: "-1",
|
|
248
|
+
role: "listbox",
|
|
249
|
+
"aria-orientation": "horizontal",
|
|
250
|
+
"aria-labelledby": _ctx.ariaLabelledby,
|
|
251
|
+
"aria-label": _ctx.ariaLabel,
|
|
252
|
+
"aria-activedescendant": $data.focused ? $options.focusedOptionId : undefined,
|
|
253
|
+
onClick: _cache[5] || (_cache[5] = $event => ($options.onWrapperClick())),
|
|
254
|
+
onFocus: _cache[6] || (_cache[6] = (...args) => ($options.onContainerFocus && $options.onContainerFocus(...args))),
|
|
255
|
+
onBlur: _cache[7] || (_cache[7] = (...args) => ($options.onContainerBlur && $options.onContainerBlur(...args))),
|
|
256
|
+
onKeydown: _cache[8] || (_cache[8] = (...args) => ($options.onContainerKeyDown && $options.onContainerKeyDown(...args)))
|
|
156
257
|
}, [
|
|
157
258
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList($props.modelValue, (val, i) => {
|
|
158
259
|
return (vue.openBlock(), vue.createElementBlock("li", {
|
|
159
260
|
key: `${i}_${val}`,
|
|
160
|
-
|
|
261
|
+
id: $data.id + '_chips_item_' + i,
|
|
262
|
+
role: "option",
|
|
263
|
+
class: vue.normalizeClass(['p-chips-token', {'p-focus': $data.focusedIndex === i}]),
|
|
264
|
+
"aria-label": val,
|
|
265
|
+
"aria-selected": true,
|
|
266
|
+
"aria-setsize": $props.modelValue.length,
|
|
267
|
+
"aria-posinset": i + 1
|
|
161
268
|
}, [
|
|
162
269
|
vue.renderSlot(_ctx.$slots, "chip", { value: val }, () => [
|
|
163
|
-
vue.createElementVNode("span",
|
|
270
|
+
vue.createElementVNode("span", _hoisted_3, vue.toDisplayString(val), 1)
|
|
164
271
|
]),
|
|
165
272
|
vue.createElementVNode("span", {
|
|
166
273
|
class: "p-chips-token-icon pi pi-times-circle",
|
|
167
|
-
onClick: $event => ($options.removeItem($event, i))
|
|
168
|
-
|
|
169
|
-
|
|
274
|
+
onClick: $event => ($options.removeItem($event, i)),
|
|
275
|
+
"aria-hidden": "true"
|
|
276
|
+
}, null, 8, _hoisted_4)
|
|
277
|
+
], 10, _hoisted_2))
|
|
170
278
|
}), 128)),
|
|
171
|
-
vue.createElementVNode("li",
|
|
279
|
+
vue.createElementVNode("li", _hoisted_5, [
|
|
172
280
|
vue.createElementVNode("input", vue.mergeProps({
|
|
173
281
|
ref: "input",
|
|
174
|
-
type: "text"
|
|
175
|
-
|
|
176
|
-
|
|
282
|
+
type: "text",
|
|
283
|
+
id: $props.inputId,
|
|
284
|
+
class: $props.inputClass,
|
|
285
|
+
style: $props.inputStyle,
|
|
286
|
+
disabled: $props.disabled || $options.maxedOut,
|
|
287
|
+
placeholder: $props.placeholder,
|
|
288
|
+
onFocus: _cache[0] || (_cache[0] = $event => ($options.onFocus($event))),
|
|
177
289
|
onBlur: _cache[1] || (_cache[1] = $event => ($options.onBlur($event))),
|
|
178
290
|
onInput: _cache[2] || (_cache[2] = (...args) => ($options.onInput && $options.onInput(...args))),
|
|
179
291
|
onKeydown: _cache[3] || (_cache[3] = $event => ($options.onKeyDown($event))),
|
|
180
|
-
onPaste: _cache[4] || (_cache[4] = $event => ($options.onPaste($event)))
|
|
181
|
-
|
|
182
|
-
}), null, 16, _hoisted_4)
|
|
292
|
+
onPaste: _cache[4] || (_cache[4] = $event => ($options.onPaste($event)))
|
|
293
|
+
}, $props.inputProps), null, 16, _hoisted_6)
|
|
183
294
|
])
|
|
184
|
-
],
|
|
185
|
-
],
|
|
295
|
+
], 40, _hoisted_1)
|
|
296
|
+
], 2))
|
|
186
297
|
}
|
|
187
298
|
|
|
188
299
|
function styleInject(css, ref) {
|
|
@@ -219,4 +330,4 @@ this.primevue.chips = (function (vue) {
|
|
|
219
330
|
|
|
220
331
|
return script;
|
|
221
332
|
|
|
222
|
-
})(Vue);
|
|
333
|
+
})(primevue.utils, Vue);
|
package/chips/chips.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
this.primevue=this.primevue||{},this.primevue.chips=function(e){"use strict";var
|
|
1
|
+
this.primevue=this.primevue||{},this.primevue.chips=function(e,t){"use strict";var n={name:"Chips",emits:["update:modelValue","add","remove","focus","blur"],props:{modelValue:{type:Array,default:null},max:{type:Number,default:null},separator:{type:String,default:null},addOnBlur:{type:Boolean,default:null},allowDuplicate:{type:Boolean,default:!0},placeholder:{type:String,default:null},inputId:null,inputClass:null,inputStyle:null,inputProps:null,disabled:{type:Boolean,default:!1},"aria-labelledby":{type:String,default:null},"aria-label":{type:String,default:null}},data:()=>({id:e.UniqueComponentId(),inputValue:null,focused:!1,focusedIndex:null}),methods:{onWrapperClick(){this.$refs.input.focus()},onInput(e){this.inputValue=e.target.value,this.focusedIndex=null},onFocus(e){this.focused=!0,this.focusedIndex=null,this.$emit("focus",e)},onBlur(e){this.focused=!1,this.focusedIndex=null,this.addOnBlur&&this.addItem(e,e.target.value,!1),this.$emit("blur",e)},onKeyDown(e){const t=e.target.value;switch(e.code){case"Backspace":0===t.length&&this.modelValue&&this.modelValue.length>0&&(null!==this.focusedIndex?this.removeItem(e,this.focusedIndex):this.removeItem(e,this.modelValue.length-1));break;case"Enter":t&&t.trim().length&&!this.maxedOut&&this.addItem(e,t,!0);break;case"ArrowLeft":0===t.length&&this.modelValue&&this.modelValue.length>0&&this.$refs.container.focus();break;case"ArrowRight":e.stopPropagation();break;default:this.separator&&","===this.separator&&","===e.key&&this.addItem(e,t,!0)}},onPaste(e){if(this.separator){let t=(e.clipboardData||window.clipboardData).getData("Text");if(t){let n=this.modelValue||[],i=t.split(this.separator);i=i.filter((e=>this.allowDuplicate||-1===n.indexOf(e))),n=[...n,...i],this.updateModel(e,n,!0)}}},onContainerFocus(){this.focused=!0},onContainerBlur(){this.focusedIndex=-1,this.focused=!1},onContainerKeyDown(e){switch(e.code){case"ArrowLeft":this.onArrowLeftKeyOn(e);break;case"ArrowRight":this.onArrowRightKeyOn(e);break;case"Backspace":this.onBackspaceKeyOn(e)}},onArrowLeftKeyOn(){0===this.inputValue.length&&this.modelValue&&this.modelValue.length>0&&(this.focusedIndex=null===this.focusedIndex?this.modelValue.length-1:this.focusedIndex-1,this.focusedIndex<0&&(this.focusedIndex=0))},onArrowRightKeyOn(){0===this.inputValue.length&&this.modelValue&&this.modelValue.length>0&&(this.focusedIndex===this.modelValue.length-1?(this.focusedIndex=null,this.$refs.input.focus()):this.focusedIndex++)},onBackspaceKeyOn(e){null!==this.focusedIndex&&this.removeItem(e,this.focusedIndex)},updateModel(e,t,n){this.$emit("update:modelValue",t),this.$emit("add",{originalEvent:e,value:t}),this.$refs.input.value="",this.inputValue="",n&&e.preventDefault()},addItem(e,t,n){if(t&&t.trim().length){let i=this.modelValue?[...this.modelValue]:[];(this.allowDuplicate||-1===i.indexOf(t))&&(i.push(t),this.updateModel(e,i,n))}},removeItem(e,t){if(this.disabled)return;let n=[...this.modelValue];const i=n.splice(t,1);this.focusedIndex=null,this.$refs.input.focus(),this.$emit("update:modelValue",n),this.$emit("remove",{originalEvent:e,value:i})}},computed:{maxedOut(){return this.max&&this.modelValue&&this.max===this.modelValue.length},containerClass(){return["p-chips p-component p-inputwrapper",{"p-disabled":this.disabled,"p-focus":this.focused,"p-inputwrapper-filled":this.modelValue&&this.modelValue.length||this.inputValue&&this.inputValue.length,"p-inputwrapper-focus":this.focused}]},focusedOptionId(){return null!==this.focusedIndex?`${this.id}_chips_item_${this.focusedIndex}`:null}}};const i=["aria-labelledby","aria-label","aria-activedescendant"],l=["id","aria-label","aria-setsize","aria-posinset"],a={class:"p-chips-token-label"},s=["onClick"],o={class:"p-chips-input-token",role:"option"},d=["id","disabled","placeholder"];return function(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var i=document.head||document.getElementsByTagName("head")[0],l=document.createElement("style");l.type="text/css","top"===n&&i.firstChild?i.insertBefore(l,i.firstChild):i.appendChild(l),l.styleSheet?l.styleSheet.cssText=e:l.appendChild(document.createTextNode(e))}}("\n.p-chips {\n display: -webkit-inline-box;\n display: -ms-inline-flexbox;\n display: inline-flex;\n}\n.p-chips-multiple-container {\n margin: 0;\n padding: 0;\n list-style-type: none;\n cursor: text;\n overflow: hidden;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -ms-flex-wrap: wrap;\n flex-wrap: wrap;\n}\n.p-chips-token {\n cursor: default;\n display: -webkit-inline-box;\n display: -ms-inline-flexbox;\n display: inline-flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-flex: 0;\n -ms-flex: 0 0 auto;\n flex: 0 0 auto;\n}\n.p-chips-input-token {\n -webkit-box-flex: 1;\n -ms-flex: 1 1 auto;\n flex: 1 1 auto;\n display: -webkit-inline-box;\n display: -ms-inline-flexbox;\n display: inline-flex;\n}\n.p-chips-token-icon {\n cursor: pointer;\n}\n.p-chips-input-token input {\n border: 0 none;\n outline: 0 none;\n background-color: transparent;\n margin: 0;\n padding: 0;\n -webkit-box-shadow: none;\n box-shadow: none;\n border-radius: 0;\n width: 100%;\n}\n.p-fluid .p-chips {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n}\n"),n.render=function(e,n,u,r,p,c){return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(c.containerClass)},[t.createElementVNode("ul",{ref:"container",class:"p-inputtext p-chips-multiple-container",tabindex:"-1",role:"listbox","aria-orientation":"horizontal","aria-labelledby":e.ariaLabelledby,"aria-label":e.ariaLabel,"aria-activedescendant":p.focused?c.focusedOptionId:void 0,onClick:n[5]||(n[5]=e=>c.onWrapperClick()),onFocus:n[6]||(n[6]=(...e)=>c.onContainerFocus&&c.onContainerFocus(...e)),onBlur:n[7]||(n[7]=(...e)=>c.onContainerBlur&&c.onContainerBlur(...e)),onKeydown:n[8]||(n[8]=(...e)=>c.onContainerKeyDown&&c.onContainerKeyDown(...e))},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(u.modelValue,((n,i)=>(t.openBlock(),t.createElementBlock("li",{key:`${i}_${n}`,id:p.id+"_chips_item_"+i,role:"option",class:t.normalizeClass(["p-chips-token",{"p-focus":p.focusedIndex===i}]),"aria-label":n,"aria-selected":!0,"aria-setsize":u.modelValue.length,"aria-posinset":i+1},[t.renderSlot(e.$slots,"chip",{value:n},(()=>[t.createElementVNode("span",a,t.toDisplayString(n),1)])),t.createElementVNode("span",{class:"p-chips-token-icon pi pi-times-circle",onClick:e=>c.removeItem(e,i),"aria-hidden":"true"},null,8,s)],10,l)))),128)),t.createElementVNode("li",o,[t.createElementVNode("input",t.mergeProps({ref:"input",type:"text",id:u.inputId,class:u.inputClass,style:u.inputStyle,disabled:u.disabled||c.maxedOut,placeholder:u.placeholder,onFocus:n[0]||(n[0]=e=>c.onFocus(e)),onBlur:n[1]||(n[1]=e=>c.onBlur(e)),onInput:n[2]||(n[2]=(...e)=>c.onInput&&c.onInput(...e)),onKeydown:n[3]||(n[3]=e=>c.onKeyDown(e)),onPaste:n[4]||(n[4]=e=>c.onPaste(e))},u.inputProps),null,16,d)])],40,i)],2)},n}(primevue.utils,Vue);
|
|
@@ -2,7 +2,7 @@ import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
|
|
|
2
2
|
|
|
3
3
|
type ColorPickerFormatType = 'hex' | 'rgb' | 'hsb' | undefined;
|
|
4
4
|
|
|
5
|
-
type ColorPickerAppendToType = 'body' | 'self' | string | undefined;
|
|
5
|
+
type ColorPickerAppendToType = 'body' | 'self' | string | undefined | HTMLElement;
|
|
6
6
|
|
|
7
7
|
export interface ColorPickerChangeEvent {
|
|
8
8
|
/**
|
|
@@ -53,16 +53,13 @@ export interface ColorPickerProps {
|
|
|
53
53
|
* Default value is 0.
|
|
54
54
|
*/
|
|
55
55
|
baseZIndex?: number | undefined;
|
|
56
|
-
/**
|
|
57
|
-
* Establishes relationships between the component and label(s) where its value should be one or more element IDs.
|
|
58
|
-
*/
|
|
59
|
-
ariaLabelledBy?: string | undefined;
|
|
60
56
|
/**
|
|
61
57
|
* Style class of the overlay panel.
|
|
62
58
|
*/
|
|
63
59
|
panelClass?: any;
|
|
64
60
|
/**
|
|
65
61
|
* A valid query selector or an HTMLElement to specify where the overlay gets attached. Special keywords are 'body' for document body and 'self' for the element itself.
|
|
62
|
+
* @see ColorPickerAppendToType
|
|
66
63
|
* Default value is 'body'.
|
|
67
64
|
*/
|
|
68
65
|
appendTo?: ColorPickerAppendToType;
|
|
@@ -86,7 +83,7 @@ export declare type ColorPickerEmits = {
|
|
|
86
83
|
* Callback to invoke when input is cleared by the user.
|
|
87
84
|
*/
|
|
88
85
|
'show': () => void;
|
|
89
|
-
|
|
86
|
+
/**
|
|
90
87
|
* Callback to invoke when input is cleared by the user.
|
|
91
88
|
*/
|
|
92
89
|
'hide': () => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div ref="container" :class="containerClass">
|
|
3
3
|
<input ref="input" type="text" :class="inputClass" readonly="readonly" :tabindex="tabindex" :disabled="disabled"
|
|
4
|
-
@click="onInputClick" @keydown="onInputKeydown" v-if="!inline"
|
|
4
|
+
@click="onInputClick" @keydown="onInputKeydown" v-if="!inline"/>
|
|
5
5
|
<Portal :appendTo="appendTo" :disabled="inline">
|
|
6
6
|
<transition name="p-connected-overlay" @enter="onOverlayEnter" @leave="onOverlayLeave" @after-leave="onOverlayAfterLeave">
|
|
7
7
|
<div :ref="pickerRef" :class="pickerClass" v-if="inline ? true : overlayVisible" @click="onOverlayClick">
|
|
@@ -64,10 +64,6 @@ export default {
|
|
|
64
64
|
type: Number,
|
|
65
65
|
default: 0
|
|
66
66
|
},
|
|
67
|
-
ariaLabelledBy: {
|
|
68
|
-
type: String,
|
|
69
|
-
default: null
|
|
70
|
-
},
|
|
71
67
|
appendTo: {
|
|
72
68
|
type: String,
|
|
73
69
|
default: 'body'
|
|
@@ -46,10 +46,6 @@ var script = {
|
|
|
46
46
|
type: Number,
|
|
47
47
|
default: 0
|
|
48
48
|
},
|
|
49
|
-
ariaLabelledBy: {
|
|
50
|
-
type: String,
|
|
51
|
-
default: null
|
|
52
|
-
},
|
|
53
49
|
appendTo: {
|
|
54
50
|
type: String,
|
|
55
51
|
default: 'body'
|
|
@@ -559,7 +555,7 @@ var script = {
|
|
|
559
555
|
}
|
|
560
556
|
};
|
|
561
557
|
|
|
562
|
-
const _hoisted_1 = ["tabindex", "disabled"
|
|
558
|
+
const _hoisted_1 = ["tabindex", "disabled"];
|
|
563
559
|
const _hoisted_2 = { class: "p-colorpicker-content" };
|
|
564
560
|
const _hoisted_3 = { class: "p-colorpicker-color" };
|
|
565
561
|
|
|
@@ -580,8 +576,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
580
576
|
tabindex: $props.tabindex,
|
|
581
577
|
disabled: $props.disabled,
|
|
582
578
|
onClick: _cache[0] || (_cache[0] = (...args) => ($options.onInputClick && $options.onInputClick(...args))),
|
|
583
|
-
onKeydown: _cache[1] || (_cache[1] = (...args) => ($options.onInputKeydown && $options.onInputKeydown(...args)))
|
|
584
|
-
"aria-labelledby": $props.ariaLabelledBy
|
|
579
|
+
onKeydown: _cache[1] || (_cache[1] = (...args) => ($options.onInputKeydown && $options.onInputKeydown(...args)))
|
|
585
580
|
}, null, 42, _hoisted_1))
|
|
586
581
|
: vue.createCommentVNode("", true),
|
|
587
582
|
vue.createVNode(_component_Portal, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("primevue/utils"),t=require("primevue/overlayeventbus"),i=require("primevue/portal"),n=require("vue");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=o(t),r={name:"ColorPicker",emits:["update:modelValue","change","show","hide"],props:{modelValue:{type:null,default:null},defaultColor:{type:null,default:"ff0000"},inline:{type:Boolean,default:!1},format:{type:String,default:"hex"},disabled:{type:Boolean,default:!1},tabindex:{type:String,default:null},autoZIndex:{type:Boolean,default:!0},baseZIndex:{type:Number,default:0},ariaLabelledBy:{type:String,default:null},appendTo:{type:String,default:"body"},panelClass:null},data:()=>({overlayVisible:!1}),hsbValue:null,outsideClickListener:null,documentMouseMoveListener:null,documentMouseUpListener:null,scrollHandler:null,resizeListener:null,hueDragging:null,colorDragging:null,selfUpdate:null,picker:null,colorSelector:null,colorHandle:null,hueView:null,hueHandle:null,beforeUnmount(){this.unbindOutsideClickListener(),this.unbindDragListeners(),this.unbindResizeListener(),this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),this.picker&&this.autoZIndex&&e.ZIndexUtils.clear(this.picker),this.clearRefs()},mounted(){this.updateUI()},watch:{modelValue:{immediate:!0,handler(e){this.hsbValue=this.toHSB(e),this.selfUpdate?this.selfUpdate=!1:this.updateUI()}}},methods:{pickColor(e){let t=this.colorSelector.getBoundingClientRect(),i=t.top+(window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0),n=t.left+document.body.scrollLeft,o=Math.floor(100*Math.max(0,Math.min(150,(e.pageX||e.changedTouches[0].pageX)-n))/150),l=Math.floor(100*(150-Math.max(0,Math.min(150,(e.pageY||e.changedTouches[0].pageY)-i)))/150);this.hsbValue=this.validateHSB({h:this.hsbValue.h,s:o,b:l}),this.selfUpdate=!0,this.updateColorHandle(),this.updateInput(),this.updateModel(),this.$emit("change",{event:e,value:this.modelValue})},pickHue(e){let t=this.hueView.getBoundingClientRect().top+(window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0);this.hsbValue=this.validateHSB({h:Math.floor(360*(150-Math.max(0,Math.min(150,(e.pageY||e.changedTouches[0].pageY)-t)))/150),s:100,b:100}),this.selfUpdate=!0,this.updateColorSelector(),this.updateHue(),this.updateModel(),this.updateInput(),this.$emit("change",{event:e,value:this.modelValue})},updateModel(){switch(this.format){case"hex":this.$emit("update:modelValue",this.HSBtoHEX(this.hsbValue));break;case"rgb":this.$emit("update:modelValue",this.HSBtoRGB(this.hsbValue));break;case"hsb":this.$emit("update:modelValue",this.hsbValue)}},updateColorSelector(){if(this.colorSelector){let e=this.validateHSB({h:this.hsbValue.h,s:100,b:100});this.colorSelector.style.backgroundColor="#"+this.HSBtoHEX(e)}},updateColorHandle(){this.colorHandle&&(this.colorHandle.style.left=Math.floor(150*this.hsbValue.s/100)+"px",this.colorHandle.style.top=Math.floor(150*(100-this.hsbValue.b)/100)+"px")},updateHue(){this.hueHandle&&(this.hueHandle.style.top=Math.floor(150-150*this.hsbValue.h/360)+"px")},updateInput(){this.$refs.input&&(this.$refs.input.style.backgroundColor="#"+this.HSBtoHEX(this.hsbValue))},updateUI(){this.updateHue(),this.updateColorHandle(),this.updateInput(),this.updateColorSelector()},validateHSB:e=>({h:Math.min(360,Math.max(0,e.h)),s:Math.min(100,Math.max(0,e.s)),b:Math.min(100,Math.max(0,e.b))}),validateRGB:e=>({r:Math.min(255,Math.max(0,e.r)),g:Math.min(255,Math.max(0,e.g)),b:Math.min(255,Math.max(0,e.b))}),validateHEX(e){var t=6-e.length;if(t>0){for(var i=[],n=0;n<t;n++)i.push("0");i.push(e),e=i.join("")}return e},HEXtoRGB(e){let t=parseInt(e.indexOf("#")>-1?e.substring(1):e,16);return{r:t>>16,g:(65280&t)>>8,b:255&t}},HEXtoHSB(e){return this.RGBtoHSB(this.HEXtoRGB(e))},RGBtoHSB(e){var t={h:0,s:0,b:0},i=Math.min(e.r,e.g,e.b),n=Math.max(e.r,e.g,e.b),o=n-i;return t.b=n,t.s=0!==n?255*o/n:0,0!==t.s?e.r===n?t.h=(e.g-e.b)/o:e.g===n?t.h=2+(e.b-e.r)/o:t.h=4+(e.r-e.g)/o:t.h=-1,t.h*=60,t.h<0&&(t.h+=360),t.s*=100/255,t.b*=100/255,t},HSBtoRGB(e){var t={r:null,g:null,b:null},i=Math.round(e.h),n=Math.round(255*e.s/100),o=Math.round(255*e.b/100);if(0===n)t={r:o,g:o,b:o};else{var l=o,r=(255-n)*o/255,s=i%60*(l-r)/60;360===i&&(i=0),i<60?(t.r=l,t.b=r,t.g=r+s):i<120?(t.g=l,t.b=r,t.r=l-s):i<180?(t.g=l,t.r=r,t.b=r+s):i<240?(t.b=l,t.r=r,t.g=l-s):i<300?(t.b=l,t.g=r,t.r=r+s):i<360?(t.r=l,t.g=r,t.b=l-s):(t.r=0,t.g=0,t.b=0)}return{r:Math.round(t.r),g:Math.round(t.g),b:Math.round(t.b)}},RGBtoHEX(e){var t=[e.r.toString(16),e.g.toString(16),e.b.toString(16)];for(var i in t)1===t[i].length&&(t[i]="0"+t[i]);return t.join("")},HSBtoHEX(e){return this.RGBtoHEX(this.HSBtoRGB(e))},toHSB(e){let t;if(e)switch(this.format){case"hex":t=this.HEXtoHSB(e);break;case"rgb":t=this.RGBtoHSB(e);break;case"hsb":t=e}else t=this.HEXtoHSB(this.defaultColor);return t},onOverlayEnter(t){this.updateUI(),this.alignOverlay(),this.bindOutsideClickListener(),this.bindScrollListener(),this.bindResizeListener(),this.autoZIndex&&e.ZIndexUtils.set("overlay",t,this.$primevue.config.zIndex.overlay),this.$emit("show")},onOverlayLeave(){this.unbindOutsideClickListener(),this.unbindScrollListener(),this.unbindResizeListener(),this.clearRefs(),this.$emit("hide")},onOverlayAfterLeave(t){this.autoZIndex&&e.ZIndexUtils.clear(t)},alignOverlay(){"self"===this.appendTo?e.DomHandler.relativePosition(this.picker,this.$refs.input):e.DomHandler.absolutePosition(this.picker,this.$refs.input)},onInputClick(){this.disabled||(this.overlayVisible=!this.overlayVisible)},onInputKeydown(e){switch(e.which){case 32:this.overlayVisible=!this.overlayVisible,e.preventDefault();break;case 27:case 9:this.overlayVisible=!1}},onColorMousedown(e){this.disabled||(this.bindDragListeners(),this.onColorDragStart(e))},onColorDragStart(t){this.disabled||(this.colorDragging=!0,this.pickColor(t),e.DomHandler.addClass(this.$el,"p-colorpicker-dragging"),t.preventDefault())},onDrag(e){this.colorDragging&&(this.pickColor(e),e.preventDefault()),this.hueDragging&&(this.pickHue(e),e.preventDefault())},onDragEnd(){this.colorDragging=!1,this.hueDragging=!1,e.DomHandler.removeClass(this.$el,"p-colorpicker-dragging"),this.unbindDragListeners()},onHueMousedown(e){this.disabled||(this.bindDragListeners(),this.onHueDragStart(e))},onHueDragStart(t){this.disabled||(this.hueDragging=!0,this.pickHue(t),e.DomHandler.addClass(this.$el,"p-colorpicker-dragging"))},isInputClicked(e){return this.$refs.input&&this.$refs.input.isSameNode(e.target)},bindDragListeners(){this.bindDocumentMouseMoveListener(),this.bindDocumentMouseUpListener()},unbindDragListeners(){this.unbindDocumentMouseMoveListener(),this.unbindDocumentMouseUpListener()},bindOutsideClickListener(){this.outsideClickListener||(this.outsideClickListener=e=>{this.overlayVisible&&this.picker&&!this.picker.contains(e.target)&&!this.isInputClicked(e)&&(this.overlayVisible=!1)},document.addEventListener("click",this.outsideClickListener))},unbindOutsideClickListener(){this.outsideClickListener&&(document.removeEventListener("click",this.outsideClickListener),this.outsideClickListener=null)},bindScrollListener(){this.scrollHandler||(this.scrollHandler=new e.ConnectedOverlayScrollHandler(this.$refs.container,(()=>{this.overlayVisible&&(this.overlayVisible=!1)}))),this.scrollHandler.bindScrollListener()},unbindScrollListener(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()},bindResizeListener(){this.resizeListener||(this.resizeListener=()=>{this.overlayVisible&&!e.DomHandler.isTouchDevice()&&(this.overlayVisible=!1)},window.addEventListener("resize",this.resizeListener))},unbindResizeListener(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)},bindDocumentMouseMoveListener(){this.documentMouseMoveListener||(this.documentMouseMoveListener=this.onDrag.bind(this),document.addEventListener("mousemove",this.documentMouseMoveListener))},unbindDocumentMouseMoveListener(){this.documentMouseMoveListener&&(document.removeEventListener("mousemove",this.documentMouseMoveListener),this.documentMouseMoveListener=null)},bindDocumentMouseUpListener(){this.documentMouseUpListener||(this.documentMouseUpListener=this.onDragEnd.bind(this),document.addEventListener("mouseup",this.documentMouseUpListener))},unbindDocumentMouseUpListener(){this.documentMouseUpListener&&(document.removeEventListener("mouseup",this.documentMouseUpListener),this.documentMouseUpListener=null)},pickerRef(e){this.picker=e},colorSelectorRef(e){this.colorSelector=e},colorHandleRef(e){this.colorHandle=e},hueViewRef(e){this.hueView=e},hueHandleRef(e){this.hueHandle=e},clearRefs(){this.picker=null,this.colorSelector=null,this.colorHandle=null,this.hueView=null,this.hueHandle=null},onOverlayClick(e){l.default.emit("overlay-click",{originalEvent:e,target:this.$el})}},computed:{containerClass(){return["p-colorpicker p-component",{"p-colorpicker-overlay":!this.inline}]},inputClass(){return["p-colorpicker-preview p-inputtext",{"p-disabled":this.disabled}]},pickerClass(){return["p-colorpicker-panel",this.panelClass,{"p-colorpicker-overlay-panel":!this.inline,"p-disabled":this.disabled,"p-input-filled":"filled"===this.$primevue.config.inputStyle,"p-ripple-disabled":!1===this.$primevue.config.ripple}]}},components:{Portal:o(i).default}};const s=["tabindex","disabled","aria-labelledby"],a={class:"p-colorpicker-content"},d={class:"p-colorpicker-color"};!function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===i&&n.firstChild?n.insertBefore(o,n.firstChild):n.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}("\n.p-colorpicker {\n display: inline-block;\n}\n.p-colorpicker-dragging {\n cursor: pointer;\n}\n.p-colorpicker-overlay {\n position: relative;\n}\n.p-colorpicker-panel {\n position: relative;\n width: 193px;\n height: 166px;\n}\n.p-colorpicker-overlay-panel {\n position: absolute;\n top: 0;\n left: 0;\n}\n.p-colorpicker-preview {\n cursor: pointer;\n}\n.p-colorpicker-panel .p-colorpicker-content {\n position: relative;\n}\n.p-colorpicker-panel .p-colorpicker-color-selector {\n width: 150px;\n height: 150px;\n top: 8px;\n left: 8px;\n position: absolute;\n}\n.p-colorpicker-panel .p-colorpicker-color {\n width: 150px;\n height: 150px;\n}\n.p-colorpicker-panel .p-colorpicker-color-handle {\n position: absolute;\n top: 0px;\n left: 150px;\n border-radius: 100%;\n width: 10px;\n height: 10px;\n border-width: 1px;\n border-style: solid;\n margin: -5px 0 0 -5px;\n cursor: pointer;\n opacity: .85;\n}\n.p-colorpicker-panel .p-colorpicker-hue {\n width: 17px;\n height: 150px;\n top: 8px;\n left: 167px;\n position: absolute;\n opacity: .85;\n}\n.p-colorpicker-panel .p-colorpicker-hue-handle {\n position: absolute;\n top: 150px;\n left: 0px;\n width: 21px;\n margin-left: -2px;\n margin-top: -5px;\n height: 10px;\n border-width: 2px;\n border-style: solid;\n opacity: .85;\n cursor: pointer;\n}\n"),r.render=function(e,t,i,o,l,r){const h=n.resolveComponent("Portal");return n.openBlock(),n.createElementBlock("div",{ref:"container",class:n.normalizeClass(r.containerClass)},[i.inline?n.createCommentVNode("",!0):(n.openBlock(),n.createElementBlock("input",{key:0,ref:"input",type:"text",class:n.normalizeClass(r.inputClass),readonly:"readonly",tabindex:i.tabindex,disabled:i.disabled,onClick:t[0]||(t[0]=(...e)=>r.onInputClick&&r.onInputClick(...e)),onKeydown:t[1]||(t[1]=(...e)=>r.onInputKeydown&&r.onInputKeydown(...e)),"aria-labelledby":i.ariaLabelledBy},null,42,s)),n.createVNode(h,{appendTo:i.appendTo,disabled:i.inline},{default:n.withCtx((()=>[n.createVNode(n.Transition,{name:"p-connected-overlay",onEnter:r.onOverlayEnter,onLeave:r.onOverlayLeave,onAfterLeave:r.onOverlayAfterLeave},{default:n.withCtx((()=>[i.inline||l.overlayVisible?(n.openBlock(),n.createElementBlock("div",{key:0,ref:r.pickerRef,class:n.normalizeClass(r.pickerClass),onClick:t[10]||(t[10]=(...e)=>r.onOverlayClick&&r.onOverlayClick(...e))},[n.createElementVNode("div",a,[n.createElementVNode("div",{ref:r.colorSelectorRef,class:"p-colorpicker-color-selector",onMousedown:t[2]||(t[2]=e=>r.onColorMousedown(e)),onTouchstart:t[3]||(t[3]=e=>r.onColorDragStart(e)),onTouchmove:t[4]||(t[4]=e=>r.onDrag(e)),onTouchend:t[5]||(t[5]=e=>r.onDragEnd())},[n.createElementVNode("div",d,[n.createElementVNode("div",{ref:r.colorHandleRef,class:"p-colorpicker-color-handle"},null,512)])],544),n.createElementVNode("div",{ref:r.hueViewRef,class:"p-colorpicker-hue",onMousedown:t[6]||(t[6]=e=>r.onHueMousedown(e)),onTouchstart:t[7]||(t[7]=e=>r.onHueDragStart(e)),onTouchmove:t[8]||(t[8]=e=>r.onDrag(e)),onTouchend:t[9]||(t[9]=e=>r.onDragEnd())},[n.createElementVNode("div",{ref:r.hueHandleRef,class:"p-colorpicker-hue-handle"},null,512)],544)])],2)):n.createCommentVNode("",!0)])),_:1},8,["onEnter","onLeave","onAfterLeave"])])),_:1},8,["appendTo","disabled"])],2)},module.exports=r;
|
|
1
|
+
"use strict";var e=require("primevue/utils"),t=require("primevue/overlayeventbus"),i=require("primevue/portal"),n=require("vue");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=o(t),l={name:"ColorPicker",emits:["update:modelValue","change","show","hide"],props:{modelValue:{type:null,default:null},defaultColor:{type:null,default:"ff0000"},inline:{type:Boolean,default:!1},format:{type:String,default:"hex"},disabled:{type:Boolean,default:!1},tabindex:{type:String,default:null},autoZIndex:{type:Boolean,default:!0},baseZIndex:{type:Number,default:0},appendTo:{type:String,default:"body"},panelClass:null},data:()=>({overlayVisible:!1}),hsbValue:null,outsideClickListener:null,documentMouseMoveListener:null,documentMouseUpListener:null,scrollHandler:null,resizeListener:null,hueDragging:null,colorDragging:null,selfUpdate:null,picker:null,colorSelector:null,colorHandle:null,hueView:null,hueHandle:null,beforeUnmount(){this.unbindOutsideClickListener(),this.unbindDragListeners(),this.unbindResizeListener(),this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),this.picker&&this.autoZIndex&&e.ZIndexUtils.clear(this.picker),this.clearRefs()},mounted(){this.updateUI()},watch:{modelValue:{immediate:!0,handler(e){this.hsbValue=this.toHSB(e),this.selfUpdate?this.selfUpdate=!1:this.updateUI()}}},methods:{pickColor(e){let t=this.colorSelector.getBoundingClientRect(),i=t.top+(window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0),n=t.left+document.body.scrollLeft,o=Math.floor(100*Math.max(0,Math.min(150,(e.pageX||e.changedTouches[0].pageX)-n))/150),s=Math.floor(100*(150-Math.max(0,Math.min(150,(e.pageY||e.changedTouches[0].pageY)-i)))/150);this.hsbValue=this.validateHSB({h:this.hsbValue.h,s:o,b:s}),this.selfUpdate=!0,this.updateColorHandle(),this.updateInput(),this.updateModel(),this.$emit("change",{event:e,value:this.modelValue})},pickHue(e){let t=this.hueView.getBoundingClientRect().top+(window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0);this.hsbValue=this.validateHSB({h:Math.floor(360*(150-Math.max(0,Math.min(150,(e.pageY||e.changedTouches[0].pageY)-t)))/150),s:100,b:100}),this.selfUpdate=!0,this.updateColorSelector(),this.updateHue(),this.updateModel(),this.updateInput(),this.$emit("change",{event:e,value:this.modelValue})},updateModel(){switch(this.format){case"hex":this.$emit("update:modelValue",this.HSBtoHEX(this.hsbValue));break;case"rgb":this.$emit("update:modelValue",this.HSBtoRGB(this.hsbValue));break;case"hsb":this.$emit("update:modelValue",this.hsbValue)}},updateColorSelector(){if(this.colorSelector){let e=this.validateHSB({h:this.hsbValue.h,s:100,b:100});this.colorSelector.style.backgroundColor="#"+this.HSBtoHEX(e)}},updateColorHandle(){this.colorHandle&&(this.colorHandle.style.left=Math.floor(150*this.hsbValue.s/100)+"px",this.colorHandle.style.top=Math.floor(150*(100-this.hsbValue.b)/100)+"px")},updateHue(){this.hueHandle&&(this.hueHandle.style.top=Math.floor(150-150*this.hsbValue.h/360)+"px")},updateInput(){this.$refs.input&&(this.$refs.input.style.backgroundColor="#"+this.HSBtoHEX(this.hsbValue))},updateUI(){this.updateHue(),this.updateColorHandle(),this.updateInput(),this.updateColorSelector()},validateHSB:e=>({h:Math.min(360,Math.max(0,e.h)),s:Math.min(100,Math.max(0,e.s)),b:Math.min(100,Math.max(0,e.b))}),validateRGB:e=>({r:Math.min(255,Math.max(0,e.r)),g:Math.min(255,Math.max(0,e.g)),b:Math.min(255,Math.max(0,e.b))}),validateHEX(e){var t=6-e.length;if(t>0){for(var i=[],n=0;n<t;n++)i.push("0");i.push(e),e=i.join("")}return e},HEXtoRGB(e){let t=parseInt(e.indexOf("#")>-1?e.substring(1):e,16);return{r:t>>16,g:(65280&t)>>8,b:255&t}},HEXtoHSB(e){return this.RGBtoHSB(this.HEXtoRGB(e))},RGBtoHSB(e){var t={h:0,s:0,b:0},i=Math.min(e.r,e.g,e.b),n=Math.max(e.r,e.g,e.b),o=n-i;return t.b=n,t.s=0!==n?255*o/n:0,0!==t.s?e.r===n?t.h=(e.g-e.b)/o:e.g===n?t.h=2+(e.b-e.r)/o:t.h=4+(e.r-e.g)/o:t.h=-1,t.h*=60,t.h<0&&(t.h+=360),t.s*=100/255,t.b*=100/255,t},HSBtoRGB(e){var t={r:null,g:null,b:null},i=Math.round(e.h),n=Math.round(255*e.s/100),o=Math.round(255*e.b/100);if(0===n)t={r:o,g:o,b:o};else{var s=o,l=(255-n)*o/255,r=i%60*(s-l)/60;360===i&&(i=0),i<60?(t.r=s,t.b=l,t.g=l+r):i<120?(t.g=s,t.b=l,t.r=s-r):i<180?(t.g=s,t.r=l,t.b=l+r):i<240?(t.b=s,t.r=l,t.g=s-r):i<300?(t.b=s,t.g=l,t.r=l+r):i<360?(t.r=s,t.g=l,t.b=s-r):(t.r=0,t.g=0,t.b=0)}return{r:Math.round(t.r),g:Math.round(t.g),b:Math.round(t.b)}},RGBtoHEX(e){var t=[e.r.toString(16),e.g.toString(16),e.b.toString(16)];for(var i in t)1===t[i].length&&(t[i]="0"+t[i]);return t.join("")},HSBtoHEX(e){return this.RGBtoHEX(this.HSBtoRGB(e))},toHSB(e){let t;if(e)switch(this.format){case"hex":t=this.HEXtoHSB(e);break;case"rgb":t=this.RGBtoHSB(e);break;case"hsb":t=e}else t=this.HEXtoHSB(this.defaultColor);return t},onOverlayEnter(t){this.updateUI(),this.alignOverlay(),this.bindOutsideClickListener(),this.bindScrollListener(),this.bindResizeListener(),this.autoZIndex&&e.ZIndexUtils.set("overlay",t,this.$primevue.config.zIndex.overlay),this.$emit("show")},onOverlayLeave(){this.unbindOutsideClickListener(),this.unbindScrollListener(),this.unbindResizeListener(),this.clearRefs(),this.$emit("hide")},onOverlayAfterLeave(t){this.autoZIndex&&e.ZIndexUtils.clear(t)},alignOverlay(){"self"===this.appendTo?e.DomHandler.relativePosition(this.picker,this.$refs.input):e.DomHandler.absolutePosition(this.picker,this.$refs.input)},onInputClick(){this.disabled||(this.overlayVisible=!this.overlayVisible)},onInputKeydown(e){switch(e.which){case 32:this.overlayVisible=!this.overlayVisible,e.preventDefault();break;case 27:case 9:this.overlayVisible=!1}},onColorMousedown(e){this.disabled||(this.bindDragListeners(),this.onColorDragStart(e))},onColorDragStart(t){this.disabled||(this.colorDragging=!0,this.pickColor(t),e.DomHandler.addClass(this.$el,"p-colorpicker-dragging"),t.preventDefault())},onDrag(e){this.colorDragging&&(this.pickColor(e),e.preventDefault()),this.hueDragging&&(this.pickHue(e),e.preventDefault())},onDragEnd(){this.colorDragging=!1,this.hueDragging=!1,e.DomHandler.removeClass(this.$el,"p-colorpicker-dragging"),this.unbindDragListeners()},onHueMousedown(e){this.disabled||(this.bindDragListeners(),this.onHueDragStart(e))},onHueDragStart(t){this.disabled||(this.hueDragging=!0,this.pickHue(t),e.DomHandler.addClass(this.$el,"p-colorpicker-dragging"))},isInputClicked(e){return this.$refs.input&&this.$refs.input.isSameNode(e.target)},bindDragListeners(){this.bindDocumentMouseMoveListener(),this.bindDocumentMouseUpListener()},unbindDragListeners(){this.unbindDocumentMouseMoveListener(),this.unbindDocumentMouseUpListener()},bindOutsideClickListener(){this.outsideClickListener||(this.outsideClickListener=e=>{this.overlayVisible&&this.picker&&!this.picker.contains(e.target)&&!this.isInputClicked(e)&&(this.overlayVisible=!1)},document.addEventListener("click",this.outsideClickListener))},unbindOutsideClickListener(){this.outsideClickListener&&(document.removeEventListener("click",this.outsideClickListener),this.outsideClickListener=null)},bindScrollListener(){this.scrollHandler||(this.scrollHandler=new e.ConnectedOverlayScrollHandler(this.$refs.container,(()=>{this.overlayVisible&&(this.overlayVisible=!1)}))),this.scrollHandler.bindScrollListener()},unbindScrollListener(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()},bindResizeListener(){this.resizeListener||(this.resizeListener=()=>{this.overlayVisible&&!e.DomHandler.isTouchDevice()&&(this.overlayVisible=!1)},window.addEventListener("resize",this.resizeListener))},unbindResizeListener(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)},bindDocumentMouseMoveListener(){this.documentMouseMoveListener||(this.documentMouseMoveListener=this.onDrag.bind(this),document.addEventListener("mousemove",this.documentMouseMoveListener))},unbindDocumentMouseMoveListener(){this.documentMouseMoveListener&&(document.removeEventListener("mousemove",this.documentMouseMoveListener),this.documentMouseMoveListener=null)},bindDocumentMouseUpListener(){this.documentMouseUpListener||(this.documentMouseUpListener=this.onDragEnd.bind(this),document.addEventListener("mouseup",this.documentMouseUpListener))},unbindDocumentMouseUpListener(){this.documentMouseUpListener&&(document.removeEventListener("mouseup",this.documentMouseUpListener),this.documentMouseUpListener=null)},pickerRef(e){this.picker=e},colorSelectorRef(e){this.colorSelector=e},colorHandleRef(e){this.colorHandle=e},hueViewRef(e){this.hueView=e},hueHandleRef(e){this.hueHandle=e},clearRefs(){this.picker=null,this.colorSelector=null,this.colorHandle=null,this.hueView=null,this.hueHandle=null},onOverlayClick(e){s.default.emit("overlay-click",{originalEvent:e,target:this.$el})}},computed:{containerClass(){return["p-colorpicker p-component",{"p-colorpicker-overlay":!this.inline}]},inputClass(){return["p-colorpicker-preview p-inputtext",{"p-disabled":this.disabled}]},pickerClass(){return["p-colorpicker-panel",this.panelClass,{"p-colorpicker-overlay-panel":!this.inline,"p-disabled":this.disabled,"p-input-filled":"filled"===this.$primevue.config.inputStyle,"p-ripple-disabled":!1===this.$primevue.config.ripple}]}},components:{Portal:o(i).default}};const r=["tabindex","disabled"],a={class:"p-colorpicker-content"},d={class:"p-colorpicker-color"};!function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===i&&n.firstChild?n.insertBefore(o,n.firstChild):n.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}("\n.p-colorpicker {\n display: inline-block;\n}\n.p-colorpicker-dragging {\n cursor: pointer;\n}\n.p-colorpicker-overlay {\n position: relative;\n}\n.p-colorpicker-panel {\n position: relative;\n width: 193px;\n height: 166px;\n}\n.p-colorpicker-overlay-panel {\n position: absolute;\n top: 0;\n left: 0;\n}\n.p-colorpicker-preview {\n cursor: pointer;\n}\n.p-colorpicker-panel .p-colorpicker-content {\n position: relative;\n}\n.p-colorpicker-panel .p-colorpicker-color-selector {\n width: 150px;\n height: 150px;\n top: 8px;\n left: 8px;\n position: absolute;\n}\n.p-colorpicker-panel .p-colorpicker-color {\n width: 150px;\n height: 150px;\n}\n.p-colorpicker-panel .p-colorpicker-color-handle {\n position: absolute;\n top: 0px;\n left: 150px;\n border-radius: 100%;\n width: 10px;\n height: 10px;\n border-width: 1px;\n border-style: solid;\n margin: -5px 0 0 -5px;\n cursor: pointer;\n opacity: .85;\n}\n.p-colorpicker-panel .p-colorpicker-hue {\n width: 17px;\n height: 150px;\n top: 8px;\n left: 167px;\n position: absolute;\n opacity: .85;\n}\n.p-colorpicker-panel .p-colorpicker-hue-handle {\n position: absolute;\n top: 150px;\n left: 0px;\n width: 21px;\n margin-left: -2px;\n margin-top: -5px;\n height: 10px;\n border-width: 2px;\n border-style: solid;\n opacity: .85;\n cursor: pointer;\n}\n"),l.render=function(e,t,i,o,s,l){const h=n.resolveComponent("Portal");return n.openBlock(),n.createElementBlock("div",{ref:"container",class:n.normalizeClass(l.containerClass)},[i.inline?n.createCommentVNode("",!0):(n.openBlock(),n.createElementBlock("input",{key:0,ref:"input",type:"text",class:n.normalizeClass(l.inputClass),readonly:"readonly",tabindex:i.tabindex,disabled:i.disabled,onClick:t[0]||(t[0]=(...e)=>l.onInputClick&&l.onInputClick(...e)),onKeydown:t[1]||(t[1]=(...e)=>l.onInputKeydown&&l.onInputKeydown(...e))},null,42,r)),n.createVNode(h,{appendTo:i.appendTo,disabled:i.inline},{default:n.withCtx((()=>[n.createVNode(n.Transition,{name:"p-connected-overlay",onEnter:l.onOverlayEnter,onLeave:l.onOverlayLeave,onAfterLeave:l.onOverlayAfterLeave},{default:n.withCtx((()=>[i.inline||s.overlayVisible?(n.openBlock(),n.createElementBlock("div",{key:0,ref:l.pickerRef,class:n.normalizeClass(l.pickerClass),onClick:t[10]||(t[10]=(...e)=>l.onOverlayClick&&l.onOverlayClick(...e))},[n.createElementVNode("div",a,[n.createElementVNode("div",{ref:l.colorSelectorRef,class:"p-colorpicker-color-selector",onMousedown:t[2]||(t[2]=e=>l.onColorMousedown(e)),onTouchstart:t[3]||(t[3]=e=>l.onColorDragStart(e)),onTouchmove:t[4]||(t[4]=e=>l.onDrag(e)),onTouchend:t[5]||(t[5]=e=>l.onDragEnd())},[n.createElementVNode("div",d,[n.createElementVNode("div",{ref:l.colorHandleRef,class:"p-colorpicker-color-handle"},null,512)])],544),n.createElementVNode("div",{ref:l.hueViewRef,class:"p-colorpicker-hue",onMousedown:t[6]||(t[6]=e=>l.onHueMousedown(e)),onTouchstart:t[7]||(t[7]=e=>l.onHueDragStart(e)),onTouchmove:t[8]||(t[8]=e=>l.onDrag(e)),onTouchend:t[9]||(t[9]=e=>l.onDragEnd())},[n.createElementVNode("div",{ref:l.hueHandleRef,class:"p-colorpicker-hue-handle"},null,512)],544)])],2)):n.createCommentVNode("",!0)])),_:1},8,["onEnter","onLeave","onAfterLeave"])])),_:1},8,["appendTo","disabled"])],2)},module.exports=l;
|
|
@@ -39,10 +39,6 @@ var script = {
|
|
|
39
39
|
type: Number,
|
|
40
40
|
default: 0
|
|
41
41
|
},
|
|
42
|
-
ariaLabelledBy: {
|
|
43
|
-
type: String,
|
|
44
|
-
default: null
|
|
45
|
-
},
|
|
46
42
|
appendTo: {
|
|
47
43
|
type: String,
|
|
48
44
|
default: 'body'
|
|
@@ -552,7 +548,7 @@ var script = {
|
|
|
552
548
|
}
|
|
553
549
|
};
|
|
554
550
|
|
|
555
|
-
const _hoisted_1 = ["tabindex", "disabled"
|
|
551
|
+
const _hoisted_1 = ["tabindex", "disabled"];
|
|
556
552
|
const _hoisted_2 = { class: "p-colorpicker-content" };
|
|
557
553
|
const _hoisted_3 = { class: "p-colorpicker-color" };
|
|
558
554
|
|
|
@@ -573,8 +569,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
573
569
|
tabindex: $props.tabindex,
|
|
574
570
|
disabled: $props.disabled,
|
|
575
571
|
onClick: _cache[0] || (_cache[0] = (...args) => ($options.onInputClick && $options.onInputClick(...args))),
|
|
576
|
-
onKeydown: _cache[1] || (_cache[1] = (...args) => ($options.onInputKeydown && $options.onInputKeydown(...args)))
|
|
577
|
-
"aria-labelledby": $props.ariaLabelledBy
|
|
572
|
+
onKeydown: _cache[1] || (_cache[1] = (...args) => ($options.onInputKeydown && $options.onInputKeydown(...args)))
|
|
578
573
|
}, null, 42, _hoisted_1))
|
|
579
574
|
: createCommentVNode("", true),
|
|
580
575
|
createVNode(_component_Portal, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ZIndexUtils as e,DomHandler as t,ConnectedOverlayScrollHandler as i}from"primevue/utils";import n from"primevue/overlayeventbus";import o from"primevue/portal";import{resolveComponent as s,openBlock as l,createElementBlock as r,normalizeClass as a,createCommentVNode as h,createVNode as d,withCtx as u,Transition as p,createElementVNode as c}from"vue";var b={name:"ColorPicker",emits:["update:modelValue","change","show","hide"],props:{modelValue:{type:null,default:null},defaultColor:{type:null,default:"ff0000"},inline:{type:Boolean,default:!1},format:{type:String,default:"hex"},disabled:{type:Boolean,default:!1},tabindex:{type:String,default:null},autoZIndex:{type:Boolean,default:!0},baseZIndex:{type:Number,default:0},ariaLabelledBy:{type:String,default:null},appendTo:{type:String,default:"body"},panelClass:null},data:()=>({overlayVisible:!1}),hsbValue:null,outsideClickListener:null,documentMouseMoveListener:null,documentMouseUpListener:null,scrollHandler:null,resizeListener:null,hueDragging:null,colorDragging:null,selfUpdate:null,picker:null,colorSelector:null,colorHandle:null,hueView:null,hueHandle:null,beforeUnmount(){this.unbindOutsideClickListener(),this.unbindDragListeners(),this.unbindResizeListener(),this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),this.picker&&this.autoZIndex&&e.clear(this.picker),this.clearRefs()},mounted(){this.updateUI()},watch:{modelValue:{immediate:!0,handler(e){this.hsbValue=this.toHSB(e),this.selfUpdate?this.selfUpdate=!1:this.updateUI()}}},methods:{pickColor(e){let t=this.colorSelector.getBoundingClientRect(),i=t.top+(window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0),n=t.left+document.body.scrollLeft,o=Math.floor(100*Math.max(0,Math.min(150,(e.pageX||e.changedTouches[0].pageX)-n))/150),s=Math.floor(100*(150-Math.max(0,Math.min(150,(e.pageY||e.changedTouches[0].pageY)-i)))/150);this.hsbValue=this.validateHSB({h:this.hsbValue.h,s:o,b:s}),this.selfUpdate=!0,this.updateColorHandle(),this.updateInput(),this.updateModel(),this.$emit("change",{event:e,value:this.modelValue})},pickHue(e){let t=this.hueView.getBoundingClientRect().top+(window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0);this.hsbValue=this.validateHSB({h:Math.floor(360*(150-Math.max(0,Math.min(150,(e.pageY||e.changedTouches[0].pageY)-t)))/150),s:100,b:100}),this.selfUpdate=!0,this.updateColorSelector(),this.updateHue(),this.updateModel(),this.updateInput(),this.$emit("change",{event:e,value:this.modelValue})},updateModel(){switch(this.format){case"hex":this.$emit("update:modelValue",this.HSBtoHEX(this.hsbValue));break;case"rgb":this.$emit("update:modelValue",this.HSBtoRGB(this.hsbValue));break;case"hsb":this.$emit("update:modelValue",this.hsbValue)}},updateColorSelector(){if(this.colorSelector){let e=this.validateHSB({h:this.hsbValue.h,s:100,b:100});this.colorSelector.style.backgroundColor="#"+this.HSBtoHEX(e)}},updateColorHandle(){this.colorHandle&&(this.colorHandle.style.left=Math.floor(150*this.hsbValue.s/100)+"px",this.colorHandle.style.top=Math.floor(150*(100-this.hsbValue.b)/100)+"px")},updateHue(){this.hueHandle&&(this.hueHandle.style.top=Math.floor(150-150*this.hsbValue.h/360)+"px")},updateInput(){this.$refs.input&&(this.$refs.input.style.backgroundColor="#"+this.HSBtoHEX(this.hsbValue))},updateUI(){this.updateHue(),this.updateColorHandle(),this.updateInput(),this.updateColorSelector()},validateHSB:e=>({h:Math.min(360,Math.max(0,e.h)),s:Math.min(100,Math.max(0,e.s)),b:Math.min(100,Math.max(0,e.b))}),validateRGB:e=>({r:Math.min(255,Math.max(0,e.r)),g:Math.min(255,Math.max(0,e.g)),b:Math.min(255,Math.max(0,e.b))}),validateHEX(e){var t=6-e.length;if(t>0){for(var i=[],n=0;n<t;n++)i.push("0");i.push(e),e=i.join("")}return e},HEXtoRGB(e){let t=parseInt(e.indexOf("#")>-1?e.substring(1):e,16);return{r:t>>16,g:(65280&t)>>8,b:255&t}},HEXtoHSB(e){return this.RGBtoHSB(this.HEXtoRGB(e))},RGBtoHSB(e){var t={h:0,s:0,b:0},i=Math.min(e.r,e.g,e.b),n=Math.max(e.r,e.g,e.b),o=n-i;return t.b=n,t.s=0!==n?255*o/n:0,0!==t.s?e.r===n?t.h=(e.g-e.b)/o:e.g===n?t.h=2+(e.b-e.r)/o:t.h=4+(e.r-e.g)/o:t.h=-1,t.h*=60,t.h<0&&(t.h+=360),t.s*=100/255,t.b*=100/255,t},HSBtoRGB(e){var t={r:null,g:null,b:null},i=Math.round(e.h),n=Math.round(255*e.s/100),o=Math.round(255*e.b/100);if(0===n)t={r:o,g:o,b:o};else{var s=o,l=(255-n)*o/255,r=i%60*(s-l)/60;360===i&&(i=0),i<60?(t.r=s,t.b=l,t.g=l+r):i<120?(t.g=s,t.b=l,t.r=s-r):i<180?(t.g=s,t.r=l,t.b=l+r):i<240?(t.b=s,t.r=l,t.g=s-r):i<300?(t.b=s,t.g=l,t.r=l+r):i<360?(t.r=s,t.g=l,t.b=s-r):(t.r=0,t.g=0,t.b=0)}return{r:Math.round(t.r),g:Math.round(t.g),b:Math.round(t.b)}},RGBtoHEX(e){var t=[e.r.toString(16),e.g.toString(16),e.b.toString(16)];for(var i in t)1===t[i].length&&(t[i]="0"+t[i]);return t.join("")},HSBtoHEX(e){return this.RGBtoHEX(this.HSBtoRGB(e))},toHSB(e){let t;if(e)switch(this.format){case"hex":t=this.HEXtoHSB(e);break;case"rgb":t=this.RGBtoHSB(e);break;case"hsb":t=e}else t=this.HEXtoHSB(this.defaultColor);return t},onOverlayEnter(t){this.updateUI(),this.alignOverlay(),this.bindOutsideClickListener(),this.bindScrollListener(),this.bindResizeListener(),this.autoZIndex&&e.set("overlay",t,this.$primevue.config.zIndex.overlay),this.$emit("show")},onOverlayLeave(){this.unbindOutsideClickListener(),this.unbindScrollListener(),this.unbindResizeListener(),this.clearRefs(),this.$emit("hide")},onOverlayAfterLeave(t){this.autoZIndex&&e.clear(t)},alignOverlay(){"self"===this.appendTo?t.relativePosition(this.picker,this.$refs.input):t.absolutePosition(this.picker,this.$refs.input)},onInputClick(){this.disabled||(this.overlayVisible=!this.overlayVisible)},onInputKeydown(e){switch(e.which){case 32:this.overlayVisible=!this.overlayVisible,e.preventDefault();break;case 27:case 9:this.overlayVisible=!1}},onColorMousedown(e){this.disabled||(this.bindDragListeners(),this.onColorDragStart(e))},onColorDragStart(e){this.disabled||(this.colorDragging=!0,this.pickColor(e),t.addClass(this.$el,"p-colorpicker-dragging"),e.preventDefault())},onDrag(e){this.colorDragging&&(this.pickColor(e),e.preventDefault()),this.hueDragging&&(this.pickHue(e),e.preventDefault())},onDragEnd(){this.colorDragging=!1,this.hueDragging=!1,t.removeClass(this.$el,"p-colorpicker-dragging"),this.unbindDragListeners()},onHueMousedown(e){this.disabled||(this.bindDragListeners(),this.onHueDragStart(e))},onHueDragStart(e){this.disabled||(this.hueDragging=!0,this.pickHue(e),t.addClass(this.$el,"p-colorpicker-dragging"))},isInputClicked(e){return this.$refs.input&&this.$refs.input.isSameNode(e.target)},bindDragListeners(){this.bindDocumentMouseMoveListener(),this.bindDocumentMouseUpListener()},unbindDragListeners(){this.unbindDocumentMouseMoveListener(),this.unbindDocumentMouseUpListener()},bindOutsideClickListener(){this.outsideClickListener||(this.outsideClickListener=e=>{this.overlayVisible&&this.picker&&!this.picker.contains(e.target)&&!this.isInputClicked(e)&&(this.overlayVisible=!1)},document.addEventListener("click",this.outsideClickListener))},unbindOutsideClickListener(){this.outsideClickListener&&(document.removeEventListener("click",this.outsideClickListener),this.outsideClickListener=null)},bindScrollListener(){this.scrollHandler||(this.scrollHandler=new i(this.$refs.container,(()=>{this.overlayVisible&&(this.overlayVisible=!1)}))),this.scrollHandler.bindScrollListener()},unbindScrollListener(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()},bindResizeListener(){this.resizeListener||(this.resizeListener=()=>{this.overlayVisible&&!t.isTouchDevice()&&(this.overlayVisible=!1)},window.addEventListener("resize",this.resizeListener))},unbindResizeListener(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)},bindDocumentMouseMoveListener(){this.documentMouseMoveListener||(this.documentMouseMoveListener=this.onDrag.bind(this),document.addEventListener("mousemove",this.documentMouseMoveListener))},unbindDocumentMouseMoveListener(){this.documentMouseMoveListener&&(document.removeEventListener("mousemove",this.documentMouseMoveListener),this.documentMouseMoveListener=null)},bindDocumentMouseUpListener(){this.documentMouseUpListener||(this.documentMouseUpListener=this.onDragEnd.bind(this),document.addEventListener("mouseup",this.documentMouseUpListener))},unbindDocumentMouseUpListener(){this.documentMouseUpListener&&(document.removeEventListener("mouseup",this.documentMouseUpListener),this.documentMouseUpListener=null)},pickerRef(e){this.picker=e},colorSelectorRef(e){this.colorSelector=e},colorHandleRef(e){this.colorHandle=e},hueViewRef(e){this.hueView=e},hueHandleRef(e){this.hueHandle=e},clearRefs(){this.picker=null,this.colorSelector=null,this.colorHandle=null,this.hueView=null,this.hueHandle=null},onOverlayClick(e){n.emit("overlay-click",{originalEvent:e,target:this.$el})}},computed:{containerClass(){return["p-colorpicker p-component",{"p-colorpicker-overlay":!this.inline}]},inputClass(){return["p-colorpicker-preview p-inputtext",{"p-disabled":this.disabled}]},pickerClass(){return["p-colorpicker-panel",this.panelClass,{"p-colorpicker-overlay-panel":!this.inline,"p-disabled":this.disabled,"p-input-filled":"filled"===this.$primevue.config.inputStyle,"p-ripple-disabled":!1===this.$primevue.config.ripple}]}},components:{Portal:o}};const g=["tabindex","disabled","aria-labelledby"],m={class:"p-colorpicker-content"},v={class:"p-colorpicker-color"};!function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===i&&n.firstChild?n.insertBefore(o,n.firstChild):n.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}("\n.p-colorpicker {\n display: inline-block;\n}\n.p-colorpicker-dragging {\n cursor: pointer;\n}\n.p-colorpicker-overlay {\n position: relative;\n}\n.p-colorpicker-panel {\n position: relative;\n width: 193px;\n height: 166px;\n}\n.p-colorpicker-overlay-panel {\n position: absolute;\n top: 0;\n left: 0;\n}\n.p-colorpicker-preview {\n cursor: pointer;\n}\n.p-colorpicker-panel .p-colorpicker-content {\n position: relative;\n}\n.p-colorpicker-panel .p-colorpicker-color-selector {\n width: 150px;\n height: 150px;\n top: 8px;\n left: 8px;\n position: absolute;\n}\n.p-colorpicker-panel .p-colorpicker-color {\n width: 150px;\n height: 150px;\n}\n.p-colorpicker-panel .p-colorpicker-color-handle {\n position: absolute;\n top: 0px;\n left: 150px;\n border-radius: 100%;\n width: 10px;\n height: 10px;\n border-width: 1px;\n border-style: solid;\n margin: -5px 0 0 -5px;\n cursor: pointer;\n opacity: .85;\n}\n.p-colorpicker-panel .p-colorpicker-hue {\n width: 17px;\n height: 150px;\n top: 8px;\n left: 167px;\n position: absolute;\n opacity: .85;\n}\n.p-colorpicker-panel .p-colorpicker-hue-handle {\n position: absolute;\n top: 150px;\n left: 0px;\n width: 21px;\n margin-left: -2px;\n margin-top: -5px;\n height: 10px;\n border-width: 2px;\n border-style: solid;\n opacity: .85;\n cursor: pointer;\n}\n"),b.render=function(e,t,i,n,o,b){const f=s("Portal");return l(),r("div",{ref:"container",class:a(b.containerClass)},[i.inline?h("",!0):(l(),r("input",{key:0,ref:"input",type:"text",class:a(b.inputClass),readonly:"readonly",tabindex:i.tabindex,disabled:i.disabled,onClick:t[0]||(t[0]=(...e)=>b.onInputClick&&b.onInputClick(...e)),onKeydown:t[1]||(t[1]=(...e)=>b.onInputKeydown&&b.onInputKeydown(...e)),"aria-labelledby":i.ariaLabelledBy},null,42,g)),d(f,{appendTo:i.appendTo,disabled:i.inline},{default:u((()=>[d(p,{name:"p-connected-overlay",onEnter:b.onOverlayEnter,onLeave:b.onOverlayLeave,onAfterLeave:b.onOverlayAfterLeave},{default:u((()=>[i.inline||o.overlayVisible?(l(),r("div",{key:0,ref:b.pickerRef,class:a(b.pickerClass),onClick:t[10]||(t[10]=(...e)=>b.onOverlayClick&&b.onOverlayClick(...e))},[c("div",m,[c("div",{ref:b.colorSelectorRef,class:"p-colorpicker-color-selector",onMousedown:t[2]||(t[2]=e=>b.onColorMousedown(e)),onTouchstart:t[3]||(t[3]=e=>b.onColorDragStart(e)),onTouchmove:t[4]||(t[4]=e=>b.onDrag(e)),onTouchend:t[5]||(t[5]=e=>b.onDragEnd())},[c("div",v,[c("div",{ref:b.colorHandleRef,class:"p-colorpicker-color-handle"},null,512)])],544),c("div",{ref:b.hueViewRef,class:"p-colorpicker-hue",onMousedown:t[6]||(t[6]=e=>b.onHueMousedown(e)),onTouchstart:t[7]||(t[7]=e=>b.onHueDragStart(e)),onTouchmove:t[8]||(t[8]=e=>b.onDrag(e)),onTouchend:t[9]||(t[9]=e=>b.onDragEnd())},[c("div",{ref:b.hueHandleRef,class:"p-colorpicker-hue-handle"},null,512)],544)])],2)):h("",!0)])),_:1},8,["onEnter","onLeave","onAfterLeave"])])),_:1},8,["appendTo","disabled"])],2)};export{b as default};
|
|
1
|
+
import{ZIndexUtils as e,DomHandler as t,ConnectedOverlayScrollHandler as i}from"primevue/utils";import n from"primevue/overlayeventbus";import o from"primevue/portal";import{resolveComponent as s,openBlock as r,createElementBlock as l,normalizeClass as a,createCommentVNode as h,createVNode as u,withCtx as d,Transition as p,createElementVNode as c}from"vue";var b={name:"ColorPicker",emits:["update:modelValue","change","show","hide"],props:{modelValue:{type:null,default:null},defaultColor:{type:null,default:"ff0000"},inline:{type:Boolean,default:!1},format:{type:String,default:"hex"},disabled:{type:Boolean,default:!1},tabindex:{type:String,default:null},autoZIndex:{type:Boolean,default:!0},baseZIndex:{type:Number,default:0},appendTo:{type:String,default:"body"},panelClass:null},data:()=>({overlayVisible:!1}),hsbValue:null,outsideClickListener:null,documentMouseMoveListener:null,documentMouseUpListener:null,scrollHandler:null,resizeListener:null,hueDragging:null,colorDragging:null,selfUpdate:null,picker:null,colorSelector:null,colorHandle:null,hueView:null,hueHandle:null,beforeUnmount(){this.unbindOutsideClickListener(),this.unbindDragListeners(),this.unbindResizeListener(),this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),this.picker&&this.autoZIndex&&e.clear(this.picker),this.clearRefs()},mounted(){this.updateUI()},watch:{modelValue:{immediate:!0,handler(e){this.hsbValue=this.toHSB(e),this.selfUpdate?this.selfUpdate=!1:this.updateUI()}}},methods:{pickColor(e){let t=this.colorSelector.getBoundingClientRect(),i=t.top+(window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0),n=t.left+document.body.scrollLeft,o=Math.floor(100*Math.max(0,Math.min(150,(e.pageX||e.changedTouches[0].pageX)-n))/150),s=Math.floor(100*(150-Math.max(0,Math.min(150,(e.pageY||e.changedTouches[0].pageY)-i)))/150);this.hsbValue=this.validateHSB({h:this.hsbValue.h,s:o,b:s}),this.selfUpdate=!0,this.updateColorHandle(),this.updateInput(),this.updateModel(),this.$emit("change",{event:e,value:this.modelValue})},pickHue(e){let t=this.hueView.getBoundingClientRect().top+(window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0);this.hsbValue=this.validateHSB({h:Math.floor(360*(150-Math.max(0,Math.min(150,(e.pageY||e.changedTouches[0].pageY)-t)))/150),s:100,b:100}),this.selfUpdate=!0,this.updateColorSelector(),this.updateHue(),this.updateModel(),this.updateInput(),this.$emit("change",{event:e,value:this.modelValue})},updateModel(){switch(this.format){case"hex":this.$emit("update:modelValue",this.HSBtoHEX(this.hsbValue));break;case"rgb":this.$emit("update:modelValue",this.HSBtoRGB(this.hsbValue));break;case"hsb":this.$emit("update:modelValue",this.hsbValue)}},updateColorSelector(){if(this.colorSelector){let e=this.validateHSB({h:this.hsbValue.h,s:100,b:100});this.colorSelector.style.backgroundColor="#"+this.HSBtoHEX(e)}},updateColorHandle(){this.colorHandle&&(this.colorHandle.style.left=Math.floor(150*this.hsbValue.s/100)+"px",this.colorHandle.style.top=Math.floor(150*(100-this.hsbValue.b)/100)+"px")},updateHue(){this.hueHandle&&(this.hueHandle.style.top=Math.floor(150-150*this.hsbValue.h/360)+"px")},updateInput(){this.$refs.input&&(this.$refs.input.style.backgroundColor="#"+this.HSBtoHEX(this.hsbValue))},updateUI(){this.updateHue(),this.updateColorHandle(),this.updateInput(),this.updateColorSelector()},validateHSB:e=>({h:Math.min(360,Math.max(0,e.h)),s:Math.min(100,Math.max(0,e.s)),b:Math.min(100,Math.max(0,e.b))}),validateRGB:e=>({r:Math.min(255,Math.max(0,e.r)),g:Math.min(255,Math.max(0,e.g)),b:Math.min(255,Math.max(0,e.b))}),validateHEX(e){var t=6-e.length;if(t>0){for(var i=[],n=0;n<t;n++)i.push("0");i.push(e),e=i.join("")}return e},HEXtoRGB(e){let t=parseInt(e.indexOf("#")>-1?e.substring(1):e,16);return{r:t>>16,g:(65280&t)>>8,b:255&t}},HEXtoHSB(e){return this.RGBtoHSB(this.HEXtoRGB(e))},RGBtoHSB(e){var t={h:0,s:0,b:0},i=Math.min(e.r,e.g,e.b),n=Math.max(e.r,e.g,e.b),o=n-i;return t.b=n,t.s=0!==n?255*o/n:0,0!==t.s?e.r===n?t.h=(e.g-e.b)/o:e.g===n?t.h=2+(e.b-e.r)/o:t.h=4+(e.r-e.g)/o:t.h=-1,t.h*=60,t.h<0&&(t.h+=360),t.s*=100/255,t.b*=100/255,t},HSBtoRGB(e){var t={r:null,g:null,b:null},i=Math.round(e.h),n=Math.round(255*e.s/100),o=Math.round(255*e.b/100);if(0===n)t={r:o,g:o,b:o};else{var s=o,r=(255-n)*o/255,l=i%60*(s-r)/60;360===i&&(i=0),i<60?(t.r=s,t.b=r,t.g=r+l):i<120?(t.g=s,t.b=r,t.r=s-l):i<180?(t.g=s,t.r=r,t.b=r+l):i<240?(t.b=s,t.r=r,t.g=s-l):i<300?(t.b=s,t.g=r,t.r=r+l):i<360?(t.r=s,t.g=r,t.b=s-l):(t.r=0,t.g=0,t.b=0)}return{r:Math.round(t.r),g:Math.round(t.g),b:Math.round(t.b)}},RGBtoHEX(e){var t=[e.r.toString(16),e.g.toString(16),e.b.toString(16)];for(var i in t)1===t[i].length&&(t[i]="0"+t[i]);return t.join("")},HSBtoHEX(e){return this.RGBtoHEX(this.HSBtoRGB(e))},toHSB(e){let t;if(e)switch(this.format){case"hex":t=this.HEXtoHSB(e);break;case"rgb":t=this.RGBtoHSB(e);break;case"hsb":t=e}else t=this.HEXtoHSB(this.defaultColor);return t},onOverlayEnter(t){this.updateUI(),this.alignOverlay(),this.bindOutsideClickListener(),this.bindScrollListener(),this.bindResizeListener(),this.autoZIndex&&e.set("overlay",t,this.$primevue.config.zIndex.overlay),this.$emit("show")},onOverlayLeave(){this.unbindOutsideClickListener(),this.unbindScrollListener(),this.unbindResizeListener(),this.clearRefs(),this.$emit("hide")},onOverlayAfterLeave(t){this.autoZIndex&&e.clear(t)},alignOverlay(){"self"===this.appendTo?t.relativePosition(this.picker,this.$refs.input):t.absolutePosition(this.picker,this.$refs.input)},onInputClick(){this.disabled||(this.overlayVisible=!this.overlayVisible)},onInputKeydown(e){switch(e.which){case 32:this.overlayVisible=!this.overlayVisible,e.preventDefault();break;case 27:case 9:this.overlayVisible=!1}},onColorMousedown(e){this.disabled||(this.bindDragListeners(),this.onColorDragStart(e))},onColorDragStart(e){this.disabled||(this.colorDragging=!0,this.pickColor(e),t.addClass(this.$el,"p-colorpicker-dragging"),e.preventDefault())},onDrag(e){this.colorDragging&&(this.pickColor(e),e.preventDefault()),this.hueDragging&&(this.pickHue(e),e.preventDefault())},onDragEnd(){this.colorDragging=!1,this.hueDragging=!1,t.removeClass(this.$el,"p-colorpicker-dragging"),this.unbindDragListeners()},onHueMousedown(e){this.disabled||(this.bindDragListeners(),this.onHueDragStart(e))},onHueDragStart(e){this.disabled||(this.hueDragging=!0,this.pickHue(e),t.addClass(this.$el,"p-colorpicker-dragging"))},isInputClicked(e){return this.$refs.input&&this.$refs.input.isSameNode(e.target)},bindDragListeners(){this.bindDocumentMouseMoveListener(),this.bindDocumentMouseUpListener()},unbindDragListeners(){this.unbindDocumentMouseMoveListener(),this.unbindDocumentMouseUpListener()},bindOutsideClickListener(){this.outsideClickListener||(this.outsideClickListener=e=>{this.overlayVisible&&this.picker&&!this.picker.contains(e.target)&&!this.isInputClicked(e)&&(this.overlayVisible=!1)},document.addEventListener("click",this.outsideClickListener))},unbindOutsideClickListener(){this.outsideClickListener&&(document.removeEventListener("click",this.outsideClickListener),this.outsideClickListener=null)},bindScrollListener(){this.scrollHandler||(this.scrollHandler=new i(this.$refs.container,(()=>{this.overlayVisible&&(this.overlayVisible=!1)}))),this.scrollHandler.bindScrollListener()},unbindScrollListener(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()},bindResizeListener(){this.resizeListener||(this.resizeListener=()=>{this.overlayVisible&&!t.isTouchDevice()&&(this.overlayVisible=!1)},window.addEventListener("resize",this.resizeListener))},unbindResizeListener(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)},bindDocumentMouseMoveListener(){this.documentMouseMoveListener||(this.documentMouseMoveListener=this.onDrag.bind(this),document.addEventListener("mousemove",this.documentMouseMoveListener))},unbindDocumentMouseMoveListener(){this.documentMouseMoveListener&&(document.removeEventListener("mousemove",this.documentMouseMoveListener),this.documentMouseMoveListener=null)},bindDocumentMouseUpListener(){this.documentMouseUpListener||(this.documentMouseUpListener=this.onDragEnd.bind(this),document.addEventListener("mouseup",this.documentMouseUpListener))},unbindDocumentMouseUpListener(){this.documentMouseUpListener&&(document.removeEventListener("mouseup",this.documentMouseUpListener),this.documentMouseUpListener=null)},pickerRef(e){this.picker=e},colorSelectorRef(e){this.colorSelector=e},colorHandleRef(e){this.colorHandle=e},hueViewRef(e){this.hueView=e},hueHandleRef(e){this.hueHandle=e},clearRefs(){this.picker=null,this.colorSelector=null,this.colorHandle=null,this.hueView=null,this.hueHandle=null},onOverlayClick(e){n.emit("overlay-click",{originalEvent:e,target:this.$el})}},computed:{containerClass(){return["p-colorpicker p-component",{"p-colorpicker-overlay":!this.inline}]},inputClass(){return["p-colorpicker-preview p-inputtext",{"p-disabled":this.disabled}]},pickerClass(){return["p-colorpicker-panel",this.panelClass,{"p-colorpicker-overlay-panel":!this.inline,"p-disabled":this.disabled,"p-input-filled":"filled"===this.$primevue.config.inputStyle,"p-ripple-disabled":!1===this.$primevue.config.ripple}]}},components:{Portal:o}};const g=["tabindex","disabled"],m={class:"p-colorpicker-content"},v={class:"p-colorpicker-color"};!function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===i&&n.firstChild?n.insertBefore(o,n.firstChild):n.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}("\n.p-colorpicker {\n display: inline-block;\n}\n.p-colorpicker-dragging {\n cursor: pointer;\n}\n.p-colorpicker-overlay {\n position: relative;\n}\n.p-colorpicker-panel {\n position: relative;\n width: 193px;\n height: 166px;\n}\n.p-colorpicker-overlay-panel {\n position: absolute;\n top: 0;\n left: 0;\n}\n.p-colorpicker-preview {\n cursor: pointer;\n}\n.p-colorpicker-panel .p-colorpicker-content {\n position: relative;\n}\n.p-colorpicker-panel .p-colorpicker-color-selector {\n width: 150px;\n height: 150px;\n top: 8px;\n left: 8px;\n position: absolute;\n}\n.p-colorpicker-panel .p-colorpicker-color {\n width: 150px;\n height: 150px;\n}\n.p-colorpicker-panel .p-colorpicker-color-handle {\n position: absolute;\n top: 0px;\n left: 150px;\n border-radius: 100%;\n width: 10px;\n height: 10px;\n border-width: 1px;\n border-style: solid;\n margin: -5px 0 0 -5px;\n cursor: pointer;\n opacity: .85;\n}\n.p-colorpicker-panel .p-colorpicker-hue {\n width: 17px;\n height: 150px;\n top: 8px;\n left: 167px;\n position: absolute;\n opacity: .85;\n}\n.p-colorpicker-panel .p-colorpicker-hue-handle {\n position: absolute;\n top: 150px;\n left: 0px;\n width: 21px;\n margin-left: -2px;\n margin-top: -5px;\n height: 10px;\n border-width: 2px;\n border-style: solid;\n opacity: .85;\n cursor: pointer;\n}\n"),b.render=function(e,t,i,n,o,b){const f=s("Portal");return r(),l("div",{ref:"container",class:a(b.containerClass)},[i.inline?h("",!0):(r(),l("input",{key:0,ref:"input",type:"text",class:a(b.inputClass),readonly:"readonly",tabindex:i.tabindex,disabled:i.disabled,onClick:t[0]||(t[0]=(...e)=>b.onInputClick&&b.onInputClick(...e)),onKeydown:t[1]||(t[1]=(...e)=>b.onInputKeydown&&b.onInputKeydown(...e))},null,42,g)),u(f,{appendTo:i.appendTo,disabled:i.inline},{default:d((()=>[u(p,{name:"p-connected-overlay",onEnter:b.onOverlayEnter,onLeave:b.onOverlayLeave,onAfterLeave:b.onOverlayAfterLeave},{default:d((()=>[i.inline||o.overlayVisible?(r(),l("div",{key:0,ref:b.pickerRef,class:a(b.pickerClass),onClick:t[10]||(t[10]=(...e)=>b.onOverlayClick&&b.onOverlayClick(...e))},[c("div",m,[c("div",{ref:b.colorSelectorRef,class:"p-colorpicker-color-selector",onMousedown:t[2]||(t[2]=e=>b.onColorMousedown(e)),onTouchstart:t[3]||(t[3]=e=>b.onColorDragStart(e)),onTouchmove:t[4]||(t[4]=e=>b.onDrag(e)),onTouchend:t[5]||(t[5]=e=>b.onDragEnd())},[c("div",v,[c("div",{ref:b.colorHandleRef,class:"p-colorpicker-color-handle"},null,512)])],544),c("div",{ref:b.hueViewRef,class:"p-colorpicker-hue",onMousedown:t[6]||(t[6]=e=>b.onHueMousedown(e)),onTouchstart:t[7]||(t[7]=e=>b.onHueDragStart(e)),onTouchmove:t[8]||(t[8]=e=>b.onDrag(e)),onTouchend:t[9]||(t[9]=e=>b.onDragEnd())},[c("div",{ref:b.hueHandleRef,class:"p-colorpicker-hue-handle"},null,512)],544)])],2)):h("",!0)])),_:1},8,["onEnter","onLeave","onAfterLeave"])])),_:1},8,["appendTo","disabled"])],2)};export{b as default};
|
|
@@ -43,10 +43,6 @@ this.primevue.colorpicker = (function (utils, OverlayEventBus, Portal, vue) {
|
|
|
43
43
|
type: Number,
|
|
44
44
|
default: 0
|
|
45
45
|
},
|
|
46
|
-
ariaLabelledBy: {
|
|
47
|
-
type: String,
|
|
48
|
-
default: null
|
|
49
|
-
},
|
|
50
46
|
appendTo: {
|
|
51
47
|
type: String,
|
|
52
48
|
default: 'body'
|
|
@@ -556,7 +552,7 @@ this.primevue.colorpicker = (function (utils, OverlayEventBus, Portal, vue) {
|
|
|
556
552
|
}
|
|
557
553
|
};
|
|
558
554
|
|
|
559
|
-
const _hoisted_1 = ["tabindex", "disabled"
|
|
555
|
+
const _hoisted_1 = ["tabindex", "disabled"];
|
|
560
556
|
const _hoisted_2 = { class: "p-colorpicker-content" };
|
|
561
557
|
const _hoisted_3 = { class: "p-colorpicker-color" };
|
|
562
558
|
|
|
@@ -577,8 +573,7 @@ this.primevue.colorpicker = (function (utils, OverlayEventBus, Portal, vue) {
|
|
|
577
573
|
tabindex: $props.tabindex,
|
|
578
574
|
disabled: $props.disabled,
|
|
579
575
|
onClick: _cache[0] || (_cache[0] = (...args) => ($options.onInputClick && $options.onInputClick(...args))),
|
|
580
|
-
onKeydown: _cache[1] || (_cache[1] = (...args) => ($options.onInputKeydown && $options.onInputKeydown(...args)))
|
|
581
|
-
"aria-labelledby": $props.ariaLabelledBy
|
|
576
|
+
onKeydown: _cache[1] || (_cache[1] = (...args) => ($options.onInputKeydown && $options.onInputKeydown(...args)))
|
|
582
577
|
}, null, 42, _hoisted_1))
|
|
583
578
|
: vue.createCommentVNode("", true),
|
|
584
579
|
vue.createVNode(_component_Portal, {
|