@citizenplane/pimp 18.19.6 → 18.19.7
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
|
@@ -95,9 +95,12 @@ defineOptions({ inheritAttrs: false })
|
|
|
95
95
|
const attrs = useAttrs()
|
|
96
96
|
|
|
97
97
|
// class is a reserved word, we can't remove 'class' property from attrs
|
|
98
|
-
const
|
|
98
|
+
const restAttributes = computed(() => {
|
|
99
|
+
const { class: _class, id, ...rest } = attrs
|
|
100
|
+
return rest
|
|
101
|
+
})
|
|
99
102
|
|
|
100
|
-
const inputIdentifier = ref<string>((id as string | undefined) || useId())
|
|
103
|
+
const inputIdentifier = ref<string>((attrs.id as string | undefined) || useId())
|
|
101
104
|
|
|
102
105
|
const helpMessageId = useId()
|
|
103
106
|
const errorMessageId = useId()
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ComponentPropsAndSlots, Meta, StoryObj } from '@storybook/vue3-vite'
|
|
2
|
+
import { expect, userEvent, within } from 'storybook/test'
|
|
2
3
|
import { ref } from 'vue'
|
|
3
4
|
|
|
4
5
|
import CpIcon from '@/components/CpIcon.vue'
|
|
@@ -321,6 +322,40 @@ export const WithUnits: Story = {
|
|
|
321
322
|
}),
|
|
322
323
|
}
|
|
323
324
|
|
|
325
|
+
/**
|
|
326
|
+
* A dynamically bound native attribute (e.g. `:placeholder`) must stay reactive
|
|
327
|
+
* instead of freezing at first render.
|
|
328
|
+
*/
|
|
329
|
+
export const ReactiveAttribute: Story = {
|
|
330
|
+
args: { ...Default.args },
|
|
331
|
+
render: (args: StoryArgs) => ({
|
|
332
|
+
components: { CpInput },
|
|
333
|
+
setup() {
|
|
334
|
+
const value = ref('')
|
|
335
|
+
const placeholder = ref('Initial placeholder')
|
|
336
|
+
const updatePlaceholder = () => {
|
|
337
|
+
placeholder.value = 'Updated placeholder'
|
|
338
|
+
}
|
|
339
|
+
return { args, value, placeholder, updatePlaceholder }
|
|
340
|
+
},
|
|
341
|
+
template: `
|
|
342
|
+
<div style="max-width: 400px; padding: 20px;">
|
|
343
|
+
<CpInput v-model="value" v-bind="args" :placeholder="placeholder" />
|
|
344
|
+
<button type="button" @click="updatePlaceholder">Update placeholder</button>
|
|
345
|
+
</div>
|
|
346
|
+
`,
|
|
347
|
+
}),
|
|
348
|
+
play: async ({ canvasElement }) => {
|
|
349
|
+
const canvas = within(canvasElement)
|
|
350
|
+
|
|
351
|
+
await expect(canvas.getByPlaceholderText('Initial placeholder')).toBeInTheDocument()
|
|
352
|
+
|
|
353
|
+
await userEvent.click(canvas.getByRole('button', { name: 'Update placeholder' }))
|
|
354
|
+
|
|
355
|
+
await expect(canvas.getByPlaceholderText('Updated placeholder')).toBeInTheDocument()
|
|
356
|
+
},
|
|
357
|
+
}
|
|
358
|
+
|
|
324
359
|
export const VisualTestingBetweenDisabledAndPlaceholder: Story = {
|
|
325
360
|
args: {
|
|
326
361
|
...Default.args,
|