@citizenplane/pimp 18.13.0 → 18.13.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": "@citizenplane/pimp",
3
- "version": "18.13.0",
3
+ "version": "18.13.2",
4
4
  "scripts": {
5
5
  "dev": "storybook dev -p 8081",
6
6
  "build-storybook": "storybook build --output-dir ./docs",
@@ -1,9 +1,11 @@
1
1
  <template>
2
- <label class="cpCheckbox" :class="computedClasses" :for="checkboxUniqueId">
2
+ <label class="cpCheckbox" :class="dynamicCheckboxClasses" :for="checkboxUniqueId">
3
3
  <div class="cpCheckbox__wrapper">
4
4
  <input
5
5
  :id="checkboxUniqueId"
6
6
  ref="inputRef"
7
+ class="cpCheckbox__input"
8
+ :class="dynamicInputClasses"
7
9
  :autofocus="autofocus"
8
10
  :checked="isChecked"
9
11
  :disabled="isDisabled"
@@ -16,7 +18,7 @@
16
18
  </div>
17
19
  <div class="cpCheckbox__content">
18
20
  <slot>
19
- <span v-if="checkboxLabel" class="cpCheckbox__label">
21
+ <span v-if="checkboxLabel" class="cpCheckbox__label" :class="dynamicLabelClasses">
20
22
  {{ checkboxLabel }}
21
23
  </span>
22
24
  </slot>
@@ -48,6 +50,7 @@ export interface Props {
48
50
  isDisabled?: boolean
49
51
  modelValue?: boolean | unknown[]
50
52
  reverseLabel?: boolean
53
+ size?: 'md' | 'lg'
51
54
  }
52
55
 
53
56
  const props = withDefaults(defineProps<Props>(), {
@@ -57,6 +60,7 @@ const props = withDefaults(defineProps<Props>(), {
57
60
  groupName: '',
58
61
  color: 'accent',
59
62
  helper: '',
63
+ size: 'md',
60
64
  })
61
65
 
62
66
  const emit = defineEmits<EmitType>()
@@ -96,7 +100,7 @@ const hasDefaultSlot = computed(() => !!slots.default)
96
100
 
97
101
  const isEmpty = computed(() => !hasDefaultSlot.value && !props.checkboxLabel)
98
102
 
99
- const computedClasses = computed(() => {
103
+ const dynamicCheckboxClasses = computed(() => {
100
104
  return [
101
105
  {
102
106
  'cpCheckbox--isEmpty': isEmpty.value,
@@ -105,9 +109,14 @@ const computedClasses = computed(() => {
105
109
  'cpCheckbox--isIndeterminate': props.indeterminate,
106
110
  },
107
111
  `cpCheckbox--is${capitalizedColor.value}`,
112
+ `cpCheckbox--${props.size}`,
108
113
  ]
109
114
  })
110
115
 
116
+ const dynamicLabelClasses = computed(() => [ `cpCheckbox__label--${props.size}` ])
117
+
118
+ const dynamicInputClasses = computed(() => [ `cpCheckbox__input--${props.size}` ])
119
+
111
120
  const onChange = () => {
112
121
  if (Array.isArray(props.modelValue)) {
113
122
  const currentValues = [...props.modelValue]
@@ -172,10 +181,14 @@ const onChange = () => {
172
181
  'Purple'
173
182
  ); // TODO: Should be replace by ACCENT
174
183
 
175
- &:not(&--isEmpty) {
184
+ &--md:not(.cpCheckbox--isEmpty) {
176
185
  gap: var(--cp-spacing-md);
177
186
  }
178
187
 
188
+ &--lg:not(.cpCheckbox--isEmpty) {
189
+ gap: var(--cp-spacing-lg);
190
+ }
191
+
179
192
  &__wrapper {
180
193
  display: flex;
181
194
  flex-shrink: 0;
@@ -184,9 +197,7 @@ const onChange = () => {
184
197
  padding: var(--cp-spacing-sm);
185
198
  }
186
199
 
187
- input {
188
- width: var(--cp-dimensions-4);
189
- height: var(--cp-dimensions-4);
200
+ &__input {
190
201
  flex-shrink: 0;
191
202
  border: var(--cp-dimensions-0_25) solid var(--cp-border-soft);
192
203
  border-radius: var(--cp-radius-sm);
@@ -237,16 +248,43 @@ const onChange = () => {
237
248
  &:active:not(:disabled) {
238
249
  transform: scale(0.8);
239
250
  }
251
+
252
+ &--md {
253
+ width: var(--cp-dimensions-4);
254
+ height: var(--cp-dimensions-4);
255
+ border-radius: var(--cp-radius-sm);
256
+ }
257
+
258
+ &--lg {
259
+ width: var(--cp-dimensions-5);
260
+ height: var(--cp-dimensions-5);
261
+ border-radius: var(--cp-radius-sm-md);
262
+ }
240
263
  }
241
264
 
242
265
  &__label,
243
266
  &__helper {
244
267
  display: block;
268
+ }
269
+
270
+ &__helper {
245
271
  line-height: var(--cp-line-height-md);
246
272
  }
247
273
 
274
+
248
275
  &__label {
249
276
  font-weight: 500;
277
+ padding-block: var(--cp-spacing-xs);
278
+
279
+ &--md {
280
+ font-size: var(--cp-text-size-sm);
281
+ line-height: var(--cp-line-height-sm);
282
+ }
283
+
284
+ &--lg {
285
+ font-size: var(--cp-text-size-md);
286
+ line-height: var(--cp-line-height-md);
287
+ }
250
288
 
251
289
  &::first-letter {
252
290
  text-transform: capitalize;
@@ -29,6 +29,7 @@
29
29
  :pt="passThroughConfig"
30
30
  :suggestions="dynamicOptions"
31
31
  :typeahead
32
+ @blur="handleBlur"
32
33
  @click="handleClick"
33
34
  @complete="handleSearch"
34
35
  @hide="handleOverlayHidden"
@@ -196,6 +197,7 @@ type ExtendedAutoComplete = InstanceType<typeof AutoComplete> & {
196
197
  overlay: HTMLElement
197
198
  overlayVisible: boolean
198
199
  show: () => void
200
+ writeValue: (value: unknown, event?: Event) => void
199
201
  }
200
202
 
201
203
  const multiselect = ref<ExtendedAutoComplete | null>(null)
@@ -245,6 +247,15 @@ const handleClear = () => (selectModel.value = null)
245
247
  const handleOverlayShown = () => emit('overlayShown')
246
248
  const handleOverlayHidden = () => emit('overlayHidden')
247
249
 
250
+ const handleBlur = () => {
251
+ if (props.multiple) {
252
+ const inputElement = getInputElement()
253
+ if (inputElement) inputElement.value = ''
254
+ } else {
255
+ multiselect.value?.writeValue(selectModel.value)
256
+ }
257
+ }
258
+
248
259
  const handleValueChange = (newValue: string | object) => {
249
260
  if (typeof newValue !== 'string') return
250
261
  searchQuery.value = newValue
@@ -52,6 +52,11 @@ const meta = {
52
52
  control: 'boolean',
53
53
  description: 'Whether the checkbox is in an indeterminate state',
54
54
  },
55
+ size: {
56
+ control: 'select',
57
+ options: ['md', 'lg'],
58
+ description: 'Size variant of the checkbox',
59
+ },
55
60
  },
56
61
  } satisfies Meta<typeof CpCheckbox>
57
62
 
@@ -100,7 +100,6 @@ export const Single: Story = {
100
100
  <CpMultiselect v-model="selectedSupplier" v-bind="args">
101
101
  <template #prefix>
102
102
  <div class="baseSelectAirline__prefix">
103
- <partner-badge size="sm" type="airline" variant="soft" />
104
103
  <cp-airline-logo :iata-code="getOptionIataCode(selectedSupplier)" size="20" />
105
104
  </div>
106
105
  </template>
@@ -192,12 +191,9 @@ export const Invalid: Story = {
192
191
  template: `
193
192
  <div style="padding: 20px; max-width: 25rem;">
194
193
  <CpMultiselect v-model="selectedSupplier" v-bind="args">
195
- <template #prefix>
196
- <cp-partner-badge type="supplier" size="sm" />
197
- </template>
198
194
  <template #option="{ option }">
199
195
  <div style="display: flex; align-items: center; gap: 8px;">
200
- <cp-partner-badge type="supplier" size="xs" />
196
+ <cp-icon type="supplier" size="16" />
201
197
  {{ option.name }}
202
198
  </div>
203
199
  </template>