hzzt-plus 2.0.4 → 2.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/index.full.js +19 -13
  2. package/dist/index.full.min.js +11 -11
  3. package/dist/index.full.min.js.map +1 -1
  4. package/dist/index.full.min.mjs +11 -11
  5. package/dist/index.full.min.mjs.map +1 -1
  6. package/dist/index.full.mjs +19 -13
  7. package/dist/locale/en.js +1 -1
  8. package/dist/locale/en.min.js +1 -1
  9. package/dist/locale/en.min.mjs +1 -1
  10. package/dist/locale/en.mjs +1 -1
  11. package/dist/locale/zh-cn.js +1 -1
  12. package/dist/locale/zh-cn.min.js +1 -1
  13. package/dist/locale/zh-cn.min.mjs +1 -1
  14. package/dist/locale/zh-cn.mjs +1 -1
  15. package/es/components/collapse/index.mjs +2 -2
  16. package/es/components/collapse/src/collapse.mjs +88 -0
  17. package/es/components/collapse/src/collapse.mjs.map +1 -1
  18. package/es/components/collapse/src/collapse2.mjs +0 -88
  19. package/es/components/collapse/src/collapse2.mjs.map +1 -1
  20. package/es/components/index.mjs +1 -1
  21. package/es/components/lazy-list/index.mjs +2 -2
  22. package/es/components/lazy-list/src/lazy-list.mjs +22 -80
  23. package/es/components/lazy-list/src/lazy-list.mjs.map +1 -1
  24. package/es/components/lazy-list/src/lazy-list2.mjs +80 -22
  25. package/es/components/lazy-list/src/lazy-list2.mjs.map +1 -1
  26. package/es/components/scroll/index.mjs +2 -2
  27. package/es/components/scroll/src/scroll.mjs +0 -90
  28. package/es/components/scroll/src/scroll.mjs.map +1 -1
  29. package/es/components/scroll/src/scroll2.mjs +90 -0
  30. package/es/components/scroll/src/scroll2.mjs.map +1 -1
  31. package/es/components/select/src/select2.mjs +7 -2
  32. package/es/components/select/src/select2.mjs.map +1 -1
  33. package/es/components/tab/index.d.ts +2 -0
  34. package/es/components/tab/src/index.mjs +10 -9
  35. package/es/components/tab/src/index.mjs.map +1 -1
  36. package/es/components/tab/src/index.vue.d.ts +2 -0
  37. package/es/index.mjs +1 -1
  38. package/es/version.d.ts +1 -1
  39. package/es/version.mjs +1 -1
  40. package/es/version.mjs.map +1 -1
  41. package/lib/components/collapse/index.js +2 -2
  42. package/lib/components/collapse/src/collapse.js +91 -0
  43. package/lib/components/collapse/src/collapse.js.map +1 -1
  44. package/lib/components/collapse/src/collapse2.js +0 -91
  45. package/lib/components/collapse/src/collapse2.js.map +1 -1
  46. package/lib/components/index.js +1 -1
  47. package/lib/components/lazy-list/index.js +2 -2
  48. package/lib/components/lazy-list/src/lazy-list.js +23 -80
  49. package/lib/components/lazy-list/src/lazy-list.js.map +1 -1
  50. package/lib/components/lazy-list/src/lazy-list2.js +80 -23
  51. package/lib/components/lazy-list/src/lazy-list2.js.map +1 -1
  52. package/lib/components/scroll/index.js +2 -2
  53. package/lib/components/scroll/src/scroll.js +0 -93
  54. package/lib/components/scroll/src/scroll.js.map +1 -1
  55. package/lib/components/scroll/src/scroll2.js +93 -0
  56. package/lib/components/scroll/src/scroll2.js.map +1 -1
  57. package/lib/components/select/src/select2.js +6 -1
  58. package/lib/components/select/src/select2.js.map +1 -1
  59. package/lib/components/tab/index.d.ts +2 -0
  60. package/lib/components/tab/src/index.js +9 -8
  61. package/lib/components/tab/src/index.js.map +1 -1
  62. package/lib/components/tab/src/index.vue.d.ts +2 -0
  63. package/lib/index.js +1 -1
  64. package/lib/version.d.ts +1 -1
  65. package/lib/version.js +1 -1
  66. package/lib/version.js.map +1 -1
  67. package/package.json +1 -1
  68. package/web-types.json +1 -1
