lkt-item-crud 2.0.27 → 2.0.29

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.
@@ -7,21 +7,21 @@ declare var __VLS_17: {
7
7
  canUpdate: boolean | undefined;
8
8
  canDrop: boolean | undefined;
9
9
  perms: string[] | undefined;
10
- }, __VLS_21: {
10
+ }, __VLS_25: {
11
11
  item: LktObject;
12
12
  loading: boolean;
13
- }, __VLS_23: {
13
+ }, __VLS_27: {
14
14
  item: LktObject;
15
15
  loading: boolean;
16
- }, __VLS_36: {
16
+ }, __VLS_40: {
17
17
  canUpdate: boolean | undefined;
18
18
  canDrop: boolean | undefined;
19
19
  perms: string[] | undefined;
20
- }, __VLS_38: {
20
+ }, __VLS_42: {
21
21
  canUpdate: boolean | undefined;
22
22
  canDrop: boolean | undefined;
23
23
  perms: string[] | undefined;
24
- }, __VLS_55: string, __VLS_56: {}, __VLS_58: {
24
+ }, __VLS_59: string, __VLS_60: {}, __VLS_62: {
25
25
  item: LktObject;
26
26
  loading: false;
27
27
  editMode: boolean;
@@ -30,27 +30,27 @@ declare var __VLS_17: {
30
30
  canDrop: boolean;
31
31
  itemBeingEdited: boolean;
32
32
  perms: string[];
33
- }, __VLS_79: {}, __VLS_81: {};
33
+ }, __VLS_83: {}, __VLS_85: {};
34
34
  type __VLS_Slots = {} & {
35
- [K in NonNullable<typeof __VLS_55>]?: (props: typeof __VLS_56) => any;
35
+ [K in NonNullable<typeof __VLS_59>]?: (props: typeof __VLS_60) => any;
36
36
  } & {
37
37
  'prev-buttons-ever'?: (props: typeof __VLS_17) => any;
38
38
  } & {
39
39
  'prev-buttons'?: (props: typeof __VLS_19) => any;
40
40
  } & {
41
- 'pre-title'?: (props: typeof __VLS_21) => any;
41
+ 'pre-title'?: (props: typeof __VLS_25) => any;
42
42
  } & {
43
- 'post-title'?: (props: typeof __VLS_23) => any;
43
+ 'post-title'?: (props: typeof __VLS_27) => any;
44
44
  } & {
45
- 'prev-buttons-ever'?: (props: typeof __VLS_36) => any;
45
+ 'prev-buttons-ever'?: (props: typeof __VLS_40) => any;
46
46
  } & {
47
- 'prev-buttons'?: (props: typeof __VLS_38) => any;
47
+ 'prev-buttons'?: (props: typeof __VLS_42) => any;
48
48
  } & {
49
- item?: (props: typeof __VLS_58) => any;
49
+ item?: (props: typeof __VLS_62) => any;
50
50
  } & {
51
- 'prev-buttons-ever'?: (props: typeof __VLS_79) => any;
51
+ 'prev-buttons-ever'?: (props: typeof __VLS_83) => any;
52
52
  } & {
53
- 'prev-buttons'?: (props: typeof __VLS_81) => any;
53
+ 'prev-buttons'?: (props: typeof __VLS_85) => any;
54
54
  };
55
55
  declare const __VLS_component: import("vue").DefineComponent<ItemCrudConfig, {
56
56
  doDrop: () => void;
@@ -90,7 +90,8 @@ declare const __VLS_component: import("vue").DefineComponent<ItemCrudConfig, {
90
90
  "onModified-data"?: ((...args: any[]) => any) | undefined;
91
91
  }>, {
92
92
  view: ItemCrudView;
93
- form: import("lkt-vue-kernel").FormConfig;
93
+ form: import("lkt-vue-kernel").FormConfig | Function;
94
+ header: import("lkt-vue-kernel").HeaderConfig;
94
95
  title: string;
95
96
  mode: ItemCrudMode;
96
97
  modelValue: LktObject;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lkt-item-crud",
3
- "version": "2.0.27",
3
+ "version": "2.0.29",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "module": "./dist/build.js",
@@ -252,7 +252,7 @@
252
252
  const formDifferencesChecker = ref(undefined);
253
253
  const resetFormDifferencesChecker = () => {
254
254
  if (computedHasForm.value) {
255
- formDifferencesChecker.value = getFormDataState(item.value, itemModifications.value, props.form);
255
+ formDifferencesChecker.value = getFormDataState(item.value, itemModifications.value, computedForm.value);
256
256
  }
257
257
  }
258
258
 
@@ -453,6 +453,11 @@
453
453
 
454
454
  return computedTitle.value.length > 0 || !!slots['post-title'];
455
455
  }),
