@dao-style/core 0.0.1-beta.13 → 0.0.1-beta.16

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.
@@ -1,5 +1,4 @@
1
- import type { Plugin } from 'vue';
2
1
  import '../styles/common.scss';
3
- import '../styles/color/alias.scss';
2
+ import type { Plugin } from 'vue';
4
3
  declare const plugin: Plugin;
5
4
  export default plugin;
@@ -1,5 +1,7 @@
1
1
  import type { PropType } from 'vue';
2
2
  import type { DaoTableColumn, DaoTableSort } from './type';
3
+ declare type DataPropType = Record<string, unknown>[];
4
+ declare type SelectablePropType = ((row: DataPropType[number], index: number) => boolean) | boolean;
3
5
  declare const tableProps: {
4
6
  id: {
5
7
  type: PropType<string>;
@@ -10,7 +12,7 @@ declare const tableProps: {
10
12
  default: () => DaoTableColumn[];
11
13
  };
12
14
  data: {
13
- type: PropType<Record<string, unknown>[]>;
15
+ type: PropType<DataPropType>;
14
16
  default: () => Record<string, unknown>[];
15
17
  };
16
18
  showHeader: {
@@ -18,7 +20,7 @@ declare const tableProps: {
18
20
  default: boolean;
19
21
  };
20
22
  selectable: {
21
- type: PropType<boolean>;
23
+ type: PropType<SelectablePropType>;
22
24
  default: boolean;
23
25
  };
24
26
  expandable: {
@@ -18,7 +18,7 @@ declare const _default: import("vue").DefineComponent<{
18
18
  default: boolean;
19
19
  };
20
20
  selectable: {
21
- type: import("vue").PropType<boolean>;
21
+ type: import("vue").PropType<boolean | ((row: Record<string, unknown>, index: number) => boolean)>;
22
22
  default: boolean;
23
23
  };
24
24
  expandable: {
@@ -136,6 +136,7 @@ declare const _default: import("vue").DefineComponent<{
136
136
  expandedRows: WeakSet<object>;
137
137
  onRowClick: (row: Record<string, unknown>, rowIndex: number) => void;
138
138
  isEmpty: import("vue").ComputedRef<boolean>;
139
+ selectableRows: import("vue").ComputedRef<Set<Record<string, unknown>>>;
139
140
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("select" | "next" | "prev" | "update:page-size" | "update:current-page" | "sortChange" | "hideColumn" | "afterResize" | "expandToggle" | "pageChange" | "sizeChange" | "row-click")[], "select" | "next" | "prev" | "update:page-size" | "update:current-page" | "sortChange" | "hideColumn" | "afterResize" | "expandToggle" | "pageChange" | "sizeChange" | "row-click", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
140
141
  id?: unknown;
141
142
  columns?: unknown;
@@ -168,7 +169,7 @@ declare const _default: import("vue").DefineComponent<{
168
169
  totalFormat: (val: number) => string;
169
170
  currentPage: number;
170
171
  pageSizerWidth: number;
171
- selectable: boolean;
172
+ selectable: boolean | ((row: Record<string, unknown>, index: number) => boolean);
172
173
  expandable: boolean;
173
174
  emptyText: string;
174
175
  noShadow: boolean;
@@ -201,7 +202,7 @@ declare const _default: import("vue").DefineComponent<{
201
202
  totalFormat: (val: number) => string;
202
203
  currentPage: number;
203
204
  pageSizerWidth: number;
204
- selectable: boolean;
205
+ selectable: boolean | ((row: Record<string, unknown>, index: number) => boolean);
205
206
  expandable: boolean;
206
207
  emptyText: string;
207
208
  noShadow: boolean;
@@ -17,8 +17,9 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- import { defineComponent, computed, openBlock, createElementBlock, normalizeClass, renderSlot, createCommentVNode, createElementVNode, unref, resolveComponent, Fragment, createBlock, createTextVNode, toDisplayString, ref, inject, watchEffect, mergeProps, provide, readonly, toRefs, createVNode, withCtx, watch, Transition, withModifiers, normalizeStyle, withDirectives, vShow, withKeys, getCurrentInstance, onMounted, onBeforeUnmount, Teleport, nextTick, reactive, renderList, getCurrentScope, onScopeDispose, vModelText, onUnmounted, h } from "vue";
20
+ import { defineComponent, computed, openBlock, createElementBlock, normalizeClass, renderSlot, createCommentVNode, createElementVNode, unref, resolveComponent, Fragment, createBlock, createTextVNode, toDisplayString, ref, inject, watchEffect, mergeProps, provide, readonly, toRefs, createVNode, withCtx, watch, onBeforeUnmount, Transition, withModifiers, normalizeStyle, withDirectives, vShow, withKeys, getCurrentInstance, onMounted, Teleport, nextTick, reactive, renderList, getCurrentScope, onScopeDispose, vModelText, onUnmounted, h } from "vue";
21
21
  import { isArray, isSet, looseIndexOf, looseEqual, isFunction, NOOP } from "@vue/shared";
22
+ var common = "";
22
23
  var actionIcon_vue_vue_type_style_index_0_lang = "";
23
24
  var _export_sfc = (sfc, props) => {
24
25
  for (const [key, val] of props) {
@@ -864,8 +865,8 @@ const _sfc_main$y = defineComponent({
864
865
  if (!lockScroll.value) {
865
866
  return;
866
867
  }
867
- const currentDialogNum = Number(document.body.getAttribute(DIALOG_NUM_ATTR) || 0);
868
- document.body.setAttribute(DIALOG_NUM_ATTR, String(currentDialogNum + 1));
868
+ const bodyDialogNum = Number(document.body.getAttribute(DIALOG_NUM_ATTR) || 0);
869
+ document.body.setAttribute(DIALOG_NUM_ATTR, String(bodyDialogNum + 1));
869
870
  document.body.style.overflow = "hidden";
870
871
  };
871
872
  const onClose = () => {
@@ -885,16 +886,18 @@ const _sfc_main$y = defineComponent({
885
886
  return;
886
887
  }
887
888
  const specDialogNum = Number(document.body.getAttribute(DIALOG_NUM_ATTR)) - 1;
888
- if (specDialogNum === 0) {
889
+ if (specDialogNum < 1) {
889
890
  document.body.removeAttribute(DIALOG_NUM_ATTR);
890
891
  document.body.style.overflow = "";
891
892
  } else {
892
893
  document.body.setAttribute(DIALOG_NUM_ATTR, String(specDialogNum));
893
894
  }
894
895
  };
896
+ let currentDialogOpened = false;
895
897
  const onBeforeEnter = () => {
896
- lockWindowScroll();
897
898
  document.addEventListener("keydown", onKeyDown);
899
+ lockWindowScroll();
900
+ currentDialogOpened = true;
898
901
  emit("before-open");
899
902
  };
900
903
  const onAfterEnter = () => {
@@ -915,8 +918,14 @@ const _sfc_main$y = defineComponent({
915
918
  const onAfterLeave = () => {
916
919
  document.removeEventListener("keydown", onKeyDown);
917
920
  unLockWindowScroll();
921
+ currentDialogOpened = false;
918
922
  emit("closed");
919
923
  };
924
+ onBeforeUnmount(() => {
925
+ if (currentDialogOpened) {
926
+ onAfterLeave();
927
+ }
928
+ });
920
929
  return {
921
930
  computedPaddingTop,
922
931
  computedPaddingBottom,
@@ -2648,14 +2657,18 @@ function updatePopperOptions(popperInstance, modifiers, popperOptions = {}) {
2648
2657
  });
2649
2658
  }
2650
2659
  function getActualRoot(app) {
2651
- var _a2, _b2, _c, _d;
2660
+ var _a2, _b2, _c, _d, _e, _f, _g, _h;
2652
2661
  let internalRoot = "body";
2653
2662
  if (!app) {
2654
2663
  return internalRoot;
2655
2664
  }
2656
- const rootNode = (_c = (_b2 = (_a2 = app == null ? void 0 : app.root) == null ? void 0 : _a2.vnode) == null ? void 0 : _b2.el) == null ? void 0 : _c.parentNode.getRootNode();
2665
+ let ele = (_f = (_c = (_b2 = (_a2 = app == null ? void 0 : app.root) == null ? void 0 : _a2.appContext) == null ? void 0 : _b2.app) == null ? void 0 : _c._container) != null ? _f : (_e = (_d = app == null ? void 0 : app.root) == null ? void 0 : _d.vnode) == null ? void 0 : _e.el;
2666
+ if ((ele == null ? void 0 : ele.nodeType) !== Node.ELEMENT_NODE && (ele == null ? void 0 : ele.nodeType) !== Node.DOCUMENT_FRAGMENT_NODE && (ele == null ? void 0 : ele.nodeType) !== Node.DOCUMENT_NODE) {
2667
+ ele = ele == null ? void 0 : ele.parentNode;
2668
+ }
2669
+ const rootNode = (_g = ele == null ? void 0 : ele.getRootNode) == null ? void 0 : _g.call(ele);
2657
2670
  if (rootNode) {
2658
- internalRoot = (_d = rootNode.body) != null ? _d : rootNode;
2671
+ internalRoot = (_h = rootNode.body) != null ? _h : rootNode;
2659
2672
  }
2660
2673
  return internalRoot;
2661
2674
  }
@@ -2684,7 +2697,7 @@ const _sfc_main$v = defineComponent({
2684
2697
  const reference2 = ref(null);
2685
2698
  const popper2 = ref(null);
2686
2699
  const isOpen = ref(false);
2687
- const actualAppendTo = ref("root");
2700
+ const actualAppendTo = ref("body");
2688
2701
  const isTelDisabled = ref(false);
2689
2702
  watch(appendTo, () => {
2690
2703
  const unrefAppendTo = unref(appendTo);
@@ -3666,7 +3679,7 @@ function _sfc_render$j(_ctx, _cache, $props, $setup, $data, $options) {
3666
3679
  return openBlock(), createElementBlock("div", {
3667
3680
  ref: "header",
3668
3681
  "aria-label": "Header",
3669
- class: normalizeClass(_ctx.ns)
3682
+ class: normalizeClass([_ctx.ns, `${_ctx.ns}--${_ctx.type}`])
3670
3683
  }, [
3671
3684
  createElementVNode("div", {
3672
3685
  class: normalizeClass(_ctx.ns + "__left-container")
@@ -5155,8 +5168,10 @@ const _sfc_main$c = defineComponent({
5155
5168
  const bindTriggerEleOutsideClick = {
5156
5169
  cleanup: void 0,
5157
5170
  visible() {
5158
- if (!this.cleanup) {
5159
- this.cleanup = onClickOutside(popper2, () => {
5171
+ var _a2;
5172
+ const el = (_a2 = popper2.value) == null ? void 0 : _a2.popper.$el;
5173
+ if (!this.cleanup && el) {
5174
+ this.cleanup = onClickOutside(el, () => {
5160
5175
  state.visible = false;
5161
5176
  }, {
5162
5177
  ignore: [triggerRef]
@@ -5399,6 +5414,7 @@ const _sfc_main$b = defineComponent({
5399
5414
  const onSelectFn = inject("onSelect");
5400
5415
  const removeFn = inject("remove");
5401
5416
  const selectState = inject("selectState");
5417
+ const { label, disabled, value } = toRefs(props);
5402
5418
  const labelValue = computed(() => {
5403
5419
  if (props.label === null || props.label === void 0) {
5404
5420
  return props.value;
@@ -5406,10 +5422,10 @@ const _sfc_main$b = defineComponent({
5406
5422
  return props.label;
5407
5423
  });
5408
5424
  const instance = reactive({
5409
- label: props.label,
5410
- value: props.value,
5411
- disabled: props.disabled,
5412
- labelValue: labelValue.value,
5425
+ label,
5426
+ value,
5427
+ disabled,
5428
+ labelValue,
5413
5429
  visible: true,
5414
5430
  setVisible(val) {
5415
5431
  instance.visible = val;
@@ -5421,8 +5437,8 @@ const _sfc_main$b = defineComponent({
5421
5437
  return ((_a2 = selectState == null ? void 0 : selectState.selectedOption) == null ? void 0 : _a2.value) === instance.value;
5422
5438
  });
5423
5439
  const isFocus = computed(() => {
5424
- var _a2;
5425
- const index2 = (_a2 = selectState == null ? void 0 : selectState.options.indexOf(instance)) != null ? _a2 : -1;
5440
+ var _a2, _b2;
5441
+ const index2 = (_b2 = (_a2 = selectState == null ? void 0 : selectState.options) == null ? void 0 : _a2.indexOf(instance)) != null ? _b2 : -1;
5426
5442
  return index2 === (selectState == null ? void 0 : selectState.optionFocusIndex);
5427
5443
  });
5428
5444
  watch(isFocus, (val) => {
@@ -5563,13 +5579,11 @@ const _sfc_main$a = defineComponent({
5563
5579
  emit("update:current-page", value);
5564
5580
  emit("page-change", value);
5565
5581
  };
5566
- watch(currentPage, (val) => {
5567
- currentShowPage.value = val;
5568
- });
5569
- watch(totalPage, (val) => {
5570
- if (currentShowPage.value > val) {
5571
- currentShowPage.value = val;
5572
- emit("update:current-page", val);
5582
+ watch([currentPage, totalPage], () => {
5583
+ currentShowPage.value = props.currentPage;
5584
+ if (currentShowPage.value > totalPage.value) {
5585
+ currentShowPage.value = totalPage.value;
5586
+ emit("update:current-page", totalPage.value);
5573
5587
  }
5574
5588
  });
5575
5589
  const updatePageSize = (val) => {
@@ -5616,14 +5630,14 @@ function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
5616
5630
  class: normalizeClass([
5617
5631
  "icon-arrow-previous",
5618
5632
  "dao-pagination__pager-prev",
5619
- { "dao-pagination__pager-icon--disabled": _ctx.currentPage === 1 }
5633
+ { "dao-pagination__pager-icon--disabled": _ctx.currentPage <= 1 }
5620
5634
  ]),
5621
5635
  onClick: _cache[0] || (_cache[0] = (...args) => _ctx.prevPage && _ctx.prevPage(...args))
5622
5636
  }, null, 2),
5623
5637
  withDirectives(createElementVNode("input", {
5624
5638
  "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => _ctx.currentShowPage = $event),
5625
5639
  class: "dao-pagination__pager-current",
5626
- disabled: _ctx.totalPage === 1,
5640
+ disabled: _ctx.totalPage <= 1,
5627
5641
  onKeydown: _cache[2] || (_cache[2] = withKeys((...args) => _ctx.targetPage && _ctx.targetPage(...args), ["enter"])),
5628
5642
  onInput: _cache[3] || (_cache[3] = (...args) => _ctx.currentShowPageFormat && _ctx.currentShowPageFormat(...args))
5629
5643
  }, null, 40, _hoisted_1$6), [
@@ -5634,7 +5648,7 @@ function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
5634
5648
  class: normalizeClass([
5635
5649
  "icon-arrow-next",
5636
5650
  "dao-pagination__pager-next",
5637
- { "dao-pagination__pager-icon--disabled": _ctx.currentPage === _ctx.totalPage }
5651
+ { "dao-pagination__pager-icon--disabled": _ctx.currentPage >= _ctx.totalPage }
5638
5652
  ]),
5639
5653
  onClick: _cache[4] || (_cache[4] = (...args) => _ctx.nextPage && _ctx.nextPage(...args))
5640
5654
  }, null, 2)
@@ -6069,7 +6083,7 @@ const tableProps = {
6069
6083
  default: true
6070
6084
  },
6071
6085
  selectable: {
6072
- type: Boolean,
6086
+ type: [Function, Boolean],
6073
6087
  default: false
6074
6088
  },
6075
6089
  expandable: {
@@ -6161,6 +6175,17 @@ const _sfc_main$3 = defineComponent({
6161
6175
  const sort = reactive(props.sort);
6162
6176
  const expandRows = reactive([]);
6163
6177
  const selectedRows = reactive(new Set());
6178
+ const selectableFn = computed(() => typeof props.selectable === "function" ? props.selectable : () => true);
6179
+ const selectableRows = computed(() => {
6180
+ var _a2;
6181
+ const selectableRowsSet = new Set();
6182
+ (_a2 = props.data) == null ? void 0 : _a2.forEach((item, index2) => {
6183
+ if (selectableFn.value && selectableFn.value(item, index2)) {
6184
+ selectableRowsSet.add(item);
6185
+ }
6186
+ });
6187
+ return selectableRowsSet;
6188
+ });
6164
6189
  const expandedRows = reactive(new WeakSet());
6165
6190
  const columnRefs = reactive({});
6166
6191
  const columns = reactive([]);
@@ -6310,14 +6335,16 @@ const _sfc_main$3 = defineComponent({
6310
6335
  }
6311
6336
  };
6312
6337
  const toggleSelectedAll = () => {
6313
- if (global2.checked) {
6314
- selectedRows.clear();
6315
- emit("select", []);
6316
- } else {
6338
+ if (!global2.checked || global2.indeterminate) {
6317
6339
  props.data.forEach((item) => {
6318
- selectedRows.add(item);
6340
+ if (selectableRows.value.has(item)) {
6341
+ selectedRows.add(item);
6342
+ }
6319
6343
  });
6320
6344
  emit("select", Array.from(selectedRows));
6345
+ } else {
6346
+ selectedRows.clear();
6347
+ emit("select", []);
6321
6348
  }
6322
6349
  };
6323
6350
  const fixedColumnWidth = () => {
@@ -6348,7 +6375,7 @@ const _sfc_main$3 = defineComponent({
6348
6375
  const item = props.data[i];
6349
6376
  if (selectedRows.has(item)) {
6350
6377
  have += 1;
6351
- } else {
6378
+ } else if (selectableRows.value.has(item)) {
6352
6379
  notHave += 1;
6353
6380
  }
6354
6381
  if (have && notHave) {
@@ -6416,7 +6443,8 @@ const _sfc_main$3 = defineComponent({
6416
6443
  tableScroll,
6417
6444
  expandedRows,
6418
6445
  onRowClick,
6419
- isEmpty
6446
+ isEmpty,
6447
+ selectableRows
6420
6448
  };
6421
6449
  }
6422
6450
  });
@@ -6518,9 +6546,10 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
6518
6546
  }, [
6519
6547
  _ctx.selectable ? (openBlock(), createElementBlock("td", _hoisted_10, [
6520
6548
  createVNode(_component_dao_checkbox, {
6549
+ disabled: !_ctx.selectableRows.has(row),
6521
6550
  checked: _ctx.isRowSelected(row),
6522
6551
  onChange: ($event) => _ctx.toggleSelected(row)
6523
- }, null, 8, ["checked", "onChange"])
6552
+ }, null, 8, ["disabled", "checked", "onChange"])
6524
6553
  ])) : createCommentVNode("", true),
6525
6554
  _ctx.expandable ? (openBlock(), createElementBlock("td", _hoisted_11, [
6526
6555
  createElementVNode("i", {
@@ -6910,8 +6939,6 @@ var components = /* @__PURE__ */ Object.freeze({
6910
6939
  TabItem: tabItem,
6911
6940
  Tooltip: _sfc_main$o
6912
6941
  });
6913
- var common = "";
6914
- var alias = "";
6915
6942
  const plugin = (app) => {
6916
6943
  Object.values(components).forEach((c) => {
6917
6944
  app.component(c.name, c);