@@ -1,94 +1,3 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var vue = require('vue');
6
- require('../../../hooks/index.js');
7
- var index$1 = require('../../icon/src/index.js');
8
- var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
9
- var index = require('../../../hooks/use-locale/index.js');
10
-
11
- const _hoisted_1 = { class: "hzzt-collapse flex column" };
12
- const _hoisted_2 = { class: "hzzt-collapse__top" };
13
- const _hoisted_3 = { class: "hzzt-collapse__title" };
14
- const _hoisted_4 = {
15
- key: 0,
16
- class: "hzzt-collapse__line"
17
- };
18
- const _hoisted_5 = { class: "hzzt-collapse__content flex-1" };
19
- const __default__ = vue.defineComponent({
20
- name: "HzztCollapse"
21
- });
22
- const _sfc_main = /* @__PURE__ */ vue.defineComponent({
23
- ...__default__,
24
- props: {
25
- defaultActive: {
26
- type: Boolean,
27
- default: true
28
- },
29
- title: {
30
- type: String,
31
- default: ""
32
- },
33
- showLine: {
34
- type: Boolean,
35
- default: true
36
- },
37
- modelValue: {
38
- type: Boolean,
39
- default: true
40
- }
41
- },
42
- emits: ["update:modelValue"],
43
- setup(__props, { emit }) {
44
- const props = __props;
45
- const { t } = index.useLocale();
46
- const expand = vue.ref(props.modelValue);
47
- if (!props.defaultActive) {
48
- emit("update:modelValue", false);
49
- expand.value = false;
50
- }
51
- vue.watch(() => props.modelValue, (v) => {
52
- expand.value = v;
53
- });
54
- function toggle() {
55
- expand.value = !expand.value;
56
- emit("update:modelValue", expand.value);
57
- }
58
- return (_ctx, _cache) => {
59
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
60
- vue.createElementVNode("div", _hoisted_2, [
61
- vue.createElementVNode("div", _hoisted_3, [
62
- vue.renderSlot(_ctx.$slots, "title", {}, () => [
63
- vue.createTextVNode(vue.toDisplayString(__props.title), 1)
64
- ])
65
- ]),
66
- __props.showLine ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_4)) : vue.createCommentVNode("v-if", true),
67
- vue.renderSlot(_ctx.$slots, "toggle-btn", {}, () => [
68
- vue.createElementVNode("div", {
69
- class: "hzzt-collapse__btn",
70
- onClick: toggle
71
- }, [
72
- vue.createVNode(index$1["default"], {
73
- name: !expand.value ? "hzzt-plus-square-outline" : "hzzt-minus-square-outline",
74
- class: "hzzt-collapse__icon",
75
- size: "14"
76
- }, null, 8, ["name"]),
77
- vue.createElementVNode("span", null, vue.toDisplayString(expand.value ? vue.unref(t)("hzzt.collapse.retract") : vue.unref(t)("hzzt.collapse.expand")), 1)
78
- ])
79
- ])
80
- ]),
81
- vue.withDirectives(vue.createElementVNode("div", _hoisted_5, [
82
- vue.renderSlot(_ctx.$slots, "default")
83
- ], 512), [
84
- [vue.vShow, expand.value]
85
- ]),
86
- vue.renderSlot(_ctx.$slots, "active", { active: expand.value })
87
- ]);
88
- };
89
- }
90
- });
91
- var Collapse = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "collapse.vue"]]);
92
-
93
- exports["default"] = Collapse;
94
3
  //# sourceMappingURL=collapse2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"collapse2.js","sources":["../../../../../../packages/components/collapse/src/collapse.vue"],"sourcesContent":["<template>\n <div class=\"hzzt-collapse flex column\">\n <div class=\"hzzt-collapse__top\">\n <div class=\"hzzt-collapse__title\">\n <slot name=\"title\">\n {{ title }}\n </slot>\n </div>\n <div v-if=\"showLine\" class=\"hzzt-collapse__line\" />\n <slot name=\"toggle-btn\">\n <div class=\"hzzt-collapse__btn\" @click=\"toggle\">\n <hzzt-icon :name=\"!expand ? 'hzzt-plus-square-outline' : 'hzzt-minus-square-outline'\"\n class=\"hzzt-collapse__icon\" size=\"14\" />\n <span>{{ expand ? t('hzzt.collapse.retract') : t('hzzt.collapse.expand') }}</span>\n </div>\n </slot>\n </div>\n <div v-show=\"expand\" class=\"hzzt-collapse__content flex-1\">\n <slot />\n </div>\n\n <slot :active=\"expand\" name=\"active\" />\n </div>\n</template>\n\n<script setup lang=\"ts\">\n import {useLocale} from '@hzzt-plus/hooks'\n import HzztIcon from '@hzzt-plus/components/icon/src/index.vue'\n import {ref, watch} from 'vue'\n\n defineOptions({\n name: 'HzztCollapse',\n })\n const {t} = useLocale()\n const props = defineProps({\n defaultActive: {\n type: Boolean,\n default: true,\n },\n title: {\n type: String,\n default: '',\n },\n showLine: {\n type: Boolean,\n default: true,\n },\n modelValue: {\n type: Boolean,\n default: true,\n },\n })\n const emit = defineEmits(['update:modelValue'])\n\n const expand = ref(props.modelValue)\n\n if (!props.defaultActive) {\n emit('update:modelValue', false);\n expand.value = false;\n }\n\n watch(() => props.modelValue, (v) => {\n expand.value = v;\n })\n\n function toggle() {\n expand.value = !expand.value;\n emit('update:modelValue', expand.value);\n }\n\n</script>\n"],"names":["useLocale","ref","watch"],"mappings":";;;;;;;;;;;;;;;;;;uCA8BgB,CAAA;AAAA,EACZ,IAAM,EAAA,cAAA;AACR,CAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAM,MAAA,EAAC,CAAC,EAAA,GAAIA,eAAU,EAAA,CAAA;AAqBtB,IAAM,MAAA,MAAA,GAASC,OAAI,CAAA,KAAA,CAAM,UAAU,CAAA,CAAA;AAEnC,IAAI,IAAA,CAAC,MAAM,aAAe,EAAA;AACxB,MAAA,IAAA,CAAK,qBAAqB,KAAK,CAAA,CAAA;AAC/B,MAAA,MAAA,CAAO,KAAQ,GAAA,KAAA,CAAA;AAAA,KACjB;AAEA,IAAAC,SAAA,CAAM,MAAM,KAAA,CAAM,UAAY,EAAA,CAAC,CAAM,KAAA;AACnC,MAAA,MAAA,CAAO,KAAQ,GAAA,CAAA,CAAA;AAAA,KAChB,CAAA,CAAA;AAED,IAAA,SAAS,MAAS,GAAA;AAChB,MAAO,MAAA,CAAA,KAAA,GAAQ,CAAC,MAAO,CAAA,KAAA,CAAA;AACvB,MAAK,IAAA,CAAA,mBAAA,EAAqB,OAAO,KAAK,CAAA,CAAA;AAAA,KACxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"collapse2.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -34,7 +34,7 @@ var inputRange = require('./input-range/src/input-range.js');
34
34
  var cascader = require('./cascader/src/cascader.js');
35
35
  var select = require('./select/src/select.js');
36
36
  var clickInput = require('./click-input/src/click-input.js');
37
- var lazyList = require('./lazy-list/src/lazy-list2.js');
37
+ var lazyList = require('./lazy-list/src/lazy-list.js');
38
38
 
39
39
 
40
40
 
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  require('../../utils/index.js');
6
- var lazyList$1 = require('./src/lazy-list.js');
7
- var lazyList = require('./src/lazy-list2.js');
6
+ var lazyList$1 = require('./src/lazy-list2.js');
7
+ var lazyList = require('./src/lazy-list.js');
8
8
  var install = require('../../utils/vue/install.js');
9
9
 
10
10
  const HzztLazyList = install.withInstall(lazyList$1["default"]);
@@ -2,88 +2,31 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var vue = require('vue');
6
- var lazyList = require('./lazy-list2.js');
7
- require('../../../hooks/index.js');
8
- var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
9
- var index = require('../../../hooks/use-namespace/index.js');
5
+ require('../../../utils/index.js');
6
+ var runtime = require('../../../utils/vue/props/runtime.js');
10
7
 