456
+ displayLktHeader = computed(() => {
457
+ if (isLoading.value) return false;
458
+ return typeof props.header === 'object'
459
+ && Object.keys(props.header).length > 0;
460
+ }),
456
461
  computedInsideModal = computed(() => {
457
462
  return props.view === ItemCrudView.Modal;
458
463
  }),
@@ -515,7 +520,7 @@
515
520
  return {};
516
521
  }),
517
522
  computedHasForm = computed(() => {
518
- return typeof props.form === 'object' && Object.keys(props.form).length > 0;
523
+ return (typeof computedForm.value === 'object' && Object.keys(computedForm.value).length > 0);
519
524
  }),
520
525
  computedModificationViews = computed(() => {
521
526
  if (Object.keys(itemModifications.value).length === 0) return [];
@@ -532,11 +537,17 @@
532
537
  })
533
538
 
534
539
  const computedFormSlots = computed(() => {
535
- if (computedHasForm.value) {
536
- return getFormSlotKeys(props.form);
537
- }
540
+ if (computedHasForm.value) return getFormSlotKeys(computedForm.value);
538
541
  return [];
539
542
  })
543
+
544
+ const computedForm = computed(() => {
545
+ if (typeof props.form === 'function') return props.form({
546
+ mode: props.mode,
547
+ view: pickedModificationView.value,
548
+ });
549
+ return props.form;
550
+ })
540
551
  </script>
541
552
 
542
553
  <template>
@@ -600,164 +611,163 @@
600
611
  </button-nav>
601
612
  </template>
602
613
 
