sard-uniapp 1.15.4 → 1.16.0

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.
Files changed (106) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/components/calendar-input/calendar-input.vue +26 -89
  3. package/components/calendar-input/common.d.ts +7 -17
  4. package/components/calendar-input/common.js +2 -1
  5. package/components/calendar-popout/calendar-popout.d.ts +17 -0
  6. package/components/calendar-popout/calendar-popout.vue +102 -0
  7. package/components/calendar-popout/common.d.ts +27 -0
  8. package/components/calendar-popout/common.js +5 -0
  9. package/components/calendar-popout/index.d.ts +1 -0
  10. package/components/calendar-popout/index.js +1 -0
  11. package/components/cascader-input/cascader-input.vue +26 -89
  12. package/components/cascader-input/common.d.ts +5 -19
  13. package/components/cascader-input/common.js +3 -1
  14. package/components/cascader-popout/cascader-popout.d.ts +23 -0
  15. package/components/cascader-popout/cascader-popout.vue +88 -0
  16. package/components/cascader-popout/common.d.ts +27 -0
  17. package/components/cascader-popout/common.js +2 -0
  18. package/components/cascader-popout/index.d.ts +1 -0
  19. package/components/cascader-popout/index.js +1 -0
  20. package/components/checkbox-input/checkbox-input.vue +21 -141
  21. package/components/checkbox-input/common.d.ts +4 -11
  22. package/components/checkbox-input/common.js +2 -5
  23. package/components/checkbox-popout/checkbox-popout.d.ts +21 -0
  24. package/components/checkbox-popout/checkbox-popout.vue +136 -0
  25. package/components/checkbox-popout/common.d.ts +22 -0
  26. package/components/checkbox-popout/common.js +5 -0
  27. package/components/checkbox-popout/index.d.ts +1 -0
  28. package/components/checkbox-popout/index.js +1 -0
  29. package/components/{checkbox-input → checkbox-popout}/index.scss +2 -2
  30. package/components/{checkbox-input → checkbox-popout}/variables.scss +1 -1
  31. package/components/config/index.d.ts +9 -7
  32. package/components/config/index.js +9 -7
  33. package/components/datetime-picker-input/common.d.ts +3 -13
  34. package/components/datetime-picker-input/common.js +1 -1
  35. package/components/datetime-picker-input/datetime-picker-input.vue +22 -109
  36. package/components/datetime-picker-popout/common.d.ts +23 -0
  37. package/components/datetime-picker-popout/common.js +5 -0
  38. package/components/datetime-picker-popout/datetime-picker-popout.d.ts +21 -0
  39. package/components/datetime-picker-popout/datetime-picker-popout.vue +113 -0
  40. package/components/datetime-picker-popout/index.d.ts +1 -0
  41. package/components/datetime-picker-popout/index.js +1 -0
  42. package/components/datetime-range-picker-input/common.d.ts +3 -13
  43. package/components/datetime-range-picker-input/common.js +1 -1
  44. package/components/datetime-range-picker-input/datetime-range-picker-input.vue +23 -97
  45. package/components/datetime-range-picker-popout/common.d.ts +23 -0
  46. package/components/datetime-range-picker-popout/common.js +5 -0
  47. package/components/datetime-range-picker-popout/datetime-range-picker-popout.d.ts +21 -0
  48. package/components/datetime-range-picker-popout/datetime-range-picker-popout.vue +102 -0
  49. package/components/datetime-range-picker-popout/index.d.ts +1 -0
  50. package/components/datetime-range-picker-popout/index.js +1 -0
  51. package/components/navbar/navbar.vue +1 -1
  52. package/components/navbar-pit/common.d.ts +6 -0
  53. package/components/navbar-pit/common.js +1 -0
  54. package/components/navbar-pit/index.d.ts +1 -0
  55. package/components/navbar-pit/index.js +1 -0
  56. package/components/navbar-pit/index.scss +11 -0
  57. package/components/navbar-pit/navbar-pit.d.ts +2 -1
  58. package/components/navbar-pit/navbar-pit.vue +29 -4
  59. package/components/picker-input/common.d.ts +3 -12
  60. package/components/picker-input/common.js +2 -4
  61. package/components/picker-input/picker-input.vue +16 -77
  62. package/components/picker-popout/common.d.ts +24 -0
  63. package/components/picker-popout/common.js +6 -0
  64. package/components/picker-popout/index.d.ts +1 -0
  65. package/components/picker-popout/index.js +1 -0
  66. package/components/picker-popout/picker-popout.d.ts +22 -0
  67. package/components/picker-popout/picker-popout.vue +84 -0
  68. package/components/popout-input/common.d.ts +2 -0
  69. package/components/popout-input/popout-input.d.ts +2 -0
  70. package/components/popout-input/popout-input.vue +4 -0
  71. package/components/radio-input/common.d.ts +4 -11
  72. package/components/radio-input/common.js +2 -5
  73. package/components/radio-input/radio-input.vue +21 -140
  74. package/components/radio-popout/common.d.ts +23 -0
  75. package/components/radio-popout/common.js +5 -0
  76. package/components/radio-popout/index.d.ts +1 -0
  77. package/components/radio-popout/index.js +1 -0
  78. package/components/{radio-input → radio-popout}/index.scss +2 -2
  79. package/components/radio-popout/radio-popout.d.ts +22 -0
  80. package/components/radio-popout/radio-popout.vue +135 -0
  81. package/components/{radio-input → radio-popout}/variables.scss +1 -1
  82. package/components/signature/signature.d.ts +2 -2
  83. package/components/tabbar/common.d.ts +2 -0
  84. package/components/tabbar/index.scss +13 -0
  85. package/components/tabbar/tabbar.vue +10 -2
  86. package/components/tabbar/variables.scss +1 -0
  87. package/components/tabbar-pit/common.d.ts +13 -0
  88. package/components/tabbar-pit/common.js +1 -0
  89. package/components/tabbar-pit/index.d.ts +1 -0
  90. package/components/tabbar-pit/index.js +1 -0
  91. package/components/tabbar-pit/index.scss +12 -0
  92. package/components/tabbar-pit/tabbar-pit.d.ts +10 -0
  93. package/components/tabbar-pit/tabbar-pit.vue +46 -0
  94. package/global.d.ts +8 -0
  95. package/index.d.ts +9 -0
  96. package/index.js +9 -0
  97. package/index.scss +2 -2
  98. package/package.json +3 -3
  99. package/use/index.d.ts +3 -0
  100. package/use/index.js +3 -0
  101. package/use/useFormPopout.d.ts +20 -0
  102. package/use/useFormPopout.js +42 -0
  103. package/use/usePopoutInput.d.ts +19 -0
  104. package/use/usePopoutInput.js +39 -0
  105. package/use/useTwoWayVisible.d.ts +9 -0
  106. package/use/useTwoWayVisible.js +13 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ # [1.16.0](https://github.com/sutras/sard-uniapp/compare/v1.15.4...v1.16.0) (2025-05-28)
