vueless 0.0.198 → 0.0.200

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.
@@ -399,7 +399,13 @@ function getNestedComponent(value) {
399
399
  @returns { Boolean }
400
400
  */
401
401
  function isSystemKey(key) {
402
- return Object.values(SYSTEM_CONFIG_KEY).some((value) => value.includes(key));
402
+ const isExactKey = Object.values(SYSTEM_CONFIG_KEY).some((value) => value === key);
403
+
404
+ return (
405
+ isExactKey ||
406
+ key.includes(SYSTEM_CONFIG_KEY.iconName) ||
407
+ key.includes(SYSTEM_CONFIG_KEY.iconNameCapitalize)
408
+ );
403
409
  }
404
410
 
405
411
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.198",
3
+ "version": "0.0.200",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless Component Framework.",
6
6
  "homepage": "https://vueless.com",
@@ -226,7 +226,6 @@ export const {
226
226
  setFavicon,
227
227
  setBrandColor,
228
228
  convertHexInRgb,
229
- isSystemKey,
230
229
  isMac,
231
230
  isPWA,
232
231
  isIOS,
@@ -33,7 +33,7 @@ export default /*tw*/ {
33
33
  ],
34
34
  },
35
35
  innerWrapper: {
36
- base: "flex px-4 min-h-full w-full overflow-hidden",
36
+ base: "flex px-4 min-h-full w-full overflow-hidden justify-between",
37
37
  variants: {
38
38
  multiple: {
39
39
  true: "grid grid-cols-1 grid-rows-[minmax(0, 1fr)_min-content]",
@@ -43,7 +43,8 @@ export default /*tw*/ {
43
43
  wrapperActive: "z-[inherit]", // applies when select active
44
44
  labelWrapperTop: "group/top", // applies when an open direction is top
45
45
  labelWrapperActive: "group/active",
46
- leftSlot: "pr-4 flex items-center",
46
+ leftIconSlot: "pr-3 flex items-center",
47
+ rightIconSlot: "pl-3 flex items-center",
47
48
  caret: {
48
49
  base: "flex items-center mt-0",
49
50
  compoundVariants: [
@@ -1,8 +1,9 @@
1
- import { getArgTypes, getSlotNames } from "../service.storybook";
1
+ import { getArgTypes, getSlotNames, allSlotsFragment } from "../service.storybook";
2
2
 
3
3
  import USelect from "../ui.form-select";
4
4
  import URow from "../ui.container-row";
5
5
  import UBadge from "../ui.text-badge";
6
+ import UIcon from "../ui.image-icon";
6
7
 
7
8
  /**
8
9
  * The `USelect` component. | [View on GitHub](https://github.com/vuelessjs/vueless/tree/main/src/ui.form-select)
@@ -43,9 +44,7 @@ const DefaultTemplate = (args) => ({
43
44
  },
44
45
  template: `
45
46
  <USelect v-bind="args" v-model="args.modelValue">
46
- <template v-for="(slot, index) of slots" :key="index" v-slot:[slot]>
47
- <template v-if="args[slot]">{{ args[slot] }}</template>
48
- </template>
47
+ ${allSlotsFragment}
49
48
  </USelect>
50
49
  `,
51
50
  });
@@ -170,7 +169,7 @@ const SizesTemplate = (args, { argTypes } = {}) => ({
170
169
  });
171
170
 
172
171
  const SlotTemplate = (args) => ({
173
- components: { USelect },
172
+ components: { USelect, UIcon },
174
173
  setup() {
175
174
  return { args };
176
175
  },
@@ -323,6 +322,43 @@ slotBeforeCaret.args = {
323
322
  `,
324
323
  };
325
324
 
325
+ export const slotBeforeOption = SlotTemplate.bind({});
326
+ slotBeforeOption.args = {
327
+ slotTemplate: `
328
+ <template #before-option>
329
+ 🤘
330
+ </template>
331
+ `,
332
+ };
333
+
334
+ export const iconLeft = DefaultTemplate.bind({});
335
+ iconLeft.args = {
336
+ iconLeft: "star",
337
+ };
338
+
339
+ export const iconRight = DefaultTemplate.bind({});
340
+ iconRight.args = {
341
+ iconRight: "star",
342
+ };
343
+
344
+ export const iconLeftSlot = SlotTemplate.bind({});
345
+ iconLeftSlot.args = {
346
+ slotTemplate: `
347
+ <template #icon-left>
348
+ <UIcon name="star" color="green" />
349
+ </template>
350
+ `,
351
+ };
352
+
353
+ export const iconRightSlot = SlotTemplate.bind({});
354
+ iconRightSlot.args = {
355
+ slotTemplate: `
356
+ <template #icon-right>
357
+ <UIcon name="star" color="green" />
358
+ </template>
359
+ `,
360
+ };
361
+
326
362
  export const slotLeft = SlotTemplate.bind({});
327
363
  slotLeft.args = {
328
364
  slotTemplate: `
@@ -332,10 +368,10 @@ slotLeft.args = {
332
368
  `,
333
369
  };
334
370
 
335
- export const slotBeforeOption = SlotTemplate.bind({});
336
- slotBeforeOption.args = {
371
+ export const slotRight = SlotTemplate.bind({});
372
+ slotRight.args = {
337
373
  slotTemplate: `
338
- <template #before-option>
374
+ <template #right>
339
375
  🤘
340
376
  </template>
341
377
  `,
@@ -28,7 +28,10 @@
28
28
  v-if="hasSlotContent($slots['after-caret']) && !(multiple && localValue.length)"
29
29
  v-bind="afterCaretSlotAttrs"
30
30
  >
31
- <!-- @slot Use it to add something after caret. -->
31
+ <!--
32
+ @slot Use it to add something after caret.
33
+ @binding {object} scope-props
34
+ -->
32
35
  <slot :scope-props="props" name="after-caret" />
33
36
  </div>
34
37
 
@@ -51,7 +54,10 @@
51
54
  v-if="hasSlotContent($slots['before-caret']) && !(multiple && localValue.length)"
52
55
  v-bind="beforeCaretSlotAttrs"
53
56
  >
54
- <!-- @slot Use it to add something after caret. -->
57
+ <!--
58
+ @slot Use it to add something before caret.
59
+ @binding {object} scope-props
60
+ -->
55
61
  <slot :scope-props="props" name="before-caret" />
56
62
  </div>
57
63
 
@@ -68,9 +74,32 @@
68
74
  </div>
69
75
 
70
76
  <div ref="innerWrapperRef" v-bind="innerWrapperAttrs">
77
+ <span
78
+ v-if="hasSlotContent($slots['icon-left']) || iconLeft"
79
+ ref="leftSlotWrapperRef"
80
+ v-bind="leftIconSlotAttrs"
81
+ >
82
+ <!--
83
+ @slot Use it to add icon before option.
84
+ @binding {string} icon-name
85
+ @binding {string} icon-size
86
+ -->
87
+ <slot name="icon-left" :icon-name="iconLeft" :icon-size="iconSize">
88
+ <UIcon v-if="iconLeft" :name="iconLeft" :size="iconSize" />
89
+ </slot>
90
+ </span>
91
+
92
+ <span v-if="hasSlotContent($slots['left'])" ref="leftSlotWrapperRef">
93
+ <!-- @slot Use it to add something before input. -->
94
+ <slot name="left" />
95
+ </span>
96
+
71
97
  <div v-if="multiple && localValue.length" v-bind="selectedLabelsAttrs">
72
98
  <span v-for="item in localValue" :key="item[valueKey]" v-bind="selectedLabelAttrs">
73
- <!-- @slot Use it to add selected value label. -->
99
+ <!--
100
+ @slot Use it to add selected value label.
101
+ @binding {string} selected-label
102
+ -->
74
103
  <slot
75
104
  name="selected-label"
76
105
  :selected-label="getOptionLabel(item)"
@@ -80,7 +109,10 @@
80
109
  {{ getOptionLabel(item) }}
81
110
  </slot>
82
111
 
83
- <!-- @slot Use it to add selected value label. -->
112
+ <!--
113
+ @slot Use it to add something after selected value label.
114
+ @binding {object} scope-props
115
+ -->
84
116
  <slot :scope-props="props" name="selected-label-after" />
85
117
 
86
118
  <div
@@ -103,15 +135,6 @@
103
135
  </div>
104
136
 
105
137
  <div v-bind="searchAttrs">
106
- <span
107
- v-if="hasSlotContent($slots['left'])"
108
- ref="leftSlotWrapperRef"
109
- v-bind="leftSlotAttrs"
110
- >
111
- <!-- @slot Use it to add some component before text. -->
112
- <slot name="left" />
113
- </span>
114
-
115
138
  <input
116
139
  v-show="searchable || !localValue || multiple || !isOpen"
117
140
  :id="id"
@@ -139,12 +162,19 @@
139
162
  v-bind="selectedLabelAttrs"
140
163
  @mousedown.prevent="toggle"
141
164
  >
142
- <!-- @slot Use it to add selected value label. -->
165
+ <!--
166
+ @slot Use it to add selected value label.
167
+ @binding {string} selected-label
168
+ @binding {string} value
169
+ -->
143
170
  <slot name="selected-label" :selected-label="selectedLabel" :value="localValue[valueKey]">
144
171
  {{ selectedLabel }}
145
172
  </slot>
146
173
 
147
- <!-- @slot Use it to add selected value label. -->
174
+ <!--
175
+ @slot Use it to add something after selected value label.
176
+ @binding {object} scope-props
177
+ -->
148
178
  <slot :scope-props="props" name="selected-label-after" />
149
179
  </span>
150
180
 
@@ -155,6 +185,20 @@
155
185
  @click.prevent.capture
156
186
  v-text="currentLocale.clear"
157
187
  />
188
+
189
+ <!-- @slot Use it to add something after input. -->
190
+ <slot name="right" />
191
+
192
+ <span v-if="hasSlotContent($slots['icon-right']) || iconRight" v-bind="rightIconSlotAttrs">
193
+ <!--
194
+ @slot Use it to add icon after option.
195
+ @binding {string} icon-name
196
+ @binding {string} icon-size
197
+ -->
198
+ <slot name="icon-right" :icon-name="iconRight" :icon-size="iconSize">
199
+ <UIcon v-if="iconRight" :name="iconRight" :size="iconSize" />
200
+ </slot>
201
+ </span>
158
202
  </div>
159
203
 
160
204
  <UDropdownList
@@ -176,16 +220,27 @@
176
220
  @click.prevent.capture
177
221
  >
178
222
  <template #before-option="{ option }">
179
- <!-- @slot Use it to add something before option. -->
223
+ <!--
224
+ @slot Use it to add something before option.
225
+ @binding {other} option
226
+ -->
180
227
  <slot :option="option" name="before-option" />
181
228
  </template>
182
229
 
183
230
  <template #option="{ option, index }">
231
+ <!--
232
+ @slot Use it to add something instead of option.
233
+ @binding {other} option
234
+ @binding {number} index
235
+ -->
184
236
  <slot name="option" :option="option" :index="index" />
185
237
  </template>
186
238
 
187
239
  <template #after-option="{ option }">
188
- <!-- @slot Use it to add something after option. -->
240
+ <!--
241
+ @slot Use it to add something after option.
242
+ @binding {other} option
243
+ -->
189
244
  <slot :option="option" name="after-option" />
190
245
  </template>
191
246
 
@@ -288,6 +343,22 @@ const props = defineProps({
288
343
  default: UIService.get(defaultConfig, USelect).default.size,
289
344
  },
290
345
 
346
+ /**
347
+ * Left side icon name.
348
+ */
349
+ iconLeft: {
350
+ type: String,
351
+ default: "",
352
+ },
353
+
354
+ /**
355
+ * Right side icon name.
356
+ */
357
+ iconRight: {
358
+ type: String,
359
+ default: "",
360
+ },
361
+
291
362
  /**
292
363
  * Select open direction.
293
364
  * @values auto, top, bottom
@@ -412,13 +483,44 @@ const props = defineProps({
412
483
  });
413
484
 
414
485
  const emit = defineEmits([
486
+ /**
487
+ * Triggers when dropdown list is opened.
488
+ * @property {string} propsId
489
+ */
415
490
  "open",
491
+
492
+ /**
493
+ * Triggers when dropdown list is closed.
494
+ * @property {string} propsId
495
+ */
416
496
  "close",
497
+
498
+ /**
499
+ * Triggers when the input value is changed.
500
+ */
417
501
  "searchChange",
502
+
503
+ /**
504
+ * Triggers when option is removed.
505
+ * @property {string} option
506
+ * @property {string} propsId
507
+ */
418
508
  "remove",
509
+
510
+ /**
511
+ * Triggers when option is selected.
512
+ * @property {number} value
513
+ */
419
514
  "update:modelValue",
420
- "select",
515
+
516
+ /**
517
+ * Triggers when dropdown options list is updated.
518
+ */
421
519
  "addOption",
520
+
521
+ /**
522
+ * Triggers when label position is changed.
523
+ */
422
524
  "change",
423
525
  ]);
424
526
 
@@ -462,7 +564,8 @@ const {
462
564
  labelAttrs,
463
565
  wrapperAttrs,
464
566
  innerWrapperAttrs,
465
- leftSlotAttrs,
567
+ leftIconSlotAttrs,
568
+ rightIconSlotAttrs,
466
569
  beforeCaretSlotAttrs,
467
570
  afterCaretSlotAttrs,
468
571
  caretToggleAttrs,
@@ -699,7 +802,13 @@ function removeElement(option, shouldClose = true) {
699
802
  }
700
803
 
701
804
  function setLabelPosition() {
702
- if (props.labelAlign === "top" || !hasSlotContent(slots["left"])) return;
805
+ if (
806
+ props.labelAlign === "top" ||
807
+ !hasSlotContent(slots["left"]) ||
808
+ (!hasSlotContent(slots["icon-left"]) && !props.iconLeft)
809
+ ) {
810
+ return;
811
+ }
703
812
 
704
813
  const leftSlotWidth = leftSlotWrapperRef.value.getBoundingClientRect().width;
705
814
  const innerWrapperPaddingLeft = parseInt(
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "vueless",
4
- "version": "0.0.198",
4
+ "version": "0.0.200",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",
@@ -6250,6 +6250,24 @@
6250
6250
  },
6251
6251
  "default": "md"
6252
6252
  },
6253
+ {
6254
+ "name": "iconLeft",
6255
+ "description": "Left side icon name.",
6256
+ "value": {
6257
+ "kind": "expression",
6258
+ "type": "string"
6259
+ },
6260
+ "default": "\"\""
6261
+ },
6262
+ {
6263
+ "name": "iconRight",
6264
+ "description": "Right side icon name.",
6265
+ "value": {
6266
+ "kind": "expression",
6267
+ "type": "string"
6268
+ },
6269
+ "default": "\"\""
6270
+ },
6253
6271
  {
6254
6272
  "name": "openDirection",
6255
6273
  "description": "Select open direction.",
@@ -6388,28 +6406,70 @@
6388
6406
  ],
6389
6407
  "events": [
6390
6408
  {
6391
- "name": "open"
6392
- },
6393
- {
6394
- "name": "close"
6409
+ "name": "open",
6410
+ "description": "Triggers when dropdown list is opened.",
6411
+ "properties": [
6412
+ {
6413
+ "type": [
6414
+ "string"
6415
+ ],
6416
+ "name": "propsId"
6417
+ }
6418
+ ]
6395
6419
  },
6396
6420
  {
6397
- "name": "searchChange"
6421
+ "name": "close",
6422
+ "description": "Triggers when dropdown list is closed.",
6423
+ "properties": [
6424
+ {
6425
+ "type": [
6426
+ "string"
6427
+ ],
6428
+ "name": "propsId"
6429
+ }
6430
+ ]
6398
6431
  },
6399
6432
  {
6400
- "name": "remove"
6433
+ "name": "searchChange",
6434
+ "description": "Triggers when the input value is changed."
6401
6435
  },
6402
6436
  {
6403
- "name": "update:modelValue"
6437
+ "name": "remove",
6438
+ "description": "Triggers when option is removed.",
6439
+ "properties": [
6440
+ {
6441
+ "type": [
6442
+ "string"
6443
+ ],
6444
+ "name": "option"
6445
+ },
6446
+ {
6447
+ "type": [
6448
+ "string"
6449
+ ],
6450
+ "name": "propsId"
6451
+ }
6452
+ ]
6404
6453
  },
6405
6454
  {
6406
- "name": "select"
6455
+ "name": "update:modelValue",
6456
+ "description": "Triggers when option is selected.",
6457
+ "properties": [
6458
+ {
6459
+ "type": [
6460
+ "number"
6461
+ ],
6462
+ "name": "value"
6463
+ }
6464
+ ]
6407
6465
  },
6408
6466
  {
6409
- "name": "addOption"
6467
+ "name": "addOption",
6468
+ "description": "Triggers when dropdown options list is updated."
6410
6469
  },
6411
6470
  {
6412
- "name": "change"
6471
+ "name": "change",
6472
+ "description": "Triggers when label position is changed."
6413
6473
  }
6414
6474
  ],
6415
6475
  "slots": [
@@ -6419,6 +6479,7 @@
6419
6479
  "description": "Use it to add something after caret.",
6420
6480
  "bindings": [
6421
6481
  {
6482
+ "type": "object",
6422
6483
  "name": "scope-props"
6423
6484
  }
6424
6485
  ]
@@ -6426,22 +6487,44 @@
6426
6487
  {
6427
6488
  "name": "before-caret",
6428
6489
  "scoped": true,
6429
- "description": "Use it to add something after caret.",
6490
+ "description": "Use it to add something before caret.",
6430
6491
  "bindings": [
6431
6492
  {
6493
+ "type": "object",
6432
6494
  "name": "scope-props"
6433
6495
  }
6434
6496
  ]
6435
6497
  },
6498
+ {
6499
+ "name": "icon-left",
6500
+ "scoped": true,
6501
+ "description": "Use it to add icon before option.",
6502
+ "bindings": [
6503
+ {
6504
+ "type": "string",
6505
+ "name": "icon-name"
6506
+ },
6507
+ {
6508
+ "type": "string",
6509
+ "name": "icon-size"
6510
+ }
6511
+ ]
6512
+ },
6513
+ {
6514
+ "name": "left",
6515
+ "description": "Use it to add something before input."
6516
+ },
6436
6517
  {
6437
6518
  "name": "selected-label",
6438
6519
  "scoped": true,
6439
6520
  "description": "Use it to add selected value label.",
6440
6521
  "bindings": [
6441
6522
  {
6523
+ "type": "string",
6442
6524
  "name": "selected-label"
6443
6525
  },
6444
6526
  {
6527
+ "type": "string",
6445
6528
  "name": "value"
6446
6529
  }
6447
6530
  ]
@@ -6449,16 +6532,32 @@
6449
6532
  {
6450
6533
  "name": "selected-label-after",
6451
6534
  "scoped": true,
6452
- "description": "Use it to add selected value label.",
6535
+ "description": "Use it to add something after selected value label.",
6453
6536
  "bindings": [
6454
6537
  {
6538
+ "type": "object",
6455
6539
  "name": "scope-props"
6456
6540
  }
6457
6541
  ]
6458
6542
  },
6459
6543
  {
6460
- "name": "left",
6461
- "description": "Use it to add some component before text."
6544
+ "name": "right",
6545
+ "description": "Use it to add something after input."
6546
+ },
6547
+ {
6548
+ "name": "icon-right",
6549
+ "scoped": true,
6550
+ "description": "Use it to add icon after option.",
6551
+ "bindings": [
6552
+ {
6553
+ "type": "string",
6554
+ "name": "icon-name"
6555
+ },
6556
+ {
6557
+ "type": "string",
6558
+ "name": "icon-size"
6559
+ }
6560
+ ]
6462
6561
  },
6463
6562
  {
6464
6563
  "name": "before-option",
@@ -6466,6 +6565,7 @@
6466
6565
  "description": "Use it to add something before option.",
6467
6566
  "bindings": [
6468
6567
  {
6568
+ "type": "other",
6469
6569
  "name": "option"
6470
6570
  }
6471
6571
  ]
@@ -6473,11 +6573,14 @@
6473
6573
  {
6474
6574
  "name": "option",
6475
6575
  "scoped": true,
6576
+ "description": "Use it to add something instead of option.",
6476
6577
  "bindings": [
6477
6578
  {
6579
+ "type": "other",
6478
6580
  "name": "option"
6479
6581
  },
6480
6582
  {
6583
+ "type": "number",
6481
6584
  "name": "index"
6482
6585
  }
6483
6586
  ]
@@ -6488,6 +6591,7 @@
6488
6591
  "description": "Use it to add something after option.",
6489
6592
  "bindings": [
6490
6593
  {
6594
+ "type": "other",
6491
6595
  "name": "option"
6492
6596
  }
6493
6597
  ]