603
- <article class="lkt-item-crud">
604
- <header class="lkt-item-crud_header" v-if="!computedInsideModal && displayHeader">
605
- <div class="lkt-item-crud_header-slot" v-if="slots['pre-title']">
606
- <slot name="pre-title" :item="item" :loading="isLoading" />
607
- </div>
608
- <h1 class="lkt-item-crud_header-title" v-if="computedTitle.length > 0">{{ computedTitle }}</h1>
609
- <div class="lkt-item-crud_header-slot" v-if="slots['post-title']">
610
- <slot name="post-title" :item="item" :loading="isLoading" />
611
- </div>
612
- </header>
613
-
614
- <button-nav
615
- ref="buttonNav"
616
- v-if="buttonNavPosition === ItemCrudButtonNavPosition.Top && (groupButton === false || !groupButtonAsModalActions) && computedHasButtons"
617
- v-model:loading="isLoading"
618
- v-model:editing="editMode"
619
- v-model:picked-modification-view="pickedModificationView"
620
- :item="item"
621
- :modifications="itemModifications"
622
- :mode="mode"
623
- :view="view"
624
- :grouped="groupButton !== false"
625
- :button-nav-visibility="buttonNavVisibility"
626
- :create-button="safeCreateButton"
627
- :update-button="safeUpdateButton"
628
- :drop-button="safeDropButton"
629
- :edit-mode-button="safeEditModeButton"
630
- :group-button="safeGroupButton"
631
- :data-changed="dataChanged"
632
- :http-success-read="httpSuccessRead"
633
- :can-update="canUpdate"
634
- :can-drop="canDrop"
635
- :can-switch-edit-mode="canSwitchEditMode"
636
- :group-button-as-modal-actions="groupButtonAsModalActions"
637
- :able-to-create="ableToCreate"
638
- :able-to-update="ableToUpdate"
639
- :able-to-drop="ableToDrop"
640
- :perms="permissions"
641
- :modification-view="computedModificationViews"
642
- :editable-view="computedEditableView"
643
- :nav-start-buttons="navStartButtons"
644
- :nav-start-buttons-editing="navStartButtonsEditing"
645
- :nav-end-buttons="navEndButtons"
646
- :nav-end-buttons-editing="navEndButtonsEditing"
647
- @create="onCreate"
648
- @save="onUpdate"
649
- @drop="onDrop"
650
- >
651
- <template #prev-buttons-ever="{canUpdate, canDrop, perms}" v-if="slots['prev-buttons-ever']">
652
- <slot name="prev-buttons-ever"
653
- :can-update="canUpdate"
654
- :can-drop="canDrop"
655
- :perms="perms"
656
- />
657
- </template>
658
- <template #prev-buttons="{canUpdate, canDrop, perms}" v-if="slots['prev-buttons']">
659
- <slot name="prev-buttons"
660
- :can-update="canUpdate"
661
- :can-drop="canDrop"
662
- :perms="perms"
663
- />
664
- </template>
665
- </button-nav>
666
-
667
- <div class="lkt-item-crud_content" v-if="!isLoading">
668
- <div v-if="httpSuccessRead" class="lkt-grid-1">
669
- <lkt-http-info
670
- v-if="showStoreMessage && notificationType === NotificationType.Inline"
671
- :code="httpStatus"
672
- :palette="httpStatus === 200 ? 'success' : 'danger'"
673
- quick
674
- can-close
675
- v-on:close="showStoreMessage = false" />
676
-
677
- <template v-if="computedHasForm">
678
- <lkt-form
679
- ref="formRef"
680
- v-model="item"
681
- v-model:modifications="itemModifications"
682
- v-model:valid="validForm"
683
- v-model:changed="changedForm"
684
- v-bind="<FormUiConfig>{
614
+ <lkt-header v-if="!computedInsideModal && displayLktHeader" v-bind="header"/>
615
+ <header class="lkt-item-crud_header" v-else-if="!computedInsideModal && displayHeader">
616
+ <div class="lkt-item-crud_header-slot" v-if="slots['pre-title']">
617
+ <slot name="pre-title" :item="item" :loading="isLoading" />
618
+ </div>
619
+ <h1 class="lkt-item-crud_header-title" v-if="computedTitle.length > 0">{{ computedTitle }}</h1>
620
+ <div class="lkt-item-crud_header-slot" v-if="slots['post-title']">
621
+ <slot name="post-title" :item="item" :loading="isLoading" />
622
+ </div>
623
+ </header>
624
+
625
+ <button-nav
626
+ ref="buttonNav"
627
+ v-if="buttonNavPosition === ItemCrudButtonNavPosition.Top && (groupButton === false || !groupButtonAsModalActions) && computedHasButtons"
628
+ v-model:loading="isLoading"
629
+ v-model:editing="editMode"
630
+ v-model:picked-modification-view="pickedModificationView"
631
+ :item="item"
632
+ :modifications="itemModifications"
633
+ :mode="mode"
634
+ :view="view"
635
+ :grouped="groupButton !== false"
636
+ :button-nav-visibility="buttonNavVisibility"
637
+ :create-button="safeCreateButton"
638
+ :update-button="safeUpdateButton"
639
+ :drop-button="safeDropButton"
640
+ :edit-mode-button="safeEditModeButton"
641
+ :group-button="safeGroupButton"
642
+ :data-changed="dataChanged"
643
+ :http-success-read="httpSuccessRead"
644
+ :can-update="canUpdate"
645
+ :can-drop="canDrop"
646
+ :can-switch-edit-mode="canSwitchEditMode"
647
+ :group-button-as-modal-actions="groupButtonAsModalActions"
648
+ :able-to-create="ableToCreate"
649
+ :able-to-update="ableToUpdate"
650
+ :able-to-drop="ableToDrop"
651
+ :perms="permissions"
652
+ :modification-view="computedModificationViews"
653
+ :editable-view="computedEditableView"
654
+ :nav-start-buttons="navStartButtons"
655
+ :nav-start-buttons-editing="navStartButtonsEditing"
656
+ :nav-end-buttons="navEndButtons"
657
+ :nav-end-buttons-editing="navEndButtonsEditing"
658
+ @create="onCreate"
659
+ @save="onUpdate"
660
+ @drop="onDrop"
661
+ >
662
+ <template #prev-buttons-ever="{canUpdate, canDrop, perms}" v-if="slots['prev-buttons-ever']">
663
+ <slot name="prev-buttons-ever"
664
+ :can-update="canUpdate"
665
+ :can-drop="canDrop"
666
+ :perms="perms"
667
+ />
668
+ </template>
669
+ <template #prev-buttons="{canUpdate, canDrop, perms}" v-if="slots['prev-buttons']">
670
+ <slot name="prev-buttons"
671
+ :can-update="canUpdate"
672
+ :can-drop="canDrop"
673
+ :perms="perms"
674
+ />
675
+ </template>
676
+ </button-nav>
677
+
678
+ <div class="lkt-item-crud_content" v-if="!isLoading">
679
+ <div v-if="httpSuccessRead" class="lkt-grid-1">
680
+ <lkt-http-info
681
+ v-if="showStoreMessage && notificationType === NotificationType.Inline"
682
+ :code="httpStatus"
683
+ :palette="httpStatus === 200 ? 'success' : 'danger'"
684
+ quick
685
+ can-close
686
+ v-on:close="showStoreMessage = false" />
687
+
688
+ <template v-if="computedHasForm">
689
+ <lkt-form
690
+ ref="formRef"
691
+ v-model="item"
692
+ v-model:modifications="itemModifications"
693
+ v-model:valid="validForm"
694
+ v-model:changed="changedForm"
695
+ v-bind="<FormUiConfig>{
685
696
  ...formUiConfig,
