@element-plus/nightly 0.0.20241112 → 0.0.20241114
Sign up to get free protection for your applications and to get access to all the features.
- package/attributes.json +1 -1
- package/dist/index.full.js +146 -115
- package/dist/index.full.min.js +11 -11
- package/dist/index.full.min.js.map +1 -1
- package/dist/index.full.min.mjs +11 -11
- package/dist/index.full.min.mjs.map +1 -1
- package/dist/index.full.mjs +146 -115
- package/dist/locale/af.js +1 -1
- package/dist/locale/af.min.js +1 -1
- package/dist/locale/af.min.mjs +1 -1
- package/dist/locale/af.mjs +1 -1
- package/dist/locale/ar-eg.js +1 -1
- package/dist/locale/ar-eg.min.js +1 -1
- package/dist/locale/ar-eg.min.mjs +1 -1
- package/dist/locale/ar-eg.mjs +1 -1
- package/dist/locale/ar.js +1 -1
- package/dist/locale/ar.min.js +1 -1
- package/dist/locale/ar.min.mjs +1 -1
- package/dist/locale/ar.mjs +1 -1
- package/dist/locale/az.js +1 -1
- package/dist/locale/az.min.js +1 -1
- package/dist/locale/az.min.mjs +1 -1
- package/dist/locale/az.mjs +1 -1
- package/dist/locale/bg.js +1 -1
- package/dist/locale/bg.min.js +1 -1
- package/dist/locale/bg.min.mjs +1 -1
- package/dist/locale/bg.mjs +1 -1
- package/dist/locale/bn.js +1 -1
- package/dist/locale/bn.min.js +1 -1
- package/dist/locale/bn.min.mjs +1 -1
- package/dist/locale/bn.mjs +1 -1
- package/dist/locale/ca.js +1 -1
- package/dist/locale/ca.min.js +1 -1
- package/dist/locale/ca.min.mjs +1 -1
- package/dist/locale/ca.mjs +1 -1
- package/dist/locale/ckb.js +1 -1
- package/dist/locale/ckb.min.js +1 -1
- package/dist/locale/ckb.min.mjs +1 -1
- package/dist/locale/ckb.mjs +1 -1
- package/dist/locale/cs.js +1 -1
- package/dist/locale/cs.min.js +1 -1
- package/dist/locale/cs.min.mjs +1 -1
- package/dist/locale/cs.mjs +1 -1
- package/dist/locale/da.js +1 -1
- package/dist/locale/da.min.js +1 -1
- package/dist/locale/da.min.mjs +1 -1
- package/dist/locale/da.mjs +1 -1
- package/dist/locale/de.js +1 -1
- package/dist/locale/de.min.js +1 -1
- package/dist/locale/de.min.mjs +1 -1
- package/dist/locale/de.mjs +1 -1
- package/dist/locale/el.js +1 -1
- package/dist/locale/el.min.js +1 -1
- package/dist/locale/el.min.mjs +1 -1
- package/dist/locale/el.mjs +1 -1
- package/dist/locale/en.js +1 -1
- package/dist/locale/en.min.js +1 -1
- package/dist/locale/en.min.mjs +1 -1
- package/dist/locale/en.mjs +1 -1
- package/dist/locale/eo.js +1 -1
- package/dist/locale/eo.min.js +1 -1
- package/dist/locale/eo.min.mjs +1 -1
- package/dist/locale/eo.mjs +1 -1
- package/dist/locale/es.js +1 -1
- package/dist/locale/es.min.js +1 -1
- package/dist/locale/es.min.mjs +1 -1
- package/dist/locale/es.mjs +1 -1
- package/dist/locale/et.js +1 -1
- package/dist/locale/et.min.js +1 -1
- package/dist/locale/et.min.mjs +1 -1
- package/dist/locale/et.mjs +1 -1
- package/dist/locale/eu.js +1 -1
- package/dist/locale/eu.min.js +1 -1
- package/dist/locale/eu.min.mjs +1 -1
- package/dist/locale/eu.mjs +1 -1
- package/dist/locale/fa.js +1 -1
- package/dist/locale/fa.min.js +1 -1
- package/dist/locale/fa.min.mjs +1 -1
- package/dist/locale/fa.mjs +1 -1
- package/dist/locale/fi.js +1 -1
- package/dist/locale/fi.min.js +1 -1
- package/dist/locale/fi.min.mjs +1 -1
- package/dist/locale/fi.mjs +1 -1
- package/dist/locale/fr.js +1 -1
- package/dist/locale/fr.min.js +1 -1
- package/dist/locale/fr.min.mjs +1 -1
- package/dist/locale/fr.mjs +1 -1
- package/dist/locale/he.js +1 -1
- package/dist/locale/he.min.js +1 -1
- package/dist/locale/he.min.mjs +1 -1
- package/dist/locale/he.mjs +1 -1
- package/dist/locale/hr.js +1 -1
- package/dist/locale/hr.min.js +1 -1
- package/dist/locale/hr.min.mjs +1 -1
- package/dist/locale/hr.mjs +1 -1
- package/dist/locale/hu.js +1 -1
- package/dist/locale/hu.min.js +1 -1
- package/dist/locale/hu.min.mjs +1 -1
- package/dist/locale/hu.mjs +1 -1
- package/dist/locale/hy-am.js +1 -1
- package/dist/locale/hy-am.min.js +1 -1
- package/dist/locale/hy-am.min.mjs +1 -1
- package/dist/locale/hy-am.mjs +1 -1
- package/dist/locale/id.js +1 -1
- package/dist/locale/id.min.js +1 -1
- package/dist/locale/id.min.mjs +1 -1
- package/dist/locale/id.mjs +1 -1
- package/dist/locale/it.js +1 -1
- package/dist/locale/it.min.js +1 -1
- package/dist/locale/it.min.mjs +1 -1
- package/dist/locale/it.mjs +1 -1
- package/dist/locale/ja.js +1 -1
- package/dist/locale/ja.min.js +1 -1
- package/dist/locale/ja.min.mjs +1 -1
- package/dist/locale/ja.mjs +1 -1
- package/dist/locale/kk.js +1 -1
- package/dist/locale/kk.min.js +1 -1
- package/dist/locale/kk.min.mjs +1 -1
- package/dist/locale/kk.mjs +1 -1
- package/dist/locale/km.js +1 -1
- package/dist/locale/km.min.js +1 -1
- package/dist/locale/km.min.mjs +1 -1
- package/dist/locale/km.mjs +1 -1
- package/dist/locale/ko.js +1 -1
- package/dist/locale/ko.min.js +1 -1
- package/dist/locale/ko.min.mjs +1 -1
- package/dist/locale/ko.mjs +1 -1
- package/dist/locale/ku.js +1 -1
- package/dist/locale/ku.min.js +1 -1
- package/dist/locale/ku.min.mjs +1 -1
- package/dist/locale/ku.mjs +1 -1
- package/dist/locale/ky.js +1 -1
- package/dist/locale/ky.min.js +1 -1
- package/dist/locale/ky.min.mjs +1 -1
- package/dist/locale/ky.mjs +1 -1
- package/dist/locale/lt.js +1 -1
- package/dist/locale/lt.min.js +1 -1
- package/dist/locale/lt.min.mjs +1 -1
- package/dist/locale/lt.mjs +1 -1
- package/dist/locale/lv.js +1 -1
- package/dist/locale/lv.min.js +1 -1
- package/dist/locale/lv.min.mjs +1 -1
- package/dist/locale/lv.mjs +1 -1
- package/dist/locale/mg.js +1 -1
- package/dist/locale/mg.min.js +1 -1
- package/dist/locale/mg.min.mjs +1 -1
- package/dist/locale/mg.mjs +1 -1
- package/dist/locale/mn.js +1 -1
- package/dist/locale/mn.min.js +1 -1
- package/dist/locale/mn.min.mjs +1 -1
- package/dist/locale/mn.mjs +1 -1
- package/dist/locale/my.js +1 -1
- package/dist/locale/my.min.js +1 -1
- package/dist/locale/my.min.mjs +1 -1
- package/dist/locale/my.mjs +1 -1
- package/dist/locale/nb-no.js +1 -1
- package/dist/locale/nb-no.min.js +1 -1
- package/dist/locale/nb-no.min.mjs +1 -1
- package/dist/locale/nb-no.mjs +1 -1
- package/dist/locale/nl.js +1 -1
- package/dist/locale/nl.min.js +1 -1
- package/dist/locale/nl.min.mjs +1 -1
- package/dist/locale/nl.mjs +1 -1
- package/dist/locale/pa.js +1 -1
- package/dist/locale/pa.min.js +1 -1
- package/dist/locale/pa.min.mjs +1 -1
- package/dist/locale/pa.mjs +1 -1
- package/dist/locale/pl.js +1 -1
- package/dist/locale/pl.min.js +1 -1
- package/dist/locale/pl.min.mjs +1 -1
- package/dist/locale/pl.mjs +1 -1
- package/dist/locale/pt-br.js +1 -1
- package/dist/locale/pt-br.min.js +1 -1
- package/dist/locale/pt-br.min.mjs +1 -1
- package/dist/locale/pt-br.mjs +1 -1
- package/dist/locale/pt.js +1 -1
- package/dist/locale/pt.min.js +1 -1
- package/dist/locale/pt.min.mjs +1 -1
- package/dist/locale/pt.mjs +1 -1
- package/dist/locale/ro.js +1 -1
- package/dist/locale/ro.min.js +1 -1
- package/dist/locale/ro.min.mjs +1 -1
- package/dist/locale/ro.mjs +1 -1
- package/dist/locale/ru.js +1 -1
- package/dist/locale/ru.min.js +1 -1
- package/dist/locale/ru.min.mjs +1 -1
- package/dist/locale/ru.mjs +1 -1
- package/dist/locale/sk.js +1 -1
- package/dist/locale/sk.min.js +1 -1
- package/dist/locale/sk.min.mjs +1 -1
- package/dist/locale/sk.mjs +1 -1
- package/dist/locale/sl.js +1 -1
- package/dist/locale/sl.min.js +1 -1
- package/dist/locale/sl.min.mjs +1 -1
- package/dist/locale/sl.mjs +1 -1
- package/dist/locale/sr.js +1 -1
- package/dist/locale/sr.min.js +1 -1
- package/dist/locale/sr.min.mjs +1 -1
- package/dist/locale/sr.mjs +1 -1
- package/dist/locale/sv.js +1 -1
- package/dist/locale/sv.min.js +1 -1
- package/dist/locale/sv.min.mjs +1 -1
- package/dist/locale/sv.mjs +1 -1
- package/dist/locale/sw.js +1 -1
- package/dist/locale/sw.min.js +1 -1
- package/dist/locale/sw.min.mjs +1 -1
- package/dist/locale/sw.mjs +1 -1
- package/dist/locale/ta.js +1 -1
- package/dist/locale/ta.min.js +1 -1
- package/dist/locale/ta.min.mjs +1 -1
- package/dist/locale/ta.mjs +1 -1
- package/dist/locale/th.js +1 -1
- package/dist/locale/th.min.js +1 -1
- package/dist/locale/th.min.mjs +1 -1
- package/dist/locale/th.mjs +1 -1
- package/dist/locale/tk.js +1 -1
- package/dist/locale/tk.min.js +1 -1
- package/dist/locale/tk.min.mjs +1 -1
- package/dist/locale/tk.mjs +1 -1
- package/dist/locale/tr.js +1 -1
- package/dist/locale/tr.min.js +1 -1
- package/dist/locale/tr.min.mjs +1 -1
- package/dist/locale/tr.mjs +1 -1
- package/dist/locale/ug-cn.js +1 -1
- package/dist/locale/ug-cn.min.js +1 -1
- package/dist/locale/ug-cn.min.mjs +1 -1
- package/dist/locale/ug-cn.mjs +1 -1
- package/dist/locale/uk.js +1 -1
- package/dist/locale/uk.min.js +1 -1
- package/dist/locale/uk.min.mjs +1 -1
- package/dist/locale/uk.mjs +1 -1
- package/dist/locale/uz-uz.js +1 -1
- package/dist/locale/uz-uz.min.js +1 -1
- package/dist/locale/uz-uz.min.mjs +1 -1
- package/dist/locale/uz-uz.mjs +1 -1
- package/dist/locale/vi.js +1 -1
- package/dist/locale/vi.min.js +1 -1
- package/dist/locale/vi.min.mjs +1 -1
- package/dist/locale/vi.mjs +1 -1
- package/dist/locale/zh-cn.js +1 -1
- package/dist/locale/zh-cn.min.js +1 -1
- package/dist/locale/zh-cn.min.mjs +1 -1
- package/dist/locale/zh-cn.mjs +1 -1
- package/dist/locale/zh-tw.js +1 -1
- package/dist/locale/zh-tw.min.js +1 -1
- package/dist/locale/zh-tw.min.mjs +1 -1
- package/dist/locale/zh-tw.mjs +1 -1
- package/es/components/cascader/src/cascader2.mjs +2 -0
- package/es/components/cascader/src/cascader2.mjs.map +1 -1
- package/es/components/cascader-panel/src/index.mjs +1 -0
- package/es/components/cascader-panel/src/index.mjs.map +1 -1
- package/es/components/color-picker/src/color-picker2.mjs +1 -0
- package/es/components/color-picker/src/color-picker2.mjs.map +1 -1
- package/es/components/descriptions/src/description-item.d.ts +4 -0
- package/es/components/descriptions/src/description-item.mjs +4 -0
- package/es/components/descriptions/src/description-item.mjs.map +1 -1
- package/es/components/descriptions/src/description.d.ts +1 -0
- package/es/components/descriptions/src/description.mjs +4 -0
- package/es/components/descriptions/src/description.mjs.map +1 -1
- package/es/components/descriptions/src/description.vue.d.ts +3 -0
- package/es/components/descriptions/src/descriptions-cell.mjs +2 -1
- package/es/components/descriptions/src/descriptions-cell.mjs.map +1 -1
- package/es/components/descriptions/src/descriptions.type.d.ts +2 -0
- package/es/components/dropdown/src/dropdown-item-impl.mjs +1 -2
- package/es/components/dropdown/src/dropdown-item-impl.mjs.map +1 -1
- package/es/components/dropdown/src/dropdown2.mjs +6 -1
- package/es/components/dropdown/src/dropdown2.mjs.map +1 -1
- package/es/components/dropdown/src/useDropdown.mjs +1 -1
- package/es/components/dropdown/src/useDropdown.mjs.map +1 -1
- package/es/components/focus-trap/src/focus-trap.mjs +2 -2
- package/es/components/focus-trap/src/focus-trap.mjs.map +1 -1
- package/es/components/mention/src/mention2.mjs +51 -45
- package/es/components/mention/src/mention2.mjs.map +1 -1
- package/es/components/menu/src/utils/menu-item.mjs +1 -0
- package/es/components/menu/src/utils/menu-item.mjs.map +1 -1
- package/es/components/menu/src/utils/submenu.mjs +1 -0
- package/es/components/menu/src/utils/submenu.mjs.map +1 -1
- package/es/components/pagination/src/components/next.mjs +36 -19
- package/es/components/pagination/src/components/next.mjs.map +1 -1
- package/es/components/pagination/src/components/next2.mjs +19 -36
- package/es/components/pagination/src/components/next2.mjs.map +1 -1
- package/es/components/pagination/src/pagination.mjs +1 -1
- package/es/components/pagination/style/css.d.ts +1 -0
- package/es/components/pagination/style/css.mjs +1 -0
- package/es/components/pagination/style/css.mjs.map +1 -1
- package/es/components/pagination/style/index.d.ts +1 -0
- package/es/components/pagination/style/index.mjs +1 -0
- package/es/components/pagination/style/index.mjs.map +1 -1
- package/es/components/roving-focus-group/src/roving-focus-item.mjs +2 -2
- package/es/components/roving-focus-group/src/roving-focus-item.mjs.map +1 -1
- package/es/components/roving-focus-group/src/utils.mjs +1 -1
- package/es/components/roving-focus-group/src/utils.mjs.map +1 -1
- package/es/components/select-v2/src/select-dropdown.mjs +7 -9
- package/es/components/select-v2/src/select-dropdown.mjs.map +1 -1
- package/es/components/select-v2/src/useSelect.mjs +2 -1
- package/es/components/select-v2/src/useSelect.mjs.map +1 -1
- package/es/components/slider/src/button.mjs +21 -91
- package/es/components/slider/src/button.mjs.map +1 -1
- package/es/components/slider/src/button2.mjs +91 -21
- package/es/components/slider/src/button2.mjs.map +1 -1
- package/es/components/slider/src/composables/use-slider-button.mjs +24 -15
- package/es/components/slider/src/composables/use-slider-button.mjs.map +1 -1
- package/es/components/slider/src/slider2.mjs +1 -1
- package/es/components/tabs/src/tab-nav.mjs +21 -25
- package/es/components/tabs/src/tab-nav.mjs.map +1 -1
- package/es/components/tabs/src/tabs.mjs +1 -1
- package/es/components/tabs/src/tabs.mjs.map +1 -1
- package/es/components/time-picker/src/time-picker-com/basic-time-spinner.mjs +8 -4
- package/es/components/time-picker/src/time-picker-com/basic-time-spinner.mjs.map +1 -1
- package/es/components/tooltip/src/trigger.mjs +1 -1
- package/es/components/tooltip/src/trigger.mjs.map +1 -1
- package/es/components/tree/src/model/useKeydown.mjs +1 -1
- package/es/components/tree/src/model/useKeydown.mjs.map +1 -1
- package/es/hooks/use-escape-keydown/index.mjs +2 -3
- package/es/hooks/use-escape-keydown/index.mjs.map +1 -1
- package/es/version.d.ts +1 -1
- package/es/version.mjs +1 -1
- package/es/version.mjs.map +1 -1
- package/lib/components/cascader/src/cascader2.js +2 -0
- package/lib/components/cascader/src/cascader2.js.map +1 -1
- package/lib/components/cascader-panel/src/index.js +1 -0
- package/lib/components/cascader-panel/src/index.js.map +1 -1
- package/lib/components/color-picker/src/color-picker2.js +1 -0
- package/lib/components/color-picker/src/color-picker2.js.map +1 -1
- package/lib/components/descriptions/src/description-item.d.ts +4 -0
- package/lib/components/descriptions/src/description-item.js +4 -0
- package/lib/components/descriptions/src/description-item.js.map +1 -1
- package/lib/components/descriptions/src/description.d.ts +1 -0
- package/lib/components/descriptions/src/description.js +4 -0
- package/lib/components/descriptions/src/description.js.map +1 -1
- package/lib/components/descriptions/src/description.vue.d.ts +3 -0
- package/lib/components/descriptions/src/descriptions-cell.js +2 -1
- package/lib/components/descriptions/src/descriptions-cell.js.map +1 -1
- package/lib/components/descriptions/src/descriptions.type.d.ts +2 -0
- package/lib/components/dropdown/src/dropdown-item-impl.js +1 -2
- package/lib/components/dropdown/src/dropdown-item-impl.js.map +1 -1
- package/lib/components/dropdown/src/dropdown2.js +6 -1
- package/lib/components/dropdown/src/dropdown2.js.map +1 -1
- package/lib/components/dropdown/src/useDropdown.js +1 -1
- package/lib/components/dropdown/src/useDropdown.js.map +1 -1
- package/lib/components/focus-trap/src/focus-trap.js +2 -2
- package/lib/components/focus-trap/src/focus-trap.js.map +1 -1
- package/lib/components/mention/src/mention2.js +51 -45
- package/lib/components/mention/src/mention2.js.map +1 -1
- package/lib/components/menu/src/utils/menu-item.js +1 -0
- package/lib/components/menu/src/utils/menu-item.js.map +1 -1
- package/lib/components/menu/src/utils/submenu.js +1 -0
- package/lib/components/menu/src/utils/submenu.js.map +1 -1
- package/lib/components/pagination/src/components/next.js +36 -19
- package/lib/components/pagination/src/components/next.js.map +1 -1
- package/lib/components/pagination/src/components/next2.js +19 -36
- package/lib/components/pagination/src/components/next2.js.map +1 -1
- package/lib/components/pagination/src/pagination.js +1 -1
- package/lib/components/pagination/style/css.d.ts +1 -0
- package/lib/components/pagination/style/css.js +1 -0
- package/lib/components/pagination/style/css.js.map +1 -1
- package/lib/components/pagination/style/index.d.ts +1 -0
- package/lib/components/pagination/style/index.js +1 -0
- package/lib/components/pagination/style/index.js.map +1 -1
- package/lib/components/roving-focus-group/src/roving-focus-item.js +2 -2
- package/lib/components/roving-focus-group/src/roving-focus-item.js.map +1 -1
- package/lib/components/roving-focus-group/src/utils.js +1 -1
- package/lib/components/roving-focus-group/src/utils.js.map +1 -1
- package/lib/components/select-v2/src/select-dropdown.js +7 -9
- package/lib/components/select-v2/src/select-dropdown.js.map +1 -1
- package/lib/components/select-v2/src/useSelect.js +2 -1
- package/lib/components/select-v2/src/useSelect.js.map +1 -1
- package/lib/components/slider/src/button.js +22 -91
- package/lib/components/slider/src/button.js.map +1 -1
- package/lib/components/slider/src/button2.js +91 -22
- package/lib/components/slider/src/button2.js.map +1 -1
- package/lib/components/slider/src/composables/use-slider-button.js +24 -15
- package/lib/components/slider/src/composables/use-slider-button.js.map +1 -1
- package/lib/components/slider/src/slider2.js +1 -1
- package/lib/components/tabs/src/tab-nav.js +21 -25
- package/lib/components/tabs/src/tab-nav.js.map +1 -1
- package/lib/components/tabs/src/tabs.js +1 -1
- package/lib/components/tabs/src/tabs.js.map +1 -1
- package/lib/components/time-picker/src/time-picker-com/basic-time-spinner.js +7 -3
- package/lib/components/time-picker/src/time-picker-com/basic-time-spinner.js.map +1 -1
- package/lib/components/tooltip/src/trigger.js +1 -1
- package/lib/components/tooltip/src/trigger.js.map +1 -1
- package/lib/components/tree/src/model/useKeydown.js +1 -1
- package/lib/components/tree/src/model/useKeydown.js.map +1 -1
- package/lib/hooks/use-escape-keydown/index.js +2 -3
- package/lib/hooks/use-escape-keydown/index.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +2 -2
- package/tags.json +1 -1
- package/web-types.json +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-slider-button.js","sources":["../../../../../../../packages/components/slider/src/composables/use-slider-button.ts"],"sourcesContent":["import { computed, inject, nextTick, ref, watch } from 'vue'\nimport { debounce } from 'lodash-unified'\nimport { useEventListener } from '@vueuse/core'\nimport { EVENT_CODE, UPDATE_MODEL_EVENT } from '@element-plus/constants'\nimport { sliderContextKey } from '../constants'\n\nimport type { CSSProperties, ComputedRef, Ref, SetupContext } from 'vue'\nimport type { SliderProps } from '../slider'\nimport type {\n SliderButtonEmits,\n SliderButtonInitData,\n SliderButtonProps,\n} from '../button'\nimport type { TooltipInstance } from '@element-plus/components/tooltip'\n\nconst { left, down, right, up, home, end, pageUp, pageDown } = EVENT_CODE\n\nconst useTooltip = (\n props: SliderButtonProps,\n formatTooltip: Ref<SliderProps['formatTooltip']>,\n showTooltip: Ref<SliderProps['showTooltip']>\n) => {\n const tooltip = ref<TooltipInstance>()\n\n const tooltipVisible = ref(false)\n\n const enableFormat = computed(() => {\n return formatTooltip.value instanceof Function\n })\n\n const formatValue = computed(() => {\n return (\n (enableFormat.value && formatTooltip.value!(props.modelValue)) ||\n props.modelValue\n )\n })\n\n const displayTooltip = debounce(() => {\n showTooltip.value && (tooltipVisible.value = true)\n }, 50)\n\n const hideTooltip = debounce(() => {\n showTooltip.value && (tooltipVisible.value = false)\n }, 50)\n\n return {\n tooltip,\n tooltipVisible,\n formatValue,\n displayTooltip,\n hideTooltip,\n }\n}\n\nexport const useSliderButton = (\n props: SliderButtonProps,\n initData: SliderButtonInitData,\n emit: SetupContext<SliderButtonEmits>['emit']\n) => {\n const {\n disabled,\n min,\n max,\n step,\n showTooltip,\n precision,\n sliderSize,\n formatTooltip,\n emitChange,\n resetSize,\n updateDragging,\n } = inject(sliderContextKey)!\n\n const { tooltip, tooltipVisible, formatValue, displayTooltip, hideTooltip } =\n useTooltip(props, formatTooltip!, showTooltip)\n\n const button = ref<HTMLDivElement>()\n\n const currentPosition = computed(() => {\n return `${\n ((props.modelValue - min.value) / (max.value - min.value)) * 100\n }%`\n })\n\n const wrapperStyle: ComputedRef<CSSProperties> = computed(() => {\n return props.vertical\n ? { bottom: currentPosition.value }\n : { left: currentPosition.value }\n })\n\n const handleMouseEnter = () => {\n initData.hovering = true\n displayTooltip()\n }\n\n const handleMouseLeave = () => {\n initData.hovering = false\n if (!initData.dragging) {\n hideTooltip()\n }\n }\n\n const onButtonDown = (event: MouseEvent | TouchEvent) => {\n if (disabled.value) return\n event.preventDefault()\n onDragStart(event)\n window.addEventListener('mousemove', onDragging)\n window.addEventListener('touchmove', onDragging)\n window.addEventListener('mouseup', onDragEnd)\n window.addEventListener('touchend', onDragEnd)\n window.addEventListener('contextmenu', onDragEnd)\n button.value!.focus()\n }\n\n const incrementPosition = (amount: number) => {\n if (disabled.value) return\n initData.newPosition =\n Number.parseFloat(currentPosition.value) +\n (amount / (max.value - min.value)) * 100\n setPosition(initData.newPosition)\n emitChange()\n }\n\n const onLeftKeyDown = () => {\n incrementPosition(-step.value)\n }\n\n const onRightKeyDown = () => {\n incrementPosition(step.value)\n }\n\n const onPageDownKeyDown = () => {\n incrementPosition(-step.value * 4)\n }\n\n const onPageUpKeyDown = () => {\n incrementPosition(step.value * 4)\n }\n\n const onHomeKeyDown = () => {\n if (disabled.value) return\n setPosition(0)\n emitChange()\n }\n\n const onEndKeyDown = () => {\n if (disabled.value) return\n setPosition(100)\n emitChange()\n }\n\n const onKeyDown = (event: KeyboardEvent) => {\n let isPreventDefault = true\n if ([left, down].includes(event.key)) {\n onLeftKeyDown()\n } else if ([right, up].includes(event.key)) {\n onRightKeyDown()\n } else if (event.key === home) {\n onHomeKeyDown()\n } else if (event.key === end) {\n onEndKeyDown()\n } else if (event.key === pageDown) {\n onPageDownKeyDown()\n } else if (event.key === pageUp) {\n onPageUpKeyDown()\n } else {\n isPreventDefault = false\n }\n isPreventDefault && event.preventDefault()\n }\n\n const getClientXY = (event: MouseEvent | TouchEvent) => {\n let clientX: number\n let clientY: number\n if (event.type.startsWith('touch')) {\n clientY = (event as TouchEvent).touches[0].clientY\n clientX = (event as TouchEvent).touches[0].clientX\n } else {\n clientY = (event as MouseEvent).clientY\n clientX = (event as MouseEvent).clientX\n }\n return {\n clientX,\n clientY,\n }\n }\n\n const onDragStart = (event: MouseEvent | TouchEvent) => {\n initData.dragging = true\n initData.isClick = true\n const { clientX, clientY } = getClientXY(event)\n if (props.vertical) {\n initData.startY = clientY\n } else {\n initData.startX = clientX\n }\n initData.startPosition = Number.parseFloat(currentPosition.value)\n initData.newPosition = initData.startPosition\n }\n\n const onDragging = (event: MouseEvent | TouchEvent) => {\n if (initData.dragging) {\n initData.isClick = false\n displayTooltip()\n resetSize()\n let diff: number\n const { clientX, clientY } = getClientXY(event)\n if (props.vertical) {\n initData.currentY = clientY\n diff = ((initData.startY - initData.currentY) / sliderSize.value) * 100\n } else {\n initData.currentX = clientX\n diff = ((initData.currentX - initData.startX) / sliderSize.value) * 100\n }\n initData.newPosition = initData.startPosition + diff\n setPosition(initData.newPosition)\n }\n }\n\n const onDragEnd = () => {\n if (initData.dragging) {\n /*\n * 防止在 mouseup 后立即触发 click,导致滑块有几率产生一小段位移\n * 不使用 preventDefault 是因为 mouseup 和 click 没有注册在同一个 DOM 上\n */\n setTimeout(() => {\n initData.dragging = false\n if (!initData.hovering) {\n hideTooltip()\n }\n if (!initData.isClick) {\n setPosition(initData.newPosition)\n }\n emitChange()\n }, 0)\n window.removeEventListener('mousemove', onDragging)\n window.removeEventListener('touchmove', onDragging)\n window.removeEventListener('mouseup', onDragEnd)\n window.removeEventListener('touchend', onDragEnd)\n window.removeEventListener('contextmenu', onDragEnd)\n }\n }\n\n const setPosition = async (newPosition: number) => {\n if (newPosition === null || Number.isNaN(+newPosition)) return\n if (newPosition < 0) {\n newPosition = 0\n } else if (newPosition > 100) {\n newPosition = 100\n }\n const lengthPerStep = 100 / ((max.value - min.value) / step.value)\n const steps = Math.round(newPosition / lengthPerStep)\n let value =\n steps * lengthPerStep * (max.value - min.value) * 0.01 + min.value\n value = Number.parseFloat(value.toFixed(precision.value))\n\n if (value !== props.modelValue) {\n emit(UPDATE_MODEL_EVENT, value)\n }\n\n if (!initData.dragging && props.modelValue !== initData.oldValue) {\n initData.oldValue = props.modelValue\n }\n\n await nextTick()\n initData.dragging && displayTooltip()\n tooltip.value!.updatePopper()\n }\n\n watch(\n () => initData.dragging,\n (val) => {\n updateDragging(val)\n }\n )\n\n useEventListener(button, 'touchstart', onButtonDown, { passive: false })\n\n return {\n disabled,\n button,\n tooltip,\n tooltipVisible,\n showTooltip,\n wrapperStyle,\n formatValue,\n handleMouseEnter,\n handleMouseLeave,\n onButtonDown,\n onKeyDown,\n setPosition,\n }\n}\n"],"names":["EVENT_CODE","ref","computed","debounce","inject","sliderContextKey","UPDATE_MODEL_EVENT","nextTick","watch","useEventListener"],"mappings":";;;;;;;;;;;;AAKA,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAGA,eAAU,CAAC;AAC1E,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,aAAa,EAAE,WAAW,KAAK;AAC1D,EAAE,MAAM,OAAO,GAAGC,OAAG,EAAE,CAAC;AACxB,EAAE,MAAM,cAAc,GAAGA,OAAG,CAAC,KAAK,CAAC,CAAC;AACpC,EAAE,MAAM,YAAY,GAAGC,YAAQ,CAAC,MAAM;AACtC,IAAI,OAAO,aAAa,CAAC,KAAK,YAAY,QAAQ,CAAC;AACnD,GAAG,CAAC,CAAC;AACL,EAAE,MAAM,WAAW,GAAGA,YAAQ,CAAC,MAAM;AACrC,IAAI,OAAO,YAAY,CAAC,KAAK,IAAI,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,UAAU,C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AAC,MAAM,QAAQ,CAAC,QAAQ,EAAE,CAAC,GAAG,KAAK;AAC1C,IAAI,cAAc,CAAC,GAAG,CAAC,CAAC;AACxB,GAAG,CAAC,CAAC;AACL,EAAEC,qBAAgB,CAAC,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;AAC3E,EAAE,OAAO;AACT,IAAI,QAAQ;AACZ,IAAI,MAAM;AACV,IAAI,OAAO;AACX,IAAI,cAAc;AAClB,IAAI,WAAW;AACf,IAAI,YAAY;AAChB,IAAI,WAAW;AACf,IAAI,gBAAgB;AACpB,IAAI,gBAAgB;AACpB,IAAI,YAAY;AAChB,IAAI,SAAS;AACb,IAAI,WAAW;AACf,GAAG,CAAC;AACJ;;;;"}
|
1
|
+
{"version":3,"file":"use-slider-button.js","sources":["../../../../../../../packages/components/slider/src/composables/use-slider-button.ts"],"sourcesContent":["import { computed, inject, nextTick, ref, watch } from 'vue'\nimport { debounce } from 'lodash-unified'\nimport { useEventListener } from '@vueuse/core'\nimport { EVENT_CODE, UPDATE_MODEL_EVENT } from '@element-plus/constants'\nimport { sliderContextKey } from '../constants'\n\nimport type { CSSProperties, ComputedRef, Ref, SetupContext } from 'vue'\nimport type { SliderProps } from '../slider'\nimport type {\n SliderButtonEmits,\n SliderButtonInitData,\n SliderButtonProps,\n} from '../button'\nimport type { TooltipInstance } from '@element-plus/components/tooltip'\n\nconst useTooltip = (\n props: SliderButtonProps,\n formatTooltip: Ref<SliderProps['formatTooltip']>,\n showTooltip: Ref<SliderProps['showTooltip']>\n) => {\n const tooltip = ref<TooltipInstance>()\n\n const tooltipVisible = ref(false)\n\n const enableFormat = computed(() => {\n return formatTooltip.value instanceof Function\n })\n\n const formatValue = computed(() => {\n return (\n (enableFormat.value && formatTooltip.value!(props.modelValue)) ||\n props.modelValue\n )\n })\n\n const displayTooltip = debounce(() => {\n showTooltip.value && (tooltipVisible.value = true)\n }, 50)\n\n const hideTooltip = debounce(() => {\n showTooltip.value && (tooltipVisible.value = false)\n }, 50)\n\n return {\n tooltip,\n tooltipVisible,\n formatValue,\n displayTooltip,\n hideTooltip,\n }\n}\n\nexport const useSliderButton = (\n props: SliderButtonProps,\n initData: SliderButtonInitData,\n emit: SetupContext<SliderButtonEmits>['emit']\n) => {\n const {\n disabled,\n min,\n max,\n step,\n showTooltip,\n precision,\n sliderSize,\n formatTooltip,\n emitChange,\n resetSize,\n updateDragging,\n } = inject(sliderContextKey)!\n\n const { tooltip, tooltipVisible, formatValue, displayTooltip, hideTooltip } =\n useTooltip(props, formatTooltip!, showTooltip)\n\n const button = ref<HTMLDivElement>()\n\n const currentPosition = computed(() => {\n return `${\n ((props.modelValue - min.value) / (max.value - min.value)) * 100\n }%`\n })\n\n const wrapperStyle: ComputedRef<CSSProperties> = computed(() => {\n return props.vertical\n ? { bottom: currentPosition.value }\n : { left: currentPosition.value }\n })\n\n const handleMouseEnter = () => {\n initData.hovering = true\n displayTooltip()\n }\n\n const handleMouseLeave = () => {\n initData.hovering = false\n if (!initData.dragging) {\n hideTooltip()\n }\n }\n\n const onButtonDown = (event: MouseEvent | TouchEvent) => {\n if (disabled.value) return\n event.preventDefault()\n onDragStart(event)\n window.addEventListener('mousemove', onDragging)\n window.addEventListener('touchmove', onDragging)\n window.addEventListener('mouseup', onDragEnd)\n window.addEventListener('touchend', onDragEnd)\n window.addEventListener('contextmenu', onDragEnd)\n button.value!.focus()\n }\n\n const incrementPosition = (amount: number) => {\n if (disabled.value) return\n initData.newPosition =\n Number.parseFloat(currentPosition.value) +\n (amount / (max.value - min.value)) * 100\n setPosition(initData.newPosition)\n emitChange()\n }\n\n const onLeftKeyDown = () => {\n incrementPosition(-step.value)\n }\n\n const onRightKeyDown = () => {\n incrementPosition(step.value)\n }\n\n const onPageDownKeyDown = () => {\n incrementPosition(-step.value * 4)\n }\n\n const onPageUpKeyDown = () => {\n incrementPosition(step.value * 4)\n }\n\n const onHomeKeyDown = () => {\n if (disabled.value) return\n setPosition(0)\n emitChange()\n }\n\n const onEndKeyDown = () => {\n if (disabled.value) return\n setPosition(100)\n emitChange()\n }\n\n const onKeyDown = (event: KeyboardEvent) => {\n let isPreventDefault = true\n\n switch (event.code) {\n case EVENT_CODE.left:\n case EVENT_CODE.down:\n onLeftKeyDown()\n break\n case EVENT_CODE.right:\n case EVENT_CODE.up:\n onRightKeyDown()\n break\n case EVENT_CODE.home:\n onHomeKeyDown()\n break\n case EVENT_CODE.end:\n onEndKeyDown()\n break\n case EVENT_CODE.pageDown:\n onPageDownKeyDown()\n break\n case EVENT_CODE.pageUp:\n onPageUpKeyDown()\n break\n default:\n isPreventDefault = false\n break\n }\n\n isPreventDefault && event.preventDefault()\n }\n\n const getClientXY = (event: MouseEvent | TouchEvent) => {\n let clientX: number\n let clientY: number\n if (event.type.startsWith('touch')) {\n clientY = (event as TouchEvent).touches[0].clientY\n clientX = (event as TouchEvent).touches[0].clientX\n } else {\n clientY = (event as MouseEvent).clientY\n clientX = (event as MouseEvent).clientX\n }\n return {\n clientX,\n clientY,\n }\n }\n\n const onDragStart = (event: MouseEvent | TouchEvent) => {\n initData.dragging = true\n initData.isClick = true\n const { clientX, clientY } = getClientXY(event)\n if (props.vertical) {\n initData.startY = clientY\n } else {\n initData.startX = clientX\n }\n initData.startPosition = Number.parseFloat(currentPosition.value)\n initData.newPosition = initData.startPosition\n }\n\n const onDragging = (event: MouseEvent | TouchEvent) => {\n if (initData.dragging) {\n initData.isClick = false\n displayTooltip()\n resetSize()\n let diff: number\n const { clientX, clientY } = getClientXY(event)\n if (props.vertical) {\n initData.currentY = clientY\n diff = ((initData.startY - initData.currentY) / sliderSize.value) * 100\n } else {\n initData.currentX = clientX\n diff = ((initData.currentX - initData.startX) / sliderSize.value) * 100\n }\n initData.newPosition = initData.startPosition + diff\n setPosition(initData.newPosition)\n }\n }\n\n const onDragEnd = () => {\n if (initData.dragging) {\n /*\n * 防止在 mouseup 后立即触发 click,导致滑块有几率产生一小段位移\n * 不使用 preventDefault 是因为 mouseup 和 click 没有注册在同一个 DOM 上\n */\n setTimeout(() => {\n initData.dragging = false\n if (!initData.hovering) {\n hideTooltip()\n }\n if (!initData.isClick) {\n setPosition(initData.newPosition)\n }\n emitChange()\n }, 0)\n window.removeEventListener('mousemove', onDragging)\n window.removeEventListener('touchmove', onDragging)\n window.removeEventListener('mouseup', onDragEnd)\n window.removeEventListener('touchend', onDragEnd)\n window.removeEventListener('contextmenu', onDragEnd)\n }\n }\n\n const setPosition = async (newPosition: number) => {\n if (newPosition === null || Number.isNaN(+newPosition)) return\n if (newPosition < 0) {\n newPosition = 0\n } else if (newPosition > 100) {\n newPosition = 100\n }\n const lengthPerStep = 100 / ((max.value - min.value) / step.value)\n const steps = Math.round(newPosition / lengthPerStep)\n let value =\n steps * lengthPerStep * (max.value - min.value) * 0.01 + min.value\n value = Number.parseFloat(value.toFixed(precision.value))\n\n if (value !== props.modelValue) {\n emit(UPDATE_MODEL_EVENT, value)\n }\n\n if (!initData.dragging && props.modelValue !== initData.oldValue) {\n initData.oldValue = props.modelValue\n }\n\n await nextTick()\n initData.dragging && displayTooltip()\n tooltip.value!.updatePopper()\n }\n\n watch(\n () => initData.dragging,\n (val) => {\n updateDragging(val)\n }\n )\n\n useEventListener(button, 'touchstart', onButtonDown, { passive: false })\n\n return {\n disabled,\n button,\n tooltip,\n tooltipVisible,\n showTooltip,\n wrapperStyle,\n formatValue,\n handleMouseEnter,\n handleMouseLeave,\n onButtonDown,\n onKeyDown,\n setPosition,\n }\n}\n"],"names":["ref","computed","debounce","inject","sliderContextKey","EVENT_CODE","UPDATE_MODEL_EVENT","nextTick","watch","useEventListener"],"mappings":";;;;;;;;;;;;AAKA,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,aAAa,EAAE,WAAW,KAAK;AAC1D,EAAE,MAAM,OAAO,GAAGA,OAAG,EAAE,CAAC;AACxB,EAAE,MAAM,cAAc,GAAGA,OAAG,CAAC,KAAK,CAAC,CAAC;AACpC,EAA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AAQ,IAAI,KAAK,CAAC,UAAU,KAAK,QAAQ,CAAC,QAAQ,EAAE;AACtE,MAAM,QAAQ,CAAC,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAC;AAC3C,KAAK;AACL,IAAI,MAAMC,YAAQ,EAAE,CAAC;AACrB,IAAI,QAAQ,CAAC,QAAQ,IAAI,cAAc,EAAE,CAAC;AAC1C,IAAI,OAAO,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;AACjC,GAAG,CAAC;AACJ,EAAEC,SAAK,CAAC,MAAM,QAAQ,CAAC,QAAQ,EAAE,CAAC,GAAG,KAAK;AAC1C,IAAI,cAAc,CAAC,GAAG,CAAC,CAAC;AACxB,GAAG,CAAC,CAAC;AACL,EAAEC,qBAAgB,CAAC,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;AAC3E,EAAE,OAAO;AACT,IAAI,QAAQ;AACZ,IAAI,MAAM;AACV,IAAI,OAAO;AACX,IAAI,cAAc;AAClB,IAAI,WAAW;AACf,IAAI,YAAY;AAChB,IAAI,WAAW;AACf,IAAI,gBAAgB;AACpB,IAAI,gBAAgB;AACpB,IAAI,YAAY;AAChB,IAAI,SAAS;AACb,IAAI,WAAW;AACf,GAAG,CAAC;AACJ;;;;"}
|
@@ -9,7 +9,7 @@ require('../../form/index.js');
|
|
9
9
|
require('../../../hooks/index.js');
|
10
10
|
var constants = require('./constants.js');
|
11
11
|
var slider = require('./slider.js');
|
12
|
-
var button = require('./
|
12
|
+
var button = require('./button2.js');
|
13
13
|
var marker = require('./marker.js');
|
14
14
|
require('./composables/index.js');
|
15
15
|
var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
|
@@ -145,31 +145,27 @@ const TabNav = vue.defineComponent({
|
|
145
145
|
}
|
146
146
|
}
|
147
147
|
};
|
148
|
-
const changeTab = (
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
} else {
|
168
|
-
|
169
|
-
nextIndex = currentIndex + 1;
|
170
|
-
} else {
|
171
|
-
nextIndex = 0;
|
172
|
-
}
|
148
|
+
const changeTab = (event) => {
|
149
|
+
let step = 0;
|
150
|
+
switch (event.code) {
|
151
|
+
case aria.EVENT_CODE.left:
|
152
|
+
case aria.EVENT_CODE.up:
|
153
|
+
step = -1;
|
154
|
+
break;
|
155
|
+
case aria.EVENT_CODE.right:
|
156
|
+
case aria.EVENT_CODE.down:
|
157
|
+
step = 1;
|
158
|
+
break;
|
159
|
+
default:
|
160
|
+
return;
|
161
|
+
}
|
162
|
+
const tabList = Array.from(event.currentTarget.querySelectorAll("[role=tab]:not(.is-disabled)"));
|
163
|
+
const currentIndex = tabList.indexOf(event.target);
|
164
|
+
let nextIndex = currentIndex + step;
|
165
|
+
if (nextIndex < 0) {
|
166
|
+
nextIndex = tabList.length - 1;
|
167
|
+
} else if (nextIndex >= tabList.length) {
|
168
|
+
nextIndex = 0;
|
173
169
|
}
|
174
170
|
tabList[nextIndex].focus({
|
175
171
|
preventScroll: true
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"tab-nav.js","sources":["../../../../../../packages/components/tabs/src/tab-nav.tsx"],"sourcesContent":["import {\n computed,\n defineComponent,\n inject,\n nextTick,\n onMounted,\n onUpdated,\n ref,\n watch,\n} from 'vue'\nimport {\n useDocumentVisibility,\n useResizeObserver,\n useWindowFocus,\n} from '@vueuse/core'\nimport {\n buildProps,\n capitalize,\n definePropType,\n mutable,\n throwError,\n} from '@element-plus/utils'\nimport { EVENT_CODE } from '@element-plus/constants'\nimport { ElIcon } from '@element-plus/components/icon'\nimport { ArrowLeft, ArrowRight, Close } from '@element-plus/icons-vue'\nimport { useNamespace } from '@element-plus/hooks'\nimport TabBar from './tab-bar.vue'\nimport { tabsRootContextKey } from './constants'\n\nimport type { CSSProperties, ExtractPropTypes } from 'vue'\nimport type { TabsPaneContext } from './constants'\nimport type { TabPaneName } from './tabs'\n\ninterface Scrollable {\n next?: boolean\n prev?: number\n}\n\nexport const tabNavProps = buildProps({\n panes: {\n type: definePropType<TabsPaneContext[]>(Array),\n default: () => mutable([] as const),\n },\n currentName: {\n type: [String, Number],\n default: '',\n },\n editable: Boolean,\n type: {\n type: String,\n values: ['card', 'border-card', ''],\n default: '',\n },\n stretch: Boolean,\n} as const)\n\nexport const tabNavEmits = {\n tabClick: (tab: TabsPaneContext, tabName: TabPaneName, ev: Event) =>\n ev instanceof Event,\n tabRemove: (tab: TabsPaneContext, ev: Event) => ev instanceof Event,\n}\n\nexport type TabNavProps = ExtractPropTypes<typeof tabNavProps>\nexport type TabNavEmits = typeof tabNavEmits\n\nconst COMPONENT_NAME = 'ElTabNav'\nconst TabNav = defineComponent({\n name: COMPONENT_NAME,\n props: tabNavProps,\n emits: tabNavEmits,\n setup(props, { expose, emit }) {\n const rootTabs = inject(tabsRootContextKey)\n if (!rootTabs) throwError(COMPONENT_NAME, `<el-tabs><tab-nav /></el-tabs>`)\n\n const ns = useNamespace('tabs')\n const visibility = useDocumentVisibility()\n const focused = useWindowFocus()\n\n const navScroll$ = ref<HTMLDivElement>()\n const nav$ = ref<HTMLDivElement>()\n const el$ = ref<HTMLDivElement>()\n\n const tabBarRef = ref<InstanceType<typeof TabBar>>()\n\n const scrollable = ref<false | Scrollable>(false)\n const navOffset = ref(0)\n const isFocus = ref(false)\n const focusable = ref(true)\n\n const sizeName = computed(() =>\n ['top', 'bottom'].includes(rootTabs.props.tabPosition)\n ? 'width'\n : 'height'\n )\n const navStyle = computed<CSSProperties>(() => {\n const dir = sizeName.value === 'width' ? 'X' : 'Y'\n return {\n transform: `translate${dir}(-${navOffset.value}px)`,\n }\n })\n\n const scrollPrev = () => {\n if (!navScroll$.value) return\n\n const containerSize =\n navScroll$.value[`offset${capitalize(sizeName.value)}`]\n const currentOffset = navOffset.value\n\n if (!currentOffset) return\n\n const newOffset =\n currentOffset > containerSize ? currentOffset - containerSize : 0\n\n navOffset.value = newOffset\n }\n\n const scrollNext = () => {\n if (!navScroll$.value || !nav$.value) return\n\n const navSize = nav$.value[`offset${capitalize(sizeName.value)}`]\n const containerSize =\n navScroll$.value[`offset${capitalize(sizeName.value)}`]\n const currentOffset = navOffset.value\n\n if (navSize - currentOffset <= containerSize) return\n\n const newOffset =\n navSize - currentOffset > containerSize * 2\n ? currentOffset + containerSize\n : navSize - containerSize\n\n navOffset.value = newOffset\n }\n\n const scrollToActiveTab = async () => {\n const nav = nav$.value\n if (!scrollable.value || !el$.value || !navScroll$.value || !nav) return\n\n await nextTick()\n\n const activeTab = el$.value.querySelector('.is-active')\n if (!activeTab) return\n\n const navScroll = navScroll$.value\n const isHorizontal = ['top', 'bottom'].includes(\n rootTabs.props.tabPosition\n )\n const activeTabBounding = activeTab.getBoundingClientRect()\n const navScrollBounding = navScroll.getBoundingClientRect()\n const maxOffset = isHorizontal\n ? nav.offsetWidth - navScrollBounding.width\n : nav.offsetHeight - navScrollBounding.height\n const currentOffset = navOffset.value\n let newOffset = currentOffset\n\n if (isHorizontal) {\n if (activeTabBounding.left < navScrollBounding.left) {\n newOffset =\n currentOffset - (navScrollBounding.left - activeTabBounding.left)\n }\n if (activeTabBounding.right > navScrollBounding.right) {\n newOffset =\n currentOffset + activeTabBounding.right - navScrollBounding.right\n }\n } else {\n if (activeTabBounding.top < navScrollBounding.top) {\n newOffset =\n currentOffset - (navScrollBounding.top - activeTabBounding.top)\n }\n if (activeTabBounding.bottom > navScrollBounding.bottom) {\n newOffset =\n currentOffset +\n (activeTabBounding.bottom - navScrollBounding.bottom)\n }\n }\n newOffset = Math.max(newOffset, 0)\n navOffset.value = Math.min(newOffset, maxOffset)\n }\n\n const update = () => {\n if (!nav$.value || !navScroll$.value) return\n\n props.stretch && tabBarRef.value?.update()\n\n const navSize = nav$.value[`offset${capitalize(sizeName.value)}`]\n const containerSize =\n navScroll$.value[`offset${capitalize(sizeName.value)}`]\n const currentOffset = navOffset.value\n\n if (containerSize < navSize) {\n scrollable.value = scrollable.value || {}\n scrollable.value.prev = currentOffset\n scrollable.value.next = currentOffset + containerSize < navSize\n if (navSize - currentOffset < containerSize) {\n navOffset.value = navSize - containerSize\n }\n } else {\n scrollable.value = false\n if (currentOffset > 0) {\n navOffset.value = 0\n }\n }\n }\n\n const changeTab = (e: KeyboardEvent) => {\n const code = e.code\n\n const { up, down, left, right } = EVENT_CODE\n if (![up, down, left, right].includes(code)) return\n\n // 左右上下键更换tab\n const tabList = Array.from(\n (e.currentTarget as HTMLDivElement).querySelectorAll<HTMLDivElement>(\n '[role=tab]:not(.is-disabled)'\n )\n )\n const currentIndex = tabList.indexOf(e.target as HTMLDivElement)\n\n let nextIndex: number\n if (code === left || code === up) {\n // left\n if (currentIndex === 0) {\n // first\n nextIndex = tabList.length - 1\n } else {\n nextIndex = currentIndex - 1\n }\n } else {\n // right\n if (currentIndex < tabList.length - 1) {\n // not last\n nextIndex = currentIndex + 1\n } else {\n nextIndex = 0\n }\n }\n tabList[nextIndex].focus({ preventScroll: true }) // 改变焦点元素\n tabList[nextIndex].click() // 选中下一个tab\n setFocus()\n }\n\n const setFocus = () => {\n if (focusable.value) isFocus.value = true\n }\n const removeFocus = () => (isFocus.value = false)\n\n watch(visibility, (visibility) => {\n if (visibility === 'hidden') {\n focusable.value = false\n } else if (visibility === 'visible') {\n setTimeout(() => (focusable.value = true), 50)\n }\n })\n watch(focused, (focused) => {\n if (focused) {\n setTimeout(() => (focusable.value = true), 50)\n } else {\n focusable.value = false\n }\n })\n\n useResizeObserver(el$, update)\n\n onMounted(() => setTimeout(() => scrollToActiveTab(), 0))\n onUpdated(() => update())\n\n expose({\n scrollToActiveTab,\n removeFocus,\n })\n\n return () => {\n const scrollBtn = scrollable.value\n ? [\n <span\n class={[\n ns.e('nav-prev'),\n ns.is('disabled', !scrollable.value.prev),\n ]}\n onClick={scrollPrev}\n >\n <ElIcon>\n <ArrowLeft />\n </ElIcon>\n </span>,\n <span\n class={[\n ns.e('nav-next'),\n ns.is('disabled', !scrollable.value.next),\n ]}\n onClick={scrollNext}\n >\n <ElIcon>\n <ArrowRight />\n </ElIcon>\n </span>,\n ]\n : null\n\n const tabs = props.panes.map((pane, index) => {\n const uid = pane.uid\n const disabled = pane.props.disabled\n const tabName = pane.props.name ?? pane.index ?? `${index}`\n const closable = !disabled && (pane.isClosable || props.editable)\n pane.index = `${index}`\n\n const btnClose = closable ? (\n <ElIcon\n class=\"is-icon-close\"\n // `onClick` not exist when generate dts\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n onClick={(ev: MouseEvent) => emit('tabRemove', pane, ev)}\n >\n <Close />\n </ElIcon>\n ) : null\n\n const tabLabelContent = pane.slots.label?.() || pane.props.label\n const tabindex = !disabled && pane.active ? 0 : -1\n\n return (\n <div\n ref={`tab-${uid}`}\n class={[\n ns.e('item'),\n ns.is(rootTabs.props.tabPosition),\n ns.is('active', pane.active),\n ns.is('disabled', disabled),\n ns.is('closable', closable),\n ns.is('focus', isFocus.value),\n ]}\n id={`tab-${tabName}`}\n key={`tab-${uid}`}\n aria-controls={`pane-${tabName}`}\n role=\"tab\"\n aria-selected={pane.active}\n tabindex={tabindex}\n onFocus={() => setFocus()}\n onBlur={() => removeFocus()}\n onClick={(ev: MouseEvent) => {\n removeFocus()\n emit('tabClick', pane, tabName, ev)\n }}\n onKeydown={(ev: KeyboardEvent) => {\n if (\n closable &&\n (ev.code === EVENT_CODE.delete ||\n ev.code === EVENT_CODE.backspace)\n ) {\n emit('tabRemove', pane, ev)\n }\n }}\n >\n {...[tabLabelContent, btnClose]}\n </div>\n )\n })\n\n return (\n <div\n ref={el$}\n class={[\n ns.e('nav-wrap'),\n ns.is('scrollable', !!scrollable.value),\n ns.is(rootTabs.props.tabPosition),\n ]}\n >\n {scrollBtn}\n <div class={ns.e('nav-scroll')} ref={navScroll$}>\n <div\n class={[\n ns.e('nav'),\n ns.is(rootTabs.props.tabPosition),\n ns.is(\n 'stretch',\n props.stretch &&\n ['top', 'bottom'].includes(rootTabs.props.tabPosition)\n ),\n ]}\n ref={nav$}\n style={navStyle.value}\n role=\"tablist\"\n onKeydown={changeTab}\n >\n {...[\n !props.type ? (\n <TabBar ref={tabBarRef} tabs={[...props.panes]} />\n ) : null,\n tabs,\n ]}\n </div>\n </div>\n </div>\n )\n }\n },\n})\n\nexport type TabNavInstance = InstanceType<typeof TabNav> & {\n scrollToActiveTab: () => Promise<void>\n removeFocus: () => void\n}\nexport default TabNav\n"],"names":["tabNavProps","buildProps","panes","type","definePropType","Array","default","mutable","currentName","String","Number","editable","Boolean","values","stretch","tabNavEmits","tabClick","tab","tabName","ev","Event","tabRemove","COMPONENT_NAME","TabNav","defineComponent","name","props","emits","expose","emit","inject","tabsRootContextKey","throwError","ns","useNamespace","visibility","useDocumentVisibility","focused","useWindowFocus","navScroll$","ref","nav$","el$","tabBarRef","scrollable","navOffset","isFocus","focusable","sizeName","computed","includes","rootTabs","tabPosition","navStyle","dir","value","transform","scrollPrev","containerSize","capitalize","currentOffset","newOffset","scrollNext","scrollToActiveTab","activeTab","navScroll","navScrollBounding","maxOffset","isHorizontal","offsetWidth","activeTabBounding","right","top","bottom","max","update","navSize","prev","changeTab","code","EVENT_CODE","left","down","tabList","currentIndex","nextIndex","preventScroll","click","setFocus","watch","_createVNode","setTimeout","ElIcon","ArrowLeft","useResizeObserver","onUpdated","ArrowRight","removeFocus","e","Close","pane","index","closable","disabled","btnClose","delete","backspace","tabLabelContent","TabBar"],"mappings":";;;;;;;;;;;;;;;;;;;;AAsCaA,MAAAA,WAAW,GAAGC,kBAAU,CAAC;AACpCC,EAAAA,KAAK,EAAE;AACLC,IAAAA,IAAI,EAAEC,sBAAc,CAAoBC,KAApB,CADf;AAELC,IAAAA,OAAO,EAAE,MAAMC,kBAAO,CAAC,EAAD,CAAA;GAHY;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,CAAA,CAAA;mBAChB,EAAAuE,eAAA,CAAA,KAAA,EAAA;eACP,EAAC,kBAAkBxE;aArB7B,EAAA,UAAA;AAAA,OAAA,EAAA,CAAAwE,eAAA,CAuBgBvE,KAAsB,EAAA;AAChC,QAAA,OAAA,aAEGA,CAAAA,EAAE,EAAF,CAAA,EAAA,CAAA,cAAsB,CAACsF,WACtBtF,CAAE,EAAF,EAAA,CAAA,EAAA,CAAA,gBAAuBuF,CAAAA,OACzB,IAAA,CAAA,KAAA,EAAA,QAAA,CAAA,CAAA,QAAA,CAAA,QAAA,CAAA,KAAA,CAAA,WAAA,CAAA,CAAA,CAAA;AACA7E,QAAAA,KAAAA,EAAAA,IAAK;AACN,QAAA,OAAA,EAAA,QAAA,CAAA,KAAA;AACF,QAAA,MAAA,EAAA,SAAA;AA/BL,QAAA,WAiCS8E,EAAAA,SAAAA;AAGV,OA1DY,EAAb,CAAA,GAAA,CAAA,CAAA,KAAA,CAAA,IAAA,GAAAjB,eAAA,CAAAkB,iBAAA,EAAA;AA4DA,QAAA,KAAA,EAAA,SAAA;AAAA,QAAA,MAAA,EAAA,CAAA,GAAA,KAAA,CAAA,KAAA,CAAA;AAAA,OAAA,EAAA,IAAA,CAAA,GAGW,IACFV,EAAE,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAL,CADK,CAAA;AAHX,KAAA,CAAA;AAAA,GAAA;;;;;;;"}
|
1
|
+
{"version":3,"file":"tab-nav.js","sources":["../../../../../../packages/components/tabs/src/tab-nav.tsx"],"sourcesContent":["import {\n computed,\n defineComponent,\n inject,\n nextTick,\n onMounted,\n onUpdated,\n ref,\n watch,\n} from 'vue'\nimport {\n useDocumentVisibility,\n useResizeObserver,\n useWindowFocus,\n} from '@vueuse/core'\nimport {\n buildProps,\n capitalize,\n definePropType,\n mutable,\n throwError,\n} from '@element-plus/utils'\nimport { EVENT_CODE } from '@element-plus/constants'\nimport { ElIcon } from '@element-plus/components/icon'\nimport { ArrowLeft, ArrowRight, Close } from '@element-plus/icons-vue'\nimport { useNamespace } from '@element-plus/hooks'\nimport TabBar from './tab-bar.vue'\nimport { tabsRootContextKey } from './constants'\n\nimport type { CSSProperties, ExtractPropTypes } from 'vue'\nimport type { TabsPaneContext } from './constants'\nimport type { TabPaneName } from './tabs'\n\ninterface Scrollable {\n next?: boolean\n prev?: number\n}\n\nexport const tabNavProps = buildProps({\n panes: {\n type: definePropType<TabsPaneContext[]>(Array),\n default: () => mutable([] as const),\n },\n currentName: {\n type: [String, Number],\n default: '',\n },\n editable: Boolean,\n type: {\n type: String,\n values: ['card', 'border-card', ''],\n default: '',\n },\n stretch: Boolean,\n} as const)\n\nexport const tabNavEmits = {\n tabClick: (tab: TabsPaneContext, tabName: TabPaneName, ev: Event) =>\n ev instanceof Event,\n tabRemove: (tab: TabsPaneContext, ev: Event) => ev instanceof Event,\n}\n\nexport type TabNavProps = ExtractPropTypes<typeof tabNavProps>\nexport type TabNavEmits = typeof tabNavEmits\n\nconst COMPONENT_NAME = 'ElTabNav'\nconst TabNav = defineComponent({\n name: COMPONENT_NAME,\n props: tabNavProps,\n emits: tabNavEmits,\n setup(props, { expose, emit }) {\n const rootTabs = inject(tabsRootContextKey)\n if (!rootTabs) throwError(COMPONENT_NAME, `<el-tabs><tab-nav /></el-tabs>`)\n\n const ns = useNamespace('tabs')\n const visibility = useDocumentVisibility()\n const focused = useWindowFocus()\n\n const navScroll$ = ref<HTMLDivElement>()\n const nav$ = ref<HTMLDivElement>()\n const el$ = ref<HTMLDivElement>()\n\n const tabBarRef = ref<InstanceType<typeof TabBar>>()\n\n const scrollable = ref<false | Scrollable>(false)\n const navOffset = ref(0)\n const isFocus = ref(false)\n const focusable = ref(true)\n\n const sizeName = computed(() =>\n ['top', 'bottom'].includes(rootTabs.props.tabPosition)\n ? 'width'\n : 'height'\n )\n const navStyle = computed<CSSProperties>(() => {\n const dir = sizeName.value === 'width' ? 'X' : 'Y'\n return {\n transform: `translate${dir}(-${navOffset.value}px)`,\n }\n })\n\n const scrollPrev = () => {\n if (!navScroll$.value) return\n\n const containerSize =\n navScroll$.value[`offset${capitalize(sizeName.value)}`]\n const currentOffset = navOffset.value\n\n if (!currentOffset) return\n\n const newOffset =\n currentOffset > containerSize ? currentOffset - containerSize : 0\n\n navOffset.value = newOffset\n }\n\n const scrollNext = () => {\n if (!navScroll$.value || !nav$.value) return\n\n const navSize = nav$.value[`offset${capitalize(sizeName.value)}`]\n const containerSize =\n navScroll$.value[`offset${capitalize(sizeName.value)}`]\n const currentOffset = navOffset.value\n\n if (navSize - currentOffset <= containerSize) return\n\n const newOffset =\n navSize - currentOffset > containerSize * 2\n ? currentOffset + containerSize\n : navSize - containerSize\n\n navOffset.value = newOffset\n }\n\n const scrollToActiveTab = async () => {\n const nav = nav$.value\n if (!scrollable.value || !el$.value || !navScroll$.value || !nav) return\n\n await nextTick()\n\n const activeTab = el$.value.querySelector('.is-active')\n if (!activeTab) return\n\n const navScroll = navScroll$.value\n const isHorizontal = ['top', 'bottom'].includes(\n rootTabs.props.tabPosition\n )\n const activeTabBounding = activeTab.getBoundingClientRect()\n const navScrollBounding = navScroll.getBoundingClientRect()\n const maxOffset = isHorizontal\n ? nav.offsetWidth - navScrollBounding.width\n : nav.offsetHeight - navScrollBounding.height\n const currentOffset = navOffset.value\n let newOffset = currentOffset\n\n if (isHorizontal) {\n if (activeTabBounding.left < navScrollBounding.left) {\n newOffset =\n currentOffset - (navScrollBounding.left - activeTabBounding.left)\n }\n if (activeTabBounding.right > navScrollBounding.right) {\n newOffset =\n currentOffset + activeTabBounding.right - navScrollBounding.right\n }\n } else {\n if (activeTabBounding.top < navScrollBounding.top) {\n newOffset =\n currentOffset - (navScrollBounding.top - activeTabBounding.top)\n }\n if (activeTabBounding.bottom > navScrollBounding.bottom) {\n newOffset =\n currentOffset +\n (activeTabBounding.bottom - navScrollBounding.bottom)\n }\n }\n newOffset = Math.max(newOffset, 0)\n navOffset.value = Math.min(newOffset, maxOffset)\n }\n\n const update = () => {\n if (!nav$.value || !navScroll$.value) return\n\n props.stretch && tabBarRef.value?.update()\n\n const navSize = nav$.value[`offset${capitalize(sizeName.value)}`]\n const containerSize =\n navScroll$.value[`offset${capitalize(sizeName.value)}`]\n const currentOffset = navOffset.value\n\n if (containerSize < navSize) {\n scrollable.value = scrollable.value || {}\n scrollable.value.prev = currentOffset\n scrollable.value.next = currentOffset + containerSize < navSize\n if (navSize - currentOffset < containerSize) {\n navOffset.value = navSize - containerSize\n }\n } else {\n scrollable.value = false\n if (currentOffset > 0) {\n navOffset.value = 0\n }\n }\n }\n\n const changeTab = (event: KeyboardEvent) => {\n let step = 0\n\n switch (event.code) {\n case EVENT_CODE.left:\n case EVENT_CODE.up:\n step = -1\n break\n case EVENT_CODE.right:\n case EVENT_CODE.down:\n step = 1\n break\n default:\n return\n }\n\n const tabList = Array.from(\n (\n event.currentTarget as HTMLDivElement\n ).querySelectorAll<HTMLDivElement>('[role=tab]:not(.is-disabled)')\n )\n const currentIndex = tabList.indexOf(event.target as HTMLDivElement)\n let nextIndex = currentIndex + step\n\n if (nextIndex < 0) {\n nextIndex = tabList.length - 1\n } else if (nextIndex >= tabList.length) {\n nextIndex = 0\n }\n\n tabList[nextIndex].focus({ preventScroll: true }) // 改变焦点元素\n tabList[nextIndex].click() // 选中下一个tab\n setFocus()\n }\n\n const setFocus = () => {\n if (focusable.value) isFocus.value = true\n }\n const removeFocus = () => (isFocus.value = false)\n\n watch(visibility, (visibility) => {\n if (visibility === 'hidden') {\n focusable.value = false\n } else if (visibility === 'visible') {\n setTimeout(() => (focusable.value = true), 50)\n }\n })\n watch(focused, (focused) => {\n if (focused) {\n setTimeout(() => (focusable.value = true), 50)\n } else {\n focusable.value = false\n }\n })\n\n useResizeObserver(el$, update)\n\n onMounted(() => setTimeout(() => scrollToActiveTab(), 0))\n onUpdated(() => update())\n\n expose({\n scrollToActiveTab,\n removeFocus,\n })\n\n return () => {\n const scrollBtn = scrollable.value\n ? [\n <span\n class={[\n ns.e('nav-prev'),\n ns.is('disabled', !scrollable.value.prev),\n ]}\n onClick={scrollPrev}\n >\n <ElIcon>\n <ArrowLeft />\n </ElIcon>\n </span>,\n <span\n class={[\n ns.e('nav-next'),\n ns.is('disabled', !scrollable.value.next),\n ]}\n onClick={scrollNext}\n >\n <ElIcon>\n <ArrowRight />\n </ElIcon>\n </span>,\n ]\n : null\n\n const tabs = props.panes.map((pane, index) => {\n const uid = pane.uid\n const disabled = pane.props.disabled\n const tabName = pane.props.name ?? pane.index ?? `${index}`\n const closable = !disabled && (pane.isClosable || props.editable)\n pane.index = `${index}`\n\n const btnClose = closable ? (\n <ElIcon\n class=\"is-icon-close\"\n // `onClick` not exist when generate dts\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n onClick={(ev: MouseEvent) => emit('tabRemove', pane, ev)}\n >\n <Close />\n </ElIcon>\n ) : null\n\n const tabLabelContent = pane.slots.label?.() || pane.props.label\n const tabindex = !disabled && pane.active ? 0 : -1\n\n return (\n <div\n ref={`tab-${uid}`}\n class={[\n ns.e('item'),\n ns.is(rootTabs.props.tabPosition),\n ns.is('active', pane.active),\n ns.is('disabled', disabled),\n ns.is('closable', closable),\n ns.is('focus', isFocus.value),\n ]}\n id={`tab-${tabName}`}\n key={`tab-${uid}`}\n aria-controls={`pane-${tabName}`}\n role=\"tab\"\n aria-selected={pane.active}\n tabindex={tabindex}\n onFocus={() => setFocus()}\n onBlur={() => removeFocus()}\n onClick={(ev: MouseEvent) => {\n removeFocus()\n emit('tabClick', pane, tabName, ev)\n }}\n onKeydown={(ev: KeyboardEvent) => {\n if (\n closable &&\n (ev.code === EVENT_CODE.delete ||\n ev.code === EVENT_CODE.backspace)\n ) {\n emit('tabRemove', pane, ev)\n }\n }}\n >\n {...[tabLabelContent, btnClose]}\n </div>\n )\n })\n\n return (\n <div\n ref={el$}\n class={[\n ns.e('nav-wrap'),\n ns.is('scrollable', !!scrollable.value),\n ns.is(rootTabs.props.tabPosition),\n ]}\n >\n {scrollBtn}\n <div class={ns.e('nav-scroll')} ref={navScroll$}>\n <div\n class={[\n ns.e('nav'),\n ns.is(rootTabs.props.tabPosition),\n ns.is(\n 'stretch',\n props.stretch &&\n ['top', 'bottom'].includes(rootTabs.props.tabPosition)\n ),\n ]}\n ref={nav$}\n style={navStyle.value}\n role=\"tablist\"\n onKeydown={changeTab}\n >\n {...[\n !props.type ? (\n <TabBar ref={tabBarRef} tabs={[...props.panes]} />\n ) : null,\n tabs,\n ]}\n </div>\n </div>\n </div>\n )\n }\n },\n})\n\nexport type TabNavInstance = InstanceType<typeof TabNav> & {\n scrollToActiveTab: () => Promise<void>\n removeFocus: () => void\n}\nexport default TabNav\n"],"names":["tabNavProps","buildProps","panes","type","definePropType","Array","default","mutable","currentName","String","Number","editable","Boolean","values","stretch","tabNavEmits","tabClick","tab","tabName","ev","Event","tabRemove","COMPONENT_NAME","TabNav","defineComponent","name","props","emits","expose","emit","inject","tabsRootContextKey","throwError","ns","useNamespace","visibility","useDocumentVisibility","focused","useWindowFocus","navScroll$","ref","nav$","el$","tabBarRef","scrollable","navOffset","isFocus","focusable","sizeName","computed","includes","rootTabs","tabPosition","navStyle","dir","value","transform","scrollPrev","containerSize","capitalize","currentOffset","newOffset","scrollNext","scrollToActiveTab","activeTab","navScroll","navScrollBounding","maxOffset","isHorizontal","offsetWidth","activeTabBounding","right","top","bottom","max","update","navSize","prev","changeTab","event","step","EVENT_CODE","left","currentIndex","tabList","nextIndex","preventScroll","click","setFocus","watch","_createVNode","setTimeout","ElIcon","ArrowLeft","useResizeObserver","onUpdated","ArrowRight","removeFocus","e","Close","pane","index","closable","disabled","btnClose","delete","backspace","tabLabelContent","TabBar"],"mappings":";;;;;;;;;;;;;;;;;;;;AAsCaA,MAAAA,WAAW,GAAGC,kBAAU,CAAC;AACpCC,EAAAA,KAAK,EAAE;AACLC,IAAAA,IAAI,EAAEC,sBAAc,CAAoBC,KAApB,CADf;AAELC,IAAAA,OAAO,EAAE,MAAMC,kBAAO,CAAC,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AAChC,QAAA,OAAA,aAEGA,CAAAA,EAAE,EAAF,CAAA,EAAA,CAAA,cAAsB,CAACsF,WACtBtF,CAAE,EAAF,EAAA,CAAA,EAAA,CAAA,gBAAuBuF,CAAAA,OACzB,IAAA,CAAA,KAAA,EAAA,QAAA,CAAA,CAAA,QAAA,CAAA,QAAA,CAAA,KAAA,CAAA,WAAA,CAAA,CAAA,CAAA;AACA7E,QAAAA,KAAAA,EAAAA,IAAK;AACN,QAAA,OAAA,EAAA,QAAA,CAAA,KAAA;AACF,QAAA,MAAA,EAAA,SAAA;AA/BL,QAAA,WAiCS8E,EAAAA,SAAAA;AAGV,OA1DY,EAAb,CAAA,GAAA,CAAA,CAAA,KAAA,CAAA,IAAA,GAAAjB,eAAA,CAAAkB,iBAAA,EAAA;AA4DA,QAAA,KAAA,EAAA,SAAA;AAAA,QAAA,MAAA,EAAA,CAAA,GAAA,KAAA,CAAA,KAAA,CAAA;AAAA,OAAA,EAAA,IAAA,CAAA,GAGW,IACFV,EAAE,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAL,CADK,CAAA;AAHX,KAAA,CAAA;AAAA,GAAA;;;;;;;"}
|
@@ -133,7 +133,7 @@ const Tabs = vue.defineComponent({
|
|
133
133
|
"tabindex": "0",
|
134
134
|
"onClick": handleTabAdd,
|
135
135
|
"onKeydown": (ev) => {
|
136
|
-
if (
|
136
|
+
if ([aria.EVENT_CODE.enter, aria.EVENT_CODE.numpadEnter].includes(ev.code))
|
137
137
|
handleTabAdd();
|
138
138
|
}
|
139
139
|
}, [addSlot ? vue.renderSlot(slots, "add-icon") : vue.createVNode(index$2.ElIcon, {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"tabs.js","sources":["../../../../../../packages/components/tabs/src/tabs.tsx"],"sourcesContent":["import {\n computed,\n createVNode,\n defineComponent,\n getCurrentInstance,\n nextTick,\n provide,\n ref,\n renderSlot,\n watch,\n} from 'vue'\nimport {\n buildProps,\n definePropType,\n isNumber,\n isString,\n isUndefined,\n} from '@element-plus/utils'\nimport { EVENT_CODE, UPDATE_MODEL_EVENT } from '@element-plus/constants'\nimport ElIcon from '@element-plus/components/icon'\nimport { Plus } from '@element-plus/icons-vue'\nimport { useNamespace, useOrderedChildren } from '@element-plus/hooks'\nimport { tabsRootContextKey } from './constants'\nimport TabNav from './tab-nav'\n\nimport type { TabNavInstance } from './tab-nav'\nimport type { TabsPaneContext } from './constants'\nimport type { ExtractPropTypes, FunctionalComponent, VNode } from 'vue'\nimport type { Awaitable } from '@element-plus/utils'\n\nexport type TabPaneName = string | number\n\nexport const tabsProps = buildProps({\n /**\n * @description type of Tab\n */\n type: {\n type: String,\n values: ['card', 'border-card', ''],\n default: '',\n },\n /**\n * @description whether Tab is closable\n */\n closable: Boolean,\n /**\n * @description whether Tab is addable\n */\n addable: Boolean,\n /**\n * @description binding value, name of the selected tab\n */\n modelValue: {\n type: [String, Number],\n },\n /**\n * @description whether Tab is addable and closable\n */\n editable: Boolean,\n /**\n * @description position of tabs\n */\n tabPosition: {\n type: String,\n values: ['top', 'right', 'bottom', 'left'],\n default: 'top',\n },\n /**\n * @description hook function before switching tab. If `false` is returned or a `Promise` is returned and then is rejected, switching will be prevented\n */\n beforeLeave: {\n type: definePropType<\n (newName: TabPaneName, oldName: TabPaneName) => Awaitable<void | boolean>\n >(Function),\n default: () => true,\n },\n /**\n * @description whether width of tab automatically fits its container\n */\n stretch: Boolean,\n} as const)\nexport type TabsProps = ExtractPropTypes<typeof tabsProps>\n\nconst isPaneName = (value: unknown): value is string | number =>\n isString(value) || isNumber(value)\n\nexport const tabsEmits = {\n [UPDATE_MODEL_EVENT]: (name: TabPaneName) => isPaneName(name),\n tabClick: (pane: TabsPaneContext, ev: Event) => ev instanceof Event,\n tabChange: (name: TabPaneName) => isPaneName(name),\n edit: (paneName: TabPaneName | undefined, action: 'remove' | 'add') =>\n ['remove', 'add'].includes(action),\n tabRemove: (name: TabPaneName) => isPaneName(name),\n tabAdd: () => true,\n}\nexport type TabsEmits = typeof tabsEmits\n\nexport type TabsPanes = Record<number, TabsPaneContext>\n\nconst Tabs = defineComponent({\n name: 'ElTabs',\n\n props: tabsProps,\n emits: tabsEmits,\n\n setup(props, { emit, slots, expose }) {\n const ns = useNamespace('tabs')\n\n const isVertical = computed(() =>\n ['left', 'right'].includes(props.tabPosition)\n )\n\n const {\n children: panes,\n addChild: sortPane,\n removeChild: unregisterPane,\n } = useOrderedChildren<TabsPaneContext>(getCurrentInstance()!, 'ElTabPane')\n\n const nav$ = ref<TabNavInstance>()\n const currentName = ref<TabPaneName>(props.modelValue ?? '0')\n\n const setCurrentName = async (value?: TabPaneName, trigger = false) => {\n // should do nothing.\n if (currentName.value === value || isUndefined(value)) return\n\n try {\n const canLeave = await props.beforeLeave?.(value, currentName.value)\n if (canLeave !== false) {\n currentName.value = value\n if (trigger) {\n emit(UPDATE_MODEL_EVENT, value)\n emit('tabChange', value)\n }\n\n nav$.value?.removeFocus?.()\n }\n } catch {}\n }\n\n const handleTabClick = (\n tab: TabsPaneContext,\n tabName: TabPaneName,\n event: Event\n ) => {\n if (tab.props.disabled) return\n setCurrentName(tabName, true)\n emit('tabClick', tab, event)\n }\n\n const handleTabRemove = (pane: TabsPaneContext, ev: Event) => {\n if (pane.props.disabled || isUndefined(pane.props.name)) return\n ev.stopPropagation()\n emit('edit', pane.props.name, 'remove')\n emit('tabRemove', pane.props.name)\n }\n\n const handleTabAdd = () => {\n emit('edit', undefined, 'add')\n emit('tabAdd')\n }\n\n watch(\n () => props.modelValue,\n (modelValue) => setCurrentName(modelValue)\n )\n\n watch(currentName, async () => {\n await nextTick()\n nav$.value?.scrollToActiveTab()\n })\n\n provide(tabsRootContextKey, {\n props,\n currentName,\n registerPane: (pane: TabsPaneContext) => {\n panes.value.push(pane)\n },\n sortPane,\n unregisterPane,\n })\n\n expose({\n currentName,\n })\n const TabNavRenderer: FunctionalComponent<{ render: () => VNode }> = ({\n render,\n }) => {\n return render()\n }\n return () => {\n const addSlot = slots['add-icon']\n const newButton =\n props.editable || props.addable ? (\n <div\n class={[\n ns.e('new-tab'),\n isVertical.value && ns.e('new-tab-vertical'),\n ]}\n tabindex=\"0\"\n onClick={handleTabAdd}\n onKeydown={(ev: KeyboardEvent) => {\n if (ev.code === EVENT_CODE.enter) handleTabAdd()\n }}\n >\n {addSlot ? (\n renderSlot(slots, 'add-icon')\n ) : (\n <ElIcon class={ns.is('icon-plus')}>\n <Plus />\n </ElIcon>\n )}\n </div>\n ) : null\n\n const header = (\n <div\n class={[\n ns.e('header'),\n isVertical.value && ns.e('header-vertical'),\n ns.is(props.tabPosition),\n ]}\n >\n <TabNavRenderer\n render={() => {\n const hasLabelSlot = panes.value.some((pane) => pane.slots.label)\n return createVNode(\n TabNav,\n {\n ref: nav$,\n currentName: currentName.value,\n editable: props.editable,\n type: props.type,\n panes: panes.value,\n stretch: props.stretch,\n onTabClick: handleTabClick,\n onTabRemove: handleTabRemove,\n },\n { $stable: !hasLabelSlot }\n )\n }}\n />\n {newButton}\n </div>\n )\n\n const panels = (\n <div class={ns.e('content')}>{renderSlot(slots, 'default')}</div>\n )\n\n return (\n <div\n class={[\n ns.b(),\n ns.m(props.tabPosition),\n {\n [ns.m('card')]: props.type === 'card',\n [ns.m('border-card')]: props.type === 'border-card',\n },\n ]}\n >\n {panels}\n {header}\n </div>\n )\n }\n },\n})\n\nexport type TabsInstance = InstanceType<typeof Tabs> & {\n currentName: TabPaneName\n}\n\nexport default Tabs\n"],"names":["tabsProps","buildProps","type","values","default","closable","addable","modelValue","isString","isNumber","UPDATE_MODEL_EVENT","editable","defineComponent","tabPosition","useNamespace","computed","beforeLeave","definePropType","ref","stretch","Boolean","isUndefined","isPaneName","name","ev","tabChange","edit","tabRemove","tabAdd","Tabs","props","emits","expose","ns","children","addChild","removeChild","getCurrentInstance","nav$","currentName","watch","setCurrentName","value","canLeave","trigger","emit","handleTabClick","pane","handleTabAdd","_createVNode","ElIcon","undefined","Plus","scrollToActiveTab","panes","push","unregisterP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AA,IAAA,CAAA,KAAA,CAAA,KAAA,CAAA,CAAA;UAKO,wCAAqB,EAAA;YAAA,GAAA,EAAA,IAAA;YAAA,WAAA,EAAA,WAAA,CAAA,KAAA;YAGd,QAAGN,OAA0B,CAAA,QAAA;AACvCO,YAAAA,IAAMZ,EAAAA,KAAMa,CAAZ,IAAA;YAJwB,KAAA,EAAA,KAAA,CAAA,KAAA;YAAA,OAAA,EAAA,KAAA,CAAA,OAAA;AAO1BC,YAAAA,UAAAA,EAAAA,cAAAA;AAP0B,YAA5B,WAAA,EAAA,eAAA;AAUAxB,WAAO,EAAA;AACLO,YAAAA,OAAAA,EAAAA,CAAAA,YAAAA;AADK,WAAP,CAAA,CAAA;;OAGMkB,EAAAA,IAAAA,CAAAA,EAAAA,WAA+D,CAAC;AACpEC,MAAAA,MAAAA,MAAAA,GAAAA,eAAAA,CAAAA,KAAAA,EAAAA;AADoE,QAEhE,OAAA,EAAA,EAAA,CAAA,CAAA,CAAA,SAAA,CAAA;AACJ,OAAA,EAAA,CAAAC,cAAA,CAAA,KAAA,EAAA,SAAA,CAAA,CAAA,CAAA,CAAA;MAHF,OAAAV,eAAA,CAAA,KAAA,EAAA;;AAKA,UAAA,CAAO,EAAM,CAAA,CAAA,CAAA,MAAA,CAAA,GAAA,KAAA,CAAA,IAAA,KAAA,MAAA;AACX,UAAA,CAAA,EAAa,CAAA,CAAA,CAAA,sBAAQ,CAArB,IAAA,KAAA,aAAA;SACMW,CAAAA;AACJ,OAAA,EAAA,CAAA,MAAA,EAGM3B,MAAK,CAAA,CAAA,CAAA;AAHX,KAAA,CAAA;AAAA,GAAA;AAAA,CAAA;;;;;;"}
|
1
|
+
{"version":3,"file":"tabs.js","sources":["../../../../../../packages/components/tabs/src/tabs.tsx"],"sourcesContent":["import {\n computed,\n createVNode,\n defineComponent,\n getCurrentInstance,\n nextTick,\n provide,\n ref,\n renderSlot,\n watch,\n} from 'vue'\nimport {\n buildProps,\n definePropType,\n isNumber,\n isString,\n isUndefined,\n} from '@element-plus/utils'\nimport { EVENT_CODE, UPDATE_MODEL_EVENT } from '@element-plus/constants'\nimport ElIcon from '@element-plus/components/icon'\nimport { Plus } from '@element-plus/icons-vue'\nimport { useNamespace, useOrderedChildren } from '@element-plus/hooks'\nimport { tabsRootContextKey } from './constants'\nimport TabNav from './tab-nav'\n\nimport type { TabNavInstance } from './tab-nav'\nimport type { TabsPaneContext } from './constants'\nimport type { ExtractPropTypes, FunctionalComponent, VNode } from 'vue'\nimport type { Awaitable } from '@element-plus/utils'\n\nexport type TabPaneName = string | number\n\nexport const tabsProps = buildProps({\n /**\n * @description type of Tab\n */\n type: {\n type: String,\n values: ['card', 'border-card', ''],\n default: '',\n },\n /**\n * @description whether Tab is closable\n */\n closable: Boolean,\n /**\n * @description whether Tab is addable\n */\n addable: Boolean,\n /**\n * @description binding value, name of the selected tab\n */\n modelValue: {\n type: [String, Number],\n },\n /**\n * @description whether Tab is addable and closable\n */\n editable: Boolean,\n /**\n * @description position of tabs\n */\n tabPosition: {\n type: String,\n values: ['top', 'right', 'bottom', 'left'],\n default: 'top',\n },\n /**\n * @description hook function before switching tab. If `false` is returned or a `Promise` is returned and then is rejected, switching will be prevented\n */\n beforeLeave: {\n type: definePropType<\n (newName: TabPaneName, oldName: TabPaneName) => Awaitable<void | boolean>\n >(Function),\n default: () => true,\n },\n /**\n * @description whether width of tab automatically fits its container\n */\n stretch: Boolean,\n} as const)\nexport type TabsProps = ExtractPropTypes<typeof tabsProps>\n\nconst isPaneName = (value: unknown): value is string | number =>\n isString(value) || isNumber(value)\n\nexport const tabsEmits = {\n [UPDATE_MODEL_EVENT]: (name: TabPaneName) => isPaneName(name),\n tabClick: (pane: TabsPaneContext, ev: Event) => ev instanceof Event,\n tabChange: (name: TabPaneName) => isPaneName(name),\n edit: (paneName: TabPaneName | undefined, action: 'remove' | 'add') =>\n ['remove', 'add'].includes(action),\n tabRemove: (name: TabPaneName) => isPaneName(name),\n tabAdd: () => true,\n}\nexport type TabsEmits = typeof tabsEmits\n\nexport type TabsPanes = Record<number, TabsPaneContext>\n\nconst Tabs = defineComponent({\n name: 'ElTabs',\n\n props: tabsProps,\n emits: tabsEmits,\n\n setup(props, { emit, slots, expose }) {\n const ns = useNamespace('tabs')\n\n const isVertical = computed(() =>\n ['left', 'right'].includes(props.tabPosition)\n )\n\n const {\n children: panes,\n addChild: sortPane,\n removeChild: unregisterPane,\n } = useOrderedChildren<TabsPaneContext>(getCurrentInstance()!, 'ElTabPane')\n\n const nav$ = ref<TabNavInstance>()\n const currentName = ref<TabPaneName>(props.modelValue ?? '0')\n\n const setCurrentName = async (value?: TabPaneName, trigger = false) => {\n // should do nothing.\n if (currentName.value === value || isUndefined(value)) return\n\n try {\n const canLeave = await props.beforeLeave?.(value, currentName.value)\n if (canLeave !== false) {\n currentName.value = value\n if (trigger) {\n emit(UPDATE_MODEL_EVENT, value)\n emit('tabChange', value)\n }\n\n nav$.value?.removeFocus?.()\n }\n } catch {}\n }\n\n const handleTabClick = (\n tab: TabsPaneContext,\n tabName: TabPaneName,\n event: Event\n ) => {\n if (tab.props.disabled) return\n setCurrentName(tabName, true)\n emit('tabClick', tab, event)\n }\n\n const handleTabRemove = (pane: TabsPaneContext, ev: Event) => {\n if (pane.props.disabled || isUndefined(pane.props.name)) return\n ev.stopPropagation()\n emit('edit', pane.props.name, 'remove')\n emit('tabRemove', pane.props.name)\n }\n\n const handleTabAdd = () => {\n emit('edit', undefined, 'add')\n emit('tabAdd')\n }\n\n watch(\n () => props.modelValue,\n (modelValue) => setCurrentName(modelValue)\n )\n\n watch(currentName, async () => {\n await nextTick()\n nav$.value?.scrollToActiveTab()\n })\n\n provide(tabsRootContextKey, {\n props,\n currentName,\n registerPane: (pane: TabsPaneContext) => {\n panes.value.push(pane)\n },\n sortPane,\n unregisterPane,\n })\n\n expose({\n currentName,\n })\n const TabNavRenderer: FunctionalComponent<{ render: () => VNode }> = ({\n render,\n }) => {\n return render()\n }\n return () => {\n const addSlot = slots['add-icon']\n const newButton =\n props.editable || props.addable ? (\n <div\n class={[\n ns.e('new-tab'),\n isVertical.value && ns.e('new-tab-vertical'),\n ]}\n tabindex=\"0\"\n onClick={handleTabAdd}\n onKeydown={(ev: KeyboardEvent) => {\n if ([EVENT_CODE.enter, EVENT_CODE.numpadEnter].includes(ev.code))\n handleTabAdd()\n }}\n >\n {addSlot ? (\n renderSlot(slots, 'add-icon')\n ) : (\n <ElIcon class={ns.is('icon-plus')}>\n <Plus />\n </ElIcon>\n )}\n </div>\n ) : null\n\n const header = (\n <div\n class={[\n ns.e('header'),\n isVertical.value && ns.e('header-vertical'),\n ns.is(props.tabPosition),\n ]}\n >\n <TabNavRenderer\n render={() => {\n const hasLabelSlot = panes.value.some((pane) => pane.slots.label)\n return createVNode(\n TabNav,\n {\n ref: nav$,\n currentName: currentName.value,\n editable: props.editable,\n type: props.type,\n panes: panes.value,\n stretch: props.stretch,\n onTabClick: handleTabClick,\n onTabRemove: handleTabRemove,\n },\n { $stable: !hasLabelSlot }\n )\n }}\n />\n {newButton}\n </div>\n )\n\n const panels = (\n <div class={ns.e('content')}>{renderSlot(slots, 'default')}</div>\n )\n\n return (\n <div\n class={[\n ns.b(),\n ns.m(props.tabPosition),\n {\n [ns.m('card')]: props.type === 'card',\n [ns.m('border-card')]: props.type === 'border-card',\n },\n ]}\n >\n {panels}\n {header}\n </div>\n )\n }\n },\n})\n\nexport type TabsInstance = InstanceType<typeof Tabs> & {\n currentName: TabPaneName\n}\n\nexport default Tabs\n"],"names":["tabsProps","buildProps","type","values","default","closable","addable","modelValue","isString","isNumber","UPDATE_MODEL_EVENT","editable","defineComponent","tabPosition","useNamespace","computed","beforeLeave","definePropType","ref","stretch","Boolean","isUndefined","isPaneName","name","ev","tabChange","edit","tabRemove","tabAdd","Tabs","props","emits","expose","ns","children","addChild","removeChild","getCurrentInstance","nav$","currentName","watch","setCurrentName","value","canLeave","trigger","emit","handleTabClick","pane","EVENT_CODE","handleTabAdd","_createVNode","ElIcon","undefined","Pl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up(__props, { emit }) {
|
28
28
|
const props = __props;
|
29
|
+
const pickerBase = vue.inject("EP_PICKER_BASE");
|
30
|
+
const { isRange } = pickerBase.props;
|
29
31
|
const ns = index.useNamespace("time");
|
30
32
|
const { getHoursList, getMinutesList, getSecondsList } = useTimePicker.getTimeLists(props.disabledHours, props.disabledMinutes, props.disabledSeconds);
|
31
33
|
let isScrolling = false;
|
@@ -50,10 +52,12 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
50
52
|
});
|
51
53
|
const timeList = vue.computed(() => {
|
52
54
|
const { hours, minutes } = vue.unref(timePartials);
|
55
|
+
const { role, spinnerDate } = props;
|
56
|
+
const compare = !isRange ? spinnerDate : void 0;
|
53
57
|
return {
|
54
|
-
hours: getHoursList(
|
55
|
-
minutes: getMinutesList(hours,
|
56
|
-
seconds: getSecondsList(hours, minutes,
|
58
|
+
hours: getHoursList(role, compare),
|
59
|
+
minutes: getMinutesList(hours, role, compare),
|
60
|
+
seconds: getSecondsList(hours, minutes, role, compare)
|
57
61
|
};
|
58
62
|
});
|
59
63
|
const arrowControlTimeList = vue.computed(() => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"basic-time-spinner.js","sources":["../../../../../../../packages/components/time-picker/src/time-picker-com/basic-time-spinner.vue"],"sourcesContent":["<template>\n <div :class=\"[ns.b('spinner'), { 'has-seconds': showSeconds }]\">\n <template v-if=\"!arrowControl\">\n <el-scrollbar\n v-for=\"item in spinnerItems\"\n :key=\"item\"\n :ref=\"(scrollbar: unknown) => setRef(scrollbar as any, item)\"\n :class=\"ns.be('spinner', 'wrapper')\"\n wrap-style=\"max-height: inherit;\"\n :view-class=\"ns.be('spinner', 'list')\"\n noresize\n tag=\"ul\"\n @mouseenter=\"emitSelectRange(item)\"\n @mousemove=\"adjustCurrentSpinner(item)\"\n >\n <li\n v-for=\"(disabled, key) in timeList[item]\"\n :key=\"key\"\n :class=\"[\n ns.be('spinner', 'item'),\n ns.is('active', key === timePartials[item]),\n ns.is('disabled', disabled),\n ]\"\n @click=\"handleClick(item, { value: key, disabled })\"\n >\n <template v-if=\"item === 'hours'\">\n {{ ('0' + (amPmMode ? key % 12 || 12 : key)).slice(-2)\n }}{{ getAmPmFlag(key) }}\n </template>\n <template v-else>\n {{ ('0' + key).slice(-2) }}\n </template>\n </li>\n </el-scrollbar>\n </template>\n <template v-if=\"arrowControl\">\n <div\n v-for=\"item in spinnerItems\"\n :key=\"item\"\n :class=\"[ns.be('spinner', 'wrapper'), ns.is('arrow')]\"\n @mouseenter=\"emitSelectRange(item)\"\n >\n <el-icon\n v-repeat-click=\"onDecrement\"\n :class=\"['arrow-up', ns.be('spinner', 'arrow')]\"\n >\n <arrow-up />\n </el-icon>\n <el-icon\n v-repeat-click=\"onIncrement\"\n :class=\"['arrow-down', ns.be('spinner', 'arrow')]\"\n >\n <arrow-down />\n </el-icon>\n <ul :class=\"ns.be('spinner', 'list')\">\n <li\n v-for=\"(time, key) in arrowControlTimeList[item]\"\n :key=\"key\"\n :class=\"[\n ns.be('spinner', 'item'),\n ns.is('active', time === timePartials[item]),\n ns.is('disabled', timeList[item][time!]),\n ]\"\n >\n <template v-if=\"isNumber(time)\">\n <template v-if=\"item === 'hours'\">\n {{ ('0' + (amPmMode ? time % 12 || 12 : time)).slice(-2)\n }}{{ getAmPmFlag(time) }}\n </template>\n <template v-else>\n {{ ('0' + time).slice(-2) }}\n </template>\n </template>\n </li>\n </ul>\n </div>\n </template>\n </div>\n</template>\n<script lang=\"ts\" setup>\nimport { computed, nextTick, onMounted, ref, unref, watch } from 'vue'\nimport { debounce } from 'lodash-unified'\nimport { vRepeatClick } from '@element-plus/directives'\nimport ElScrollbar from '@element-plus/components/scrollbar'\nimport ElIcon from '@element-plus/components/icon'\nimport { ArrowDown, ArrowUp } from '@element-plus/icons-vue'\nimport { useNamespace } from '@element-plus/hooks'\nimport { getStyle, isNumber } from '@element-plus/utils'\nimport { timeUnits } from '../constants'\nimport { buildTimeList } from '../utils'\nimport { basicTimeSpinnerProps } from '../props/basic-time-spinner'\nimport { getTimeLists } from '../composables/use-time-picker'\n\nimport type { Ref } from 'vue'\nimport type { ScrollbarInstance } from '@element-plus/components/scrollbar'\nimport type { TimeUnit } from '../constants'\nimport type { TimeList } from '../utils'\n\nconst props = defineProps(basicTimeSpinnerProps)\nconst emit = defineEmits(['change', 'select-range', 'set-option'])\n\nconst ns = useNamespace('time')\n\nconst { getHoursList, getMinutesList, getSecondsList } = getTimeLists(\n props.disabledHours,\n props.disabledMinutes,\n props.disabledSeconds\n)\n\n// data\nlet isScrolling = false\n\nconst currentScrollbar = ref<TimeUnit>()\nconst listHoursRef = ref<ScrollbarInstance>()\nconst listMinutesRef = ref<ScrollbarInstance>()\nconst listSecondsRef = ref<ScrollbarInstance>()\nconst listRefsMap: Record<TimeUnit, Ref<ScrollbarInstance | undefined>> = {\n hours: listHoursRef,\n minutes: listMinutesRef,\n seconds: listSecondsRef,\n}\n\n// computed\nconst spinnerItems = computed(() => {\n return props.showSeconds ? timeUnits : timeUnits.slice(0, 2)\n})\n\nconst timePartials = computed<Record<TimeUnit, number>>(() => {\n const { spinnerDate } = props\n const hours = spinnerDate.hour()\n const minutes = spinnerDate.minute()\n const seconds = spinnerDate.second()\n return { hours, minutes, seconds }\n})\n\nconst timeList = computed(() => {\n const { hours, minutes } = unref(timePartials)\n return {\n hours: getHoursList(props.role),\n minutes: getMinutesList(hours, props.role),\n seconds: getSecondsList(hours, minutes, props.role),\n }\n})\n\nconst arrowControlTimeList = computed<Record<TimeUnit, TimeList>>(() => {\n const { hours, minutes, seconds } = unref(timePartials)\n\n return {\n hours: buildTimeList(hours, 23),\n minutes: buildTimeList(minutes, 59),\n seconds: buildTimeList(seconds, 59),\n }\n})\n\nconst debouncedResetScroll = debounce((type) => {\n isScrolling = false\n adjustCurrentSpinner(type)\n}, 200)\n\nconst getAmPmFlag = (hour: number) => {\n const shouldShowAmPm = !!props.amPmMode\n if (!shouldShowAmPm) return ''\n const isCapital = props.amPmMode === 'A'\n // todo locale\n let content = hour < 12 ? ' am' : ' pm'\n if (isCapital) content = content.toUpperCase()\n return content\n}\n\nconst emitSelectRange = (type: TimeUnit) => {\n let range\n\n switch (type) {\n case 'hours':\n range = [0, 2]\n break\n case 'minutes':\n range = [3, 5]\n break\n case 'seconds':\n range = [6, 8]\n break\n }\n const [left, right] = range\n\n emit('select-range', left, right)\n currentScrollbar.value = type\n}\n\nconst adjustCurrentSpinner = (type: TimeUnit) => {\n adjustSpinner(type, unref(timePartials)[type])\n}\n\nconst adjustSpinners = () => {\n adjustCurrentSpinner('hours')\n adjustCurrentSpinner('minutes')\n adjustCurrentSpinner('seconds')\n}\n\nconst getScrollbarElement = (el: HTMLElement) =>\n el.querySelector(`.${ns.namespace.value}-scrollbar__wrap`) as HTMLElement\n\nconst adjustSpinner = (type: TimeUnit, value: number) => {\n if (props.arrowControl) return\n const scrollbar = unref(listRefsMap[type])\n if (scrollbar && scrollbar.$el) {\n getScrollbarElement(scrollbar.$el).scrollTop = Math.max(\n 0,\n value * typeItemHeight(type)\n )\n }\n}\n\nconst typeItemHeight = (type: TimeUnit): number => {\n const scrollbar = unref(listRefsMap[type])\n const listItem = scrollbar?.$el.querySelector('li')\n if (listItem) {\n return Number.parseFloat(getStyle(listItem, 'height')) || 0\n }\n return 0\n}\n\nconst onIncrement = () => {\n scrollDown(1)\n}\n\nconst onDecrement = () => {\n scrollDown(-1)\n}\n\nconst scrollDown = (step: number) => {\n if (!currentScrollbar.value) {\n emitSelectRange('hours')\n }\n\n const label = currentScrollbar.value!\n const now = unref(timePartials)[label]\n const total = currentScrollbar.value === 'hours' ? 24 : 60\n const next = findNextUnDisabled(label, now, step, total)\n\n modifyDateField(label, next)\n adjustSpinner(label, next)\n nextTick(() => emitSelectRange(label))\n}\n\nconst findNextUnDisabled = (\n type: TimeUnit,\n now: number,\n step: number,\n total: number\n) => {\n let next = (now + step + total) % total\n const list = unref(timeList)[type]\n while (list[next] && next !== now) {\n next = (next + step + total) % total\n }\n return next\n}\n\nconst modifyDateField = (type: TimeUnit, value: number) => {\n const list = unref(timeList)[type]\n const isDisabled = list[value]\n if (isDisabled) return\n\n const { hours, minutes, seconds } = unref(timePartials)\n\n let changeTo\n switch (type) {\n case 'hours':\n changeTo = props.spinnerDate.hour(value).minute(minutes).second(seconds)\n break\n case 'minutes':\n changeTo = props.spinnerDate.hour(hours).minute(value).second(seconds)\n break\n case 'seconds':\n changeTo = props.spinnerDate.hour(hours).minute(minutes).second(value)\n break\n }\n emit('change', changeTo)\n}\n\nconst handleClick = (\n type: TimeUnit,\n { value, disabled }: { value: number; disabled: boolean }\n) => {\n if (!disabled) {\n modifyDateField(type, value)\n emitSelectRange(type)\n adjustSpinner(type, value)\n }\n}\n\nconst handleScroll = (type: TimeUnit) => {\n const scrollbar = unref(listRefsMap[type])\n if (!scrollbar) return\n\n isScrolling = true\n debouncedResetScroll(type)\n const value = Math.min(\n Math.round(\n (getScrollbarElement(scrollbar.$el).scrollTop -\n (scrollBarHeight(type) * 0.5 - 10) / typeItemHeight(type) +\n 3) /\n typeItemHeight(type)\n ),\n type === 'hours' ? 23 : 59\n )\n modifyDateField(type, value)\n}\n\nconst scrollBarHeight = (type: TimeUnit) => {\n return unref(listRefsMap[type])!.$el.offsetHeight\n}\n\nconst bindScrollEvent = () => {\n const bindFunction = (type: TimeUnit) => {\n const scrollbar = unref(listRefsMap[type])\n if (scrollbar && scrollbar.$el) {\n getScrollbarElement(scrollbar.$el).onscroll = () => {\n // TODO: scroll is emitted when set scrollTop programmatically\n // should find better solutions in the future!\n handleScroll(type)\n }\n }\n }\n bindFunction('hours')\n bindFunction('minutes')\n bindFunction('seconds')\n}\n\nonMounted(() => {\n nextTick(() => {\n !props.arrowControl && bindScrollEvent()\n adjustSpinners()\n // set selection on the first hour part\n if (props.role === 'start') emitSelectRange('hours')\n })\n})\n\nconst setRef = (scrollbar: ScrollbarInstance | null, type: TimeUnit) => {\n listRefsMap[type].value = scrollbar ?? undefined\n}\n\nemit('set-option', [`${props.role}_scrollDown`, scrollDown])\nemit('set-option', [`${props.role}_emitSelectRange`, emitSelectRange])\n\nwatch(\n () => props.spinnerDate,\n () => {\n if (isScrolling) return\n adjustSpinners()\n }\n)\n</script>\n"],"names":["useNamespace","getTimeLists","ref","computed","timeUnits","unref","buildTimeList","debounce","getStyle","nextTick","onMounted","watch","_openBlock","_createElementBlock","_normalizeClass","_unref","_Fragment","_renderList","_createBlock","ElScrollbar"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqGA,IAAM,MAAA,EAAA,GAAKA,mBAAa,MAAM,CAAA,CAAA;AAE9B,IAAA,MAAM,EAAE,YAAA,EAAc,cAAgB,EAAA,cAAA,EAAmB,GAAAC,0BAAA,CAAA,KAAA,CAAA,aAAA,EAAA,KAAA,CAAA,eAAA,EAAA,KAAA,CAAA,eAAA,CAAA,CAAA;AAAA,IAAA,IACjD,WAAA,GAAA,KAAA,CAAA;AAAA,IAAA,MACA,gBAAA,GAAAC,OAAA,EAAA,CAAA;AAAA,IAAA,MACA,YAAA,GAAAA,OAAA,EAAA,CAAA;AAAA,IACR,MAAA,cAAA,GAAAA,OAAA,EAAA,CAAA;AAGA,IAAA,MAAkB,cAAA,GAAAA,OAAA,EAAA,CAAA;AAElB,IAAA,MAAM;AACN,MAAA,mBAAqB;AACrB,MAAA,uBAA8C;AAC9C,MAAA,uBAA8C;AAC9C,KAAA,CAAA;AAA0E,IAAA,MACjE,YAAA,GAAAC,YAAA,CAAA,MAAA;AAAA,MACP,OAAS,KAAA,CAAA,WAAA,GAAAC,mBAAA,GAAAA,mBAAA,CAAA,KAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA;AAAA,KAAA,CACT,CAAS;AAAA,IACX,MAAA,YAAA,GAAAD,YAAA,CAAA,MAAA;AAGA,MAAM,MAAA,EAAA,WAAe,UAAe,CAAA;AAClC,MAAA,MAAA,QAA2B,WAAA,CAAA,IAAA,EAAA,CAAA;AAAgC,MAC5D,MAAA,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SAAA,CAAAI,mBAAA,CAAA,EAAA;AAAA,YACjB,GAAA,EAAA,IAAA;AAAA,YACF,OAAA,EAAA,IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
1
|
+
{"version":3,"file":"basic-time-spinner.js","sources":["../../../../../../../packages/components/time-picker/src/time-picker-com/basic-time-spinner.vue"],"sourcesContent":["<template>\n <div :class=\"[ns.b('spinner'), { 'has-seconds': showSeconds }]\">\n <template v-if=\"!arrowControl\">\n <el-scrollbar\n v-for=\"item in spinnerItems\"\n :key=\"item\"\n :ref=\"(scrollbar: unknown) => setRef(scrollbar as any, item)\"\n :class=\"ns.be('spinner', 'wrapper')\"\n wrap-style=\"max-height: inherit;\"\n :view-class=\"ns.be('spinner', 'list')\"\n noresize\n tag=\"ul\"\n @mouseenter=\"emitSelectRange(item)\"\n @mousemove=\"adjustCurrentSpinner(item)\"\n >\n <li\n v-for=\"(disabled, key) in timeList[item]\"\n :key=\"key\"\n :class=\"[\n ns.be('spinner', 'item'),\n ns.is('active', key === timePartials[item]),\n ns.is('disabled', disabled),\n ]\"\n @click=\"handleClick(item, { value: key, disabled })\"\n >\n <template v-if=\"item === 'hours'\">\n {{ ('0' + (amPmMode ? key % 12 || 12 : key)).slice(-2)\n }}{{ getAmPmFlag(key) }}\n </template>\n <template v-else>\n {{ ('0' + key).slice(-2) }}\n </template>\n </li>\n </el-scrollbar>\n </template>\n <template v-if=\"arrowControl\">\n <div\n v-for=\"item in spinnerItems\"\n :key=\"item\"\n :class=\"[ns.be('spinner', 'wrapper'), ns.is('arrow')]\"\n @mouseenter=\"emitSelectRange(item)\"\n >\n <el-icon\n v-repeat-click=\"onDecrement\"\n :class=\"['arrow-up', ns.be('spinner', 'arrow')]\"\n >\n <arrow-up />\n </el-icon>\n <el-icon\n v-repeat-click=\"onIncrement\"\n :class=\"['arrow-down', ns.be('spinner', 'arrow')]\"\n >\n <arrow-down />\n </el-icon>\n <ul :class=\"ns.be('spinner', 'list')\">\n <li\n v-for=\"(time, key) in arrowControlTimeList[item]\"\n :key=\"key\"\n :class=\"[\n ns.be('spinner', 'item'),\n ns.is('active', time === timePartials[item]),\n ns.is('disabled', timeList[item][time!]),\n ]\"\n >\n <template v-if=\"isNumber(time)\">\n <template v-if=\"item === 'hours'\">\n {{ ('0' + (amPmMode ? time % 12 || 12 : time)).slice(-2)\n }}{{ getAmPmFlag(time) }}\n </template>\n <template v-else>\n {{ ('0' + time).slice(-2) }}\n </template>\n </template>\n </li>\n </ul>\n </div>\n </template>\n </div>\n</template>\n<script lang=\"ts\" setup>\nimport { computed, inject, nextTick, onMounted, ref, unref, watch } from 'vue'\nimport { debounce } from 'lodash-unified'\nimport { vRepeatClick } from '@element-plus/directives'\nimport ElScrollbar from '@element-plus/components/scrollbar'\nimport ElIcon from '@element-plus/components/icon'\nimport { ArrowDown, ArrowUp } from '@element-plus/icons-vue'\nimport { useNamespace } from '@element-plus/hooks'\nimport { getStyle, isNumber } from '@element-plus/utils'\nimport { timeUnits } from '../constants'\nimport { buildTimeList } from '../utils'\nimport { basicTimeSpinnerProps } from '../props/basic-time-spinner'\nimport { getTimeLists } from '../composables/use-time-picker'\n\nimport type { Ref } from 'vue'\nimport type { ScrollbarInstance } from '@element-plus/components/scrollbar'\nimport type { TimeUnit } from '../constants'\nimport type { TimeList } from '../utils'\n\nconst props = defineProps(basicTimeSpinnerProps)\nconst pickerBase = inject('EP_PICKER_BASE') as any\nconst { isRange } = pickerBase.props\nconst emit = defineEmits(['change', 'select-range', 'set-option'])\n\nconst ns = useNamespace('time')\n\nconst { getHoursList, getMinutesList, getSecondsList } = getTimeLists(\n props.disabledHours,\n props.disabledMinutes,\n props.disabledSeconds\n)\n\n// data\nlet isScrolling = false\n\nconst currentScrollbar = ref<TimeUnit>()\nconst listHoursRef = ref<ScrollbarInstance>()\nconst listMinutesRef = ref<ScrollbarInstance>()\nconst listSecondsRef = ref<ScrollbarInstance>()\nconst listRefsMap: Record<TimeUnit, Ref<ScrollbarInstance | undefined>> = {\n hours: listHoursRef,\n minutes: listMinutesRef,\n seconds: listSecondsRef,\n}\n\n// computed\nconst spinnerItems = computed(() => {\n return props.showSeconds ? timeUnits : timeUnits.slice(0, 2)\n})\n\nconst timePartials = computed<Record<TimeUnit, number>>(() => {\n const { spinnerDate } = props\n const hours = spinnerDate.hour()\n const minutes = spinnerDate.minute()\n const seconds = spinnerDate.second()\n return { hours, minutes, seconds }\n})\n\nconst timeList = computed(() => {\n const { hours, minutes } = unref(timePartials)\n const { role, spinnerDate } = props\n const compare = !isRange ? spinnerDate : undefined\n return {\n hours: getHoursList(role, compare),\n minutes: getMinutesList(hours, role, compare),\n seconds: getSecondsList(hours, minutes, role, compare),\n }\n})\n\nconst arrowControlTimeList = computed<Record<TimeUnit, TimeList>>(() => {\n const { hours, minutes, seconds } = unref(timePartials)\n\n return {\n hours: buildTimeList(hours, 23),\n minutes: buildTimeList(minutes, 59),\n seconds: buildTimeList(seconds, 59),\n }\n})\n\nconst debouncedResetScroll = debounce((type) => {\n isScrolling = false\n adjustCurrentSpinner(type)\n}, 200)\n\nconst getAmPmFlag = (hour: number) => {\n const shouldShowAmPm = !!props.amPmMode\n if (!shouldShowAmPm) return ''\n const isCapital = props.amPmMode === 'A'\n // todo locale\n let content = hour < 12 ? ' am' : ' pm'\n if (isCapital) content = content.toUpperCase()\n return content\n}\n\nconst emitSelectRange = (type: TimeUnit) => {\n let range\n\n switch (type) {\n case 'hours':\n range = [0, 2]\n break\n case 'minutes':\n range = [3, 5]\n break\n case 'seconds':\n range = [6, 8]\n break\n }\n const [left, right] = range\n\n emit('select-range', left, right)\n currentScrollbar.value = type\n}\n\nconst adjustCurrentSpinner = (type: TimeUnit) => {\n adjustSpinner(type, unref(timePartials)[type])\n}\n\nconst adjustSpinners = () => {\n adjustCurrentSpinner('hours')\n adjustCurrentSpinner('minutes')\n adjustCurrentSpinner('seconds')\n}\n\nconst getScrollbarElement = (el: HTMLElement) =>\n el.querySelector(`.${ns.namespace.value}-scrollbar__wrap`) as HTMLElement\n\nconst adjustSpinner = (type: TimeUnit, value: number) => {\n if (props.arrowControl) return\n const scrollbar = unref(listRefsMap[type])\n if (scrollbar && scrollbar.$el) {\n getScrollbarElement(scrollbar.$el).scrollTop = Math.max(\n 0,\n value * typeItemHeight(type)\n )\n }\n}\n\nconst typeItemHeight = (type: TimeUnit): number => {\n const scrollbar = unref(listRefsMap[type])\n const listItem = scrollbar?.$el.querySelector('li')\n if (listItem) {\n return Number.parseFloat(getStyle(listItem, 'height')) || 0\n }\n return 0\n}\n\nconst onIncrement = () => {\n scrollDown(1)\n}\n\nconst onDecrement = () => {\n scrollDown(-1)\n}\n\nconst scrollDown = (step: number) => {\n if (!currentScrollbar.value) {\n emitSelectRange('hours')\n }\n\n const label = currentScrollbar.value!\n const now = unref(timePartials)[label]\n const total = currentScrollbar.value === 'hours' ? 24 : 60\n const next = findNextUnDisabled(label, now, step, total)\n\n modifyDateField(label, next)\n adjustSpinner(label, next)\n nextTick(() => emitSelectRange(label))\n}\n\nconst findNextUnDisabled = (\n type: TimeUnit,\n now: number,\n step: number,\n total: number\n) => {\n let next = (now + step + total) % total\n const list = unref(timeList)[type]\n while (list[next] && next !== now) {\n next = (next + step + total) % total\n }\n return next\n}\n\nconst modifyDateField = (type: TimeUnit, value: number) => {\n const list = unref(timeList)[type]\n const isDisabled = list[value]\n if (isDisabled) return\n\n const { hours, minutes, seconds } = unref(timePartials)\n\n let changeTo\n switch (type) {\n case 'hours':\n changeTo = props.spinnerDate.hour(value).minute(minutes).second(seconds)\n break\n case 'minutes':\n changeTo = props.spinnerDate.hour(hours).minute(value).second(seconds)\n break\n case 'seconds':\n changeTo = props.spinnerDate.hour(hours).minute(minutes).second(value)\n break\n }\n emit('change', changeTo)\n}\n\nconst handleClick = (\n type: TimeUnit,\n { value, disabled }: { value: number; disabled: boolean }\n) => {\n if (!disabled) {\n modifyDateField(type, value)\n emitSelectRange(type)\n adjustSpinner(type, value)\n }\n}\n\nconst handleScroll = (type: TimeUnit) => {\n const scrollbar = unref(listRefsMap[type])\n if (!scrollbar) return\n\n isScrolling = true\n debouncedResetScroll(type)\n const value = Math.min(\n Math.round(\n (getScrollbarElement(scrollbar.$el).scrollTop -\n (scrollBarHeight(type) * 0.5 - 10) / typeItemHeight(type) +\n 3) /\n typeItemHeight(type)\n ),\n type === 'hours' ? 23 : 59\n )\n modifyDateField(type, value)\n}\n\nconst scrollBarHeight = (type: TimeUnit) => {\n return unref(listRefsMap[type])!.$el.offsetHeight\n}\n\nconst bindScrollEvent = () => {\n const bindFunction = (type: TimeUnit) => {\n const scrollbar = unref(listRefsMap[type])\n if (scrollbar && scrollbar.$el) {\n getScrollbarElement(scrollbar.$el).onscroll = () => {\n // TODO: scroll is emitted when set scrollTop programmatically\n // should find better solutions in the future!\n handleScroll(type)\n }\n }\n }\n bindFunction('hours')\n bindFunction('minutes')\n bindFunction('seconds')\n}\n\nonMounted(() => {\n nextTick(() => {\n !props.arrowControl && bindScrollEvent()\n adjustSpinners()\n // set selection on the first hour part\n if (props.role === 'start') emitSelectRange('hours')\n })\n})\n\nconst setRef = (scrollbar: ScrollbarInstance | null, type: TimeUnit) => {\n listRefsMap[type].value = scrollbar ?? undefined\n}\n\nemit('set-option', [`${props.role}_scrollDown`, scrollDown])\nemit('set-option', [`${props.role}_emitSelectRange`, emitSelectRange])\n\nwatch(\n () => props.spinnerDate,\n () => {\n if (isScrolling) return\n adjustSpinners()\n }\n)\n</script>\n"],"names":["inject","useNamespace","getTimeLists","ref","computed","timeUnits","unref","buildTimeList","debounce","getStyle","nextTick","onMounted","watch","_openBlock","_createElementBlock","_normalizeClass","_unref","_Fragment","_renderList","_createBlock","ElScrollbar"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmGA,IAAM,MAAA,UAAA,GAAaA,WAAO,gBAAgB,CAAA,CAAA;AAC1C,IAAM,MAAA,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
@@ -18,7 +18,7 @@ const useTooltipTriggerProps = runtime.buildProps({
|
|
18
18
|
},
|
19
19
|
triggerKeys: {
|
20
20
|
type: runtime.definePropType(Array),
|
21
|
-
default: () => [aria.EVENT_CODE.enter, aria.EVENT_CODE.space]
|
21
|
+
default: () => [aria.EVENT_CODE.enter, aria.EVENT_CODE.numpadEnter, aria.EVENT_CODE.space]
|
22
22
|
}
|
23
23
|
});
|
24
24
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"trigger.js","sources":["../../../../../../packages/components/tooltip/src/trigger.ts"],"sourcesContent":["import { buildProps, definePropType } from '@element-plus/utils'\nimport { popperTriggerProps } from '@element-plus/components/popper'\nimport { EVENT_CODE } from '@element-plus/constants'\nimport type { Arrayable } from '@element-plus/utils'\nimport type { ExtractPropTypes } from 'vue'\n\nexport type TooltipTriggerType = 'hover' | 'focus' | 'click' | 'contextmenu'\n\nexport const useTooltipTriggerProps = buildProps({\n ...popperTriggerProps,\n /**\n * @description whether Tooltip is disabled\n */\n disabled: Boolean,\n /**\n * @description How should the tooltip be triggered (to show)\n */\n trigger: {\n type: definePropType<Arrayable<TooltipTriggerType>>([String, Array]),\n default: 'hover',\n },\n /**\n * @description When you click the mouse to focus on the trigger element, you can define a set of keyboard codes to control the display of tooltip through the keyboard\n */\n triggerKeys: {\n type: definePropType<string[]>(Array),\n default: () => [EVENT_CODE.enter, EVENT_CODE.space],\n },\n} as const)\n\nexport type ElTooltipTriggerProps = ExtractPropTypes<\n typeof useTooltipTriggerProps\n>\n"],"names":["buildProps","popperTriggerProps","definePropType","EVENT_CODE"],"mappings":";;;;;;;;;;;AAGY,MAAC,sBAAsB,GAAGA,kBAAU,CAAC;AACjD,EAAE,GAAGC,0BAAkB;AACvB,EAAE,QAAQ,EAAE,OAAO;AACnB,EAAE,OAAO,EAAE;AACX,IAAI,IAAI,EAAEC,sBAAc,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AACzC,IAAI,OAAO,EAAE,OAAO;AACpB,GAAG;AACH,EAAE,WAAW,EAAE;AACf,IAAI,IAAI,EAAEA,sBAAc,CAAC,KAAK,CAAC;AAC/B,IAAI,OAAO,EAAE,MAAM,CAACC,eAAU,CAAC,KAAK,EAAEA,eAAU,CAAC,KAAK,CAAC;
|
1
|
+
{"version":3,"file":"trigger.js","sources":["../../../../../../packages/components/tooltip/src/trigger.ts"],"sourcesContent":["import { buildProps, definePropType } from '@element-plus/utils'\nimport { popperTriggerProps } from '@element-plus/components/popper'\nimport { EVENT_CODE } from '@element-plus/constants'\nimport type { Arrayable } from '@element-plus/utils'\nimport type { ExtractPropTypes } from 'vue'\n\nexport type TooltipTriggerType = 'hover' | 'focus' | 'click' | 'contextmenu'\n\nexport const useTooltipTriggerProps = buildProps({\n ...popperTriggerProps,\n /**\n * @description whether Tooltip is disabled\n */\n disabled: Boolean,\n /**\n * @description How should the tooltip be triggered (to show)\n */\n trigger: {\n type: definePropType<Arrayable<TooltipTriggerType>>([String, Array]),\n default: 'hover',\n },\n /**\n * @description When you click the mouse to focus on the trigger element, you can define a set of keyboard codes to control the display of tooltip through the keyboard\n */\n triggerKeys: {\n type: definePropType<string[]>(Array),\n default: () => [EVENT_CODE.enter, EVENT_CODE.numpadEnter, EVENT_CODE.space],\n },\n} as const)\n\nexport type ElTooltipTriggerProps = ExtractPropTypes<\n typeof useTooltipTriggerProps\n>\n"],"names":["buildProps","popperTriggerProps","definePropType","EVENT_CODE"],"mappings":";;;;;;;;;;;AAGY,MAAC,sBAAsB,GAAGA,kBAAU,CAAC;AACjD,EAAE,GAAGC,0BAAkB;AACvB,EAAE,QAAQ,EAAE,OAAO;AACnB,EAAE,OAAO,EAAE;AACX,IAAI,IAAI,EAAEC,sBAAc,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AACzC,IAAI,OAAO,EAAE,OAAO;AACpB,GAAG;AACH,EAAE,WAAW,EAAE;AACf,IAAI,IAAI,EAAEA,sBAAc,CAAC,KAAK,CAAC;AAC/B,IAAI,OAAO,EAAE,MAAM,CAACC,eAAU,CAAC,KAAK,EAAEA,eAAU,CAAC,WAAW,EAAEA,eAAU,CAAC,KAAK,CAAC;AAC/E,GAAG;AACH,CAAC;;;;"}
|
@@ -73,7 +73,7 @@ function useKeydown({ el$ }, store) {
|
|
73
73
|
currentItem.click();
|
74
74
|
}
|
75
75
|
const hasInput = currentItem.querySelector('[type="checkbox"]');
|
76
|
-
if ([aria.EVENT_CODE.enter, aria.EVENT_CODE.space].includes(code) && hasInput) {
|
76
|
+
if ([aria.EVENT_CODE.enter, aria.EVENT_CODE.numpadEnter, aria.EVENT_CODE.space].includes(code) && hasInput) {
|
77
77
|
ev.preventDefault();
|
78
78
|
hasInput.click();
|
79
79
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useKeydown.js","sources":["../../../../../../../packages/components/tree/src/model/useKeydown.ts"],"sourcesContent":["// @ts-nocheck\nimport { onMounted, onUpdated, shallowRef, watch } from 'vue'\nimport { useEventListener } from '@vueuse/core'\nimport { EVENT_CODE } from '@element-plus/constants'\nimport { useNamespace } from '@element-plus/hooks'\nimport type TreeStore from './tree-store'\n\nimport type { Ref } from 'vue'\nimport type { Nullable } from '@element-plus/utils'\n\ninterface UseKeydownOption {\n el$: Ref<HTMLElement>\n}\nexport function useKeydown({ el$ }: UseKeydownOption, store: Ref<TreeStore>) {\n const ns = useNamespace('tree')\n\n const treeItems = shallowRef<Nullable<HTMLElement>[]>([])\n const checkboxItems = shallowRef<Nullable<HTMLElement>[]>([])\n\n onMounted(() => {\n initTabIndex()\n })\n\n onUpdated(() => {\n treeItems.value = Array.from(el$.value.querySelectorAll('[role=treeitem]'))\n checkboxItems.value = Array.from(\n el$.value.querySelectorAll('input[type=checkbox]')\n )\n })\n\n watch(checkboxItems, (val) => {\n val.forEach((checkbox) => {\n checkbox.setAttribute('tabindex', '-1')\n })\n })\n\n const handleKeydown = (ev: KeyboardEvent): void => {\n const currentItem = ev.target as HTMLElement\n if (!currentItem.className.includes(ns.b('node'))) return\n const code = ev.code\n treeItems.value = Array.from(\n el$.value.querySelectorAll(`.${ns.is('focusable')}[role=treeitem]`)\n )\n const currentIndex = treeItems.value.indexOf(currentItem)\n let nextIndex\n if ([EVENT_CODE.up, EVENT_CODE.down].includes(code)) {\n ev.preventDefault()\n if (code === EVENT_CODE.up) {\n nextIndex =\n currentIndex === -1\n ? 0\n : currentIndex !== 0\n ? currentIndex - 1\n : treeItems.value.length - 1\n const startIndex = nextIndex\n while (true) {\n if (\n store.value.getNode(treeItems.value[nextIndex].dataset.key).canFocus\n )\n break\n nextIndex--\n if (nextIndex === startIndex) {\n nextIndex = -1\n break\n }\n if (nextIndex < 0) {\n nextIndex = treeItems.value.length - 1\n }\n }\n } else {\n nextIndex =\n currentIndex === -1\n ? 0\n : currentIndex < treeItems.value.length - 1\n ? currentIndex + 1\n : 0\n const startIndex = nextIndex\n while (true) {\n if (\n store.value.getNode(treeItems.value[nextIndex].dataset.key).canFocus\n )\n break\n nextIndex++\n if (nextIndex === startIndex) {\n nextIndex = -1\n break\n }\n if (nextIndex >= treeItems.value.length) {\n nextIndex = 0\n }\n }\n }\n nextIndex !== -1 && treeItems.value[nextIndex].focus()\n }\n if ([EVENT_CODE.left, EVENT_CODE.right].includes(code)) {\n ev.preventDefault()\n currentItem.click()\n }\n const hasInput = currentItem.querySelector(\n '[type=\"checkbox\"]'\n ) as Nullable<HTMLInputElement>\n if ([EVENT_CODE.enter, EVENT_CODE.space].includes(code)
|
1
|
+
{"version":3,"file":"useKeydown.js","sources":["../../../../../../../packages/components/tree/src/model/useKeydown.ts"],"sourcesContent":["// @ts-nocheck\nimport { onMounted, onUpdated, shallowRef, watch } from 'vue'\nimport { useEventListener } from '@vueuse/core'\nimport { EVENT_CODE } from '@element-plus/constants'\nimport { useNamespace } from '@element-plus/hooks'\nimport type TreeStore from './tree-store'\n\nimport type { Ref } from 'vue'\nimport type { Nullable } from '@element-plus/utils'\n\ninterface UseKeydownOption {\n el$: Ref<HTMLElement>\n}\nexport function useKeydown({ el$ }: UseKeydownOption, store: Ref<TreeStore>) {\n const ns = useNamespace('tree')\n\n const treeItems = shallowRef<Nullable<HTMLElement>[]>([])\n const checkboxItems = shallowRef<Nullable<HTMLElement>[]>([])\n\n onMounted(() => {\n initTabIndex()\n })\n\n onUpdated(() => {\n treeItems.value = Array.from(el$.value.querySelectorAll('[role=treeitem]'))\n checkboxItems.value = Array.from(\n el$.value.querySelectorAll('input[type=checkbox]')\n )\n })\n\n watch(checkboxItems, (val) => {\n val.forEach((checkbox) => {\n checkbox.setAttribute('tabindex', '-1')\n })\n })\n\n const handleKeydown = (ev: KeyboardEvent): void => {\n const currentItem = ev.target as HTMLElement\n if (!currentItem.className.includes(ns.b('node'))) return\n const code = ev.code\n treeItems.value = Array.from(\n el$.value.querySelectorAll(`.${ns.is('focusable')}[role=treeitem]`)\n )\n const currentIndex = treeItems.value.indexOf(currentItem)\n let nextIndex\n if ([EVENT_CODE.up, EVENT_CODE.down].includes(code)) {\n ev.preventDefault()\n if (code === EVENT_CODE.up) {\n nextIndex =\n currentIndex === -1\n ? 0\n : currentIndex !== 0\n ? currentIndex - 1\n : treeItems.value.length - 1\n const startIndex = nextIndex\n while (true) {\n if (\n store.value.getNode(treeItems.value[nextIndex].dataset.key).canFocus\n )\n break\n nextIndex--\n if (nextIndex === startIndex) {\n nextIndex = -1\n break\n }\n if (nextIndex < 0) {\n nextIndex = treeItems.value.length - 1\n }\n }\n } else {\n nextIndex =\n currentIndex === -1\n ? 0\n : currentIndex < treeItems.value.length - 1\n ? currentIndex + 1\n : 0\n const startIndex = nextIndex\n while (true) {\n if (\n store.value.getNode(treeItems.value[nextIndex].dataset.key).canFocus\n )\n break\n nextIndex++\n if (nextIndex === startIndex) {\n nextIndex = -1\n break\n }\n if (nextIndex >= treeItems.value.length) {\n nextIndex = 0\n }\n }\n }\n nextIndex !== -1 && treeItems.value[nextIndex].focus()\n }\n if ([EVENT_CODE.left, EVENT_CODE.right].includes(code)) {\n ev.preventDefault()\n currentItem.click()\n }\n const hasInput = currentItem.querySelector(\n '[type=\"checkbox\"]'\n ) as Nullable<HTMLInputElement>\n if (\n [EVENT_CODE.enter, EVENT_CODE.numpadEnter, EVENT_CODE.space].includes(\n code\n ) &&\n hasInput\n ) {\n ev.preventDefault()\n hasInput.click()\n }\n }\n\n useEventListener(el$, 'keydown', handleKeydown)\n\n const initTabIndex = (): void => {\n treeItems.value = Array.from(\n el$.value.querySelectorAll(`.${ns.is('focusable')}[role=treeitem]`)\n )\n checkboxItems.value = Array.from(\n el$.value.querySelectorAll('input[type=checkbox]')\n )\n const checkedItem = el$.value.querySelectorAll(\n `.${ns.is('checked')}[role=treeitem]`\n )\n if (checkedItem.length) {\n checkedItem[0].setAttribute('tabindex', '0')\n return\n }\n treeItems.value[0]?.setAttribute('tabindex', '0')\n }\n}\n"],"names":["useNamespace","shallowRef","onMounted","onUpdated","watch","EVENT_CODE","useEventListener"],"mappings":";;;;;;;;;;;AAIO,SAAS,UAAU,CAAC,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE;AAC3C,EAAE,MAAM,EAAE,GAAGA,kBAAY,CAAC,MAAM,CAAC,CAAC;AAClC,EAAE,MAAM,SAAS,GAAGC,cAAU,CAAC,EAAE,CAAC,CAAC;AACnC,EAAE,MAAM,aAAa,GAAGA,cAAU,CAAC,EAAE,CAAC,CAAC;AACvC,EAAEC,aAAS,CAAC,MAAM;AAClB,IAAI,YAAY,EAAE,CAAC;AACnB,GAAG,CAAC,CAAC;AACL,EAAEC,aAAS,CAAC,MAAM;AAClB,IAAI,SAAS,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC,CAAC;AAChF,IAAI,aAAa,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,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AAS,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC;AAC1F,IAAI,IAAI,WAAW,CAAC,MAAM,EAAE;AAC5B,MAAM,WAAW,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;AACnD,MAAM,OAAO;AACb,KAAK;AACL,IAAI,CAAC,EAAE,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;AAClF,GAAG,CAAC;AACJ;;;;"}
|
@@ -9,9 +9,8 @@ var aria = require('../../constants/aria.js');
|
|
9
9
|
var core = require('@vueuse/core');
|
10
10
|
|
11
11
|
let registeredEscapeHandlers = [];
|
12
|
-
const cachedHandler = (
|
13
|
-
|
14
|
-
if (event.key === aria.EVENT_CODE.esc) {
|
12
|
+
const cachedHandler = (event) => {
|
13
|
+
if (event.code === aria.EVENT_CODE.esc) {
|
15
14
|
registeredEscapeHandlers.forEach((registeredHandler) => registeredHandler(event));
|
16
15
|
}
|
17
16
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../packages/hooks/use-escape-keydown/index.ts"],"sourcesContent":["import { onBeforeUnmount, onMounted } from 'vue'\nimport { isClient } from '@element-plus/utils'\nimport { EVENT_CODE } from '@element-plus/constants'\n\nlet registeredEscapeHandlers: ((e: KeyboardEvent) => void)[] = []\n\nconst cachedHandler = (
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../packages/hooks/use-escape-keydown/index.ts"],"sourcesContent":["import { onBeforeUnmount, onMounted } from 'vue'\nimport { isClient } from '@element-plus/utils'\nimport { EVENT_CODE } from '@element-plus/constants'\n\nlet registeredEscapeHandlers: ((e: KeyboardEvent) => void)[] = []\n\nconst cachedHandler = (event: KeyboardEvent) => {\n if (event.code === EVENT_CODE.esc) {\n registeredEscapeHandlers.forEach((registeredHandler) =>\n registeredHandler(event)\n )\n }\n}\n\nexport const useEscapeKeydown = (handler: (e: KeyboardEvent) => void) => {\n onMounted(() => {\n if (registeredEscapeHandlers.length === 0) {\n document.addEventListener('keydown', cachedHandler)\n }\n if (isClient) registeredEscapeHandlers.push(handler)\n })\n\n onBeforeUnmount(() => {\n registeredEscapeHandlers = registeredEscapeHandlers.filter(\n (registeredHandler) => registeredHandler !== handler\n )\n if (registeredEscapeHandlers.length === 0) {\n if (isClient) document.removeEventListener('keydown', cachedHandler)\n }\n })\n}\n"],"names":["EVENT_CODE","onMounted","isClient","onBeforeUnmount"],"mappings":";;;;;;;;;;AAGA,IAAI,wBAAwB,GAAG,EAAE,CAAC;AAClC,MAAM,aAAa,GAAG,CAAC,KAAK,KAAK;AACjC,EAAE,IAAI,KAAK,CAAC,IAAI,KAAKA,eAAU,CAAC,GAAG,EAAE;AACrC,IAAI,wBAAwB,CAAC,OAAO,CAAC,CAAC,iBAAiB,KAAK,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;AACtF,GAAG;AACH,CAAC,CAAC;AACU,MAAC,gBAAgB,GAAG,CAAC,OAAO,KAAK;AAC7C,EAAEC,aAAS,CAAC,MAAM;AAClB,IAAI,IAAI,wBAAwB,CAAC,MAAM,KAAK,CAAC,EAAE;AAC/C,MAAM,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;AAC1D,KAAK;AACL,IAAI,IAAIC,aAAQ;AAChB,MAAM,wBAAwB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC7C,GAAG,CAAC,CAAC;AACL,EAAEC,mBAAe,CAAC,MAAM;AACxB,IAAI,wBAAwB,GAAG,wBAAwB,CAAC,MAAM,CAAC,CAAC,iBAAiB,KAAK,iBAAiB,KAAK,OAAO,CAAC,CAAC;AACrH,IAAI,IAAI,wBAAwB,CAAC,MAAM,KAAK,CAAC,EAAE;AAC/C,MAAM,IAAID,aAAQ;AAClB,QAAQ,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;AAC/D,KAAK;AACL,GAAG,CAAC,CAAC;AACL;;;;"}
|
package/lib/version.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export declare const version = "0.0.
|
1
|
+
export declare const version = "0.0.20241114";
|
package/lib/version.js
CHANGED
package/lib/version.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"version.js","sources":["../../../packages/element-plus/version.ts"],"sourcesContent":["export const version = '0.0.
|
1
|
+
{"version":3,"file":"version.js","sources":["../../../packages/element-plus/version.ts"],"sourcesContent":["export const version = '0.0.20241114'\n"],"names":[],"mappings":";;;;AAAY,MAAC,OAAO,GAAG;;;;"}
|