@nethserver/ns8-ui-lib 0.0.99 → 0.1.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nethserver/ns8-ui-lib",
3
- "version": "0.0.99",
3
+ "version": "0.1.2",
4
4
  "description": "Vue.js library for NethServer 8 UI",
5
5
  "keywords": [
6
6
  "nethserver",
@@ -0,0 +1,113 @@
1
+ <template>
2
+ <div
3
+ class="ns-checkbox cv-checkbox"
4
+ :class="[
5
+ `${carbonPrefix}--checkbox-wrapper`,
6
+ { [`${carbonPrefix}--form-item`]: formItem },
7
+ ]"
8
+ >
9
+ <input
10
+ ref="input"
11
+ v-bind="$attrs"
12
+ v-on="inputListeners"
13
+ :class="`${carbonPrefix}--checkbox`"
14
+ type="checkbox"
15
+ :checked="isChecked === true"
16
+ :aria-checked="`${isChecked}`"
17
+ @focus="onFocus"
18
+ @blur="onBlur"
19
+ :value="value"
20
+ :id="uid"
21
+ />
22
+ <label
23
+ :class="[
24
+ `${carbonPrefix}--checkbox-label`,
25
+ {
26
+ [`${carbonPrefix}--label--disabled`]:
27
+ $attrs.disabled !== undefined && this.$attrs.disabled,
28
+ [`${carbonPrefix}--checkbox-label__focus`]: hasFocus,
29
+ },
30
+ ]"
31
+ :data-contained-checkbox-state="isChecked"
32
+ :data-contained-checkbox-disabled="$attrs.disabled"
33
+ :for="uid"
34
+ >
35
+ <!-- <span ////
36
+ :class="[
37
+ `${carbonPrefix}--checkbox-label-text`,
38
+ { [`${carbonPrefix}--visually-hidden`]: hideLabel },
39
+ ]"
40
+ >
41
+ {{ label }}
42
+ </span> -->
43
+ <div
44
+ :class="[
45
+ `${carbonPrefix}--checkbox-label-text`,
46
+ { [`${carbonPrefix}--visually-hidden`]: hideLabel },
47
+ ]"
48
+ >
49
+ <div class="label-with-tooltip">
50
+ <span>
51
+ {{ label }}
52
+ </span>
53
+ <!-- tooltip -->
54
+ <cv-interactive-tooltip
55
+ v-if="hasTooltipSlot"
56
+ :alignment="tooltipAlignment"
57
+ :direction="tooltipDirection"
58
+ class="info"
59
+ >
60
+ <template slot="content">
61
+ <slot name="tooltip"></slot>
62
+ </template>
63
+ </cv-interactive-tooltip>
64
+ </div>
65
+ </div>
66
+ </label>
67
+ </div>
68
+ </template>
69
+
70
+ <script>
71
+ import { CvCheckbox } from "@carbon/vue";
72
+
73
+ export default {
74
+ name: "NsCheckbox",
75
+ extends: CvCheckbox,
76
+ inheritAttrs: false,
77
+ props: {
78
+ hideLabel: Boolean,
79
+ label: String,
80
+ mixed: Boolean,
81
+ formItem: { type: Boolean, default: true },
82
+ tooltipAlignment: {
83
+ type: String,
84
+ default: "start",
85
+ validator: (val) => ["start", "center", "end"].includes(val),
86
+ },
87
+ tooltipDirection: {
88
+ type: String,
89
+ default: "bottom",
90
+ validator: (val) => ["top", "left", "bottom", "right".includes(val)],
91
+ },
92
+ },
93
+ computed: {
94
+ hasTooltipSlot() {
95
+ return !!this.$slots.tooltip;
96
+ },
97
+ },
98
+ };
99
+ </script>
100
+
101
+ <style scoped lang="scss">
102
+ .label-with-tooltip {
103
+ display: flex;
104
+ }
105
+ </style>
106
+
107
+ <style lang="scss">
108
+ // global styles
109
+
110
+ .ns-checkbox .bx--tooltip__label .bx--tooltip__trigger {
111
+ margin-left: 0.25rem;
112
+ }
113
+ </style>
@@ -1,7 +1,11 @@
1
1
  <template>
2
2
  <div
3
- class="ns-combo-box cv-combo-box"
4
- :class="`${carbonPrefix}--list-box__wrapper`"
3
+ :class="[
4
+ 'ns-combo-box',
5
+ 'cv-combo-box',
6
+ `${carbonPrefix}--list-box__wrapper`,
7
+ { 'margin-bottom-on-open': marginBottomOnOpenEnabled },
8
+ ]"
5
9
  @focusout="onFocusOut"
6
10
  >
7
11
  <label
@@ -11,8 +15,24 @@
11
15
  `${carbonPrefix}--label`,
12
16
  { [`${carbonPrefix}--label--disabled`]: disabled },
13
17
  ]"