686
- form,
697
+ form: computedForm,
687
698
  differencesTableConfig,
688
699
  visibleView: pickedModificationView,
689
700
  modificationDataState: formDifferencesChecker,
690
701
  editableViews: [computedEditableView],
691
702
  disabled: !editMode,
692
703
  }"
693
- >
694
- <template v-for="formSlot in computedFormSlots" v-slot:[formSlot]="{}">
695
- <slot :name="formSlot"/>
696
- </template>
697
- </lkt-form>
698
- </template>
699
-
700
- <template v-else>
701
- <slot name="item"
702
- :item="item"
703
- :loading="isLoading"
704
- :edit-mode="editMode"
705
- :is-create="createMode"
706
- :can-update="canUpdate"
707
- :can-drop="canDrop"
708
- :item-being-edited="itemBeingEdited"
709
- :perms="permissions"
710
- />
711
- </template>
712
- </div>
713
- <lkt-http-info :code="httpStatus" v-else-if="notificationType === NotificationType.Inline" />
714
- </div>
715
- <lkt-loader v-if="isLoading" />
716
-
717
- <button-nav
718
- ref="buttonNav"
719
- v-if="buttonNavPosition === ItemCrudButtonNavPosition.Bottom && (groupButton === false || !groupButtonAsModalActions) && computedHasButtons"
720
- v-model:loading="isLoading"
721
- v-model:editing="editMode"
722
- v-model:picked-modification-view="pickedModificationView"
723
- :item="item"
724
- :modifications="itemModifications"
725
- :mode="mode"
726
- :view="view"
727
- :grouped="groupButton !== false"
728
- :button-nav-visibility="buttonNavVisibility"
729
- :create-button="safeCreateButton"
730
- :update-button="safeUpdateButton"
731
- :drop-button="safeDropButton"
732
- :edit-mode-button="safeEditModeButton"
733
- :group-button="safeGroupButton"
734
- :data-changed="dataChanged"
735
- :http-success-read="httpSuccessRead"
736
- :can-update="canUpdate"
737
- :can-drop="canDrop"
738
- :can-switch-edit-mode="canSwitchEditMode"
739
- :group-button-as-modal-actions="groupButtonAsModalActions"
740
- :able-to-create="ableToCreate"
741
- :able-to-update="ableToUpdate"
742
- :able-to-drop="ableToDrop"
743
- :perms="permissions"
744
- :modification-view="computedModificationViews"
745
- :editable-view="computedEditableView"
746
- :nav-start-buttons="navStartButtons"
747
- :nav-start-buttons-editing="navStartButtonsEditing"
748
- :nav-end-buttons="navEndButtons"
749
- :nav-end-buttons-editing="navEndButtonsEditing"
750
- @create="onCreate"
751
- @save="onUpdate"
752
- @drop="onDrop"
753
- >
754
- <template #prev-buttons-ever v-if="slots['prev-buttons-ever']">
755
- <slot name="prev-buttons-ever" />
704
+ >
705
+ <template v-for="formSlot in computedFormSlots" v-slot:[formSlot]="{}">
706
+ <slot :name="formSlot"/>
707
+ </template>
708
+ </lkt-form>
756
709
  </template>