11
- const _hoisted_1 = ["onClick"];
12
- const __default__ = vue.defineComponent({
13
- name: "HzztLazyList"
14
- });
15
- const _sfc_main = /* @__PURE__ */ vue.defineComponent({
16
- ...__default__,
17
- props: lazyList.lazyListProps,
18
- emits: lazyList.lazyListEmits,
19
- setup(__props, { emit }) {
20
- const props = __props;
21
- const totalHeight = vue.ref("100%");
22
- const marginTop = vue.ref("0px");
23
- const currentIndex = vue.ref(1);
24
- const current = vue.ref(null);
25
- const nsLazy = index.useNamespace("lazy-list");
26
- const containerCls = vue.computed(() => [
27
- "overflow-y-auto",
28
- nsLazy.b()
29
- ]);
30
- vue.watch(() => props.data, () => {
31
- totalHeight.value = props.data.length * props.height + "px";
32
- }, {
33
- immediate: true
34
- });
35
- const calcList = vue.computed(() => props.data.slice(currentIndex.value === 1 ? 0 : (currentIndex.value - 1) * props.size - props.size / 2, (currentIndex.value + 1) * props.size + props.size / 2));
36
- function scrollList(e) {
37
- const target = e.target;
38
- const scrollTop = target.scrollTop;
39
- if (scrollTop < props.size / 2 * props.height) {
40
- currentIndex.value = 1;
41
- } else {
42
- currentIndex.value = Math.ceil((scrollTop - props.size / 2 * props.height) / props.size / props.height);
43
- }
44
- if (currentIndex.value === 1) {
45
- marginTop.value = "0px";
46
- } else {
47
- marginTop.value = ((currentIndex.value - 1) * props.size - props.size / 2) * props.height + "px";
48
- }
49
- }
50
- function rowClick(row) {
51
- current.value = row;
52
- emit("row-click", row);
53
- }
54
- return (_ctx, _cache) => {
55
- return vue.openBlock(), vue.createElementBlock("div", {
56
- class: vue.normalizeClass(vue.unref(containerCls)),
57
- onScroll: scrollList
58
- }, [
59
- vue.createElementVNode("div", {
60
- style: vue.normalizeStyle({
61
- height: totalHeight.value,
62
- width: 0,
63
- float: "left"
64
- })
65
- }, null, 4),
66
- vue.createElementVNode("div", {
67
- style: vue.normalizeStyle({ marginTop: marginTop.value })
68
- }, [
69
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(calcList), (item) => {
70
- return vue.openBlock(), vue.createElementBlock("div", {
71
- key: item[_ctx.rowKey],
72
- style: vue.normalizeStyle({
73
- height: _ctx.height + "px"
74
- }),
75
- class: vue.normalizeClass(["hzzt-lazy-list__item", current.value === item ? "is-active" : ""]),
76
- onClick: ($event) => rowClick(item)
77
- }, [
78
- vue.renderSlot(_ctx.$slots, "default", { data: item })
79
- ], 14, _hoisted_1);
80
- }), 128))
81
- ], 4)
82
- ], 34);
83
- };
8
+ const lazyListProps = runtime.buildProps({
9
+ size: {
10
+ type: Number,
11
+ default: 20
12
+ },
13
+ height: {
14
+ type: Number,
15
+ default: 30
16
+ },
17
+ data: {
18
+ type: runtime.definePropType(Array),
19
+ default: () => []
20
+ },
21
+ rowKey: {
22
+ type: String,
23
+ default: "id"
84
24
  }
85
25
  });
86
- var LazyList = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "lazy-list.vue"]]);
26
+ const lazyListEmits = {
27
+ "row-click": (row) => row
28
+ };
87
29
 
