@fastkit/vui 0.6.15 → 0.6.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,12 +1,13 @@
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, isVNode, ref, withDirectives, vModelSelect, createTextVNode } from 'vue';
4
+ import { inject, computed, provide, defineComponent, createVNode, mergeProps, watch, isVNode, ref, Fragment, withDirectives, vShow, vModelSelect, createTextVNode } from 'vue';
5
5
  import { useScopeColorClass, colorSchemeProps, useColorClasses } from '@fastkit/vue-color-scheme';
6
- import { createPropsOptions as createPropsOptions$1, defineSlotsProps as defineSlotsProps$1, renderSlotOrEmpty as renderSlotOrEmpty$1, navigationableProps, navigationableEmits, useNavigationable } from '@fastkit/vue-utils';
6
+ import { createPropsOptions as createPropsOptions$1, defineSlotsProps as defineSlotsProps$1, renderSlotOrEmpty as renderSlotOrEmpty$1, navigationableProps, navigationableEmits, useNavigationable, 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 { useLink, useRoute } from 'vue-router';
10
11
 
11
12
  const CONTROL_SIZES = ['sm', 'md', 'lg'];
12
13
  const CONTROL_FIELD_VARIANTS = ['outlined', 'filled', 'flat'];
@@ -252,16 +253,24 @@ function useElevation(props, opts = {}) {
252
253
  };
253
254
  }
254
255
 
