@kiva/kv-components 0.21.0 → 0.21.4

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/CHANGELOG.md CHANGED
@@ -3,6 +3,51 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.21.4](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@0.21.3...@kiva/kv-components@0.21.4) (2021-09-30)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **KvCheckbox, KvRadio, KvSwitch:** Avoid SSR problems when setting the UUID ([ff55726](https://github.com/kiva/kv-ui-elements/commit/ff55726e7052908c58dc71ea6d14d6bffb922da7))
12
+
13
+
14
+
15
+
16
+
17
+ ## [0.21.3](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@0.21.2...@kiva/kv-components@0.21.3) (2021-09-30)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **KvCheckbox:** Background color now reliably changes when checkbox is clicked ([fc509b2](https://github.com/kiva/kv-ui-elements/commit/fc509b20fbed89e39df729090aa97beedd684636))
23
+
24
+
25
+
26
+
27
+
28
+ ## [0.21.2](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@0.21.1...@kiva/kv-components@0.21.2) (2021-09-30)
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * **KvCheckbox:** Allow checkboxes to use an array in v-model ([39b2e92](https://github.com/kiva/kv-ui-elements/commit/39b2e92a3c71ebb94e6da0f7133ae67d40758035))
34
+
35
+
36
+
37
+
38
+
39
+ ## [0.21.1](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@0.21.0...@kiva/kv-components@0.21.1) (2021-09-28)
40
+
41
+
42
+ ### Bug Fixes
43
+
44
+ * **KvButton:** prevent underline on focus when button is an anchor tag ([10199ba](https://github.com/kiva/kv-ui-elements/commit/10199badc4bec6ae0badc420df5b0c2d7fed59e3))
45
+ * Use themable class names. Change to low-opacity instead of text-color for disabled state. ([6aa9f0d](https://github.com/kiva/kv-ui-elements/commit/6aa9f0dc9d0952e172848fdbd834fecb94cd0bc2))
46
+
47
+
48
+
49
+
50
+
6
51
  # [0.21.0](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@0.20.5...@kiva/kv-components@0.21.0) (2021-09-23)
7
52
 
8
53
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kiva/kv-components",
3
- "version": "0.21.0",
3
+ "version": "0.21.4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -53,5 +53,5 @@
53
53
  "vue": "^2.6.12",
54
54
  "vue-focus-lock": "^1.4.1"
55
55
  },
56
- "gitHead": "2584a3a30fc82ecaaf33453c5fd32283e09f3e7a"
56
+ "gitHead": "edea8bf2d45ca9a2e7a27377ab53c2555d76f6be"
57
57
  }
@@ -28,7 +28,7 @@ export const decorators = [(story) => ({
28
28
  template: '<kv-theme-provider :theme="theme"><story /></kv-theme-provider>',
29
29
  data() {
30
30
  return {
31
- theme: ''
31
+ theme: {}
32
32
  }
33
33
  },
34
34
  methods: {
package/vue/KvButton.vue CHANGED
@@ -6,7 +6,7 @@
6
6
  :href="href"
7
7
  :type="computedType"
8
8
  :disabled="isDisabled"
9
- class="hover:tw-no-underline tw-inline-block"
9
+ class="hover:tw-no-underline focus:tw-no-underline tw-inline-block"
10
10
  :class="{
11
11
  'tw-opacity-low': state === 'disabled',
12
12
  'tw-pointer-events-none': state === 'loading' || isDisabled
@@ -33,11 +33,12 @@
33
33
  tw-mt-4 tw-w-full"
34
34
  >
35
35
  <button
36
- class="tw-text-gray-800 disabled:tw-text-gray-300
36
+ class="tw-text-primary
37
37
  tw-rounded-full
38
- tw-border-2 tw-border-text-gray-800
38
+ tw-border-2 tw-border-primary
39
39
  tw-h-4 tw-w-4
40
- tw-flex tw-items-center tw-justify-center"
40
+ tw-flex tw-items-center tw-justify-center
41
+ disabled:tw-opacity-low disabled:tw-cursor-default"
41
42
  :disabled="embla && !embla.canScrollPrev()"
42
43
  @click="handleUserInteraction(previousIndex, 'click-left-arrow')"
43
44
  >
@@ -51,11 +52,12 @@
51
52
  {{ currentIndex + 1 }}/{{ slideIndicatorListLength() }}
52
53
  </div>
53
54
  <button
54
- class="tw-text-gray-800 disabled:tw-text-gray-300
55
+ class="tw-text-primary
55
56
  tw-rounded-full
56
- tw-border-2 tw-border-text-gray-800
57
+ tw-border-2 tw-border-primary
57
58
  tw-h-4 tw-w-4
58
- tw-flex tw-items-center tw-justify-center"
59
+ tw-flex tw-items-center tw-justify-center
60
+ disabled:tw-opacity-low disabled:tw-cursor-default"
59
61
  :disabled="embla && !embla.canScrollNext()"
60
62
  @click="handleUserInteraction(nextIndex, 'click-right-arrow')"
61
63
  >
@@ -11,7 +11,7 @@
11
11
  ref="checkboxRef"
12
12
  class="tw-peer tw-appearance-none tw-w-max"
13
13
  type="checkbox"
14
- :checked="checked"
14
+ :checked="isChecked"
15
15
  :value="value"
16
16
  :disabled="disabled"
17
17
  v-on="inputListeners"
@@ -26,14 +26,15 @@
26
26
  tw-border
27
27
  tw-flex tw-justify-center tw-items-center tw-overflow-hidden
28
28
  tw-transition-all tw-duration-100
29
- peer-focus-visible:tw-ring-2 peer-focus-visible:tw-ring-action
30
- tw-bg-white tw-border-secondary
31
- peer-checked:tw-bg-action peer-checked:tw-border-action
32
- "
29
+ peer-focus-visible:tw-ring-2 peer-focus-visible:tw-ring-action"
30
+ :class="{
31
+ 'tw-bg-white tw-border-secondary' : !isChecked,
32
+ 'tw-bg-action tw-border-action' : isChecked,
33
+ }"
33
34
  >
34
35
  <!-- checkbox icon -->
35
36
  <svg
36
- v-if="checked"
37
+ v-if="isChecked"
37
38
  class="tw-w-1.5 tw-h-auto"
38
39
  viewBox="0 0 12 9"
39
40
  fill="none"
@@ -75,7 +76,7 @@ export default {
75
76
  * Whether the checkbox is checked or not
76
77
  * */
77
78
  checked: {
78
- type: Boolean,
79
+ type: [Boolean, Array],
79
80
  default: false,
80
81
  },
81
82
  /**
@@ -85,10 +86,18 @@ export default {
85
86
  type: Boolean,
86
87
  default: false,
87
88
  },
89
+ /**
90
+ * Value of the checkbox if v-model is an array
91
+ * */
92
+ value: {
93
+ type: String,
94
+ default: '',
95
+ },
88
96
  },
89
97
  data() {
90
98
  return {
91
99
  uuid: `kvc-${nanoid(10)}`,
100
+ isChecked: false,
92
101
  };
93
102
  },
94
103
  computed: {
@@ -102,9 +111,49 @@ export default {
102
111
  };
103
112
  },
104
113
  },
114
+ watch: {
115
+ checked() {
116
+ this.setChecked();
117
+ },
118
+ },
119
+ mounted() {
120
+ this.uuid = `kvc-${nanoid(10)}`;
121
+ },
122
+ created() {
123
+ this.setChecked();
124
+ },
105
125
  methods: {
106
126
  onChange(event) {
107
- this.$emit('change', event.target.checked);
127
+ // get the input[type=checkbox] state
128
+ const isChecked = event.target.checked;
129
+
130
+ let checkboxValue;
131
+
132
+ if (Array.isArray(this.checked)) {
133
+ // if the model is an array, add or remove our value from it
134
+ if (isChecked) {
135
+ checkboxValue = [...this.checked, event.target.value];
136
+ } else {
137
+ checkboxValue = this.checked.filter((item) => item !== this.value);
138
+ }
139
+ } else {
140
+ checkboxValue = isChecked;
141
+ }
142
+
143
+ // emit the change event to update the model
144
+ this.$emit('change', checkboxValue);
145
+ },
146
+ /**
147
+ * Updates the visual state of the checkbox
148
+ * */
149
+ setChecked() {
150
+ if (Array.isArray(this.checked)) {
151
+ // if the model is array like <kv-checkbox v-model="['item1', 'item2']" value="item1">
152
+ this.isChecked = this.checked.includes(this.value);
153
+ } else {
154
+ // else it's a boolean like <kv-checkbox v-model="true">
155
+ this.isChecked = this.checked;
156
+ }
108
157
  },
109
158
  focus() {
110
159
  this.$refs.checkboxRef.focus();
package/vue/KvRadio.vue CHANGED
@@ -146,6 +146,9 @@ export default {
146
146
  };
147
147
  },
148
148
  },
149
+ mounted() {
150
+ this.uuid = `kvr-${nanoid(10)}`;
151
+ },
149
152
  methods: {
150
153
  onChange(event) {
151
154
  /**
package/vue/KvSwitch.vue CHANGED
@@ -104,6 +104,9 @@ export default {
104
104
  };
105
105
  },
106
106
  },
107
+ mounted() {
108
+ this.uuid = `kvs-${nanoid(10)}`;
109
+ },
107
110
  methods: {
108
111
  onChange(event) {
109
112
  this.$emit('change', event.target.checked);
@@ -111,3 +111,46 @@ export const Multiple = (args, {
111
111
  </kv-checkbox>
112
112
  </div>`,
113
113
  });
114
+
115
+ const ArrayModelTemplate = (args, {
116
+ argTypes,
117
+ }) => ({
118
+ props: Object.keys(argTypes),
119
+ components: {
120
+ KvCheckbox,
121
+ },
122
+ data: () => ({
123
+ checkboxExampleModel: ['item1', 'item2'],
124
+ }),
125
+ template: `
126
+ <div class="tw-flex tw-flex-col tw-gap-2">
127
+ <kv-checkbox
128
+ value="item1"
129
+ v-model="checkboxExampleModel"
130
+ @change="onChange"
131
+ >
132
+ item1
133
+ </kv-checkbox>
134
+ <kv-checkbox
135
+ value="item2"
136
+ v-model="checkboxExampleModel"
137
+ @change="onChange"
138
+ >
139
+ item2
140
+ </kv-checkbox>
141
+ <kv-checkbox
142
+ value="item3"
143
+ v-model="checkboxExampleModel"
144
+ @change="onChange"
145
+ >
146
+ item3
147
+ </kv-checkbox>
148
+ <div>Checked items: <span v-for="item in checkboxExampleModel" :key="item">{{item}} </span></div>
149
+ </div>`,
150
+ methods: {
151
+ onChange(e) {
152
+ console.log(e);
153
+ },
154
+ },
155
+ });
156
+ export const ArrayModel = ArrayModelTemplate.bind({});