@fastkit/vui 0.6.20 → 0.6.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/vui.cjs.js CHANGED
@@ -3,9 +3,9 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var vueKit = require('@fastkit/vue-kit');
6
+ var vueUtils = require('@fastkit/vue-utils');
6
7
  var vue = require('vue');
7
8
  var vueColorScheme = require('@fastkit/vue-color-scheme');
8
- var vueUtils = require('@fastkit/vue-utils');
9
9
  var vueLoading = require('@fastkit/vue-loading');
10
10
  var iconFont = require('@fastkit/icon-font');
11
11
  var helpers = require('@fastkit/helpers');
@@ -164,7 +164,7 @@ const VFormControl = vue.defineComponent({
164
164
  }
165
165
  }, [label, control.required && vui.getRequiredChip()]), vue.createVNode("div", {
166
166
  "class": "v-form-control__body"
167
- }, [vueKit.renderSlotOrEmpty(ctx.slots, 'default', control), vue.createVNode("div", {
167
+ }, [vueKit.renderSlotOrEmpty(ctx.slots, 'default', control), !props.hiddenInfo && vue.createVNode("div", {
168
168
  "class": "v-form-control__info"
169
169
  }, [!!message && vue.createVNode("div", {
170
170
  "class": "v-form-control__message"
@@ -217,6 +217,7 @@ function defineFormSelectorComponent(opts) {
217
217
  return vue.createVNode(VFormControl, {
218
218
  "nodeControl": this.nodeControl,
219
219
  "focused": this.nodeControl.focused,
220
+ "hiddenInfo": this.hiddenInfo,
220
221
  "class": ['v-form-selector', className, { ...this.classes,
221
222
  'v-form-selector--stacked': this.stacked
222
223
  }],
@@ -590,7 +591,6 @@ const VPagination = vue.defineComponent({
590
591
  const vui = useVui();
591
592
  const elRef = vue.ref(null);
592
593
  const router = vueRouter.useRouter();
593
- const route = vueRouter.useRoute();
594
594
  const internalValue = vue.ref(1);
595
595
  const containerWidth = vue.ref(0);
596
596
  const itemSize = vue.ref(0);
@@ -611,13 +611,22 @@ const VPagination = vue.defineComponent({
611
611
  } = props;
612
612
 
613
613
  if (routeQuery) {
614
- return vueUtils.getRouteQuery(route.query, routeQuery, Number, 1);
614
+ return vui.location.getQuery(routeQuery, Number, 1);
615
615
  }
616
616
 
617
617
  return internalValue.value;
618
618
  });
619
619
 
620
- const _range = (from, to) => helpers.range(to - from, from);
620
+ const _range = (from, to) => {
621
+ const range = [];
622
+ from = from > 0 ? from : 1;
623
+
624
+ for (let i = from; i <= to; i++) {
625
+ range.push(i);
626
+ }
627
+
628
+ return range;
629
+ };
621
630
 
622
631
  const computedItems = vue.computed(() => {
623
632
  const maxButtons = computedNumbersLength.value;
@@ -653,10 +662,7 @@ const VPagination = vue.defineComponent({
653
662
  const {
654
663
  routeQuery
655
664
  } = props;
656
- if (!routeQuery) return false; // @TODO
657
- // return this.$location.isQueryOnlyTransitioning(routeQuery);
658
-
659
- return false;
665
+ return vui.location.isQueryOnlyTransitioning(routeQuery);
660
666
  });
661
667
  const isDisabled = vue.computed(() => props.disabled || isTransitioning.value);
662
668
  const classes = vue.computed(() => [{
@@ -729,9 +735,9 @@ const VPagination = vue.defineComponent({
729
735
  }
730
736
 
731
737
  function createRoutableLocationByPage(page, routeQuery) {
732
- return vueUtils.getQueryMergedLocation({
738
+ return vui.location.getQueryMergedLocation({
733
739
  [routeQuery]: page
734
- }, route);
740
+ });
735
741
  }
736
742
 
737
743
  function genItem(source, index) {
@@ -741,8 +747,7 @@ const VPagination = vue.defineComponent({
741
747
  active,
742
748
  disabled
743
749
  } = createPageInfo(source);
744
- const type = number ? 'num' : source; // const staticClass = `pagination__item`;
745
-
750
+ const type = number ? 'num' : source;
746
751
  const classes = ['v-pagination__item', {
747
752
  [`v-pagination__item--${type}`]: true,
748
753
  'v-pagination__item--active': active,
@@ -754,11 +759,10 @@ const VPagination = vue.defineComponent({
754
759
  }
755
760
 
756
761
  const isPrev = type === 'prev';
757
- const name = isPrev ? 'chevron-left' : 'chevron-right';
758
- return vue.createVNode(VIcon, {
759
- "class": "v-pagination__item__icon",
760
- "name": name
761
- }, null);
762
+ const icon = isPrev ? vui.icon('prev') : vui.icon('next');
763
+ return resolveRawIconProp(false, icon, {
764
+ class: 'v-pagination__item__icon'
765
+ });
762
766
  })();
763
767
 
764
768
  const onClick = ev => {
@@ -1744,6 +1748,7 @@ const VSelect = vue.defineComponent({
1744
1748
  "class": ['v-select', this.classes],
1745
1749
  "label": this.label,
1746
1750
  "hint": this.hint,
1751
+ "hiddenInfo": this.hiddenInfo,
1747
1752
  "onClickLabel": ev => {
1748
1753
  this.focus();
1749
1754
  }
@@ -1770,7 +1775,20 @@ const VSelect = vue.defineComponent({
1770
1775
  "focused": this.menuOpened,
1771
1776
  "onClick": ev => {
1772
1777
  if (this.canOperation && !control.isActive) {
1773
- control.show(ev);
1778
+ let t = ev.target;
1779
+ const count = 0;
1780
+ let hit = false;
1781
+
1782
+ while (count < 5) {
1783
+ if (t.classList.contains('v-select__input')) {
1784
+ hit = true;
1785
+ break;
1786
+ }
1787
+
1788
+ t = t.parentElement;
1789
+ }
1790
+
1791
+ control.show(hit ? t : ev);
1774
1792
  }
1775
1793
  }
1776
1794
  }, { ...this.$slots,
@@ -1855,6 +1873,7 @@ const VTextField = vue.defineComponent({
1855
1873
  return vue.createVNode(VFormControl, {
1856
1874
  "nodeControl": this.nodeControl,
1857
1875
  "focused": this.nodeControl.focused,
1876
+ "hiddenInfo": this.hiddenInfo,
1858
1877
  "class": ['v-text-field', this.classes],
1859
1878
  "label": this.label,
1860
1879
  "hint": this.hint,
@@ -1918,6 +1937,7 @@ const VTextarea = vue.defineComponent({
1918
1937
  "class": ['v-textarea', this.classes],
1919
1938
  "label": this.label,
1920
1939
  "hint": this.hint,
1940
+ "hiddenInfo": this.hiddenInfo,
1921
1941
  "onClickLabel": ev => {
1922
1942
  this.focus();
1923
1943
  }
@@ -2003,6 +2023,633 @@ const VForm = vue.defineComponent({
2003
2023
 
2004
2024
  });
2005
2025
 
2026
+ const DATA_TABLE_DEFAULTS = {
2027
+ itemKey: 'id',
2028
+ pageQuery: 'page',
2029
+ sortQuery: 'sort',
2030
+ orderQuery: 'order',
2031
+ limitQuery: 'limit',
2032
+ defaultOrder: 'ASC',
2033
+ ascQueryValue: 'ASC',
2034
+ descQueryValue: 'DESC',
2035
+ limits: [5, 10, 20, 50, 100],
2036
+ limitDefault: 20,
2037
+ contorolThreshold: 10
2038
+ };
2039
+ function configureDataTableDefaults(defaults) {
2040
+ Object.assign(DATA_TABLE_DEFAULTS, defaults);
2041
+
2042
+ if (!defaults.defaultOrder && defaults.ascQueryValue) {
2043
+ DATA_TABLE_DEFAULTS.defaultOrder = defaults.ascQueryValue;
2044
+ }
2045
+ }
2046
+ const SELECTABLE_HEADER_SYMBOL = '__selectable_header__';
2047
+ const VDataTable = vue.defineComponent({
2048
+ name: 'VDataTable',
2049
+ props: {
2050
+ /** 選択中のkeyの配列 */
2051
+ modelValue: {
2052
+ type: Array,
2053
+ default: () => []
2054
+ },
2055
+ itemKey: {
2056
+ type: String,
2057
+ default: () => DATA_TABLE_DEFAULTS.itemKey
2058
+ },
2059
+
2060
+ /**
2061
+ * ページネーションクエリ名
2062
+ */
2063
+ pageQuery: {
2064
+ type: String,
2065
+ default: () => DATA_TABLE_DEFAULTS.pageQuery
2066
+ },
2067
+
2068
+ /**
2069
+ * ソートクエリ名
2070
+ */
2071
+ sortQuery: {
2072
+ type: String,
2073
+ default: () => DATA_TABLE_DEFAULTS.sortQuery
2074
+ },
2075
+
2076
+ /**
2077
+ * 表示順クエリ名
2078
+ */
2079
+ orderQuery: {
2080
+ type: String,
2081
+ default: () => DATA_TABLE_DEFAULTS.orderQuery
2082
+ },
2083
+
2084
+ /**
2085
+ * リミット件数クエリ名
2086
+ */
2087
+ limitQuery: {
2088
+ type: String,
2089
+ default: () => DATA_TABLE_DEFAULTS.limitQuery
2090
+ },
2091
+ defaultOrder: {
2092
+ type: String,
2093
+ default: () => DATA_TABLE_DEFAULTS.defaultOrder
2094
+ },
2095
+ ascQueryValue: {
2096
+ type: String,
2097
+ default: () => DATA_TABLE_DEFAULTS.ascQueryValue
2098
+ },
2099
+ descQueryValue: {
2100
+ type: String,
2101
+ default: () => DATA_TABLE_DEFAULTS.descQueryValue
2102
+ },
2103
+ limits: {
2104
+ type: Array,
2105
+ default: () => DATA_TABLE_DEFAULTS.limits
2106
+ },
2107
+ limitDefault: {
2108
+ type: Number,
2109
+ default: () => DATA_TABLE_DEFAULTS.limitDefault
2110
+ },
2111
+ contorolThreshold: {
2112
+ type: Number,
2113
+ default: () => DATA_TABLE_DEFAULTS.contorolThreshold
2114
+ },
2115
+ headers: {
2116
+ type: Array,
2117
+ required: true
2118
+ },
2119
+ items: {
2120
+ type: Array,
2121
+ default: () => []
2122
+ },
2123
+ total: {
2124
+ type: Number,
2125
+ default: 0
2126
+ },
2127
+ selectable: Boolean,
2128
+ fixedHeader: Boolean,
2129
+ maxHeight: [Number, String]
2130
+ },
2131
+ emits: {
2132
+ input: selecteds => true
2133
+ },
2134
+
2135
+ setup(props, ctx) {
2136
+ const vui = useVui();
2137
+ const bootedRef = vue.ref(false);
2138
+ const footerHeightRef = vue.ref(0);
2139
+ const internalValues = vue.ref(props.modelValue.slice());
2140
+ const sortedItemKeysRef = vue.computed(() => props.items.map(item => item[props.itemKey]));
2141
+ const isEmptyRef = vue.computed(() => props.items.length === 0);
2142
+ const headersRef = vue.computed(() => {
2143
+ const {
2144
+ headers,
2145
+ selectable
2146
+ } = props;
2147
+ const ret = [];
2148
+
2149
+ if (selectable) {
2150
+ ret.push({
2151
+ key: SELECTABLE_HEADER_SYMBOL
2152
+ });
2153
+ }
2154
+
2155
+ ret.push(...headers.filter(h => !h.hidden));
2156
+ return ret;
2157
+ });
2158
+ const classesRef = vue.computed(() => [{
2159
+ 'v-data-table--fixed-header': props.fixedHeader
2160
+ }]);
2161
+ const layout = vueAppLayout.VAppLayoutControl.use();
2162
+ const bodyInnerStylesRef = vue.computed(() => {
2163
+ if (!bootedRef.value) return;
2164
+ const {
2165
+ fixedHeader,
2166
+ maxHeight
2167
+ } = props;
2168
+ const footerHeight = footerHeightRef.value;
2169
+
2170
+ const _maxHeight = maxHeight || (fixedHeader ? '100%' : maxHeight);
2171
+
2172
+ if (!_maxHeight) {
2173
+ return;
2174
+ }
2175
+
2176
+ return {
2177
+ maxHeight: layout.calicurateViewHeight(_maxHeight, -footerHeight - 100, 200)
2178
+ };
2179
+ });
2180
+ const defaultOrderQueryRef = vue.computed(() => props.defaultOrder === props.ascQueryValue ? props.ascQueryValue : props.descQueryValue);
2181
+ const isTransitioningRef = vue.computed(() => {
2182
+ return vui.location.isQueryOnlyTransitioning([props.pageQuery, props.sortQuery, props.orderQuery, props.limitQuery]);
2183
+ });
2184
+ const pageRef = vue.computed(() => vui.location.getQuery(props.pageQuery, Number, 1));
2185
+ const needShowHeaderControlRef = vue.computed(() => props.items.length > props.contorolThreshold);
2186
+ const sortByRef = vue.computed({
2187
+ get: () => {
2188
+ return vui.location.getQuery(props.sortQuery);
2189
+ },
2190
+
2191
+ set(value) {
2192
+ vui.location.pushQuery({
2193
+ [props.sortQuery]: value || null,
2194
+ [props.pageQuery]: 1
2195
+ });
2196
+ }
2197
+
2198
+ });
2199
+ const ordersRef = vue.computed(() => [props.ascQueryValue, props.descQueryValue]);
2200
+ const usePaigingRef = vue.computed(() => props.limits.length > 0);
2201
+ const orderByRef = vue.computed({
2202
+ get: () => {
2203
+ const value = vui.location.getQuery(props.orderQuery);
2204
+
2205
+ if (typeof value !== 'string' || !ordersRef.value.includes(value)) {
2206
+ return;
2207
+ }
2208
+
2209
+ return value;
2210
+ },
2211
+
2212
+ set(value) {
2213
+ vui.location.pushQuery({
2214
+ [props.orderQuery]: value || null,
2215
+ [props.pageQuery]: 1
2216
+ });
2217
+ }
2218
+
2219
+ });
2220
+ const offsetRef = vue.computed(() => (pageRef.value - 1) * limitRef.value);
2221
+ const limitRef = vue.computed({
2222
+ get: () => vui.location.getQuery(props.limitQuery, Number, props.limitDefault),
2223
+ set: value => {
2224
+ const page = Math.floor(offsetRef.value / value) + 1;
2225
+ vui.location.pushQuery({
2226
+ [props.limitQuery]: value,
2227
+ [props.pageQuery]: page
2228
+ });
2229
+ }
2230
+ });
2231
+ const pageLengthRef = vue.computed(() => {
2232
+ const {
2233
+ total
2234
+ } = props;
2235
+ const _limit = limitRef.value;
2236
+ if (!total) return 0;
2237
+ return Math.ceil(total / _limit);
2238
+ });
2239
+ const lengthRef = vue.computed(() => props.items.length);
2240
+ const isASCRef = vue.computed(() => orderByRef.value === props.ascQueryValue); // const isDESCRef = computed(() => orderByRef.value === props.descQueryValue);
2241
+
2242
+ const sortIconRef = vue.computed(() => {
2243
+ let icon = vui.icon('sort');
2244
+
2245
+ if (typeof icon === 'string') {
2246
+ const name = icon;
2247
+
2248
+ icon = gen => {
2249
+ return gen({
2250
+ name,
2251
+ rotate: isASCRef.value ? 180 : 0
2252
+ });
2253
+ };
2254
+ }
2255
+
2256
+ return icon;
2257
+ });
2258
+ const isIndeterminateRef = vue.computed(() => {
2259
+ const {
2260
+ length
2261
+ } = internalValues.value;
2262
+ return length > 0 && length < sortedItemKeysRef.value.length;
2263
+ });
2264
+ const isAllSelectedRef = vue.computed(() => internalValues.value.length === sortedItemKeysRef.value.length);
2265
+
2266
+ function setSort(settings) {
2267
+ const {
2268
+ sort,
2269
+ order
2270
+ } = settings;
2271
+ if ((sort === undefined || sortByRef.value === sort) && (order === undefined || orderByRef.value === order)) return;
2272
+ const queries = {};
2273
+
2274
+ if (sort) {
2275
+ queries[props.sortQuery] = sort;
2276
+ }
2277
+
2278
+ if (order) {
2279
+ queries[props.orderQuery] = order;
2280
+ }
2281
+
2282
+ vui.location.pushQuery({ ...queries,
2283
+ [props.pageQuery]: 1
2284
+ });
2285
+ }
2286
+
2287
+ function toggleOrderBy() {
2288
+ return setSort({
2289
+ order: orderByRef.value === props.ascQueryValue ? props.descQueryValue : props.ascQueryValue
2290
+ });
2291
+ }
2292
+
2293
+ function isSelected(key) {
2294
+ return internalValues.value.includes(key);
2295
+ }
2296
+
2297
+ function select(key) {
2298
+ if (!internalValues.value.includes(key)) {
2299
+ const values = internalValues.value.slice();
2300
+ values.push(key);
2301
+ const sortedKeys = sortedItemKeysRef.value;
2302
+ values.sort((a, b) => {
2303
+ const ai = sortedKeys.indexOf(a);
2304
+ const bi = sortedKeys.indexOf(b);
2305
+ if (ai < bi) return -1;
2306
+ if (ai > bi) return 1;
2307
+ return 0;
2308
+ });
2309
+ internalValues.value = values;
2310
+ ctx.emit('input', values);
2311
+ }
2312
+ }
2313
+
2314
+ function selectAll() {
2315
+ if (!isAllSelectedRef.value) {
2316
+ const values = sortedItemKeysRef.value.slice();
2317
+ internalValues.value = values;
2318
+ ctx.emit('input', values);
2319
+ }
2320
+ }
2321
+
2322
+ function deselectAll() {
2323
+ if (internalValues.value.length) {
2324
+ const values = [];
2325
+ internalValues.value = values;
2326
+ ctx.emit('input', values);
2327
+ }
2328
+ }
2329
+
2330
+ function deselect(key) {
2331
+ const values = internalValues.value.slice();
2332
+ const index = values.indexOf(key);
2333
+
2334
+ if (index !== -1) {
2335
+ values.splice(index, 1);
2336
+ internalValues.value = values;
2337
+ ctx.emit('input', values);
2338
+ }
2339
+ }
2340
+
2341
+ function handleClickSortHeader(header, ev) {
2342
+ const {
2343
+ sortQuery
2344
+ } = header;
2345
+ if (!sortQuery) return;
2346
+
2347
+ if (sortByRef.value === sortQuery) {
2348
+ return toggleOrderBy();
2349
+ }
2350
+
2351
+ return setSort({
2352
+ sort: sortQuery,
2353
+ order: defaultOrderQueryRef.value
2354
+ });
2355
+ }
2356
+
2357
+ function genPagination() {
2358
+ return vue.createVNode(VPagination, {
2359
+ "class": "v-data-table__pagination",
2360
+ "dense": true,
2361
+ "align": "right",
2362
+ "routeQuery": props.pageQuery,
2363
+ "modelValue": pageRef.value,
2364
+ "length": pageLengthRef.value
2365
+ }, null);
2366
+ }
2367
+
2368
+ function genControls() {
2369
+ const {
2370
+ total
2371
+ } = props;
2372
+ const offset = offsetRef.value;
2373
+ const length = lengthRef.value;
2374
+ return vue.createVNode("div", {
2375
+ "class": "v-data-table__controls"
2376
+ }, [vue.createVNode("div", {
2377
+ "class": "v-data-table__controls__info"
2378
+ }, [vue.createVNode("small", {
2379
+ "class": "v-data-table__controls__info__length"
2380
+ }, [vue.createTextVNode("\u5168 "), total, vue.createTextVNode(" \u4EF6\u4E2D "), offset + 1, vue.createTextVNode(" \u4EF6 \u301C "), offset + length, vue.createTextVNode(" \u4EF6\u3092\u8868\u793A")])]), vue.createVNode("div", {
2381
+ "class": "v-data-table__controls__select-limit"
2382
+ }, [vue.createVNode("span", {
2383
+ "class": "v-data-table__controls__select-limit__prefix"
2384
+ }, [vue.createTextVNode("1\u30DA\u30FC\u30B8\u306B")]), vue.createVNode(VSelect, {
2385
+ "class": "v-data-table__controls__select-limit__node",
2386
+ "size": "sm",
2387
+ "hiddenInfo": true,
2388
+ "disabled": isTransitioningRef.value,
2389
+ "items": props.limits.map(limit => {
2390
+ return {
2391
+ label: `${limit}件`,
2392
+ value: limit
2393
+ };
2394
+ }),
2395
+ "modelValue": limitRef.value,
2396
+ "onUpdate:modelValue": $event => limitRef.value = $event
2397
+ }, null)]), vue.createVNode("div", {
2398
+ "class": "v-data-table__controls__pagination"
2399
+ }, [genPagination()])]);
2400
+ }
2401
+
2402
+ function genTableHeader() {
2403
+ const sortBy = sortByRef.value;
2404
+ const isIndeterminate = isIndeterminateRef.value;
2405
+ const isAllSelected = isAllSelectedRef.value;
2406
+ const {
2407
+ defaultOrder,
2408
+ ascQueryValue
2409
+ } = props;
2410
+ const usePaiging = usePaigingRef.value;
2411
+ const children = headersRef.value.map(header => {
2412
+ const {
2413
+ label,
2414
+ sortQuery,
2415
+ align,
2416
+ key
2417
+ } = header;
2418
+ const headerChildren = [];
2419
+
2420
+ if (label != null && typeof label !== 'boolean') {
2421
+ let _children = typeof label === 'function' ? label(vui) : label;
2422
+
2423
+ if (_children && !Array.isArray(_children) && typeof _children === 'object') {
2424
+ _children = JSON.stringify(_children);
2425
+ }
2426
+
2427
+ headerChildren.push(_children);
2428
+ }
2429
+
2430
+ if (key === SELECTABLE_HEADER_SYMBOL) {
2431
+ headerChildren.push(vue.createVNode(VCheckbox, {
2432
+ "modelValue": isAllSelected,
2433
+ "indeterminate": isIndeterminate,
2434
+ "onChange": ev => {
2435
+ if (isAllSelectedRef.value) {
2436
+ deselectAll();
2437
+ } else {
2438
+ selectAll();
2439
+ }
2440
+ }
2441
+ }, null));
2442
+ } // if (key === DELETOR_HEADER_SYMBOL) {
2443
+ // headerChildren.push('削除');
2444
+ // }
2445
+
2446
+
2447
+ const sortActive = sortBy === sortQuery;
2448
+
2449
+ if (sortQuery && usePaiging) {
2450
+ const isASC = sortActive ? isASCRef.value : defaultOrder === ascQueryValue;
2451
+ headerChildren.unshift(vue.createVNode(VIcon, {
2452
+ "class": "v-data-table__table__sort-icon v-data-table__table__sort-icon--empty",
2453
+ "name": "$empty"
2454
+ }, null));
2455
+ headerChildren.push(resolveRawIconProp(false, sortIconRef.value, {
2456
+ class: ['v-data-table__table__sort-icon v-data-table__table__sort-icon--arrow', {
2457
+ 'v-data-table__table__sort-icon--asc': isASC,
2458
+ 'v-data-table__table__sort-icon--desc': !isASC
2459
+ }]
2460
+ }));
2461
+ }
2462
+
2463
+ const classes = ['v-data-table__table__cell', {
2464
+ 'v-data-table__table__cell--active': sortActive
2465
+ }];
2466
+
2467
+ if (align) {
2468
+ classes.push(`v-data-table__table__cell--${align}`);
2469
+ }
2470
+
2471
+ return vue.createVNode("th", {
2472
+ "class": classes,
2473
+ "key": header.key,
2474
+ "tabindex": sortQuery && usePaiging ? 0 : undefined,
2475
+ "onClick": ev => {
2476
+ if (!sortQuery || !usePaiging) return;
2477
+ handleClickSortHeader(header);
2478
+ }
2479
+ }, [vue.createVNode("div", {
2480
+ "class": "v-data-table__table__cell__tile"
2481
+ }, [headerChildren])]);
2482
+ });
2483
+ return vue.createVNode("thead", {
2484
+ "class": "v-data-table__table__header"
2485
+ }, [vue.createVNode("tr", null, [children])]);
2486
+ }
2487
+
2488
+ function toggleSelect(key) {
2489
+ return isSelected(key) ? deselect(key) : select(key);
2490
+ }
2491
+
2492
+ function defaultItemSlot(payload) {
2493
+ const {
2494
+ key,
2495
+ item,
2496
+ selected
2497
+ } = payload;
2498
+ const headers = headersRef.value; // const { $scopedSlots, $createElement, deletor } = this;
2499
+
2500
+ const children = headers.map(header => {
2501
+ const {
2502
+ cell,
2503
+ align,
2504
+ key: headerKey
2505
+ } = header;
2506
+ const cellSlot = cell || ctx.slots.cell;
2507
+ let cellChildren;
2508
+
2509
+ if (cellSlot) {
2510
+ const cellPayload = {
2511
+ vui,
2512
+ item,
2513
+ selected
2514
+ };
2515
+
2516
+ let _children = cellSlot(cellPayload);
2517
+
2518
+ if (_children && !Array.isArray(_children) && typeof _children === 'object') {
2519
+ _children = JSON.stringify(_children);
2520
+ }
2521
+
2522
+ cellChildren = _children;
2523
+ }
2524
+
2525
+ if (!cellChildren) {
2526
+ switch (headerKey) {
2527
+ case SELECTABLE_HEADER_SYMBOL:
2528
+ {
2529
+ cellChildren = [vue.createVNode(VCheckbox, {
2530
+ "modelValue": selected,
2531
+ "onChange": ev => {
2532
+ toggleSelect(key);
2533
+ }
2534
+ }, null)];
2535
+ break;
2536
+ }
2537
+ // case DELETOR_HEADER_SYMBOL: {
2538
+ // if (deletor) {
2539
+ // const onClick = async (event: MouseEvent) => {
2540
+ // if (
2541
+ // await this.$confirm(`${key}を削除します。よろしいですか?`)
2542
+ // ) {
2543
+ // this.deletingTargets.push(key);
2544
+ // await deletor(item);
2545
+ // this.deletingTargets.splice(
2546
+ // this.deletingTargets.indexOf(key),
2547
+ // 1,
2548
+ // );
2549
+ // }
2550
+ // };
2551
+ // cellChildren = [
2552
+ // <VBtn
2553
+ // icon="trush"
2554
+ // onClick={onClick}
2555
+ // disabled={this.deletingTargets.includes(key)}
2556
+ // />,
2557
+ // ];
2558
+ // }
2559
+ // break;
2560
+ // }
2561
+ }
2562
+ }
2563
+
2564
+ const classes = align ? {
2565
+ [`v-data-table__table__cell--${align}`]: true
2566
+ } : undefined;
2567
+ return vue.createVNode("td", {
2568
+ "class": ['v-data-table__table__cell', classes],
2569
+ "key": header.key
2570
+ }, [cellChildren]);
2571
+ });
2572
+ return vue.createVNode("tr", {
2573
+ "class": ['v-data-table__table__item', {
2574
+ 'v-data-table__table__item--selected': selected
2575
+ }],
2576
+ "key": key
2577
+ }, [children]);
2578
+ }
2579
+
2580
+ function genBody() {
2581
+ const {
2582
+ items,
2583
+ itemKey
2584
+ } = props;
2585
+ const {
2586
+ item: itemSlot = defaultItemSlot
2587
+ } = ctx.slots;
2588
+ const children = items.map(item => {
2589
+ const key = item[itemKey];
2590
+ const payload = {
2591
+ key,
2592
+ item,
2593
+ selected: isSelected(key)
2594
+ };
2595
+ return itemSlot(payload);
2596
+ });
2597
+ return vue.createVNode("tbody", {
2598
+ "class": "v-data-table__table__body"
2599
+ }, [children]);
2600
+ }
2601
+
2602
+ vue.watch(() => props.modelValue, modelValue => {
2603
+ internalValues.value = modelValue.slice();
2604
+ });
2605
+ vue.watch(() => props.items, items => {
2606
+ internalValues.value = internalValues.value.filter(key => {
2607
+ return sortedItemKeysRef.value.includes(key);
2608
+ });
2609
+ });
2610
+ vue.onMounted(() => {
2611
+ bootedRef.value = true;
2612
+ });
2613
+ return () => {
2614
+ const isEmpty = isEmptyRef.value;
2615
+ const usePaiging = usePaigingRef.value;
2616
+ return vue.createVNode("div", {
2617
+ "class": ['v-data-table', classesRef.value]
2618
+ }, [!isEmpty && usePaiging && needShowHeaderControlRef.value && vue.createVNode("div", {
2619
+ "class": "v-data-table__header"
2620
+ }, [genControls()]), vue.createVNode("div", {
2621
+ "class": "v-data-table__body container-pull"
2622
+ }, [isEmpty ? vue.createVNode("div", {
2623
+ "class": "v-data-table__empty--message"
2624
+ }, null) : vue.createVNode(VPaper, {
2625
+ "class": "v-data-table__body__inner",
2626
+ "style": bodyInnerStylesRef.value
2627
+ }, {
2628
+ default: () => [vue.createVNode("div", {
2629
+ "class": "v-data-table__table-wrapper"
2630
+ }, [vue.createVNode("table", {
2631
+ "class": "v-data-table__table"
2632
+ }, [genTableHeader(), genBody()])])]
2633
+ }), vue.createVNode(vue.Transition, {
2634
+ "name": "fade"
2635
+ }, {
2636
+ default: () => [isTransitioningRef.value && vue.createVNode("div", {
2637
+ "class": "v-data-table__loading"
2638
+ }, [vue.createVNode(vueLoading.VProgressCircular, {
2639
+ "indeterminate": true
2640
+ }, null)])]
2641
+ })]), !isEmpty && usePaiging && vue.withDirectives(vue.createVNode("div", {
2642
+ "class": "v-data-table__footer"
2643
+ }, [genControls()]), [vueUtils.resizeDirectiveArgument(({
2644
+ height
2645
+ }) => {
2646
+ footerHeightRef.value = height;
2647
+ })])]);
2648
+ };
2649
+ }
2650
+
2651
+ });
2652
+
2006
2653
  function _isSlot$2(s) {
2007
2654
  return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !vue.isVNode(s);
2008
2655
  }
@@ -2144,6 +2791,8 @@ class VuiService {
2144
2791
  autoScrollToElementOffsetTop;
2145
2792
  textareaRows;
2146
2793
  requiredChip;
2794
+ router;
2795
+ location;
2147
2796
  constructor(options) {
2148
2797
  this.options = options;
2149
2798
  const { selectionSeparator = () => ', ', autoScrollToElementOffsetTop = DEFAULT_AUTO_SCROLL_TO_ELEMENT_OFFSET_TOP, textareaRows = DEFAULT_TEXTAREA_ROWS, requiredChip = () => '*', } = options;
@@ -2151,6 +2800,10 @@ class VuiService {
2151
2800
  this.autoScrollToElementOffsetTop = autoScrollToElementOffsetTop;
2152
2801
  this.textareaRows = textareaRows;
2153
2802
  this.requiredChip = requiredChip;
2803
+ this.router = options.router;
2804
+ this.location = new vueUtils.LocationService({
2805
+ router: this.router,
2806
+ });
2154
2807
  }
2155
2808
  setting(key) {
2156
2809
  return this.options.uiSettings[key];
@@ -2242,6 +2895,7 @@ exports.VCardActions = VCardActions;
2242
2895
  exports.VCardContent = VCardContent;
2243
2896
  exports.VCheckbox = VCheckbox;
2244
2897
  exports.VCheckboxGroup = VCheckboxGroup;
2898
+ exports.VDataTable = VDataTable;
2245
2899
  exports.VDrawerLayout = VDrawerLayout;
2246
2900
  exports.VForm = VForm;
2247
2901
  exports.VHero = VHero;
@@ -2281,6 +2935,7 @@ exports.VuiControlInjectionKey = VuiControlInjectionKey;
2281
2935
  exports.VuiInjectionKey = VuiInjectionKey;
2282
2936
  exports.VuiPlugin = VuiPlugin;
2283
2937
  exports.VuiService = VuiService;
2938
+ exports.configureDataTableDefaults = configureDataTableDefaults;
2284
2939
  exports.createCardProps = createCardProps;
2285
2940
  exports.createControlFieldProviderProps = createControlFieldProviderProps;
2286
2941
  exports.createControlProps = createControlProps;