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