255
- function createPaperProps() {
256
- return { ...createElevationProps(),
257
- square: Boolean,
256
+ function createPaperBaseProps() {
257
+ return {
258
258
  color: String,
259
259
  tag: {
260
260
  type: String,
261
261
  default: 'div'
262
262
  },
263
263
  ...defineSlotsProps$1()
264
- }; //
264
+ };
265
+ }
266
+ function createPaperProps() {
267
+ return { ...createElevationProps(),
268
+ ...createPaperBaseProps(),
269
+ square: Boolean,
270
+ headerProps: Object,
271
+ bodyProps: Object,
272
+ footerProps: Object
273
+ };
265
274
  }
266
275
  const VPaper = defineComponent({
267
276
  name: 'VPaper',
@@ -278,6 +287,9 @@ const VPaper = defineComponent({
278
287
  'v-paper--has-color': !!scope.value.value,
279
288
  'v-paper--square': props.square
280
289
  }]);
290
+ const headerProps = computed(() => props.headerProps);
291
+ const bodyProps = computed(() => props.bodyProps);
292
+ const footerProps = computed(() => props.footerProps);
281
293
  return () => {
282
294
  const TagName = tag.value;
283
295
  const header = renderSlotOrEmpty$1(ctx.slots, 'header');
@@ -285,13 +297,13 @@ const VPaper = defineComponent({
285
297
  return createVNode(TagName, {
286
298
  "class": ['v-paper', classes.value]
287
299
  }, {
288
- default: () => [header && createVNode("div", {
300
+ default: () => [header && createVNode("div", mergeProps({
289
301
  "class": "v-paper__header"
290
- }, [header]), createVNode("div", {
302
+ }, headerProps.value), [header]), createVNode("div", mergeProps({
291
303
  "class": "v-paper__body"
292
- }, [renderSlotOrEmpty$1(ctx.slots, 'default')]), footer && createVNode("div", {
304
+ }, bodyProps.value), [renderSlotOrEmpty$1(ctx.slots, 'default')]), footer && createVNode("div", mergeProps({
293
305
  "class": "v-paper__footer"
294
- }, [footer])]
306
+ }, footerProps.value), [footer])]
295
307
  });
296
308
  };
297
309
  }
@@ -344,13 +356,27 @@ const VCardActions = defineComponent({
344
356
 
345
357
  });
346
358
 
347
- const _rawRawIconProp = [String, Function];
348
- function rawRawIconProp() {
349
- return _rawRawIconProp;
359
+ // prop: RawIconProp<T>,
360
+ // payload: () => T,
361
+ // ): RawIconProp {
362
+ // if (!prop || typeof prop !== 'function') {
363
+ // return prop;
364
+ // }
365
+ // const fn = (gen: IconGenerator): VNodeChild => {
366
+ // const t = payload();
367
+ // return prop(gen, t);
368
+ // };
369
+ // return fn;
370
+ // }
371
+ // export const rawRawIconProp = [String, Function] as PropType<RawIconProp>;
372
+
373
+ const _rawIconProp = [String, Function];
374
+ function rawIconProp() {
375
+ return _rawIconProp;
350
376
  }
351
- function resolveRawIconProp(prop, extraProps) {
377
+ function resolveRawIconProp(payload, prop, extraProps) {
352
378
  if (!prop) return;
353
- return typeof prop === 'function' ? prop(input => createVNode(VIcon, mergeProps(input, extraProps), null)) : createVNode(VIcon, mergeProps(extraProps, {
379
+ return typeof prop === 'function' ? prop(input => createVNode(VIcon, mergeProps(input, extraProps), null), payload) : createVNode(VIcon, mergeProps(extraProps, {
354
380
  "name": prop
355
381
  }), null);
356
382
  }
@@ -421,7 +447,7 @@ const LOADING_SIZE_MAP = {
421
447
  const VButton = defineComponent({
422
448
  name: 'VButton',
423
449
  props: vueButtonProps,
424
- emits: { ...navigationableEmits.emits
450
+ emits: { ...navigationableEmits
425
451
  },
426
452
 
427
453
  setup(props, ctx) {
@@ -505,17 +531,22 @@ const VButton = defineComponent({
505
531
  });
506
532
 
507
533
  function createListTileProps() {
508
- const icon = rawRawIconProp();
509
- return createPropsOptions$1({ ...navigationableProps,
510
- startIcon: icon,
511
- endIcon: icon,
512
- fallbackTag: {
513
- type: String,
514
- default: 'div'
515
- }
516
- });
534
+ const icon = rawIconProp();
535
+ return { ...navigationableProps,
536
+ ...createPropsOptions$1({
537
+ startIcon: icon,
538
+ endIcon: icon,
539
+ fallbackTag: {
540
+ type: String,
541
+ default: 'div'
542
+ },
543
+ startIconEmptySpace: Boolean,
544
+ color: String
545
+ })
546
+ };
517
547
  }
518
- const listTileEmits = { ...navigationableEmits.emits
548
+ const listTileEmits = { ...navigationableEmits,
549
+ changeActive: isActive => true
519
550
  };
520
551
  const VListTile = defineComponent({
521
552
  name: 'VListTile',
@@ -524,20 +555,57 @@ const VListTile = defineComponent({
524
555
  },
525
556
 
526
557
  setup(props, ctx) {
527
- const startIcon = computed(() => resolveRawIconProp(props.startIcon));
528
- const endIcon = computed(() => resolveRawIconProp(props.endIcon));
529
- const navigationable = useNavigationable(props, () => props.fallbackTag);
558
+ const startIcon = computed(() => {
559
+ let icon = resolveRawIconProp(false, props.startIcon);
560
+
561
+ if (!icon && props.startIconEmptySpace) {
562
+ icon = resolveRawIconProp(false, '$empty');
563
+ }
564
+
565
+ return icon;
566
+ });
567
+ const endIcon = computed(() => resolveRawIconProp(false, props.endIcon));
568
+ const navigationable = useNavigationable(props, () => props.fallbackTag, ctx);
569
+ const hasTo = computed(() => !!props.to);
570
+ const link = useLink({
571
+ to: props.to || ''
572
+ });
573
+ const isActive = computed(() => {
574
+ if (!hasTo.value) return false;
575
+ return link.isActive.value;
576
+ });
577
+ const color = useScopeColorClass(props);
578
+ const classes = computed(() => {
579
+ const _color = color.value;
580
+ const hasColor = !!_color.value;
581
+ const _navigationable = navigationable.value;
582
+ const clickable = _navigationable.clickable;
583
+ return [color.value.className, _navigationable.classes, {
584
+ 'v-list-tile--clickable': clickable,
585
+ 'v-list-tile--plain': !hasColor,
586
+ 'v-list-tile--has-color': hasColor,
587
+ 'v-list-tile--active': isActive.value
588
+ }];
589
+ });
590
+ watch(() => isActive.value, isActive => {
591
+ ctx.emit('changeActive', isActive);
592
+ }, {
593
+ immediate: true
594
+ });
530
595
  return () => {
531
596
  const _startIcon = startIcon.value;
532
597
  const _endIcon = endIcon.value;
533
598
  const {
534
599
  Tag,
535
- attrs,
536
- classes
600
+ attrs
537
601
  } = navigationable.value;
538
602
  return createVNode(Tag, mergeProps({
539
- "class": ['v-list-tile', classes]
540
- }, attrs), {
603
+ "class": ['v-list-tile', classes.value]
604
+ }, attrs, {
605
+ "onClick": ev => {
606
+ ctx.emit('click', ev);
607
+ }
608
+ }), {
541
609
  default: () => [_startIcon && createVNode("span", {
542
610
  "class": "v-list-tile__icon v-list-tile__icon--start"
543
611
  }, [_startIcon]), createVNode("span", {
@@ -551,81 +619,260 @@ const VListTile = defineComponent({
551
619
 
552
620
  });
553
621
 
554
- const VAccordion = defineComponent({
555
- name: 'VAccordion'
622
+ const VDrawerLayout = defineComponent({
623
+ name: 'VDrawerLayout',
624
+ props: { ...createPaperBaseProps()
625
+ },
626
+
627
+ setup(props, ctx) {
628
+ return () => {
629
+ const paperProps = computed(() => ({
630
+ color: props.color,
631
+ tag: props.tag
632
+ }));
633
+ return createVNode(VPaper, mergeProps({
634
+ "class": "v-drawer-layout"
635
+ }, paperProps.value, {
636
+ "square": true,
637
+ "headerProps": {
638
+ class: 'v-drawer-layout__header'
639
+ },
640
+ "bodyProps": {
641
+ class: 'v-drawer-layout__body'
642
+ },
643
+ "footerProps": {
644
+ class: 'v-drawer-layout__footer'
645
+ }
646
+ }), ctx.slots);
647
+ };
648
+ }
649
+
556
650
  });
557
651
 
558
- function _isSlot$6(s) {
652
+ function _isSlot$5(s) {
559
653
  return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
560
654
  }
561
655
 
562
656
  function createNavigationItemProps() {
563
- return { ...createListTileProps()
657
+ return { ...createListTileProps(),
658
+ match: String
564
659
  };
565
660
  }
661
+ function resolveNavigationItemInput(input) {
662
+ let label = input.label;
663
+ const props = { ...input
664
+ };
665
+
666
+ if (typeof label === 'function') {
667
+ label = label();
668
+ }
669
+
670
+ delete props.label;
671
+ return {
672
+ label,
673
+ props
674
+ };
675
+ }
676
+ function renderNavigationItemInput(input, extraProps) {
677
+ const {
678
+ label,
679
+ props
680
+ } = resolveNavigationItemInput(input);
681
+ return createVNode(VNavigationItem, { ...props,
682
+ ...extraProps
683
+ }, _isSlot$5(label) ? label : {
684
+ default: () => [label]
685
+ });
686
+ }
566
687
  const VNavigationItem = defineComponent({
567
688
  name: 'VNavigationItem',
568
- props: createNavigationItemProps(),
689
+ inheritAttrs: false,
690
+ props: { ...createNavigationItemProps(),
691
+ children: Array
692
+ },
569
693
  emits: { ...listTileEmits
570
694
  },
571
695
 
572
696
  setup(props, ctx) {
573
- const _props = computed(() => ({ ...props
574
- }));
697
+ const vui = useVui();
698
+ const opened = ref(false);
699
+ const children = computed(() => {
700
+ const c = props.children;
701
+ return c && c.length ? c : undefined;
702
+ });
703
+ const to = computed(() => props.to);
704
+ const match = computed(() => {
705
+ const {
706
+ match,
707
+ to
708
+ } = props;
709
+ if (match) return match;
710
+ if (!to) return;
711
+ if (typeof to === 'string') return to;
712
+ return to.path;
713
+ });
714
+ const classes = computed(() => [{
715
+ 'v-navigation-item--opened': opened.value
716
+ }]);
717
+ const route = useRoute(); // const classes = computed(() => [
718
+ // // {
719
+ // // 'v-navigation-item--matched': matched.value,
720
+ // // },
721
+ // ]);
722
+
723
+ watch(() => route.path, newPath => {
724
+ const c = children.value;
725
+ const m = match.value;
726
+
727
+ if (!c || !m) {
728
+ // matched.value = false;
729
+ return;
730
+ }
731
+
732
+ if (newPath.match(m)) {
733
+ open(); // matched.value = true;
734
+ } else {
735
+ close(); // matched.value = false;
736
+ }
737
+ }, {
738
+ immediate: true
739
+ }); // const iconPayload = () => opened.value;
740
+
741
+ const _props = computed(() => {
742
+ const c = children.value;
743
+ let {
744
+ endIcon
745
+ } = props;
746
+
747
+ if (c && !endIcon) {
748
+ endIcon = vui.icon('navigationExpand');
749
+
750
+ if (typeof endIcon === 'string') {
751
+ const name = endIcon;
752
+
753
+ endIcon = gen => {
754
+ return gen({
755
+ name,
756
+ rotate: opened.value ? 180 : 0
757
+ });
758
+ };
759
+ }
760
+ }
761
+
762
+ const __props = { ...props,
763
+ endIcon
764
+ };
765
+ delete __props.children; // const _activeClass = props.activeClass;
766
+ // const activeClass = `v-navigation-item--active${
767
+ // _activeClass ? ` ${_activeClass}` : ''
768
+ // }`;
769
+
770
+ return { ...__props // activeClass,
771
+ // startIcon: toRawIconProp(__props.startIcon, iconPayload),
772
+ // endIcon: toRawIconProp(__props.endIcon, iconPayload),
773
+
774
+ };
775
+ });
776
+
777
+ function open() {
778
+ opened.value = true;
779
+ }
780
+
781
+ function close() {
782
+ opened.value = false;
783
+ }
784
+
785
+ function toggle() {
786
+ return opened.value ? close() : open();
787
+ }
788
+
789
+ const onClick = ev => {
790
+ if (!to.value) {
791
+ toggle();
792
+ }
793
+
794
+ ctx.emit('click', ev);
795
+ };
796
+
797
+ const onChangeActive = isActive => {
798
+ // if (isActive) {
799
+ // // open();
800
+ // // if (typeof window !== 'undefined') {
801
+ // // // open();
802
+ // // // console.log('hoge', window);
803
+ // // setTimeout(() => {
804
+ // // open();
805
+ // // }, 1000);
806
+ // // }
807
+ // // open();
808
+ // // console.log(props);
809
+ // // setTimeout(() => {
810
+ // // open();
811
+ // // }, 500);
812
+ // }
813
+ ctx.emit('changeActive', isActive);
814
+ };
575
815
 
576
816
  return () => {
577
817
  let _slot;
578
818
 
579
- return createVNode(VListTile, mergeProps(_props.value, {
580
- "class": "v-navigation-item"
581
- }), _isSlot$6(_slot = renderSlotOrEmpty$1(ctx.slots, 'default')) ? _slot : {
819
+ const _children = children.value;
820
+ const fallbackTag = _children ? 'button' : undefined;
821
+ return createVNode(Fragment, null, [createVNode(VListTile, mergeProps(_props.value, {
822
+ "fallbackTag": fallbackTag,
823
+ "endIcon": _props.value.endIcon,
824
+ "class": ['v-navigation-item', classes.value],
825
+ "onClick": onClick,
826
+ "onChangeActive": onChangeActive
827
+ }), _isSlot$5(_slot = renderSlotOrEmpty$1(ctx.slots, 'default')) ? _slot : {
582
828
  default: () => [_slot]
583
- });
829
+ }), _children && createVNode(VExpandTransition, null, {
830
+ default: () => [withDirectives(createVNode("div", {
831
+ "class": "v-navigation-item__expand"
832
+ }, [_children.map(child => renderNavigationItemInput(child, {
833
+ startIconEmptySpace: _props.value.startIconEmptySpace // onClick,
834
+ // onChangeActive,
835
+
836
+ }))]), [[vShow, opened.value]])]
837
+ })]);
584
838
  };
585
839
  }
586
840
 
587
841
  });
588
842
 
589
- function _isSlot$5(s) {
590
- return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
591
- }
592
-
593
843
  const VNavigation = defineComponent({
594
844
  name: 'VNavigation',
595
845
  props: {
596
846
  items: {
597
847
  type: Array,
598
848
  required: true
599
- }
849
+ },
850
+ color: String,
851
+ startIconEmptySpace: {
852
+ type: Boolean,
853
+ default: true
854
+ },
855
+ caption: [String, Function]
600
856
  },
601
857
 
602
858
  setup(props, ctx) {
603
859
  const items = computed(() => props.items);
604
- const $items = computed(() => items.value.map(item => {
605
- let label = item.label;
606
- const _props = { ...item
607
- };
608
-
609
- if (typeof label === 'function') {
610
- label = label();
611
- }
612
-
613
- delete _props.label;
614
- return {
615
- label,
616
- props: _props
617
- };
618
- }));
860
+ const color = useScopeColorClass(props);
861
+ const classes = computed(() => [color.value.className]);
862
+ const startIconEmptySpace = computed(() => props.startIconEmptySpace);
863
+ const caption = computed(() => {
864
+ const c = props.caption;
865
+ return typeof c === 'function' ? c() : c;
866
+ });
619
867
  return () => {
868
+ const $caption = caption.value;
620
869
  return createVNode("nav", {
621
- "class": "v-navigation"
622
- }, [$items.value.map(({
623
- label,
624
- props
625
- }) => createVNode(VNavigationItem, mergeProps(props, {
626
- "class": "v-navigation__item"
627
- }), _isSlot$5(label) ? label : {
628
- default: () => [label]
870
+ "class": ['v-navigation', classes.value]
871
+ }, [!!$caption && createVNode("div", {
872
+ "class": "v-navigation__caption"
873
+ }, [$caption]), items.value.map(item => renderNavigationItemInput(item, {
874
+ class: 'v-navigation__item',
875
+ startIconEmptySpace: startIconEmptySpace.value
629
876
  }))]);
630
877
  };
631
878
  }
@@ -1615,4 +1862,4 @@ function installVuiPlugin(app, opts) {
1615
1862
  return app.use(VuiPlugin, opts);
1616
1863
  }
1617
1864
 
1618
- export { CONTROL_FIELD_VARIANTS, CONTROL_SIZES, VAccordion, VApp, VButton, VCard, VCardActions, VCardContent, VCheckbox, VCheckboxGroup, VForm, VIcon, VListTile, VNavigation, VNavigationItem, VOption, VOptionGroup, VPaper, VRadio, VRadioGroup, VSelect, VSwitch, VSwitchGroup, VTextField, VTextarea, VToolbar, 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, createPaperProps, defineFormSelectorComponent, iconProps, installVuiPlugin, listTileEmits, rawRawIconProp, resolveRawIconProp, useControl, useControlField, useElevation, useVui, useVuiColorProvider, vueButtonProps };
1865
+ export { CONTROL_FIELD_VARIANTS, CONTROL_SIZES, VApp, VButton, VCard, VCardActions, VCardContent, VCheckbox, VCheckboxGroup, VDrawerLayout, VForm, VIcon, VListTile, VNavigation, VNavigationItem, VOption, VOptionGroup, VPaper, VRadio, VRadioGroup, VSelect, VSwitch, VSwitchGroup, VTextField, VTextarea, VToolbar, 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, rawIconProp, renderNavigationItemInput, resolveNavigationItemInput, resolveRawIconProp, useControl, useControlField, useElevation, useVui, useVuiColorProvider, vueButtonProps };