2
+
3
+
4
+ ### Features
5
+
6
+ * 新增7个 *Input 对应的 *Popout 组件 ([c3645d4](https://github.com/sutras/sard-uniapp/commit/c3645d47c397ed729e43a518ac7036ed29e818e3))
7
+ * 新增TabbarPit组件, Tabbar 组件新增fixed和safe-area-inset-bottom属性 ([b9f3197](https://github.com/sutras/sard-uniapp/commit/b9f319799609c82489a71a7f8aec287b6f08b672))
8
+
9
+
10
+
1
11
  ## [1.15.4](https://github.com/sutras/sard-uniapp/compare/v1.15.3...v1.15.4) (2025-05-27)
2
12
 
3
13
 
@@ -8,58 +8,48 @@
8
8
  :root-class="rootClass"
9
9
  :root-style="rootStyle"
10
10
  @clear="onClear"
11
- @click="onInputClick"
11
+ @click="show"
12
12
  >
13
- <sar-popout
14
- :visible="innerVisible"
13
+ <sar-calendar-popout
14
+ v-model:visible="innerVisible"
15
+ v-model="innerValue"
15
16
  :title="title ?? placeholder"
16
17
  :show-confirm="showConfirm"
17
- :confirm-disabled="confirmDisabled"
18
18
  :root-class="popoutClass"
19
19
  :root-style="popoutStyle"
20
- @update:visible="onVisible"
21
- @confirm="onConfirm"
22
- >
23
- <template #visible="{ already }">
24
- <sar-calendar
25
- v-if="already"
26
- :model-value="popoutValue"
27
- @change="onChange"
28
- :type="type"
29
- :min="min"
30
- :max="max"
31
- :current-date="currentDate"
32
- :disabled-date="disabledDate"
33
- :max-days="maxDays"
34
- :over-max-days="overMaxDays"
35
- :week-starts-on="weekStartsOn"
36
- :formatter="formatter"
37
- :allow-same-day="allowSameDay"
38
- :several-months="severalMonths"
39
- :value-format="valueFormat"
40
- />
41
- </template>
42
- </sar-popout>
20
+ :type="type"
21
+ :min="min"
22
+ :max="max"
23
+ :current-date="currentDate"
24
+ :disabled-date="disabledDate"
25
+ :max-days="maxDays"
26
+ :over-max-days="overMaxDays"
27
+ :week-starts-on="weekStartsOn"
28
+ :formatter="formatter"
29
+ :allow-same-day="allowSameDay"
30
+ :several-months="severalMonths"
31
+ :value-format="valueFormat"
32
+ :validate-event="validateEvent"
33
+ @change="onChange"
34
+ />
43
35
  </sar-popout-input>
44
36
  </template>
45
37
 
46
38
  <script>
47
39
  import { mergeDefaults as _mergeDefaults, defineComponent as _defineComponent } from "vue";
48
- import { ref, watch, computed } from "vue";
40
+ import { watch } from "vue";
49
41
  import SarPopoutInput from "../popout-input/popout-input.vue";
50
- import SarCalendar from "../calendar/calendar.vue";
51
- import SarPopout from "../popout/popout.vue";
42
+ import SarCalendarPopout from "../calendar-popout/calendar-popout.vue";
52
43
  import { formatDate, isString, parseDate } from "../../utils";
44
+ import { usePopoutInput } from "../../use";
53
45
  import { useTranslate } from "../locale";
54
46
  import {
55
47
  defaultCalendarInputProps
56
48
  } from "./common";
57
- import { useFormItemContext } from "../form/common";
58
49
  export default _defineComponent({
59
50
  components: {
60
51
  SarPopoutInput,
61
- SarCalendar,
62
- SarPopout,
52
+ SarCalendarPopout,
63
53
  },
64
54
  ...{
65
55
  options: {
@@ -69,10 +59,10 @@ export default _defineComponent({
69
59
  },
70
60
  __name: "calendar-input",
71
61
  props: _mergeDefaults({
62
+ outletFormat: { type: String, required: false },
72
63
  visible: { type: Boolean, required: false },
73
64
  title: { type: String, required: false },
74
65
  showConfirm: { type: Boolean, required: false },
75
- outletFormat: { type: String, required: false },
76
66
  validateEvent: { type: Boolean, required: false },
77
67
  popoutClass: { type: String, required: false },
78
68
  popoutStyle: { type: [Boolean, null, String, Object, Array], required: false, skipCheck: true },
@@ -102,39 +92,7 @@ export default _defineComponent({
102
92
  __expose();
103
93
  const props = __props;
104
94
  const emit = __emit;
105
- const formItemContext = useFormItemContext();
106
- const innerValue = ref(props.modelValue);
107
- watch(
108
- () => props.modelValue,
109
- () => {
110
- innerValue.value = props.modelValue;
111
- if (props.validateEvent) {
112
- formItemContext?.onChange();
113
- }
114
- }
115
- );
116
- const popoutValue = ref(props.modelValue);
117
- watch(innerValue, () => {
118
- popoutValue.value = innerValue.value;
119
- });
120
- const confirmDisabled = computed(() => {
121
- const value = popoutValue.value;
122
- return !value || Array.isArray(value) && value.length === 0;
123
- });
124
- const onChange = (value) => {
125
- popoutValue.value = value;
126
- if (!props.showConfirm && !confirmDisabled.value) {
127
- onConfirm();
128
- innerVisible.value = false;
129
- }
130
- };
131
- const onConfirm = () => {
132
- innerValue.value = popoutValue.value;
133
- emit("update:model-value", popoutValue.value);
134
- emit("change", popoutValue.value);
135
- inputValue.value = getInputValue();
136
- };
137
- const inputValue = ref("");
95
+ const { innerVisible, innerValue, inputValue, show, onChange, onClear } = usePopoutInput(props, emit);
138
96
  const { t } = useTranslate("calendar");
139
97
  function getOutletTextMayByStr(date) {
140
98
  if (isString(date) && props.valueFormat) {
@@ -177,28 +135,7 @@ export default _defineComponent({
177
135
  immediate: true
178
136
  }
179
137
  );
180
- const onClear = () => {
181
- inputValue.value = "";
182
- innerValue.value = void 0;
183
- emit("update:model-value", void 0);
184
- emit("change", void 0);
185
- };
186
- const innerVisible = ref(props.visible);
187
- watch(
188
- () => props.visible,
189
- () => {
190
- innerVisible.value = props.visible;
191
- }
192
- );
193
- const onVisible = (visible) => {
194
- innerVisible.value = visible;
195
- emit("update:visible", visible);
196
- };
197
- const onInputClick = () => {
198
- innerVisible.value = true;
199
- emit("update:visible", true);
200
- };
201
- const __returned__ = { props, emit, formItemContext, innerValue, popoutValue, confirmDisabled, onChange, onConfirm, inputValue, t, getOutletTextMayByStr, getOutletText, getInputValue, onClear, innerVisible, onVisible, onInputClick, SarPopoutInput, SarCalendar, SarPopout };
138
+ const __returned__ = { props, emit, innerVisible, innerValue, inputValue, show, onChange, onClear, t, getOutletTextMayByStr, getOutletText, getInputValue, SarPopoutInput, SarCalendarPopout };
202
139
  return __returned__;
203
140
  }
204
141
  });
@@ -1,25 +1,15 @@
1
- import { type CalendarProps } from '../calendar/common';
1
+ import { type CalendarPopoutEmits, type CalendarPopoutProps } from '../calendar-popout/common';
2
2
  import { type PopoutInputProps } from '../popout-input/common';
3
- import { type StyleValue } from 'vue';
4
- export interface CalendarInputProps extends CalendarProps, Omit<PopoutInputProps, 'modelValue' | 'loading'> {
5
- visible?: boolean;
6
- title?: string;
7
- showConfirm?: boolean;
3
+ export interface CalendarInputProps extends CalendarPopoutProps, Omit<PopoutInputProps, 'modelValue' | 'loading'> {
8
4
  outletFormat?: string;
9
- validateEvent?: boolean;
10
- popoutClass?: string;
11
- popoutStyle?: StyleValue;
12
5
  }
13
6
  export declare const defaultCalendarInputProps: () => {
14
- type: CalendarProps["type"];
15
- maxDays: number;
16
- weekStartsOn: number;
7
+ outletFormat: string;
17
8
  showConfirm: boolean;
18
9
  validateEvent: boolean;
19
- outletFormat: string;
10
+ type: import("../calendar").CalendarProps["type"];
11
+ maxDays: number;
12
+ weekStartsOn: number;
20
13
  };
21
- export interface CalendarInputEmits {
22
- (e: 'update:visible', visible: boolean): void;
23
- (e: 'update:model-value', value: Date | Date[] | string | string[] | undefined): void;
24
- (e: 'change', value: Date | Date[] | string | string[] | undefined): void;
14
+ export interface CalendarInputEmits extends CalendarPopoutEmits {
25
15
  }
@@ -1,5 +1,6 @@
1
1
  import { defaultConfig } from '../config';
2
2
  export const defaultCalendarInputProps = () => ({
3
- ...defaultConfig.calendarInput,
4
3
  ...defaultConfig.calendar,
4
+ ...defaultConfig.calendarPopout,
5
+ ...defaultConfig.calendarInput,
5
6
  });
@@ -0,0 +1,17 @@
1
+ import { type CalendarPopoutProps } from './common';
2
+ declare const _default: import("vue").DefineComponent<CalendarPopoutProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
3
+ "update:model-value": (value: string | string[] | Date | Date[] | undefined) => any;
4
+ change: (value: string | string[] | Date | Date[] | undefined) => any;
5
+ "update:visible": (visible: boolean) => any;
6
+ }, string, import("vue").PublicProps, Readonly<CalendarPopoutProps> & Readonly<{
7
+ "onUpdate:model-value"?: ((value: string | string[] | Date | Date[] | undefined) => any) | undefined;
8
+ onChange?: ((value: string | string[] | Date | Date[] | undefined) => any) | undefined;
9
+ "onUpdate:visible"?: ((visible: boolean) => any) | undefined;
10
+ }>, {
11
+ type: import("../calendar/common.js").CalendarType;
12
+ validateEvent: boolean;
13
+ weekStartsOn: number;
14
+ showConfirm: boolean;
15
+ maxDays: number;
16
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
+ export default _default;
@@ -0,0 +1,102 @@
1
+ <template>
2
+ <sar-popout
3
+ v-model:visible="innerVisible"
4
+ :title="title"
5
+ :show-confirm="showConfirm"
6
+ :confirm-disabled="confirmDisabled"
7
+ :root-class="popoutClass"
8
+ :root-style="popoutStyle"
9
+ @confirm="onConfirm"
10
+ >
11
+ <template #visible="{ already }">
12
+ <sar-calendar
13
+ v-if="already"
14
+ :model-value="popoutValue"
15
+ :type="type"
16
+ :min="min"
17
+ :max="max"
18
+ :current-date="currentDate"
19
+ :disabled-date="disabledDate"
20
+ :max-days="maxDays"
21
+ :over-max-days="overMaxDays"
22
+ :week-starts-on="weekStartsOn"
23
+ :formatter="formatter"
24
+ :allow-same-day="allowSameDay"
25
+ :several-months="severalMonths"
26
+ :value-format="valueFormat"
27
+ @change="onChange"
28
+ />
29
+ </template>
30
+ </sar-popout>
31
+ </template>
32
+
33
+ <script>
34
+ import { mergeDefaults as _mergeDefaults, defineComponent as _defineComponent } from "vue";
35
+ import { computed } from "vue";
36
+ import SarPopout from "../popout/popout.vue";
37
+ import SarCalendar from "../calendar/calendar.vue";
38
+ import {
39
+ defaultCalendarPopoutProps
40
+ } from "./common";
41
+ import { useFormPopout } from "../../use";
42
+ export default _defineComponent({
43
+ components: {
44
+ SarPopout,
45
+ SarCalendar,
46
+ },
47
+ ...{
48
+ options: {
49
+ virtualHost: true,
50
+ styleIsolation: "shared"
51
+ }
52
+ },
53
+ __name: "calendar-popout",
54
+ props: _mergeDefaults({
55
+ visible: { type: Boolean, required: false },
56
+ title: { type: String, required: false },
57
+ showConfirm: { type: Boolean, required: false },
58
+ validateEvent: { type: Boolean, required: false },
59
+ popoutClass: { type: String, required: false },
60
+ popoutStyle: { type: [Boolean, null, String, Object, Array], required: false, skipCheck: true },
61
+ rootStyle: { type: [Boolean, null, String, Object, Array], required: false, skipCheck: true },
62
+ rootClass: { type: String, required: false },
63
+ type: { type: String, required: false },
64
+ modelValue: { type: [Date, Array, String], required: false },
65
+ min: { type: Date, required: false },
66
+ max: { type: Date, required: false },
67
+ currentDate: { type: Date, required: false },
68
+ disabledDate: { type: Function, required: false },
69
+ maxDays: { type: Number, required: false },
70
+ overMaxDays: { type: Function, required: false },
71
+ weekStartsOn: { type: Number, required: false },
72
+ formatter: { type: Function, required: false },
73
+ allowSameDay: { type: Boolean, required: false },
74
+ severalMonths: { type: Boolean, required: false },
75
+ valueFormat: { type: String, required: false }
76
+ }, defaultCalendarPopoutProps()),
77
+ emits: ["update:visible", "update:model-value", "change"],
78
+ setup(__props, { expose: __expose, emit: __emit }) {
79
+ __expose();
80
+ const props = __props;
81
+ const emit = __emit;
82
+ const { innerVisible, popoutValue, onChange, onConfirm } = useFormPopout(
83
+ props,
84
+ emit,
85
+ {
86
+ onChange() {
87
+ if (!props.showConfirm && !confirmDisabled.value) {
88
+ onConfirm();
89
+ innerVisible.value = false;
90
+ }
91
+ }
92
+ }
93
+ );
94
+ const confirmDisabled = computed(() => {
95
+ const value = popoutValue.value;
96
+ return !value || Array.isArray(value) && value.length === 0;
97
+ });
98
+ const __returned__ = { props, emit, innerVisible, popoutValue, onChange, onConfirm, confirmDisabled, SarPopout, SarCalendar };
99
+ return __returned__;
100
+ }
101
+ });
102
+ </script>
@@ -0,0 +1,27 @@
1
+ import { type StyleValue } from 'vue';
2
+ import { type CalendarProps } from '../calendar/common';
3
+ export interface CalendarPopoutProps extends CalendarProps {
4
+ visible?: boolean;
5
+ title?: string;
6
+ showConfirm?: boolean;
7
+ validateEvent?: boolean;
8
+ popoutClass?: string;
9
+ popoutStyle?: StyleValue;
10
+ }
11
+ export declare const defaultCalendarPopoutProps: () => {
12
+ showConfirm: boolean;
13
+ validateEvent: boolean;
14
+ type: CalendarProps["type"];
15
+ maxDays: number;
16
+ weekStartsOn: number;
17
+ };
18
+ export interface CalendarPopoutSlots {
19
+ default?(props: Record<string, never>): any;
20
+ }
21
+ export interface CalendarPopoutEmits {
22
+ (e: 'update:visible', visible: boolean): void;
23
+ (e: 'update:model-value', value: Date | Date[] | string | string[] | undefined): void;
24
+ (e: 'change', value: Date | Date[] | string | string[] | undefined): void;
25
+ }
26
+ export interface CalendarPopoutExpose {
27
+ }
@@ -0,0 +1,5 @@
1
+ import { defaultConfig } from '../config';
2
+ export const defaultCalendarPopoutProps = () => ({
3
+ ...defaultConfig.calendar,
4
+ ...defaultConfig.calendarPopout,
5
+ });
@@ -0,0 +1 @@
1
+ export type { CalendarPopoutProps, CalendarPopoutSlots, CalendarPopoutEmits, CalendarPopoutExpose, } from './common';
@@ -0,0 +1 @@
1
+ export {};
@@ -9,58 +9,49 @@
9
9
  :root-class="rootClass"
10
10
  :root-style="rootStyle"
11
11
  @clear="onClear"
12
- @click="onInputClick"
12
+ @click="show"
13
13
  >
14
- <sar-popout
15
- :visible="innerVisible"
14
+ <sar-cascader-popout
15
+ v-model:visible="innerVisible"
16
+ v-model="innerValue"
16
17
  :title="title ?? placeholder"
17
18
  :show-confirm="showConfirm"
18
19
  :root-class="popoutClass"
19
20
  :root-style="popoutStyle"
20
- @confirm="onConfirm"
21
- @update:visible="onVisible"
21
+ :options="options"
22
+ :field-keys="fieldKeys"
23
+ :hint-text="hintText"
24
+ :change-on-select="changeOnSelect"
25
+ :label-render="labelRender"
26
+ :validate-event="validateEvent"
27
+ @select="(option, tabIndex) => $emit('select', option, tabIndex)"
28
+ @change="onChange"
22
29
  >
23
- <template #visible="{ already }">
24
- <sar-cascader
25
- v-if="already"
26
- :model-value="popoutValue"
27
- :options="options"
28
- :field-keys="fieldKeys"
29
- :hint-text="hintText"
30
- :change-on-select="changeOnSelect"
31
- :label-render="labelRender"
32
- @select="(option, tabIndex) => $emit('select', option, tabIndex)"
33
- @change="onChange"
34
- >
35
- <template #top="{ tabIndex }">
36
- <slot name="top" :tab-index="tabIndex"></slot>
37
- </template>
38
- </sar-cascader>
30
+ <template #top="{ tabIndex }">
31
+ <slot name="top" :tab-index="tabIndex"></slot>
39
32
  </template>
40
- </sar-popout>
33
+ </sar-cascader-popout>
41
34
  </sar-popout-input>
42
35
  </template>
43
36
 
44
37
  <script>
45
38
  import { mergeDefaults as _mergeDefaults, defineComponent as _defineComponent } from "vue";
46
- import { ref, watch, computed } from "vue";
39
+ import { watch, computed } from "vue";
47
40
  import SarPopoutInput from "../popout-input/popout-input.vue";
48
- import SarCascader from "../cascader/cascader.vue";
41
+ import SarCascaderPopout from "../cascader-popout/cascader-popout.vue";
49
42
  import {
50
43
  defaultFieldKeys,
51
44
  getSelectedOptionsByValue
52
45
  } from "../cascader/common";
53
- import SarPopout from "../popout/popout.vue";
54
46
  import { isNullish } from "../../utils";
47
+ import { usePopoutInput } from "../../use";
55
48
  import {
56
49
  defaultCascaderInputProps
57
50
  } from "./common";
58
- import { useFormItemContext } from "../form/common";
59
51
  export default _defineComponent({
60
52
  components: {
61
53
  SarPopoutInput,
62
- SarCascader,
63
- SarPopout,
54
+ SarCascaderPopout,
64
55
  },
65
56
  ...{
66
57
  options: {
@@ -90,45 +81,18 @@ export default _defineComponent({
90
81
  clearable: { type: Boolean, required: false },
91
82
  loading: { type: Boolean, required: false },
92
83
  multiline: { type: Boolean, required: false }
93
- }, defaultCascaderInputProps),
84
+ }, defaultCascaderInputProps()),
94
85
  emits: ["update:visible", "update:model-value", "change", "select"],
95
86
  setup(__props, { expose: __expose, emit: __emit }) {
96
87
  __expose();
97
88
  const props = __props;
98
89
  const emit = __emit;
99
- const formItemContext = useFormItemContext();
100
- const innerValue = ref(props.modelValue);
101
- watch(
102
- () => props.modelValue,
103
- () => {
104
- innerValue.value = props.modelValue;
105
- if (props.validateEvent) {
106
- formItemContext?.onChange();
107
- }
90
+ const { innerVisible, innerValue, inputValue, show, onChange, onClear } = usePopoutInput(props, emit, {
91
+ onClear() {
92
+ emit("update:model-value", void 0, []);
93
+ emit("change", void 0, []);
108
94
  }
109
- );
110
- const popoutValue = ref(props.modelValue);
111
- const popoutOptions = ref([]);
112
- watch(innerValue, () => {
113
- popoutValue.value = innerValue.value;
114
95
  });
115
- const onChange = (value, selectedOptions) => {
116
- popoutValue.value = value;
117
- popoutOptions.value = selectedOptions;
118
- if (!props.showConfirm && !isNullish(popoutValue.value)) {
119
- onConfirm();
120
- innerVisible.value = false;
121
- }
122
- };
123
- const onConfirm = () => {
124
- if (popoutValue.value !== innerValue.value) {
125
- innerValue.value = popoutValue.value;
126
- inputValue.value = getInputValue();
127
- emit("update:model-value", innerValue.value, popoutOptions.value);
128
- emit("change", innerValue.value, popoutOptions.value);
129
- }
130
- };
131
- const inputValue = ref("");
132
96
  const fieldkeys = computed(() => {
133
97
  return Object.assign(
134
98
  {},
@@ -151,7 +115,7 @@ export default _defineComponent({
151
115
  return getOutletText(props.options, innerValue.value, fieldkeys.value);
152
116
  }
153
117
  watch(
154
- innerValue,
118
+ [innerValue, () => props.options],
155
119
  () => {
156
120
  inputValue.value = getInputValue();
157
121
  },
@@ -159,34 +123,7 @@ export default _defineComponent({
159
123
  immediate: true
160
124
  }
161
125
  );
162
- watch(
163
- () => props.options,
164
- () => {
165
- inputValue.value = getInputValue();
166
- }
167
- );
168
- const onClear = () => {
169
- inputValue.value = "";
170
- innerValue.value = void 0;
171
- emit("update:model-value", void 0, []);
172
- emit("change", void 0, []);
173
- };
174
- const innerVisible = ref(props.visible);
175
- watch(
176
- () => props.visible,
177
- () => {
178
- innerVisible.value = props.visible;
179
- }
180
- );
181
- const onVisible = (visible) => {
182
- innerVisible.value = visible;
183
- emit("update:visible", visible);
184
- };
185
- const onInputClick = () => {
186
- innerVisible.value = true;
187
- emit("update:visible", true);
188
- };
189
- const __returned__ = { props, emit, formItemContext, innerValue, popoutValue, popoutOptions, onChange, onConfirm, inputValue, fieldkeys, getOutletText, getInputValue, onClear, innerVisible, onVisible, onInputClick, SarPopoutInput, SarCascader, SarPopout };
126
+ const __returned__ = { props, emit, innerVisible, innerValue, inputValue, show, onChange, onClear, fieldkeys, getOutletText, getInputValue, SarPopoutInput, SarCascaderPopout };
190
127
  return __returned__;
191
128
  }
192
129
  });
@@ -1,26 +1,12 @@
1
- import { type CascaderProps, type CascaderOption } from '../cascader/common';
2
1
  import { type PopoutInputProps } from '../popout-input/common';
3
- import { type StyleValue } from 'vue';
4
- export interface CascaderInputProps extends CascaderProps, Omit<PopoutInputProps, 'modelValue'> {
5
- visible?: boolean;
6
- title?: string;
7
- showConfirm?: boolean;
8
- validateEvent?: boolean;
9
- popoutClass?: string;
10
- popoutStyle?: StyleValue;
2
+ import { type CascaderPopoutProps, type CascaderPopoutEmits, type CascaderPopoutSlots } from '../cascader-popout/common';
3
+ export interface CascaderInputProps extends CascaderPopoutProps, Omit<PopoutInputProps, 'modelValue'> {
11
4
  }
12
- export declare const defaultCascaderInputProps: {
5
+ export declare const defaultCascaderInputProps: () => {
13
6
  showConfirm: boolean;
14
7
  validateEvent: boolean;
15
8
  };
16
- export interface CascaderInputSlots {
17
- top?(props: {
18
- tabIndex: number;
19
- }): any;
9
+ export interface CascaderInputSlots extends CascaderPopoutSlots {
20
10
  }
21
- export interface CascaderInputEmits {
22
- (e: 'update:visible', visible: boolean): void;
23
- (e: 'update:model-value', value: any, selectedOptions: CascaderOption[]): void;
24
- (e: 'change', value: any, selectedOptions: CascaderOption[]): void;
25
- (e: 'select', option: CascaderOption, tabIndex: number): void;
11
+ export interface CascaderInputEmits extends CascaderPopoutEmits {
26
12
  }
@@ -1,2 +1,4 @@
1
1
  import { defaultConfig } from '../config';
2
- export const defaultCascaderInputProps = defaultConfig.cascaderInput;
2
+ export const defaultCascaderInputProps = () => ({
3
+ ...defaultConfig.cascaderPopout,
4
+ });
@@ -0,0 +1,23 @@
1
+ import { type CascaderPopoutProps, type CascaderPopoutSlots } from './common';
2
+ declare function __VLS_template(): Readonly<CascaderPopoutSlots> & CascaderPopoutSlots;
3
+ declare const __VLS_component: import("vue").DefineComponent<CascaderPopoutProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
4
+ "update:model-value": (value: any, selectedOptions: import("../cascader/common.js").CascaderOption[]) => any;
5
+ change: (value: any, selectedOptions: import("../cascader/common.js").CascaderOption[]) => any;
6
+ select: (option: import("../cascader/common.js").CascaderOption, tabIndex: number) => any;
7
+ "update:visible": (visible: boolean) => any;
8
+ }, string, import("vue").PublicProps, Readonly<CascaderPopoutProps> & Readonly<{
9
+ "onUpdate:model-value"?: ((value: any, selectedOptions: import("../cascader/common.js").CascaderOption[]) => any) | undefined;
10
+ onChange?: ((value: any, selectedOptions: import("../cascader/common.js").CascaderOption[]) => any) | undefined;
11
+ onSelect?: ((option: import("../cascader/common.js").CascaderOption, tabIndex: number) => any) | undefined;
12
+ "onUpdate:visible"?: ((visible: boolean) => any) | undefined;
13
+ }>, {
14
+ validateEvent: boolean;
15
+ showConfirm: boolean;
16
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
18
+ export default _default;
19
+ type __VLS_WithTemplateSlots<T, S> = T & {
20
+ new (): {
21
+ $slots: S;
22
+ };
23
+ };