@citizenplane/pimp 18.16.0 → 18.16.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.16.0",
3
+ "version": "18.16.2",
4
4
  "scripts": {
5
5
  "dev": "storybook dev -p 8081",
6
6
  "build-storybook": "storybook build --output-dir ./docs",
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="cpMultiselect">
2
+ <div class="cpMultiselect" :class="multiselectDynamicClasses">
3
3
  <base-input-label
4
4
  v-if="label"
5
5
  v-bind-once="{ for: multiselectId }"
@@ -216,6 +216,20 @@ const chevronDynamicClass = computed(() => {
216
216
 
217
217
  const hasPrefixSlot = computed(() => !!slots.prefix)
218
218
 
219
+ const hasValue = computed(() => {
220
+ if (props.multiple) return !!selectModel.value?.length
221
+ return !isEmpty(selectModel.value)
222
+ })
223
+
224
+ const hasError = computed(() => (props.isInvalid ?? false) && !!props.errorMessage)
225
+
226
+ const multiselectDynamicClasses = computed(() => ({
227
+ 'cpMultiselect--hasPrefix': hasPrefixSlot.value,
228
+ 'cpMultiselect--isMultiple': props.multiple ?? false,
229
+ 'cpMultiselect--hasValue': hasValue.value,
230
+ 'cpMultiselect--hasError': hasError.value,
231
+ }))
232
+
219
233
  const displayClearButton = computed(() => {
220
234
  if (props.multiple) return false
221
235
  return props.isClearable && !isEmpty(selectModel.value)
@@ -348,6 +362,14 @@ onMounted(() => overrideAlignOverlay())
348
362
  }
349
363
  }
350
364
 
365
+ &--hasPrefix#{&}--isMultiple#{&}--hasValue .cpMultiselect__select {
366
+ gap: var(--cp-spacing-sm);
367
+ }
368
+
369
+ &--hasError .cpMultiselect__select {
370
+ margin-bottom: var(--cp-spacing-md);
371
+ }
372
+
351
373
  &__select {
352
374
  position: relative;
353
375
  display: flex;
@@ -267,6 +267,7 @@ export {
267
267
  CpTelInput,
268
268
  CpText,
269
269
  CpTextarea,
270
+ CpTextMorph,
270
271
  CpToast,
271
272
  CpTooltip,
272
273
  CpTransitionCounter,
@@ -109,6 +109,36 @@ export const Single: Story = {
109
109
  }),
110
110
  }
111
111
 
112
+ /**
113
+ * Multi-value selection with a supplier prefix badge. Selected options are
114
+ * rendered as chips.
115
+ */
116
+ export const Multiple: Story = {
117
+ args: {
118
+ placeholder: 'Select suppliers',
119
+ multiple: true,
120
+ options: supplierOptions,
121
+ trackBy: 'id',
122
+ },
123
+ render: (args) => ({
124
+ components: { CpMultiselect },
125
+ setup() {
126
+ const selectedSuppliers = ref([])
127
+
128
+ return { args, selectedSuppliers }
129
+ },
130
+ template: `
131
+ <div style="padding: 20px; max-width: 25rem;">
132
+ <CpMultiselect v-model="selectedSuppliers" v-bind="args">
133
+ <template #prefix>
134
+ <cp-badge color="magenta" is-square leading-icon="supplier" size="sm" />
135
+ </template>
136
+ </CpMultiselect>
137
+ </div>
138
+ `,
139
+ }),
140
+ }
141
+
112
142
  /**
113
143
  * Multi-value selection with an async search handler. Selected options are
114
144
  * rendered as chips and can be customized through `#tag-leading-icon` and