88
- exports["default"] = LazyList;
30
+ exports.lazyListEmits = lazyListEmits;
31
+ exports.lazyListProps = lazyListProps;
89
32
  //# sourceMappingURL=lazy-list.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lazy-list.js","sources":["../../../../../../packages/components/lazy-list/src/lazy-list.vue"],"sourcesContent":["<template>\n <div :class=\"containerCls\" @scroll=\"scrollList\">\n <div\n :style=\"{\n height: totalHeight,\n width: 0,\n float: 'left',\n }\"\n />\n <div :style=\"{marginTop: marginTop}\">\n <div\n v-for=\"item in calcList\"\n :key=\"item[rowKey]\"\n :style=\"{\n height: height+'px'\n }\"\n :class=\"['hzzt-lazy-list__item', current === item?'is-active':'']\"\n @click=\"rowClick(item)\"\n >\n <slot :data=\"item\" />\n </div>\n </div>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\n import {lazyListEmits, lazyListProps} from './lazy-list'\n import {computed, ref, watch} from \"vue\";\n import {useNamespace} from \"@hzzt-plus/hooks\";\n\n defineOptions({\n name: 'HzztLazyList',\n })\n\n const props = defineProps(lazyListProps)\n const emit = defineEmits(lazyListEmits)\n\n const totalHeight = ref('100%');\n const marginTop = ref('0px');\n const currentIndex = ref(1);\n const current = ref(null);\n\n const nsLazy = useNamespace('lazy-list');\n\n const containerCls = computed(() => [\n 'overflow-y-auto',\n nsLazy.b(),\n ])\n\n watch(() => props.data, () => {\n totalHeight.value = props.data.length * props.height + 'px';\n }, {\n immediate: true,\n });\n\n const calcList = computed(\n () => props.data.slice(currentIndex.value === 1 ? 0 : ((currentIndex.value - 1) * props.size -\n props.size / 2), (currentIndex.value + 1) * props.size + props.size / 2));\n\n function scrollList(e: Event) {\n const target = e.target as HTMLElement;\n const scrollTop = target.scrollTop;\n if (scrollTop < props.size / 2 * props.height) {\n currentIndex.value = 1;\n } else {\n currentIndex.value = Math.ceil((scrollTop - props.size / 2 * props.height) / props.size / props.height);\n }\n if (currentIndex.value === 1) {\n marginTop.value = '0px';\n } else {\n marginTop.value = ((currentIndex.value - 1) * props.size - props.size / 2) * props.height + 'px';\n }\n }\n\n function rowClick(row: any) {\n current.value = row;\n emit('row-click', row);\n }\n\n\n</script>\n"],"names":["ref","useNamespace","computed","watch","_openBlock","_createElementBlock"],"mappings":";;;;;;;;;;;uCA8BgB,CAAA;AAAA,EACZ,IAAM,EAAA,cAAA;AACR,CAAA,CAAA,CAAA;;;;;;;AAKA,IAAM,MAAA,WAAA,GAAcA,QAAI,MAAM,CAAA,CAAA;AAC9B,IAAM,MAAA,SAAA,GAAYA,QAAI,KAAK,CAAA,CAAA;AAC3B,IAAM,MAAA,YAAA,GAAeA,QAAI,CAAC,CAAA,CAAA;AAC1B,IAAM,MAAA,OAAA,GAAUA,QAAI,IAAI,CAAA,CAAA;AAExB,IAAM,MAAA,MAAA,GAASC,mBAAa,WAAW,CAAA,CAAA;AAEvC,IAAM,MAAA,YAAA,GAAeC,aAAS,MAAM;AAAA,MAClC,iBAAA;AAAA,MACA,OAAO,CAAE,EAAA;AAAA,KACV,CAAA,CAAA;AAED,IAAMC,SAAA,CAAA,MAAM,KAAM,CAAA,IAAA,EAAM,MAAM;AAC5B,MAAA,WAAA,CAAY,KAAQ,GAAA,KAAA,CAAM,IAAK,CAAA,MAAA,GAAS,MAAM,MAAS,GAAA,IAAA,CAAA;AAAA,KACtD,EAAA;AAAA,MACD,SAAW,EAAA,IAAA;AAAA,KACZ,CAAA,CAAA;AAED,IAAA,MAAM,QAAW,GAAAD,YAAA,CAAA,MAAA,KAAA,CAAA,IAAA,CAAA,KAAA,CAAA,YAAA,CAAA,KAAA,KAAA,CAAA,GAAA,CAAA,GAAA,CAAA,YAAA,CAAA,KAAA,GAAA,CAAA,IAAA,KAAA,CAAA,IAAA,GAAA,KAAA,CAAA,IAAA,GAAA,CAAA,EAAA,CAAA,YAAA,CAAA,KAAA,GAAA,CAAA,IAAA,KAAA,CAAA,IAAA,GAAA,KAAA,CAAA,IAAA,GAAA,CAAA,CAAA,CAAA,CAAA;AAAA,IACf,mBAAiB,CAAA,CAAA,EAAA;AACwD,MAAC,MAAA,MAAA,GAAA,CAAA,CAAA,MAAA,CAAA;AAE5E,MAAA,MAAA,YAAoB,MAAU,CAAA,SAAA,CAAA;AAC5B,MAAA,IAAA,YAAiB,KAAA,CAAA,IAAA,GAAA,CAAA,GAAA,KAAA,CAAA,MAAA,EAAA;AACjB,QAAA,kBAAyB,GAAA,CAAA,CAAA;AACzB,OAAA,MAAgB;AACd,QAAA,YAAA,CAAa,KAAQ,GAAA,IAAA,CAAA,IAAA,CAAA,CAAA,SAAA,GAAA,KAAA,CAAA,IAAA,GAAA,CAAA,GAAA,KAAA,CAAA,MAAA,IAAA,KAAA,CAAA,IAAA,GAAA,KAAA,CAAA,MAAA,CAAA,CAAA;AAAA,OAChB;AACL,MAAA,IAAA,YAAqB,CAAA,KAAA,KAAA,CAAK,EAAM;AAAsE,QACxG,SAAA,CAAA,KAAA,GAAA,KAAA,CAAA;AACA,OAAI,MAAA;AACF,QAAA,SAAA,CAAU,KAAQ,GAAA,CAAA,CAAA,YAAA,CAAA,KAAA,GAAA,CAAA,IAAA,KAAA,CAAA,IAAA,GAAA,KAAA,CAAA,IAAA,GAAA,CAAA,IAAA,KAAA,CAAA,MAAA,GAAA,IAAA,CAAA;AAAA,OACb;AACL,KAAU;AAAkF,IAC9F,SAAA,QAAA,CAAA,GAAA,EAAA;AAAA,MACF,OAAA,CAAA,KAAA,GAAA,GAAA,CAAA;AAEA,MAAA,IAAA,CAAA,WAAkB,EAAU,GAAA,CAAA,CAAA;AAC1B,KAAA;AACA,IAAA,OAAK,aAAa,KAAG;AAAA,MACvB,OAAAE,aAAA,EAAA,EAAAC,sBAAA,CAAA,KAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"lazy-list.js","sources":["../../../../../../packages/components/lazy-list/src/lazy-list.ts"],"sourcesContent":["import {buildProps, definePropType} from '@hzzt-plus/utils'\nimport type {ExtractPropTypes} from 'vue'\nimport type LazyList from './lazy-list.vue'\n\nexport const lazyListProps = buildProps({\n size: {\n type: Number,\n default: 20,\n },\n height: {\n type: Number,\n default: 30,\n },\n data: {\n type: definePropType<Record<string, any>[]>(Array),\n default: () => [],\n },\n rowKey: {\n type: String,\n default: 'id',\n },\n})\n\nexport type LazyListProps = ExtractPropTypes<typeof lazyListProps>\n\nexport const lazyListEmits = {\n 'row-click': (row: any) => row\n}\n\nexport type LazyListEmits = typeof lazyListEmits\n\n\nexport type LazyListInstance = InstanceType<typeof LazyList>\n"],"names":["buildProps","definePropType"],"mappings":";;;;;;;AACY,MAAC,aAAa,GAAGA,kBAAU,CAAC;AACxC,EAAE,IAAI,EAAE;AACR,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,MAAM,EAAE;AACV,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,IAAI,EAAE;AACR,IAAI,IAAI,EAAEC,sBAAc,CAAC,KAAK,CAAC;AAC/B,IAAI,OAAO,EAAE,MAAM,EAAE;AACrB,GAAG;AACH,EAAE,MAAM,EAAE;AACV,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,IAAI;AACjB,GAAG;AACH,CAAC,EAAE;AACS,MAAC,aAAa,GAAG;AAC7B,EAAE,WAAW,EAAE,CAAC,GAAG,KAAK,GAAG;AAC3B;;;;;"}
@@ -2,31 +2,88 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- require('../../../utils/index.js');
6
- var runtime = require('../../../utils/vue/props/runtime.js');
5
+ var vue = require('vue');
6
+ var lazyList = require('./lazy-list.js');
7
+ require('../../../hooks/index.js');
8
+ var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
9
+ var index = require('../../../hooks/use-namespace/index.js');
7
10
 
