selectic 3.2.0 → 3.3.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.
package/.tool-versions CHANGED
@@ -1,5 +1,5 @@
1
- # ASDF configuration file for mmsx repository.
1
+ # ASDF configuration file for Selectic repository.
2
2
  #
3
3
  # https://asdf-vm.com/manage/configuration.html
4
4
 
5
- nodejs 12.18.4 system
5
+ nodejs 20.11.1 system
@@ -2921,6 +2921,17 @@ let Selectic = class Selectic extends vtyx.Vue {
2921
2921
  }
2922
2922
  const target = evt.target;
2923
2923
  if (!extendedListEl.contains(target) && !this.$el.contains(target)) {
2924
+ if (keepOpenWithOtherSelectic) {
2925
+ let classSelector = '.selectic';
2926
+ if (typeof keepOpenWithOtherSelectic === 'string') {
2927
+ classSelector += keepOpenWithOtherSelectic;
2928
+ }
2929
+ const parentIsSelectic = target === null || target === void 0 ? void 0 : target.closest(classSelector);
2930
+ if (parentIsSelectic) {
2931
+ /* Do not close current Selectic */
2932
+ return;
2933
+ }
2934
+ }
2924
2935
  store.commit('isOpen', false);
2925
2936
  }
2926
2937
  };
@@ -3306,7 +3317,7 @@ let Selectic = class Selectic extends vtyx.Vue {
3306
3317
  multiple: ((_a = this.multiple) !== null && _a !== void 0 ? _a : false) !== false,
3307
3318
  pageSize: this.params.pageSize || 100,
3308
3319
  hideFilter: (_b = this.params.hideFilter) !== null && _b !== void 0 ? _b : 'auto',
3309
- allowRevert: this.params.allowRevert,
3320
+ allowRevert: this.params.allowRevert, /* it can be undefined */
3310
3321
  forceSelectAll: this.params.forceSelectAll || 'auto',
3311
3322
  allowClearSelection: this.params.allowClearSelection || false,
3312
3323
  autoSelect: this.params.autoSelect === undefined
@@ -3320,7 +3331,7 @@ let Selectic = class Selectic extends vtyx.Vue {
3320
3331
  formatOption: this.params.formatOption,
3321
3332
  formatSelection: this.params.formatSelection,
3322
3333
  listPosition: this.params.listPosition || 'auto',
3323
- optionBehavior: this.params.optionBehavior,
3334
+ optionBehavior: this.params.optionBehavior, /* it can be undefined */
3324
3335
  isOpen: ((_c = this.open) !== null && _c !== void 0 ? _c : false) !== false,
3325
3336
  disableGroupSelection: this.params.disableGroupSelection,
3326
3337
  },
@@ -2917,6 +2917,17 @@ let Selectic = class Selectic extends Vue {
2917
2917
  }
2918
2918
  const target = evt.target;
2919
2919
  if (!extendedListEl.contains(target) && !this.$el.contains(target)) {
2920
+ if (keepOpenWithOtherSelectic) {
2921
+ let classSelector = '.selectic';
2922
+ if (typeof keepOpenWithOtherSelectic === 'string') {
2923
+ classSelector += keepOpenWithOtherSelectic;
2924
+ }
2925
+ const parentIsSelectic = target === null || target === void 0 ? void 0 : target.closest(classSelector);
2926
+ if (parentIsSelectic) {
2927
+ /* Do not close current Selectic */
2928
+ return;
2929
+ }
2930
+ }
2920
2931
  store.commit('isOpen', false);
2921
2932
  }
2922
2933
  };