14
- >{{ title }}</label
15
18
  >
19
+ <div class="label-with-tooltip">
20
+ <span>
21
+ {{ title }}
22
+ </span>
23
+ <!-- tooltip -->
24
+ <cv-interactive-tooltip
25
+ v-if="hasTooltipSlot"
26
+ :alignment="tooltipAlignment"
27
+ :direction="tooltipDirection"
28
+ class="info"
29
+ >
30
+ <template slot="content">
31
+ <slot name="tooltip"></slot>
32
+ </template>
33
+ </cv-interactive-tooltip>
34
+ </div>
35
+ </label>
16
36
 
17
37
  <div
18
38
  role="listbox"
@@ -206,6 +226,17 @@ export default {
206
226
  maxDisplayOptions: { type: Number, default: 100 },
207
227
  acceptUserInput: { type: Boolean, default: false },
208
228
  showItemType: { type: Boolean, default: false },
229
+ marginBottomOnOpen: { type: Boolean, default: false },
230
+ tooltipAlignment: {
231
+ type: String,
232
+ default: "start",
233
+ validator: (val) => ["start", "center", "end"].includes(val),
234
+ },
235
+ tooltipDirection: {
236
+ type: String,
237
+ default: "bottom",
238
+ validator: (val) => ["top", "left", "bottom", "right".includes(val)],
239
+ },
209
240
  },
210
241
  data() {
211
242
  return {
@@ -218,6 +249,7 @@ export default {
218
249
  isInvalid: false,
219
250
  // includes user input items
220
251
  internalOptions: [],
252
+ marginBottomOnOpenEnabled: false,
221
253
  };
222
254
  },
223
255
  model: {
@@ -237,6 +269,19 @@ export default {
237
269
  this.internalOptions = _cloneDeep(this.options);
238
270
  this.updateOptions();
239
271
  },
272
+ open() {
273
+ if (this.marginBottomOnOpen) {
274
+ if (this.open) {
275
+ setTimeout(() => {
276
+ this.marginBottomOnOpenEnabled = true;
277
+ }, 300);
278
+ } else {
279
+ setTimeout(() => {
280
+ this.marginBottomOnOpenEnabled = false;
281
+ }, 300);
282
+ }
283
+ }
284
+ },
240
285
  },
241
286
  created() {
242
287
  this.internalOptions = _cloneDeep(this.options);
@@ -286,6 +331,9 @@ export default {
286
331
  limitedDataOptions() {
287
332
  return this.dataOptions.slice(0, this.maxDisplayOptions);
288
333
  },
334
+ hasTooltipSlot() {
335
+ return !!this.$slots.tooltip;
336
+ },
289
337
  },
290
338
  methods: {
291
339
  checkSlots() {
@@ -510,3 +558,22 @@ export default {
510
558
  },
511
559
  };
512
560
  </script>
561
+
562
+ <style scoped lang="scss">
563
+ .margin-bottom-on-open {
564
+ margin-bottom: 14rem;
565
+ }
566
+
567
+ .label-with-tooltip {
568
+ display: flex;
569
+ align-items: baseline;
570
+ }
571
+ </style>
572
+
573
+ <style lang="scss">
574
+ // global styles
575
+
576
+ .ns-combo-box .bx--tooltip__label .bx--tooltip__trigger {
577
+ margin-left: 0.25rem;
578
+ }
579
+ </style>
@@ -380,6 +380,7 @@ export default {
380
380
  backwardText: { type: String, default: undefined },
381
381
  forwardText: { type: String, default: undefined },
382
382
  pageNumberLabel: { type: String, default: undefined },
383
+ filterRowsCallback: { type: Function }
383
384
  },
384
385
  data() {
385
386
  return {
@@ -455,9 +456,17 @@ export default {
455
456
  }
456
457
  },
457
458
  filterRows() {
459
+ if (this.filterRowsCallback) {
460
+ // call custom filterRows function
461
+ this.filteredRows = this.filterRowsCallback(this.searchFilter);
462
+ } else {
463
+ this.filteredRows = this.defaultFilterRows();
464
+ }
465
+ },
466
+ defaultFilterRows() {
458
467
  if (!this.searchFilter) {
459
- this.filteredRows = this.allRows;
460
- } else if (this.searchFilter) {
468
+ return this.allRows;
469
+ } else {
461
470
  // clean query
462
471
  const cleanRegex = /[^a-zA-Z0-9]/g;
463
472
  const queryText = this.searchFilter.replace(cleanRegex, "");
@@ -486,7 +495,7 @@ export default {
486
495
  }
487
496
  });
488
497
  }, this);
489
- this.filteredRows = searchResults;
498
+ return searchResults;
490
499
  }
491
500
  },