8
- const lazyListProps = runtime.buildProps({
9
- size: {
10
- type: Number,
11
- default: 20
12
- },
13
- height: {
14
- type: Number,
15
- default: 30
16
- },
17
- data: {
18
- type: runtime.definePropType(Array),
19
- default: () => []
20
- },
21
- rowKey: {
22
- type: String,
23
- default: "id"
11
+ const _hoisted_1 = ["onClick"];
12
+ const __default__ = vue.defineComponent({
13
+ name: "HzztLazyList"
14
+ });
15
+ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
16
+ ...__default__,
17
+ props: lazyList.lazyListProps,
18
+ emits: lazyList.lazyListEmits,
19
+ setup(__props, { emit }) {
20
+ const props = __props;
21
+ const totalHeight = vue.ref("100%");
22
+ const marginTop = vue.ref("0px");
23
+ const currentIndex = vue.ref(1);
24
+ const current = vue.ref(null);
25
+ const nsLazy = index.useNamespace("lazy-list");
26
+ const containerCls = vue.computed(() => [
27
+ "overflow-y-auto",
28
+ nsLazy.b()
29
+ ]);
30
+ vue.watch(() => props.data, () => {
31
+ totalHeight.value = props.data.length * props.height + "px";
32
+ }, {
33
+ immediate: true
34
+ });
35
+ const calcList = vue.computed(() => props.data.slice(currentIndex.value === 1 ? 0 : (currentIndex.value - 1) * props.size - props.size / 2, (currentIndex.value + 1) * props.size + props.size / 2));
36
+ function scrollList(e) {
37
+ const target = e.target;
38
+ const scrollTop = target.scrollTop;
39
+ if (scrollTop < props.size / 2 * props.height) {
40
+ currentIndex.value = 1;
41
+ } else {
42
+ currentIndex.value = Math.ceil((scrollTop - props.size / 2 * props.height) / props.size / props.height);
43
+ }
44
+ if (currentIndex.value === 1) {
45
+ marginTop.value = "0px";
46
+ } else {
47
+ marginTop.value = ((currentIndex.value - 1) * props.size - props.size / 2) * props.height + "px";
48
+ }
49
+ }
50
+ function rowClick(row) {
51
+ current.value = row;
52
+ emit("row-click", row);
53
+ }
54
+ return (_ctx, _cache) => {
55
+ return vue.openBlock(), vue.createElementBlock("div", {
56
+ class: vue.normalizeClass(vue.unref(containerCls)),
57
+ onScroll: scrollList
58
+ }, [
59
+ vue.createElementVNode("div", {
60
+ style: vue.normalizeStyle({
61
+ height: totalHeight.value,
62
+ width: 0,
63
+ float: "left"
64
+ })
65
+ }, null, 4),
66
+ vue.createElementVNode("div", {
67
+ style: vue.normalizeStyle({ marginTop: marginTop.value })
68
+ }, [
69
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(calcList), (item) => {
70
+ return vue.openBlock(), vue.createElementBlock("div", {
71
+ key: item[_ctx.rowKey],
72
+ style: vue.normalizeStyle({
73
+ height: _ctx.height + "px"
74
+ }),
75
+ class: vue.normalizeClass(["hzzt-lazy-list__item", current.value === item ? "is-active" : ""]),
76
+ onClick: ($event) => rowClick(item)
77
+ }, [
78
+ vue.renderSlot(_ctx.$slots, "default", { data: item })
79
+ ], 14, _hoisted_1);
80
+ }), 128))
81
+ ], 4)
82
+ ], 34);
83
+ };
24
84
  }
25
85
  });
26
- const lazyListEmits = {
27
- "row-click": (row) => row
28
- };
86
+ var LazyList = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "lazy-list.vue"]]);
29
87
 
30
- exports.lazyListEmits = lazyListEmits;
31
- exports.lazyListProps = lazyListProps;
88
+ exports["default"] = LazyList;
32
89
  //# sourceMappingURL=lazy-list2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lazy-list2.js","sources":["../../../../../../packages/components/lazy-list/src/lazy-list.ts"],"sourcesContent":["import {buildProps, definePropType} from '@hzzt-plus/utils'\nimport type {ExtractPropTypes} from 'vue'\nimport type LazyList from './lazy-list.vue'\n\nexport const lazyListProps = buildProps({\n size: {\n type: Number,\n default: 20,\n },\n height: {\n type: Number,\n default: 30,\n },\n data: {\n type: definePropType<Record<string, any>[]>(Array),\n default: () => [],\n },\n rowKey: {\n type: String,\n default: 'id',\n },\n})\n\nexport type LazyListProps = ExtractPropTypes<typeof lazyListProps>\n\nexport const lazyListEmits = {\n 'row-click': (row: any) => row\n}\n\nexport type LazyListEmits = typeof lazyListEmits\n\n\nexport type LazyListInstance = InstanceType<typeof LazyList>\n"],"names":["buildProps","definePropType"],"mappings":";;;;;;;AACY,MAAC,aAAa,GAAGA,kBAAU,CAAC;AACxC,EAAE,IAAI,EAAE;AACR,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,MAAM,EAAE;AACV,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,IAAI,EAAE;AACR,IAAI,IAAI,EAAEC,sBAAc,CAAC,KAAK,CAAC;AAC/B,IAAI,OAAO,EAAE,MAAM,EAAE;AACrB,GAAG;AACH,EAAE,MAAM,EAAE;AACV,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,IAAI;AACjB,GAAG;AACH,CAAC,EAAE;AACS,MAAC,aAAa,GAAG;AAC7B,EAAE,WAAW,EAAE,CAAC,GAAG,KAAK,GAAG;AAC3B;;;;;"}