@@ -3302,7 +3313,7 @@ let Selectic = class Selectic extends Vue {
3302
3313
  multiple: ((_a = this.multiple) !== null && _a !== void 0 ? _a : false) !== false,
3303
3314
  pageSize: this.params.pageSize || 100,
3304
3315
  hideFilter: (_b = this.params.hideFilter) !== null && _b !== void 0 ? _b : 'auto',
3305
- allowRevert: this.params.allowRevert,
3316
+ allowRevert: this.params.allowRevert, /* it can be undefined */
3306
3317
  forceSelectAll: this.params.forceSelectAll || 'auto',
3307
3318
  allowClearSelection: this.params.allowClearSelection || false,
3308
3319
  autoSelect: this.params.autoSelect === undefined
@@ -3316,7 +3327,7 @@ let Selectic = class Selectic extends Vue {
3316
3327
  formatOption: this.params.formatOption,
3317
3328
  formatSelection: this.params.formatSelection,
3318
3329
  listPosition: this.params.listPosition || 'auto',
3319
- optionBehavior: this.params.optionBehavior,
3330
+ optionBehavior: this.params.optionBehavior, /* it can be undefined */
3320
3331
  isOpen: ((_c = this.open) !== null && _c !== void 0 ? _c : false) !== false,
3321
3332
  disableGroupSelection: this.params.disableGroupSelection,
3322
3333
  },
package/doc/params.md CHANGED
@@ -312,12 +312,17 @@ will not be displayed and the filter panel is always open.
312
312
 
313
313
  ## keepOpenWithOtherSelectic
314
314
 
315
- Type: `boolean`
315
+ Type: `boolean | string`
316
316
 
317
317
  Default value: `false`
318
318
 
319
- By default, only one selectic component can be open at the same time. So if another Selectic component is open (mainly programmatically) then any previously open component is closed.
320
- If `keepOpenWithOtherSelectic` is set to `true`, this component stays open when another Selectic component opens.
319
+ By default, only one selectic component can be open at the same time. So if another Selectic component is open then any previously open component is closed.
320
+
321
+ When `keepOpenWithOtherSelectic` is set to `true`, this component stays open when any other Selectic component opens.
322
+
323
+ When it is set to a `non-empty string`, this component stays open only when another Selectic component that matches the given CSS selector opens.
324
+
325
+ For falsy values, the component always closes when another Selectic opens.
321
326
 
322
327
  Note: This attribute does not prevent closing when user clicks outside the component.
323
328
 
@@ -330,6 +335,15 @@ Note: This attribute does not prevent closing when user clicks outside the compo
330
335
  />
331
336
  ```
332
337
 
338
+ ```html
339
+ <selectic
340
+ :params="{
341
+ keepOpenWithOtherSelectic: '.class-name',
342
+ }"
343
+ :options="optionList"
344
+ />
345
+ ```
346
+
333
347
  ## listPosition
334
348
 
335
349
  Type: `'auto' | 'bottom' | 'top'`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "selectic",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "description": "Smart Select for VueJS 3.x",
5
5
  "main": "dist/selectic.common.js",
6
6
  "module": "dist/selectic.esm.js",
@@ -39,13 +39,13 @@
39
39
  "test": "npm run build && tape test/**/*.spec.js"
40
40
  },
41
41
  "dependencies": {
42
- "vtyx": "4.2.1"
42
+ "vtyx": "4.4.2"
43
43
  },
44
44
  "devDependencies": {
45
- "@babel/types": "^7.28.1",
45
+ "@babel/types": "^7.28.2",
46
46
  "rollup": "^2.79.2",
47
47
  "rollup-plugin-postcss": "^4.0.2",
48
48
  "tape": "^4.17.0",
49
- "typescript": "~4.8"
49
+ "typescript": "~5.9"
50
50
  }
51
51
  }
package/src/Store.tsx CHANGED
@@ -208,8 +208,15 @@ export interface Props {
208
208
  /** Overwrite default icon family */
209
209
  iconFamily?: IconFamily | null;
210
210
 
211
- /** Keep this component open if another Selectic component opens */
212
- keepOpenWithOtherSelectic?: boolean;
211
+ /** Keep this component open if another Selectic component opens.
212
+ *
213
+ * - `true` → Keep open for **any** Selectic component.
214
+ * - `string` → Keep open only when the other Selectic matches the given CSS selector.
215
+ * - `false` (default) → Always close when another Selectic opens.
216
+ *
217
+ * An empty string is treated the same as `false`.
218
+ */
219
+ keepOpenWithOtherSelectic?: boolean | string;
213
220
 
214
221
  /** Selectic configuration */
215
222
  params?: SelecticStoreStateParams;
package/src/index.tsx CHANGED
@@ -146,8 +146,15 @@ export interface ParamProps {
146
146
  */
147
147
  optionBehavior?: string;
148
148
 
149
- /** Keep this component open if another Selectic component opens */
150
- keepOpenWithOtherSelectic?: boolean;
149
+ /** Keep this component open if another Selectic component opens.
150
+ *
151
+ * - `true` → Keep open for **any** Selectic component.
152
+ * - `string` → Keep open only when the other Selectic matches the given CSS selector.
153
+ * - `false` (default) → Always close when another Selectic opens.
154
+ *
155
+ * An empty string is treated the same as `false`.
156
+ */
157
+ keepOpenWithOtherSelectic?: boolean | string;
151
158
 
152
159
  /** Avoid click on group name to select all items in this group. */
153
160
  disableGroupSelection?: boolean;
@@ -361,9 +368,24 @@ export default class Selectic extends Vue<Props> {
361
368
  return;
362
369
  }
363
370
 
364
- const target = evt.target as Node;
371
+ const target = evt.target as Element | null;
365
372
 
366
373
  if (!extendedListEl.contains(target) && !this.$el.contains(target)) {
374
+ if (keepOpenWithOtherSelectic) {
375
+ let classSelector = '.selectic';
376
+
377
+ if (typeof keepOpenWithOtherSelectic === 'string') {
378
+ classSelector += keepOpenWithOtherSelectic;
379
+ }
380
+
381
+ const parentIsSelectic = target?.closest(classSelector);
382
+
383
+ if (parentIsSelectic) {
384
+ /* Do not close current Selectic */
385
+ return;
386
+ }
387
+ }
388
+
367
389
  store.commit('isOpen', false);
368
390
  }
369
391
  };
package/types/Store.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { ComputedRef } from 'vue';
2
- declare type MandateProps<T extends {}> = {
2
+ type MandateProps<T extends {}> = {
3
3
  [TK in keyof T]-?: T[TK];
4
4
  };
5
- export declare type StrictOptionId = string | number;
6
- export declare type OptionId = StrictOptionId | null;
7
- export declare type SelectedValue = OptionId | StrictOptionId[];
5
+ export type StrictOptionId = string | number;
6
+ export type OptionId = StrictOptionId | null;
7
+ export type SelectedValue = OptionId | StrictOptionId[];
8
8
  export interface OptionValue {
9
9
  id: OptionId;
10
10
  text: string;
@@ -18,19 +18,19 @@ export interface OptionValue {
18
18
  exclusive?: boolean;
19
19
  data?: any;
20
20
  }
21
- declare type OptionBehaviorOperation = 'sort' | 'force';
22
- declare type OptionBehaviorOrder = 'O' | 'D' | 'E';
21
+ type OptionBehaviorOperation = 'sort' | 'force';
22
+ type OptionBehaviorOrder = 'O' | 'D' | 'E';
23
23
  export interface OptionItem extends OptionValue {
24
24
  selected: boolean;
25
25
  disabled: boolean;
26
26
  isGroup: boolean;
27
27
  }
28
- export declare type OptionProp = OptionValue | string;
28
+ export type OptionProp = OptionValue | string;
29
29
  export interface GroupValue {
30
30
  id: StrictOptionId;
31
31
  text: string;
32
32
  }
33
- export declare type RequestResult = {
33
+ export type RequestResult = {
34
34
  /** The total number of expecting options.
35
35
  * Needed to know if there are more items to fetch, and to size the scrollbar.
36
36
  */
@@ -38,20 +38,20 @@ export declare type RequestResult = {
38
38
  /** The list of the options. */
39
39
  result: OptionValue[];
40
40
  };
41
- export declare type FetchCallback = (_search: string, _offsetItem: number, _pageSize: number) => Promise<RequestResult>;
42
- export declare type GetCallback = (_ids: OptionId[]) => Promise<OptionValue[]>;
43
- export declare type FormatCallback = (_option: OptionItem) => OptionItem;
44
- export declare type SelectionOverflow =
41
+ export type FetchCallback = (_search: string, _offsetItem: number, _pageSize: number) => Promise<RequestResult>;
42
+ export type GetCallback = (_ids: OptionId[]) => Promise<OptionValue[]>;
43
+ export type FormatCallback = (_option: OptionItem) => OptionItem;
44
+ export type SelectionOverflow =
45
45
  /** Items are reduced in width and an ellipsis is displayed in their name. */
46
46
  'collapsed' | 'multiline';
47
- export declare type ListPosition =
47
+ export type ListPosition =
48
48
  /** Display the list at bottom */
49
49
  'bottom'
50
50
  /** Display the list at bottom */
51
51
  | 'top'
52
52
  /** Display the list at bottom but if there is not enough space, display it at top */
53
53
  | 'auto';
54
- export declare type HideFilter =
54
+ export type HideFilter =
55
55
  /** Display or hide the filter panel */
56
56
  boolean
57
57
  /** The handler to open the filter panel is hidden only if there is less
@@ -59,7 +59,7 @@ boolean
59
59
  | 'auto'
60
60
  /** The panel filter is always open */
61
61
  | 'open';
62
- export declare type SelectAllOption =
62
+ export type SelectAllOption =
63
63
  /** Display the "select all" only when data are all fetched or allowRevert */
64
64
  'auto'
65
65
  /** Always display the "select all" in mulitple mode. */
@@ -135,8 +135,15 @@ export interface Props {
135
135
  icons?: PartialIcons | null;
136
136
  /** Overwrite default icon family */
137
137
  iconFamily?: IconFamily | null;
138
- /** Keep this component open if another Selectic component opens */
139
- keepOpenWithOtherSelectic?: boolean;
138
+ /** Keep this component open if another Selectic component opens.
139
+ *
140
+ * - `true` → Keep open for **any** Selectic component.
141
+ * - `string` → Keep open only when the other Selectic matches the given CSS selector.
142
+ * - `false` (default) → Always close when another Selectic opens.
143
+ *
144
+ * An empty string is treated the same as `false`.
145
+ */
146
+ keepOpenWithOtherSelectic?: boolean | string;
140
147
  /** Selectic configuration */
141
148
  params?: SelecticStoreStateParams;
142
149
  /** Method to call to fetch extra data */
@@ -144,7 +151,7 @@ export interface Props {
144
151
  /** Method to call to get specific item */
145
152
  getItemsCallback?: GetCallback | null;
146
153
  }
147
- declare type InternalProps = MandateProps<Props>;
154
+ type InternalProps = MandateProps<Props>;
148
155
  export interface Data {
149
156
  /** Number of items displayed in a page (before scrolling) */
150
157
  itemsPerPage: number;
@@ -246,11 +253,11 @@ export interface SelecticStoreState {
246
253
  automaticClose: boolean;
247
254
  };
248
255
  }
249
- export declare type IconFamily = '' | 'selectic' | 'font-awesome-4' | 'font-awesome-5' | 'font-awesome-6' | 'raw' | `prefix:${string}`;
250
- export declare type IconKey = 'caret-down' | 'caret-up' | 'check' | 'dot' | 'search' | 'spinner' | 'strikethrough' | 'times' | 'question' | 'spin';
251
- export declare type IconValue = `selectic:${IconKey}${'' | ':spin'}` | `raw:${string}` | `current:${IconKey}${'' | ':spin'}` | string;
252
- export declare type Icons = Record<IconKey, IconValue>;
253
- export declare type PartialIcons = {
256
+ export type IconFamily = '' | 'selectic' | 'font-awesome-4' | 'font-awesome-5' | 'font-awesome-6' | 'raw' | `prefix:${string}`;
257
+ export type IconKey = 'caret-down' | 'caret-up' | 'check' | 'dot' | 'search' | 'spinner' | 'strikethrough' | 'times' | 'question' | 'spin';
258
+ export type IconValue = `selectic:${IconKey}${'' | ':spin'}` | `raw:${string}` | `current:${IconKey}${'' | ':spin'}` | string;
259
+ export type Icons = Record<IconKey, IconValue>;
260
+ export type PartialIcons = {
254
261
  [K in IconKey]?: Icons[K];
255
262
  };
256
263
  interface Messages {
@@ -272,7 +279,7 @@ interface Messages {
272
279
  unknownPropertyValue: string;
273
280
  wrongQueryResult: string;
274
281
  }
275
- export declare type PartialMessages = {
282
+ export type PartialMessages = {
276
283
  [K in keyof Messages]?: Messages[K];
277
284
  };
278
285
  export declare function changeTexts(texts: PartialMessages): void;
package/types/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import { OptionProp, OptionId, StrictOptionId, GroupValue, SelectedValue, FetchC
4
4
  import MainInput from './MainInput';
5
5
  import ExtendedList from './ExtendedList';
6
6
  export { GroupValue, OptionValue, OptionItem, OptionProp, OptionId, StrictOptionId, SelectedValue, PartialMessages, GetCallback, FetchCallback, FormatCallback, SelectionOverflow, ListPosition, HideFilter, };
7
- declare type EventType = 'input' | 'change' | 'open' | 'close' | 'focus' | 'blur' | 'item:click';
7
+ type EventType = 'input' | 'change' | 'open' | 'close' | 'focus' | 'blur' | 'item:click';
8
8
  export interface EventOptions {
9
9
  instance: Selectic;
10
10
  eventType: EventType;
@@ -65,13 +65,20 @@ export interface ParamProps {
65
65
  * Example: "sort-ODE"
66
66
  */
67
67
  optionBehavior?: string;
68
- /** Keep this component open if another Selectic component opens */
69
- keepOpenWithOtherSelectic?: boolean;
68
+ /** Keep this component open if another Selectic component opens.
69
+ *
70
+ * - `true` → Keep open for **any** Selectic component.
71
+ * - `string` → Keep open only when the other Selectic matches the given CSS selector.
72
+ * - `false` (default) → Always close when another Selectic opens.
73
+ *
74
+ * An empty string is treated the same as `false`.
75
+ */
76
+ keepOpenWithOtherSelectic?: boolean | string;
70
77
  /** Avoid click on group name to select all items in this group. */
71
78
  disableGroupSelection?: boolean;
72
79
  }
73
- export declare type OnCallback = (event: string, ...args: any[]) => void;
74
- export declare type GetMethodsCallback = (methods: {
80
+ export type OnCallback = (event: string, ...args: any[]) => void;
81
+ export type GetMethodsCallback = (methods: {
75
82
  clearCache: Selectic['clearCache'];
76
83
  changeTexts: Selectic['changeTexts'];
77
84
  changeIcons: Selectic['changeIcons'];