757
- <template #prev-buttons-ever v-if="slots['prev-buttons']">
758
- <slot name="prev-buttons" />
710
+
711
+ <template v-else>
712
+ <slot name="item"
713
+ :item="item"
714
+ :loading="isLoading"
715
+ :edit-mode="editMode"
716
+ :is-create="createMode"
717
+ :can-update="canUpdate"
718
+ :can-drop="canDrop"
719
+ :item-being-edited="itemBeingEdited"
720
+ :perms="permissions"
721
+ />
759
722
  </template>
760
- </button-nav>
761
- </article>
723
+ </div>
724
+ <lkt-http-info :code="httpStatus" v-else-if="notificationType === NotificationType.Inline" />
725
+ </div>
726
+ <lkt-loader v-if="isLoading" />
727
+
728
+ <button-nav
729
+ ref="buttonNav"
730
+ v-if="buttonNavPosition === ItemCrudButtonNavPosition.Bottom && (groupButton === false || !groupButtonAsModalActions) && computedHasButtons"
731
+ v-model:loading="isLoading"
732
+ v-model:editing="editMode"
733
+ v-model:picked-modification-view="pickedModificationView"
734
+ :item="item"
735
+ :modifications="itemModifications"
736
+ :mode="mode"
737
+ :view="view"
738
+ :grouped="groupButton !== false"
739
+ :button-nav-visibility="buttonNavVisibility"
740
+ :create-button="safeCreateButton"
741
+ :update-button="safeUpdateButton"
742
+ :drop-button="safeDropButton"
743
+ :edit-mode-button="safeEditModeButton"
744
+ :group-button="safeGroupButton"
745
+ :data-changed="dataChanged"
746
+ :http-success-read="httpSuccessRead"
747
+ :can-update="canUpdate"
748
+ :can-drop="canDrop"
749
+ :can-switch-edit-mode="canSwitchEditMode"
750
+ :group-button-as-modal-actions="groupButtonAsModalActions"
751
+ :able-to-create="ableToCreate"
752
+ :able-to-update="ableToUpdate"
753
+ :able-to-drop="ableToDrop"
754
+ :perms="permissions"
755
+ :modification-view="computedModificationViews"
756
+ :editable-view="computedEditableView"
757
+ :nav-start-buttons="navStartButtons"
758
+ :nav-start-buttons-editing="navStartButtonsEditing"
759
+ :nav-end-buttons="navEndButtons"
760
+ :nav-end-buttons-editing="navEndButtonsEditing"
761
+ @create="onCreate"
762
+ @save="onUpdate"
763
+ @drop="onDrop"
764
+ >
765
+ <template #prev-buttons-ever v-if="slots['prev-buttons-ever']">
766
+ <slot name="prev-buttons-ever" />
767
+ </template>
768
+ <template #prev-buttons-ever v-if="slots['prev-buttons']">
769
+ <slot name="prev-buttons" />
770
+ </template>
771
+ </button-nav>
762
772
  </component>
763
773
  </template>