1
+ {"version":3,"file":"lazy-list2.js","sources":["../../../../../../packages/components/lazy-list/src/lazy-list.vue"],"sourcesContent":["<template>\n <div :class=\"containerCls\" @scroll=\"scrollList\">\n <div\n :style=\"{\n height: totalHeight,\n width: 0,\n float: 'left',\n }\"\n />\n <div :style=\"{marginTop: marginTop}\">\n <div\n v-for=\"item in calcList\"\n :key=\"item[rowKey]\"\n :style=\"{\n height: height+'px'\n }\"\n :class=\"['hzzt-lazy-list__item', current === item?'is-active':'']\"\n @click=\"rowClick(item)\"\n >\n <slot :data=\"item\" />\n </div>\n </div>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\n import {lazyListEmits, lazyListProps} from './lazy-list'\n import {computed, ref, watch} from \"vue\";\n import {useNamespace} from \"@hzzt-plus/hooks\";\n\n defineOptions({\n name: 'HzztLazyList',\n })\n\n const props = defineProps(lazyListProps)\n const emit = defineEmits(lazyListEmits)\n\n const totalHeight = ref('100%');\n const marginTop = ref('0px');\n const currentIndex = ref(1);\n const current = ref(null);\n\n const nsLazy = useNamespace('lazy-list');\n\n const containerCls = computed(() => [\n 'overflow-y-auto',\n nsLazy.b(),\n ])\n\n watch(() => props.data, () => {\n totalHeight.value = props.data.length * props.height + 'px';\n }, {\n immediate: true,\n });\n\n const calcList = computed(\n () => props.data.slice(currentIndex.value === 1 ? 0 : ((currentIndex.value - 1) * props.size -\n props.size / 2), (currentIndex.value + 1) * props.size + props.size / 2));\n\n function scrollList(e: Event) {\n const target = e.target as HTMLElement;\n const scrollTop = target.scrollTop;\n if (scrollTop < props.size / 2 * props.height) {\n currentIndex.value = 1;\n } else {\n currentIndex.value = Math.ceil((scrollTop - props.size / 2 * props.height) / props.size / props.height);\n }\n if (currentIndex.value === 1) {\n marginTop.value = '0px';\n } else {\n marginTop.value = ((currentIndex.value - 1) * props.size - props.size / 2) * props.height + 'px';\n }\n }\n\n function rowClick(row: any) {\n current.value = row;\n emit('row-click', row);\n }\n\n\n</script>\n"],"names":["ref","useNamespace","computed","watch","_openBlock","_createElementBlock"],"mappings":";;;;;;;;;;;uCA8BgB,CAAA;AAAA,EACZ,IAAM,EAAA,cAAA;AACR,CAAA,CAAA,CAAA;;;;;;;AAKA,IAAM,MAAA,WAAA,GAAcA,QAAI,MAAM,CAAA,CAAA;AAC9B,IAAM,MAAA,SAAA,GAAYA,QAAI,KAAK,CAAA,CAAA;AAC3B,IAAM,MAAA,YAAA,GAAeA,QAAI,CAAC,CAAA,CAAA;AAC1B,IAAM,MAAA,OAAA,GAAUA,QAAI,IAAI,CAAA,CAAA;AAExB,IAAM,MAAA,MAAA,GAASC,mBAAa,WAAW,CAAA,CAAA;AAEvC,IAAM,MAAA,YAAA,GAAeC,aAAS,MAAM;AAAA,MAClC,iBAAA;AAAA,MACA,OAAO,CAAE,EAAA;AAAA,KACV,CAAA,CAAA;AAED,IAAMC,SAAA,CAAA,MAAM,KAAM,CAAA,IAAA,EAAM,MAAM;AAC5B,MAAA,WAAA,CAAY,KAAQ,GAAA,KAAA,CAAM,IAAK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AAA,MAAA,GAAA,IAAA,CAAA;AAAA,OACb;AACL,KAAU;AAAkF,IAC9F,SAAA,QAAA,CAAA,GAAA,EAAA;AAAA,MACF,OAAA,CAAA,KAAA,GAAA,GAAA,CAAA;AAEA,MAAA,IAAA,CAAA,WAAkB,EAAU,GAAA,CAAA,CAAA;AAC1B,KAAA;AACA,IAAA,OAAK,aAAa,KAAG;AAAA,MACvB,OAAAE,aAAA,EAAA,EAAAC,sBAAA,CAAA,KAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  require('../../utils/index.js');
6
- var scroll = require('./src/scroll.js');
7
- require('./src/scroll2.js');
6
+ var scroll = require('./src/scroll2.js');
7
+ require('./src/scroll.js');
8
8
  var install = require('../../utils/vue/install.js');
9
9
 
10
10
  const HzztScroll = install.withInstall(scroll["default"]);
@@ -1,96 +1,3 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var vue = require('vue');
6
- var core = require('@vueuse/core');
7
- var index = require('../../icon/src/index.js');
8
- var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
9
-
10
- const __default__ = vue.defineComponent({
11
- name: "HzztScroll"
12
- });
13
- const _sfc_main = /* @__PURE__ */ vue.defineComponent({
14
- ...__default__,
15
- setup(__props) {
16
- const navTranslateX = vue.ref(0);
17
- const scrollMainRef = vue.ref(null);
18
- const scrollRef = vue.ref(null);
19
- const scrollContentRef = vue.ref(null);
20
- const scrollable = vue.ref(false);
21
- function update() {
22
- if (!scrollRef.value || !scrollContentRef.value)
23
- return;
24
- const scrollWidth = scrollRef.value ? scrollRef.value.offsetWidth : 0;
25
- const contentWidth = scrollContentRef.value ? scrollContentRef.value.offsetWidth : 0;
26
- if (scrollWidth >= contentWidth) {
27
- scrollable.value = false;
28
- navTranslateX.value = 0;
29
- return;
30
- }
31
- scrollable.value = true;
32
- }
33
- core.useResizeObserver(scrollMainRef, update);
34
- core.useResizeObserver(scrollContentRef, update);
35
- vue.onUpdated(() => update());
36
- function btnNavPrev() {
37
- var _a;
38
- const containerSize = ((_a = scrollRef.value) == null ? void 0 : _a.offsetWidth) || 0;
39
- const currentOffset = navTranslateX.value;
40
- if (!currentOffset)
41
- return;
42
- const newOffset = currentOffset > containerSize ? currentOffset - containerSize : 0;
43
- navTranslateX.value = newOffset;
44
- }
45
- function btnNavNext() {
46
- var _a, _b;
47
- const navSize = ((_a = scrollContentRef.value) == null ? void 0 : _a.offsetWidth) || 0;
48
- const currentOffset = navTranslateX.value;
49
- const containerSize = ((_b = scrollRef.value) == null ? void 0 : _b.offsetWidth) || 0;
50
- if (navSize - currentOffset < containerSize)
51
- return;
52
- const newOffset = navSize - currentOffset > containerSize * 2 ? currentOffset + containerSize : navSize - containerSize;
53
- navTranslateX.value = newOffset;
54
- }
55
- return (_ctx, _cache) => {
56
- return vue.openBlock(), vue.createElementBlock("div", {
57
- ref_key: "scrollMainRef",
58
- ref: scrollMainRef,
59
- class: vue.normalizeClass([{ "is-scrollable": scrollable.value }, "relative hzzt-scroll"])
60
- }, [
61
- scrollable.value ? (vue.openBlock(), vue.createElementBlock("div", {
62
- key: 0,
63
- class: "hzzt-scroll__nav-prev",
64
- onClick: btnNavPrev
65
- }, [
66
- vue.createVNode(index["default"], { name: "arrow-left" })
67
- ])) : vue.createCommentVNode("v-if", true),
68
- scrollable.value ? (vue.openBlock(), vue.createElementBlock("div", {
69
- key: 1,
70
- class: "hzzt-scroll__nav-next",
71
- onClick: btnNavNext
72
- }, [
73
- vue.createVNode(index["default"], { name: "arrow-right" })
74
- ])) : vue.createCommentVNode("v-if", true),
75
- vue.createElementVNode("div", {
76
- ref_key: "scrollRef",
77
- ref: scrollRef,
78
- class: "overflow-hidden"
79
- }, [
80
- vue.createElementVNode("div", {
81
- ref_key: "scrollContentRef",
82
- ref: scrollContentRef,
83
- style: vue.normalizeStyle({ transform: `translateX(${-navTranslateX.value}px)` }),
84
- class: "hzzt-scroll__content"
85
- }, [
86
- vue.renderSlot(_ctx.$slots, "default")
87
- ], 4)
88
- ], 512)
89
- ], 2);
90
- };
91
- }
92
- });
93
- var Scroll = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "scroll.vue"]]);
94
-
95
- exports["default"] = Scroll;
96
3
  //# sourceMappingURL=scroll.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"scroll.js","sources":["../../../../../../packages/components/scroll/src/scroll.vue"],"sourcesContent":["<template>\n <div ref=\"scrollMainRef\" :class=\"{'is-scrollable':scrollable}\" class=\"relative hzzt-scroll\">\n <div v-if=\"scrollable\" class=\"hzzt-scroll__nav-prev\" @click=\"btnNavPrev\">\n <hzzt-icon name=\"arrow-left\" />\n </div>\n <div v-if=\"scrollable\" class=\"hzzt-scroll__nav-next\" @click=\"btnNavNext\">\n <hzzt-icon name=\"arrow-right\" />\n </div>\n <div ref=\"scrollRef\" class=\"overflow-hidden\">\n <div ref=\"scrollContentRef\" :style=\"{transform: `translateX(${-navTranslateX}px)`}\" class=\"hzzt-scroll__content\">\n <slot />\n </div>\n </div>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\n import {onUpdated, ref} from 'vue';\n import {useResizeObserver} from '@vueuse/core';\n import HzztIcon from \"@hzzt-plus/components/icon/src/index.vue\";\n\n defineOptions({\n name: 'HzztScroll',\n })\n\n const navTranslateX = ref(0);\n const scrollMainRef = ref<HTMLElement | null>(null);\n const scrollRef = ref<HTMLElement | null>(null);\n const scrollContentRef = ref<HTMLElement | null>(null);\n const scrollable = ref(false);\n\n function update() {\n if (!scrollRef.value || !scrollContentRef.value) return;\n const scrollWidth = scrollRef.value ? scrollRef.value.offsetWidth : 0;\n const contentWidth = scrollContentRef.value ? scrollContentRef.value.offsetWidth : 0;\n if (scrollWidth >= contentWidth) {\n scrollable.value = false;\n navTranslateX.value = 0;\n return;\n }\n scrollable.value = true;\n }\n\n useResizeObserver(scrollMainRef, update);\n useResizeObserver(scrollContentRef, update);\n\n onUpdated(() => update());\n\n function btnNavPrev() {\n const containerSize = scrollRef.value?.offsetWidth || 0;\n const currentOffset = navTranslateX.value;\n if (!currentOffset) return;\n const newOffset = currentOffset > containerSize ? currentOffset - containerSize : 0;\n navTranslateX.value = newOffset;\n }\n\n function btnNavNext() {\n const navSize = scrollContentRef.value?.offsetWidth || 0;\n const currentOffset = navTranslateX.value;\n const containerSize = scrollRef.value?.offsetWidth || 0;\n if (navSize - currentOffset < containerSize) return;\n const newOffset = navSize - currentOffset > containerSize * 2 ?\n currentOffset + containerSize :\n navSize - containerSize;\n navTranslateX.value = newOffset;\n }\n</script>\n"],"names":["ref","useResizeObserver","onUpdated"],"mappings":";;;;;;;;;uCAqBgB,CAAA;AAAA,EACZ,IAAM,EAAA,YAAA;AACR,CAAA,CAAA,CAAA;;;;AAEA,IAAM,MAAA,aAAA,GAAgBA,QAAI,CAAC,CAAA,CAAA;AAC3B,IAAM,MAAA,aAAA,GAAgBA,QAAwB,IAAI,CAAA,CAAA;AAClD,IAAM,MAAA,SAAA,GAAYA,QAAwB,IAAI,CAAA,CAAA;AAC9C,IAAM,MAAA,gBAAA,GAAmBA,QAAwB,IAAI,CAAA,CAAA;AACrD,IAAM,MAAA,UAAA,GAAaA,QAAI,KAAK,CAAA,CAAA;AAE5B,IAAA,SAAS,MAAS,GAAA;AAChB,MAAA,IAAI,CAAC,SAAA,CAAU,KAAS,IAAA,CAAC,gBAAiB,CAAA,KAAA;AAAO,QAAA,OAAA;AACjD,MAAA,MAAM,WAAc,GAAA,SAAA,CAAU,KAAQ,GAAA,SAAA,CAAU,MAAM,WAAc,GAAA,CAAA,CAAA;AACpE,MAAA,MAAM,YAAe,GAAA,gBAAA,CAAiB,KAAQ,GAAA,gBAAA,CAAiB,MAAM,WAAc,GAAA,CAAA,CAAA;AACnF,MAAA,IAAI,eAAe,YAAc,EAAA;AAC/B,QAAA,UAAA,CAAW,KAA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,MACxB,MAAA,SAAA,GAAA,OAAA,GAAA,aAAA,GAAA,aAAA,GAAA,CAAA,GAAA,aAAA,GAAA,aAAA,GAAA,OAAA,GAAA,aAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"scroll.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -1,3 +1,96 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var vue = require('vue');