492
501
  paginateTable(ev) {
@@ -8,6 +8,7 @@
8
8
  [`${carbonPrefix}--multi-select__wrapper--inline--invalid ${carbonPrefix}--list-box__wrapper--inline--invalid`]:
9
9
  inline && isInvalid,
10
10
  [`${carbonPrefix}--multi-select--filterable`]: filterable,
11
+ 'margin-bottom-on-open': marginBottomOnOpenEnabled,
11
12
  },
12
13
  ]"
13
14
  @focusout="onFocusOut"
@@ -19,8 +20,24 @@
19
20
  `${carbonPrefix}--label`,
20
21
  { [`${carbonPrefix}--label--disabled`]: disabled },
21
22
  ]"
22
- >{{ title }}</label
23
23
  >
24
+ <div class="label-with-tooltip">
25
+ <span>
26
+ {{ title }}
27
+ </span>
28
+ <!-- tooltip -->
29
+ <cv-interactive-tooltip
30
+ v-if="hasTooltipSlot"
31
+ :alignment="tooltipAlignment"
32
+ :direction="tooltipDirection"
33
+ class="info"
34
+ >
35
+ <template slot="content">
36
+ <slot name="tooltip"></slot>
37
+ </template>
38
+ </cv-interactive-tooltip>
39
+ </div>
40
+ </label>
24
41
 
25
42
  <div
26
43
  role="listbox"
@@ -102,6 +119,7 @@
102
119
  @input="onInput"
103
120
  @focus="inputFocus"
104
121
  @click.stop.prevent="inputClick"
122
+ :disabled="disabled"
105
123
  />
106
124
  <div
107
125
  v-if="filter.length > 0"
@@ -194,6 +212,7 @@
194
212
  :key="item.value"
195
213
  :label="item.label"
196
214
  :kind="selectedItemsColor"
215
+ :disabled="disabled"
197
216
  class="selected-item"
198
217
  />
199
218
  </div>
@@ -291,6 +310,17 @@ export default {
291
310
  showItemType: { type: Boolean, default: false },
292
311
  // use cv-tag color
293
312
  selectedItemsColor: { type: String, default: "high-contrast" },
313
+ marginBottomOnOpen: { type: Boolean, default: false },
314
+ tooltipAlignment: {
315
+ type: String,
316
+ default: "start",
317
+ validator: (val) => ["start", "center", "end"].includes(val),
318
+ },
319
+ tooltipDirection: {
320
+ type: String,
321
+ default: "bottom",
322
+ validator: (val) => ["top", "left", "bottom", "right".includes(val)],
323
+ },
294
324
  },
295
325
  data() {
296
326
  return {
@@ -303,6 +333,7 @@ export default {
303
333
  dataFilter: "",
304
334
  isHelper: false,
305
335
  isInvalid: false,
336
+ marginBottomOnOpenEnabled: false,
306
337
  };
307
338
  },
308
339
  model: {
@@ -329,6 +360,19 @@ export default {
329
360
  selectionFeedback() {
330
361
  this.updateOptions();
331
362
  },
363
+ open() {
364
+ if (this.marginBottomOnOpen) {
365
+ if (this.open) {
366
+ setTimeout(() => {
367
+ this.marginBottomOnOpenEnabled = true;
368
+ }, 300);
369
+ } else {
370
+ setTimeout(() => {
371
+ this.marginBottomOnOpenEnabled = false;
372
+ }, 300);
373
+ }
374
+ }
375
+ },
332
376
  },
333
377
  created() {
334
378
  this.internalOptions = _cloneDeep(this.options);
@@ -389,6 +433,9 @@ export default {
389
433
  this.internalOptions.find((opt) => opt.value === val)
390
434
  );
391
435
  },
436
+ hasTooltipSlot() {
437
+ return !!this.$slots.tooltip;
438
+ },
392
439
  },
393
440
  methods: {
394
441
  checkSlots() {
@@ -650,6 +697,15 @@ export default {
650
697
  margin-left: 0;
651
698
  margin-bottom: 0.25rem;
652
699
  }
700
+
701
+ .margin-bottom-on-open {
702
+ margin-bottom: 14rem;
703
+ }
704
+
705
+ .label-with-tooltip {
706
+ display: flex;
707
+ align-items: baseline;
708
+ }
653
709
  </style>
654
710
 
655
711
  <style lang="scss">
@@ -659,4 +715,8 @@ export default {
659
715
  position: relative;
660
716
  right: 1px;
661
717
  }
718
+
719
+ .ns-multi-select .bx--tooltip__label .bx--tooltip__trigger {
720
+ margin-left: 0.25rem;
721
+ }
662
722
  </style>
@@ -7,6 +7,7 @@
7
7
  `cv-tag ${carbonPrefix}--tag`,
8
8
  `${carbonPrefix}--tag--${tagKind}`,
9
9
  {
10
+ [`${carbonPrefix}--tag--disabled`]: disabled,
10
11
  [`${carbonPrefix}--tag--filter`]: isFilter,
11
12
  [`${carbonPrefix}--tag--${size}`]: size,
12
13
  },