@onereach/ui-components 5.1.0 → 5.1.1-beta.3159.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.
@@ -1,4 +1,4 @@
1
- import { defineComponent, getCurrentInstance, ref, computed, toRef, onMounted, watch } from 'vue-demi';
1
+ import { defineComponent, getCurrentInstance, ref, computed, toRefs, onMounted, watch } from 'vue-demi';
2
2
  import { isEmptyValue } from '../../utils/isEmptyValue.js';
3
3
  import { Select, SelectControl, SelectSearchControl, SelectPlaceholder, SelectDropdown, SelectDropdownFlipped, SelectDropdownDefault, SelectDropdownItem, SelectNoSearchResults } from './styles.js';
4
4
  import __vue_component__$1 from '../OrCheckboxV3/OrCheckbox.js';
@@ -147,6 +147,10 @@ var script = defineComponent({
147
147
  type: Boolean,
148
148
  default: false
149
149
  },
150
+ enableClear: {
151
+ type: Boolean,
152
+ default: false
153
+ },
150
154
  searchFunction: {
151
155
  type: Function,
152
156
  default: async (searchText, options) => {
@@ -190,6 +194,11 @@ var script = defineComponent({
190
194
  var _a;
191
195
  return (_a = popover.value) === null || _a === void 0 ? void 0 : _a.state;
192
196
  });
197
+ // Props
198
+ const {
199
+ enableClear,
200
+ modelValue
201
+ } = toRefs(props);
193
202
  // Styles
194
203
  const rootStyles = computed(() => ['or-select-v3', ...Select]);
195
204
  const controlStyles = computed(() => [...SelectControl]);
@@ -203,10 +212,13 @@ var script = defineComponent({
203
212
  const noSearchResultsStyles = computed(() => [...SelectNoSearchResults]);
204
213
  // State
205
214
  const controlId = ref((_a = context.attrs.id) !== null && _a !== void 0 ? _a : currentInstance.uid.toString());
206
- const proxyModelValue = useProxyModelValue(toRef(props, 'modelValue'), context.emit);
215
+ const proxyModelValue = useProxyModelValue(modelValue, context.emit);
207
216
  const isEmptyModelValue = computed(() => {
208
217
  return Array.isArray(proxyModelValue.value) ? proxyModelValue.value.length === 0 : isEmptyValue(proxyModelValue.value);
209
218
  });
219
+ const showClear = computed(() => {
220
+ return enableClear.value && !isEmptyModelValue.value;
221
+ });
210
222
  onMounted(() => {
211
223
  if (!proxyModelValue.value && props.multiple) {
212
224
  proxyModelValue.value = [];
@@ -314,6 +326,7 @@ var script = defineComponent({
314
326
  proxyModelValue,
315
327
  readonly,
316
328
  isEmptyModelValue,
329
+ showClear,
317
330
  selection,
318
331
  searchText,
319
332
  internalSearchOptions,
@@ -451,7 +464,7 @@ var __vue_render__ = function () {
451
464
  class: ['grow']
452
465
  })], _vm._v(" "), _c('div', {
453
466
  class: ['layout-inline-row', 'gap-sm']
454
- }, [_vm.popoverState === 'closed' && !_vm.isEmptyModelValue ? [_c('OrIconButton', {
467
+ }, [_vm.showClear ? [_c('OrIconButton', {
455
468
  attrs: {
456
469
  "icon": 'close',
457
470
  "color": 'inherit',
@@ -29,6 +29,7 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
29
29
  proxyModelValue: import("../../hooks").UseProxyModelValueReturn<string | number | object | string[] | object[] | number[]>;
30
30
  readonly: import("@vue/composition-api").ComputedRef<boolean>;
31
31
  isEmptyModelValue: import("@vue/composition-api").ComputedRef<boolean>;
32
+ showClear: import("@vue/composition-api").ComputedRef<boolean>;
32
33
  selection: import("@vue/composition-api").ComputedRef<SelectOption | (SelectOption | undefined)[] | undefined>;
33
34
  searchText: import("@vue/composition-api").Ref<string>;
34
35
  internalSearchOptions: import("@vue/composition-api").Ref<{
@@ -102,6 +103,10 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
102
103
  type: BooleanConstructor;
103
104
  default: boolean;
104
105
  };
106
+ enableClear: {
107
+ type: BooleanConstructor;
108
+ default: boolean;
109
+ };
105
110
  searchFunction: {
106
111
  type: PropType<SelectSearchFunction>;
107
112
  default: SelectSearchFunction;
@@ -171,6 +176,10 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
171
176
  type: BooleanConstructor;
172
177
  default: boolean;
173
178
  };
179
+ enableClear: {
180
+ type: BooleanConstructor;
181
+ default: boolean;
182
+ };
174
183
  searchFunction: {
175
184
  type: PropType<SelectSearchFunction>;
176
185
  default: SelectSearchFunction;
@@ -198,6 +207,7 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
198
207
  disabled: boolean;
199
208
  disableDefaultStyles: boolean;
200
209
  enableSearch: boolean;
210
+ enableClear: boolean;
201
211
  searchFunction: SelectSearchFunction;
202
212
  groupByFunction: SelectGroupByFunction;
203
213
  externalControl: boolean;
@@ -231,6 +241,7 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
231
241
  proxyModelValue: import("../../hooks").UseProxyModelValueReturn<string | number | object | string[] | object[] | number[]>;
232
242
  readonly: import("@vue/composition-api").ComputedRef<boolean>;
233
243
  isEmptyModelValue: import("@vue/composition-api").ComputedRef<boolean>;
244
+ showClear: import("@vue/composition-api").ComputedRef<boolean>;
234
245
  selection: import("@vue/composition-api").ComputedRef<SelectOption | (SelectOption | undefined)[] | undefined>;
235
246
  searchText: import("@vue/composition-api").Ref<string>;
236
247
  internalSearchOptions: import("@vue/composition-api").Ref<{
@@ -262,6 +273,7 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
262
273
  disabled: boolean;
263
274
  disableDefaultStyles: boolean;
264
275
  enableSearch: boolean;
276
+ enableClear: boolean;
265
277
  searchFunction: SelectSearchFunction;
266
278
  groupByFunction: SelectGroupByFunction;
267
279
  externalControl: boolean;
@@ -282,6 +294,7 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
282
294
  disabled: boolean;
283
295
  disableDefaultStyles: boolean;
284
296
  enableSearch: boolean;
297
+ enableClear: boolean;
285
298
  searchFunction: SelectSearchFunction;
286
299
  groupByFunction: SelectGroupByFunction;
287
300
  externalControl: boolean;
@@ -1,4 +1,4 @@
1
- import { defineComponent, getCurrentInstance, ref, computed, toRef, onMounted, watch } from 'vue-demi';
1
+ import { defineComponent, getCurrentInstance, ref, computed, toRefs, onMounted, watch } from 'vue-demi';
2
2
  import { isEmptyValue } from './utils/isEmptyValue.js';
3
3
  import { Select, SelectControl, SelectSearchControl, SelectPlaceholder, SelectDropdown, SelectDropdownFlipped, SelectDropdownDefault, SelectDropdownItem, SelectNoSearchResults } from './components/OrSelectV3/styles.js';
4
4
  import './components/OrCheckboxV3/OrCheckbox.js';
@@ -112,6 +112,10 @@ var script = defineComponent({
112
112
  type: Boolean,
113
113
  default: false
114
114
  },
115
+ enableClear: {
116
+ type: Boolean,
117
+ default: false
118
+ },
115
119
  searchFunction: {
116
120
  type: Function,
117
121
  default: async (searchText, options) => {
@@ -155,6 +159,11 @@ var script = defineComponent({
155
159
  var _a;
156
160
  return (_a = popover.value) === null || _a === void 0 ? void 0 : _a.state;
157
161
  });
162
+ // Props
163
+ const {
164
+ enableClear,
165
+ modelValue
166
+ } = toRefs(props);
158
167
  // Styles
159
168
  const rootStyles = computed(() => ['or-select-v3', ...Select]);
160
169
  const controlStyles = computed(() => [...SelectControl]);
@@ -168,10 +177,13 @@ var script = defineComponent({
168
177
  const noSearchResultsStyles = computed(() => [...SelectNoSearchResults]);
169
178
  // State
170
179
  const controlId = ref((_a = context.attrs.id) !== null && _a !== void 0 ? _a : currentInstance.uid.toString());
171
- const proxyModelValue = useProxyModelValue(toRef(props, 'modelValue'), context.emit);
180
+ const proxyModelValue = useProxyModelValue(modelValue, context.emit);
172
181
  const isEmptyModelValue = computed(() => {
173
182
  return Array.isArray(proxyModelValue.value) ? proxyModelValue.value.length === 0 : isEmptyValue(proxyModelValue.value);
174
183
  });
184
+ const showClear = computed(() => {
185
+ return enableClear.value && !isEmptyModelValue.value;
186
+ });
175
187
  onMounted(() => {
176
188
  if (!proxyModelValue.value && props.multiple) {
177
189
  proxyModelValue.value = [];
@@ -279,6 +291,7 @@ var script = defineComponent({
279
291
  proxyModelValue,
280
292
  readonly,
281
293
  isEmptyModelValue,
294
+ showClear,
282
295
  selection,
283
296
  searchText,
284
297
  internalSearchOptions,
@@ -1,5 +1,5 @@
1
- import { s as script } from '../../OrSelect.vue_vue_type_script_lang-19739ac1.js';
2
- export { s as default } from '../../OrSelect.vue_vue_type_script_lang-19739ac1.js';
1
+ import { s as script } from '../../OrSelect.vue_vue_type_script_lang-20ddfbd0.js';
2
+ export { s as default } from '../../OrSelect.vue_vue_type_script_lang-20ddfbd0.js';
3
3
  import { resolveComponent, resolveDirective, openBlock, createElementBlock, normalizeClass, createBlock, withCtx, renderSlot, createTextVNode, toDisplayString, createCommentVNode, withDirectives, createElementVNode, Fragment, renderList, withModifiers, createVNode, vShow } from 'vue';
4
4
  import 'vue-demi';
5
5
  import '../../utils/isEmptyValue.js';
@@ -192,7 +192,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
192
192
  size: _ctx.size,
193
193
  "disable-default-styles": true,
194
194
  onClick: _cache[3] || (_cache[3] = withModifiers(() => {}, ["stop"]))
195
- }, null, 8 /* PROPS */, ["modelValue", "class", "placeholder", "size"])) : (openBlock(), createElementBlock("div", _hoisted_5)), createElementVNode("div", _hoisted_6, [_ctx.popoverState === 'closed' && !_ctx.isEmptyModelValue ? (openBlock(), createBlock(_component_OrIconButton, {
195
+ }, null, 8 /* PROPS */, ["modelValue", "class", "placeholder", "size"])) : (openBlock(), createElementBlock("div", _hoisted_5)), createElementVNode("div", _hoisted_6, [_ctx.showClear ? (openBlock(), createBlock(_component_OrIconButton, {
196
196
  key: 0,
197
197
  icon: 'close',
198
198
  color: 'inherit',
@@ -58,6 +58,10 @@ declare const _default: import("vue-demi").DefineComponent<{
58
58
  type: BooleanConstructor;
59
59
  default: boolean;
60
60
  };
61
+ enableClear: {
62
+ type: BooleanConstructor;
63
+ default: boolean;
64
+ };
61
65
  searchFunction: {
62
66
  type: PropType<SelectSearchFunction>;
63
67
  default: SelectSearchFunction;
@@ -90,6 +94,7 @@ declare const _default: import("vue-demi").DefineComponent<{
90
94
  proxyModelValue: import("../../hooks").UseProxyModelValueReturn<string | number | object | string[] | object[] | number[] | undefined>;
91
95
  readonly: import("vue-demi").ComputedRef<boolean>;
92
96
  isEmptyModelValue: import("vue-demi").ComputedRef<boolean>;
97
+ showClear: import("vue-demi").ComputedRef<boolean>;
93
98
  selection: import("vue-demi").ComputedRef<SelectOption | (SelectOption | undefined)[] | undefined>;
94
99
  searchText: import("vue-demi").Ref<string>;
95
100
  internalSearchOptions: import("vue-demi").Ref<{
@@ -163,6 +168,10 @@ declare const _default: import("vue-demi").DefineComponent<{
163
168
  type: BooleanConstructor;
164
169
  default: boolean;
165
170
  };
171
+ enableClear: {
172
+ type: BooleanConstructor;
173
+ default: boolean;
174
+ };
166
175
  searchFunction: {
167
176
  type: PropType<SelectSearchFunction>;
168
177
  default: SelectSearchFunction;
@@ -195,6 +204,7 @@ declare const _default: import("vue-demi").DefineComponent<{
195
204
  disabled: boolean;
196
205
  disableDefaultStyles: boolean;
197
206
  enableSearch: boolean;
207
+ enableClear: boolean;
198
208
  searchFunction: SelectSearchFunction;
199
209
  groupByFunction: SelectGroupByFunction;
200
210
  externalControl: boolean;
@@ -1,4 +1,4 @@
1
- export { s as OrSelectV3 } from '../../OrSelect.vue_vue_type_script_lang-19739ac1.js';
1
+ export { s as OrSelectV3 } from '../../OrSelect.vue_vue_type_script_lang-20ddfbd0.js';
2
2
  export { InputBoxSize as SelectSize } from '../OrInputBoxV3/props.js';
3
3
  import 'vue-demi';
4
4
  import '../../utils/isEmptyValue.js';
@@ -114,7 +114,7 @@ export { s as OrSearchV3 } from '../OrSearch.vue_vue_type_script_lang-e055677e.j
114
114
  export { s as OrSegmentedControlV3 } from '../OrSegmentedControl.vue_vue_type_script_lang-3a7df112.js';
115
115
  export { SegmentedControlSize } from './OrSegmentedControlV3/props.js';
116
116
  export { s as OrSelect } from '../OrSelect.vue_vue_type_script_lang-2516881b.js';
117
- export { s as OrSelectV3 } from '../OrSelect.vue_vue_type_script_lang-19739ac1.js';
117
+ export { s as OrSelectV3 } from '../OrSelect.vue_vue_type_script_lang-20ddfbd0.js';
118
118
  export { s as OrSidebar } from '../OrSidebar.vue_vue_type_script_lang-81941fe6.js';
119
119
  export { OrSidebarSide } from './OrSidebar/constants.js';
120
120
  export { s as OrSidebarV3 } from '../OrSidebar.vue_vue_type_script_lang-47572822.js';
@@ -74,7 +74,7 @@ export { s as OrSegmentedControlV3 } from './OrSegmentedControl.vue_vue_type_scr
74
74
  import './components/OrSelect/OrSelect.js';
75
75
  export { s as OrSelect } from './OrSelect.vue_vue_type_script_lang-2516881b.js';
76
76
  import './components/OrSelectV3/OrSelect.js';
77
- export { s as OrSelectV3 } from './OrSelect.vue_vue_type_script_lang-19739ac1.js';
77
+ export { s as OrSelectV3 } from './OrSelect.vue_vue_type_script_lang-20ddfbd0.js';
78
78
  import './components/OrSidebar/OrSidebar.js';
79
79
  export { s as OrSidebar } from './OrSidebar.vue_vue_type_script_lang-81941fe6.js';
80
80
  import './components/OrSidebarV3/OrSidebar.js';
@@ -1,4 +1,4 @@
1
- import { defineComponent, getCurrentInstance, ref, computed, toRef, onMounted, watch } from 'vue-demi';
1
+ import { defineComponent, getCurrentInstance, ref, computed, toRefs, onMounted, watch } from 'vue-demi';
2
2
  import { D as DropdownClose, a as DropdownOpen } from './dropdown-open-06d651cf.js';
3
3
  import { u as useOverflow } from './useOverflow-c856b7b7.js';
4
4
  import '@vueuse/core';
@@ -162,6 +162,10 @@ var script = defineComponent({
162
162
  type: Boolean,
163
163
  default: false
164
164
  },
165
+ enableClear: {
166
+ type: Boolean,
167
+ default: false
168
+ },
165
169
  searchFunction: {
166
170
  type: Function,
167
171
  default: async (searchText, options) => {
@@ -205,6 +209,11 @@ var script = defineComponent({
205
209
  var _a;
206
210
  return (_a = popover.value) === null || _a === void 0 ? void 0 : _a.state;
207
211
  });
212
+ // Props
213
+ const {
214
+ enableClear,
215
+ modelValue
216
+ } = toRefs(props);
208
217
  // Styles
209
218
  const rootStyles = computed(() => ['or-select-v3', ...Select]);
210
219
  const controlStyles = computed(() => [...SelectControl]);
@@ -218,10 +227,13 @@ var script = defineComponent({
218
227
  const noSearchResultsStyles = computed(() => [...SelectNoSearchResults]);
219
228
  // State
220
229
  const controlId = ref((_a = context.attrs.id) !== null && _a !== void 0 ? _a : currentInstance.uid.toString());
221
- const proxyModelValue = useProxyModelValue(toRef(props, 'modelValue'), context.emit);
230
+ const proxyModelValue = useProxyModelValue(modelValue, context.emit);
222
231
  const isEmptyModelValue = computed(() => {
223
232
  return Array.isArray(proxyModelValue.value) ? proxyModelValue.value.length === 0 : isEmptyValue(proxyModelValue.value);
224
233
  });
234
+ const showClear = computed(() => {
235
+ return enableClear.value && !isEmptyModelValue.value;
236
+ });
225
237
  onMounted(() => {
226
238
  if (!proxyModelValue.value && props.multiple) {
227
239
  proxyModelValue.value = [];
@@ -329,6 +341,7 @@ var script = defineComponent({
329
341
  proxyModelValue,
330
342
  readonly,
331
343
  isEmptyModelValue,
344
+ showClear,
332
345
  selection,
333
346
  searchText,
334
347
  internalSearchOptions,
@@ -466,7 +479,7 @@ var __vue_render__ = function () {
466
479
  class: ['grow']
467
480
  })], _vm._v(" "), _c('div', {
468
481
  class: ['layout-inline-row', 'gap-sm']
469
- }, [_vm.popoverState === 'closed' && !_vm.isEmptyModelValue ? [_c('OrIconButton', {
482
+ }, [_vm.showClear ? [_c('OrIconButton', {
470
483
  attrs: {
471
484
  "icon": 'close',
472
485
  "color": 'inherit',
@@ -78,7 +78,7 @@ export { _ as OrSearch } from '../OrSearch-ac542dd6.js';
78
78
  export { _ as OrSearchV3 } from '../OrSearch-15ecfbf0.js';
79
79
  export { _ as OrSegmentedControlV3, S as SegmentedControlSize } from '../OrSegmentedControl-d4e32f80.js';
80
80
  export { _ as OrSelect } from '../OrSelect-c0d04cf6.js';
81
- export { _ as OrSelectV3 } from '../OrSelect-ee398af5.js';
81
+ export { _ as OrSelectV3 } from '../OrSelect-667ece82.js';
82
82
  export { _ as OrSidebar, O as OrSidebarSide } from '../OrSidebar-c56a9221.js';
83
83
  export { _ as OrSidebarV3 } from '../OrSidebar-18d20059.js';
84
84
  export { O as OrSidebarPlacement } from '../OrSidebarCollapseButton-b490ff86.js';
@@ -29,6 +29,7 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
29
29
  proxyModelValue: import("../../hooks").UseProxyModelValueReturn<string | number | object | string[] | object[] | number[]>;
30
30
  readonly: import("@vue/composition-api").ComputedRef<boolean>;
31
31
  isEmptyModelValue: import("@vue/composition-api").ComputedRef<boolean>;
32
+ showClear: import("@vue/composition-api").ComputedRef<boolean>;
32
33
  selection: import("@vue/composition-api").ComputedRef<SelectOption | (SelectOption | undefined)[] | undefined>;
33
34
  searchText: import("@vue/composition-api").Ref<string>;
34
35
  internalSearchOptions: import("@vue/composition-api").Ref<{
@@ -102,6 +103,10 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
102
103
  type: BooleanConstructor;
103
104
  default: boolean;
104
105
  };
106
+ enableClear: {
107
+ type: BooleanConstructor;
108
+ default: boolean;
109
+ };
105
110
  searchFunction: {
106
111
  type: PropType<SelectSearchFunction>;
107
112
  default: SelectSearchFunction;
@@ -171,6 +176,10 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
171
176
  type: BooleanConstructor;
172
177
  default: boolean;
173
178
  };
179
+ enableClear: {
180
+ type: BooleanConstructor;
181
+ default: boolean;
182
+ };
174
183
  searchFunction: {
175
184
  type: PropType<SelectSearchFunction>;
176
185
  default: SelectSearchFunction;
@@ -198,6 +207,7 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
198
207
  disabled: boolean;
199
208
  disableDefaultStyles: boolean;
200
209
  enableSearch: boolean;
210
+ enableClear: boolean;
201
211
  searchFunction: SelectSearchFunction;
202
212
  groupByFunction: SelectGroupByFunction;
203
213
  externalControl: boolean;
@@ -231,6 +241,7 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
231
241
  proxyModelValue: import("../../hooks").UseProxyModelValueReturn<string | number | object | string[] | object[] | number[]>;
232
242
  readonly: import("@vue/composition-api").ComputedRef<boolean>;
233
243
  isEmptyModelValue: import("@vue/composition-api").ComputedRef<boolean>;
244
+ showClear: import("@vue/composition-api").ComputedRef<boolean>;
234
245
  selection: import("@vue/composition-api").ComputedRef<SelectOption | (SelectOption | undefined)[] | undefined>;
235
246
  searchText: import("@vue/composition-api").Ref<string>;
236
247
  internalSearchOptions: import("@vue/composition-api").Ref<{
@@ -262,6 +273,7 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
262
273
  disabled: boolean;
263
274
  disableDefaultStyles: boolean;
264
275
  enableSearch: boolean;
276
+ enableClear: boolean;
265
277
  searchFunction: SelectSearchFunction;
266
278
  groupByFunction: SelectGroupByFunction;
267
279
  externalControl: boolean;
@@ -282,6 +294,7 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
282
294
  disabled: boolean;
283
295
  disableDefaultStyles: boolean;
284
296
  enableSearch: boolean;
297
+ enableClear: boolean;
285
298
  searchFunction: SelectSearchFunction;
286
299
  groupByFunction: SelectGroupByFunction;
287
300
  externalControl: boolean;
@@ -1,4 +1,4 @@
1
- export { _ as OrSelectV3 } from '../../OrSelect-ee398af5.js';
1
+ export { _ as OrSelectV3 } from '../../OrSelect-667ece82.js';
2
2
  export { I as SelectSize } from '../../OrInputBox.vue_rollup-plugin-vue_script-4fde9829.js';
3
3
  import 'vue-demi';
4
4
  import '../../dropdown-open-06d651cf.js';
@@ -78,7 +78,7 @@ export { _ as OrSearch } from './OrSearch-ac542dd6.js';
78
78
  export { _ as OrSearchV3 } from './OrSearch-15ecfbf0.js';
79
79
  export { _ as OrSegmentedControlV3, S as SegmentedControlSize } from './OrSegmentedControl-d4e32f80.js';
80
80
  export { _ as OrSelect } from './OrSelect-c0d04cf6.js';
81
- export { _ as OrSelectV3 } from './OrSelect-ee398af5.js';
81
+ export { _ as OrSelectV3 } from './OrSelect-667ece82.js';
82
82
  export { _ as OrSidebar, O as OrSidebarSide } from './OrSidebar-c56a9221.js';
83
83
  export { _ as OrSidebarV3 } from './OrSidebar-18d20059.js';
84
84
  export { O as OrSidebarPlacement } from './OrSidebarCollapseButton-b490ff86.js';
@@ -1,4 +1,4 @@
1
- import { defineComponent, getCurrentInstance, ref, computed, toRef, onMounted, watch } from 'vue-demi';
1
+ import { defineComponent, getCurrentInstance, ref, computed, toRefs, onMounted, watch } from 'vue-demi';
2
2
  import { D as DropdownClose, a as DropdownOpen } from './dropdown-open-06d651cf.js';
3
3
  import { u as useOverflow } from './useOverflow-c856b7b7.js';
4
4
  import '@vueuse/core';
@@ -161,6 +161,10 @@ var script = defineComponent({
161
161
  type: Boolean,
162
162
  default: false
163
163
  },
164
+ enableClear: {
165
+ type: Boolean,
166
+ default: false
167
+ },
164
168
  searchFunction: {
165
169
  type: Function,
166
170
  default: async (searchText, options) => {
@@ -204,6 +208,11 @@ var script = defineComponent({
204
208
  var _a;
205
209
  return (_a = popover.value) === null || _a === void 0 ? void 0 : _a.state;
206
210
  });
211
+ // Props
212
+ const {
213
+ enableClear,
214
+ modelValue
215
+ } = toRefs(props);
207
216
  // Styles
208
217
  const rootStyles = computed(() => ['or-select-v3', ...Select]);
209
218
  const controlStyles = computed(() => [...SelectControl]);
@@ -217,10 +226,13 @@ var script = defineComponent({
217
226
  const noSearchResultsStyles = computed(() => [...SelectNoSearchResults]);
218
227
  // State
219
228
  const controlId = ref((_a = context.attrs.id) !== null && _a !== void 0 ? _a : currentInstance.uid.toString());
220
- const proxyModelValue = useProxyModelValue(toRef(props, 'modelValue'), context.emit);
229
+ const proxyModelValue = useProxyModelValue(modelValue, context.emit);
221
230
  const isEmptyModelValue = computed(() => {
222
231
  return Array.isArray(proxyModelValue.value) ? proxyModelValue.value.length === 0 : isEmptyValue(proxyModelValue.value);
223
232
  });
233
+ const showClear = computed(() => {
234
+ return enableClear.value && !isEmptyModelValue.value;
235
+ });
224
236
  onMounted(() => {
225
237
  if (!proxyModelValue.value && props.multiple) {
226
238
  proxyModelValue.value = [];
@@ -328,6 +340,7 @@ var script = defineComponent({
328
340
  proxyModelValue,
329
341
  readonly,
330
342
  isEmptyModelValue,
343
+ showClear,
331
344
  selection,
332
345
  searchText,
333
346
  internalSearchOptions,
@@ -452,7 +465,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
452
465
  size: _ctx.size,
453
466
  "disable-default-styles": true,
454
467
  onClick: _cache[3] || (_cache[3] = withModifiers(() => {}, ["stop"]))
455
- }, null, 8 /* PROPS */, ["modelValue", "class", "placeholder", "size"])) : (openBlock(), createElementBlock("div", _hoisted_5)), createElementVNode("div", _hoisted_6, [_ctx.popoverState === 'closed' && !_ctx.isEmptyModelValue ? (openBlock(), createBlock(_component_OrIconButton, {
468
+ }, null, 8 /* PROPS */, ["modelValue", "class", "placeholder", "size"])) : (openBlock(), createElementBlock("div", _hoisted_5)), createElementVNode("div", _hoisted_6, [_ctx.showClear ? (openBlock(), createBlock(_component_OrIconButton, {
456
469
  key: 0,
457
470
  icon: 'close',
458
471
  color: 'inherit',
@@ -75,7 +75,7 @@ export { s as OrSearch } from '../OrSearch-2800e9bf.js';
75
75
  export { s as OrSearchV3 } from '../OrSearch-9c694c80.js';
76
76
  export { s as OrSegmentedControlV3, S as SegmentedControlSize } from '../OrSegmentedControl-c8eb217d.js';
77
77
  export { s as OrSelect } from '../OrSelect-9520d6e6.js';
78
- export { s as OrSelectV3 } from '../OrSelect-3a39f89e.js';
78
+ export { s as OrSelectV3 } from '../OrSelect-c1c0fa31.js';
79
79
  export { s as OrSidebar, O as OrSidebarSide } from '../OrSidebar-aaf73310.js';
80
80
  export { s as OrSidebarV3 } from '../OrSidebar-34492810.js';
81
81
  export { O as OrSidebarPlacement } from '../OrSidebarCollapseButton-f6f5ec80.js';
@@ -58,6 +58,10 @@ declare const _default: import("vue-demi").DefineComponent<{
58
58
  type: BooleanConstructor;
59
59
  default: boolean;
60
60
  };
61
+ enableClear: {
62
+ type: BooleanConstructor;
63
+ default: boolean;
64
+ };
61
65
  searchFunction: {
62
66
  type: PropType<SelectSearchFunction>;
63
67
  default: SelectSearchFunction;
@@ -90,6 +94,7 @@ declare const _default: import("vue-demi").DefineComponent<{
90
94
  proxyModelValue: import("../../hooks").UseProxyModelValueReturn<string | number | object | string[] | object[] | number[] | undefined>;
91
95
  readonly: import("vue-demi").ComputedRef<boolean>;
92
96
  isEmptyModelValue: import("vue-demi").ComputedRef<boolean>;
97
+ showClear: import("vue-demi").ComputedRef<boolean>;
93
98
  selection: import("vue-demi").ComputedRef<SelectOption | (SelectOption | undefined)[] | undefined>;
94
99
  searchText: import("vue-demi").Ref<string>;
95
100
  internalSearchOptions: import("vue-demi").Ref<{
@@ -163,6 +168,10 @@ declare const _default: import("vue-demi").DefineComponent<{
163
168
  type: BooleanConstructor;
164
169
  default: boolean;
165
170
  };
171
+ enableClear: {
172
+ type: BooleanConstructor;
173
+ default: boolean;
174
+ };
166
175
  searchFunction: {
167
176
  type: PropType<SelectSearchFunction>;
168
177
  default: SelectSearchFunction;
@@ -195,6 +204,7 @@ declare const _default: import("vue-demi").DefineComponent<{
195
204
  disabled: boolean;
196
205
  disableDefaultStyles: boolean;
197
206
  enableSearch: boolean;
207
+ enableClear: boolean;
198
208
  searchFunction: SelectSearchFunction;
199
209
  groupByFunction: SelectGroupByFunction;
200
210
  externalControl: boolean;
@@ -1,4 +1,4 @@
1
- export { s as OrSelectV3 } from '../../OrSelect-3a39f89e.js';
1
+ export { s as OrSelectV3 } from '../../OrSelect-c1c0fa31.js';
2
2
  export { I as SelectSize } from '../../OrInputBox-912a6254.js';
3
3
  import 'vue-demi';
4
4
  import '../../dropdown-open-06d651cf.js';
@@ -75,7 +75,7 @@ export { s as OrSearch } from './OrSearch-2800e9bf.js';
75
75
  export { s as OrSearchV3 } from './OrSearch-9c694c80.js';
76
76
  export { s as OrSegmentedControlV3, S as SegmentedControlSize } from './OrSegmentedControl-c8eb217d.js';
77
77
  export { s as OrSelect } from './OrSelect-9520d6e6.js';
78
- export { s as OrSelectV3 } from './OrSelect-3a39f89e.js';
78
+ export { s as OrSelectV3 } from './OrSelect-c1c0fa31.js';
79
79
  export { s as OrSidebar, O as OrSidebarSide } from './OrSidebar-aaf73310.js';
80
80
  export { s as OrSidebarV3 } from './OrSidebar-34492810.js';
81
81
  export { O as OrSidebarPlacement } from './OrSidebarCollapseButton-f6f5ec80.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onereach/ui-components",
3
- "version": "5.1.0",
3
+ "version": "5.1.1-beta.3159.0",
4
4
  "npmUnpacked": "4.15.2",
5
5
  "description": "Vue components library for v2/3",
6
6
  "sideEffects": false,
@@ -148,6 +148,5 @@
148
148
  "default": "./dist/bundled/v3/components/*/index.js"
149
149
  },
150
150
  "./package.json": "./package.json"
151
- },
152
- "gitHead": "836bd5ff950876d0076ddc862dcc93d5f64ca794"
151
+ }
153
152
  }
@@ -111,7 +111,7 @@
111
111
  </template>
112
112
 
113
113
  <div :class="['layout-inline-row', 'gap-sm']">
114
- <template v-if="popoverState === 'closed' && !isEmptyModelValue">
114
+ <template v-if="showClear">
115
115
  <OrIconButton
116
116
  :icon="'close'"
117
117
  :color="'inherit'"
@@ -269,7 +269,7 @@
269
269
  </template>
270
270
 
271
271
  <script lang="ts">
272
- import { computed, defineComponent, getCurrentInstance, onMounted, PropType, ref, toRef, watch } from 'vue-demi';
272
+ import { computed, defineComponent, getCurrentInstance, onMounted, PropType, ref, toRefs, watch } from 'vue-demi';
273
273
  import { DropdownClose, DropdownOpen } from '../../directives';
274
274
  import { useOverflow, useProxyModelValue, useResponsive } from '../../hooks';
275
275
  import { isEmptyValue } from '../../utils/isEmptyValue';
@@ -386,6 +386,11 @@ export default defineComponent({
386
386
  default: false,
387
387
  },
388
388
 
389
+ enableClear: {
390
+ type: Boolean,
391
+ default: false,
392
+ },
393
+
389
394
  searchFunction: {
390
395
  type: Function as PropType<SelectSearchFunction>,
391
396
 
@@ -435,6 +440,9 @@ export default defineComponent({
435
440
  const popoverRoot = computed(() => popover.value?.root);
436
441
  const popoverState = computed(() => popover.value?.state);
437
442
 
443
+ // Props
444
+ const { enableClear, modelValue } = toRefs(props);
445
+
438
446
  // Styles
439
447
  const rootStyles = computed(() => [
440
448
  'or-select-v3',
@@ -469,7 +477,7 @@ export default defineComponent({
469
477
  // State
470
478
  const controlId = ref(context.attrs.id as string ?? currentInstance.uid.toString());
471
479
 
472
- const proxyModelValue = useProxyModelValue(toRef(props, 'modelValue'), context.emit);
480
+ const proxyModelValue = useProxyModelValue(modelValue, context.emit);
473
481
 
474
482
  const isEmptyModelValue = computed(() => {
475
483
  return Array.isArray(proxyModelValue.value)
@@ -477,6 +485,10 @@ export default defineComponent({
477
485
  : isEmptyValue(proxyModelValue.value);
478
486
  });
479
487
 
488
+ const showClear = computed(() => {
489
+ return enableClear.value && !isEmptyModelValue.value;
490
+ });
491
+
480
492
  onMounted(() => {
481
493
  if (!proxyModelValue.value && props.multiple) {
482
494
  proxyModelValue.value = [];
@@ -606,6 +618,7 @@ export default defineComponent({
606
618
  proxyModelValue,
607
619
  readonly,
608
620
  isEmptyModelValue,
621
+ showClear,
609
622
  selection,
610
623
  searchText,
611
624
  internalSearchOptions,