6
+ var core = require('@vueuse/core');
7
+ var index = require('../../icon/src/index.js');
8
+ var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
9
+
10
+ const __default__ = vue.defineComponent({
11
+ name: "HzztScroll"
12
+ });
13
+ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
14
+ ...__default__,
15
+ setup(__props) {
16
+ const navTranslateX = vue.ref(0);
17
+ const scrollMainRef = vue.ref(null);
18
+ const scrollRef = vue.ref(null);
19
+ const scrollContentRef = vue.ref(null);
20
+ const scrollable = vue.ref(false);
21
+ function update() {
22
+ if (!scrollRef.value || !scrollContentRef.value)
23
+ return;
24
+ const scrollWidth = scrollRef.value ? scrollRef.value.offsetWidth : 0;
25
+ const contentWidth = scrollContentRef.value ? scrollContentRef.value.offsetWidth : 0;
26
+ if (scrollWidth >= contentWidth) {
27
+ scrollable.value = false;
28
+ navTranslateX.value = 0;
29
+ return;
30
+ }
31
+ scrollable.value = true;
32
+ }
33
+ core.useResizeObserver(scrollMainRef, update);
34
+ core.useResizeObserver(scrollContentRef, update);
35
+ vue.onUpdated(() => update());
36
+ function btnNavPrev() {
37
+ var _a;
38
+ const containerSize = ((_a = scrollRef.value) == null ? void 0 : _a.offsetWidth) || 0;
39
+ const currentOffset = navTranslateX.value;
40
+ if (!currentOffset)
41
+ return;
42
+ const newOffset = currentOffset > containerSize ? currentOffset - containerSize : 0;
43
+ navTranslateX.value = newOffset;
44
+ }
45
+ function btnNavNext() {
46
+ var _a, _b;
47
+ const navSize = ((_a = scrollContentRef.value) == null ? void 0 : _a.offsetWidth) || 0;
48
+ const currentOffset = navTranslateX.value;
49
+ const containerSize = ((_b = scrollRef.value) == null ? void 0 : _b.offsetWidth) || 0;
50
+ if (navSize - currentOffset < containerSize)
51
+ return;
52
+ const newOffset = navSize - currentOffset > containerSize * 2 ? currentOffset + containerSize : navSize - containerSize;
53
+ navTranslateX.value = newOffset;
54
+ }
55
+ return (_ctx, _cache) => {
56
+ return vue.openBlock(), vue.createElementBlock("div", {
57
+ ref_key: "scrollMainRef",
58
+ ref: scrollMainRef,
59
+ class: vue.normalizeClass([{ "is-scrollable": scrollable.value }, "relative hzzt-scroll"])
60
+ }, [
61
+ scrollable.value ? (vue.openBlock(), vue.createElementBlock("div", {
62
+ key: 0,
63
+ class: "hzzt-scroll__nav-prev",
64
+ onClick: btnNavPrev
65
+ }, [
66
+ vue.createVNode(index["default"], { name: "arrow-left" })
67
+ ])) : vue.createCommentVNode("v-if", true),
68
+ scrollable.value ? (vue.openBlock(), vue.createElementBlock("div", {
69
+ key: 1,
70
+ class: "hzzt-scroll__nav-next",
71
+ onClick: btnNavNext
72
+ }, [
73
+ vue.createVNode(index["default"], { name: "arrow-right" })
74
+ ])) : vue.createCommentVNode("v-if", true),
75
+ vue.createElementVNode("div", {
76
+ ref_key: "scrollRef",
77
+ ref: scrollRef,
78
+ class: "overflow-hidden"
79
+ }, [
80
+ vue.createElementVNode("div", {
81
+ ref_key: "scrollContentRef",
82
+ ref: scrollContentRef,
83
+ style: vue.normalizeStyle({ transform: `translateX(${-navTranslateX.value}px)` }),
84
+ class: "hzzt-scroll__content"
85
+ }, [
86
+ vue.renderSlot(_ctx.$slots, "default")
87
+ ], 4)
88
+ ], 512)
89
+ ], 2);
90
+ };
91
+ }
92
+ });
93
+ var Scroll = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "scroll.vue"]]);
94
+
95
+ exports["default"] = Scroll;
3
96
  //# sourceMappingURL=scroll2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"scroll2.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
1
+ {"version":3,"file":"scroll2.js","sources":["../../../../../../packages/components/scroll/src/scroll.vue"],"sourcesContent":["<template>\n <div ref=\"scrollMainRef\" :class=\"{'is-scrollable':scrollable}\" class=\"relative hzzt-scroll\">\n <div v-if=\"scrollable\" class=\"hzzt-scroll__nav-prev\" @click=\"btnNavPrev\">\n <hzzt-icon name=\"arrow-left\" />\n </div>\n <div v-if=\"scrollable\" class=\"hzzt-scroll__nav-next\" @click=\"btnNavNext\">\n <hzzt-icon name=\"arrow-right\" />\n </div>\n <div ref=\"scrollRef\" class=\"overflow-hidden\">\n <div ref=\"scrollContentRef\" :style=\"{transform: `translateX(${-navTranslateX}px)`}\" class=\"hzzt-scroll__content\">\n <slot />\n </div>\n </div>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\n import {onUpdated, ref} from 'vue';\n import {useResizeObserver} from '@vueuse/core';\n import HzztIcon from \"@hzzt-plus/components/icon/src/index.vue\";\n\n defineOptions({\n name: 'HzztScroll',\n })\n\n const navTranslateX = ref(0);\n const scrollMainRef = ref<HTMLElement | null>(null);\n const scrollRef = ref<HTMLElement | null>(null);\n const scrollContentRef = ref<HTMLElement | null>(null);\n const scrollable = ref(false);\n\n function update() {\n if (!scrollRef.value || !scrollContentRef.value) return;\n const scrollWidth = scrollRef.value ? scrollRef.value.offsetWidth : 0;\n const contentWidth = scrollContentRef.value ? scrollContentRef.value.offsetWidth : 0;\n if (scrollWidth >= contentWidth) {\n scrollable.value = false;\n navTranslateX.value = 0;\n return;\n }\n scrollable.value = true;\n }\n\n useResizeObserver(scrollMainRef, update);\n useResizeObserver(scrollContentRef, update);\n\n onUpdated(() => update());\n\n function btnNavPrev() {\n const containerSize = scrollRef.value?.offsetWidth || 0;\n const currentOffset = navTranslateX.value;\n if (!currentOffset) return;\n const newOffset = currentOffset > containerSize ? currentOffset - containerSize : 0;\n navTranslateX.value = newOffset;\n }\n\n function btnNavNext() {\n const navSize = scrollContentRef.value?.offsetWidth || 0;\n const currentOffset = navTranslateX.value;\n const containerSize = scrollRef.value?.offsetWidth || 0;\n if (navSize - currentOffset < containerSize) return;\n const newOffset = navSize - currentOffset > containerSize * 2 ?\n currentOffset + containerSize :\n navSize - containerSize;\n navTranslateX.value = newOffset;\n }\n</script>\n"],"names":["ref","useResizeObserver","onUpdated"],"mappings":";;;;;;;;;uCAqBgB,CAAA;AAAA,EACZ,IAAM,EAAA,YAAA;AACR,CAAA,CAAA,CAAA;;;;AAEA,IAAM,MAAA,aAAA,GAAgBA,QAAI,CAAC,CAAA,CAAA;AAC3B,IAAM,MAAA,aAAA,GAAgBA,QAAwB,IAAI,CAAA,CAAA;AAClD,IAAM,MAAA,SAAA,GAAYA,QAAwB,IAAI,CAAA,CAAA;AAC9C,IAAM,MAAA,gBAAA,GAAmBA,QAAwB,IAAI,CAAA,CAAA;AACrD,IAAM,MAAA,UAAA,GAAaA,QAAI,KAAK,CAAA,CAAA;AAE5B,IAAA,SAAS,MAAS,GAAA;AAChB,MAAA,IAAI,CAAC,SAAA,CAAU,KAAS,IAAA,CAAC,gBAAiB,CAAA,KAAA;AAAO,QAAA,OAAA;AACjD,MAAA,MAAM,WAAc,GAAA,SAAA,CAAU,KAAQ,GAAA,SAAA,CAAU,MAAM,WAAc,GAAA,CAAA,CAAA;AACpE,MAAA,MAAM,YAAe,GAAA,gBAAA,CAAiB,KAAQ,GAAA,gBAAA,CAAiB,MAAM,WAAc,GAAA,CAAA,CAAA;AACnF,MAAA,IAAI,eAAe,YAAc,EAAA;AAC/B,QAAA,UAAA,CAAW,KAAQ,GAAA,KAAA,CAAA;AACnB,QAAA,aAAA,CAAc,KAAQ,GAAA,CAAA,CAAA;AACtB,QAAA,OAAA;AAAA,OACF;AACA,MAAA,UAAA,CAAW,KAAQ,GAAA,IAAA,CAAA;AAAA,KACrB;AAEA,IAAAC,sBAA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@@ -186,7 +186,12 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
186
186
  }, vue.unref(_selectProps), {
187
187
  onChange: selectChange,
188
188
  onVisibleChange: selectVisibleChange
189
- }), null, 16, ["class", "modelValue"])) : vue.createCommentVNode("v-if", true)
189
+ }), {
190
+ default: vue.withCtx(({ item }) => [
191
+ vue.renderSlot(_ctx.$slots, "default", { item })
192
+ ]),
193
+ _: 3
194
+ }, 16, ["class", "modelValue"])) : vue.createCommentVNode("v-if", true)
190
195
  ], 6);
191
196
  };
192
197
  }