@citizenplane/pimp 16.0.3 → 16.2.0

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.
Files changed (71) hide show
  1. package/dist/pimp.es.js +781 -757
  2. package/dist/pimp.umd.js +21 -21
  3. package/dist/style.css +1 -1
  4. package/package.json +10 -8
  5. package/src/components/CpDate.vue +3 -1
  6. package/src/components/CpHeading.vue +4 -5
  7. package/src/components/CpMultiselect.vue +2 -5
  8. package/src/components/CpTable.vue +4 -2
  9. package/src/components/CpTelInput.vue +18 -12
  10. package/src/components/CpText.vue +141 -0
  11. package/src/components/CpToast.vue +1 -1
  12. package/src/components/CpTransitionExpand.vue +23 -20
  13. package/src/components/index.ts +2 -0
  14. package/src/libs/CoreDatepicker.vue +1 -0
  15. package/src/stories/BaseInputLabel.stories.ts +36 -9
  16. package/src/stories/Colors.mdx +9 -0
  17. package/src/stories/Colors.stories.ts +177 -0
  18. package/src/stories/CpAccordion.stories.ts +188 -159
  19. package/src/stories/CpAccordionGroup.stories.ts +51 -95
  20. package/src/stories/CpAirlineLogo.stories.ts +52 -28
  21. package/src/stories/CpAlert.stories.ts +196 -159
  22. package/src/stories/CpBadge.stories.ts +260 -194
  23. package/src/stories/CpButton.stories.ts +257 -426
  24. package/src/stories/CpCheckbox.stories.ts +102 -30
  25. package/src/stories/CpContextualMenu.stories.ts +14 -9
  26. package/src/stories/CpDate.stories.ts +53 -26
  27. package/src/stories/CpDatepicker.stories.ts +53 -80
  28. package/src/stories/CpDialog.stories.ts +23 -2
  29. package/src/stories/CpHeading.stories.ts +60 -20
  30. package/src/stories/CpIcon.stories.ts +98 -31
  31. package/src/stories/CpInput.stories.ts +164 -73
  32. package/src/stories/CpItemActions.stories.ts +23 -12
  33. package/src/stories/CpLoader.stories.ts +55 -7
  34. package/src/stories/CpMenuItem.stories.ts +53 -27
  35. package/src/stories/CpMultiselect.stories.ts +53 -72
  36. package/src/stories/CpPartnerBadge.stories.ts +58 -76
  37. package/src/stories/CpRadio.stories.ts +45 -49
  38. package/src/stories/CpRadioGroup.stories.ts +47 -40
  39. package/src/stories/CpSelect.stories.ts +108 -34
  40. package/src/stories/CpSelectMenu.stories.ts +66 -55
  41. package/src/stories/CpSelectableButton.stories.ts +170 -81
  42. package/src/stories/CpSwitch.stories.ts +136 -134
  43. package/src/stories/CpTable.stories.ts +69 -13
  44. package/src/stories/CpTableEmptyState.stories.ts +11 -7
  45. package/src/stories/CpTabs.stories.ts +23 -5
  46. package/src/stories/CpTelInput.stories.ts +28 -19
  47. package/src/stories/CpText.stories.ts +131 -0
  48. package/src/stories/CpTextarea.stories.ts +74 -27
  49. package/src/stories/CpToast.stories.ts +75 -109
  50. package/src/stories/CpTooltip.stories.ts +82 -77
  51. package/src/stories/CpTransitionCounter.stories.ts +5 -1
  52. package/src/stories/CpTransitionExpand.stories.ts +12 -7
  53. package/src/stories/CpTransitionListItems.stories.ts +6 -1
  54. package/src/stories/CpTransitionSize.stories.ts +9 -1
  55. package/src/stories/CpTransitionSlide.stories.ts +5 -1
  56. package/src/stories/CpTransitionTabContent.stories.ts +5 -1
  57. package/src/stories/Dimensions.mdx +9 -0
  58. package/src/stories/Dimensions.stories.ts +119 -0
  59. package/src/stories/Easings.mdx +9 -0
  60. package/src/stories/Easings.stories.ts +101 -0
  61. package/src/stories/FocusRings.mdx +9 -0
  62. package/src/stories/FocusRings.stories.ts +74 -0
  63. package/src/stories/Shadows.mdx +9 -0
  64. package/src/stories/Shadows.stories.ts +100 -0
  65. package/src/stories/Typography.mdx +9 -0
  66. package/src/stories/Typography.stories.ts +181 -0
  67. package/src/stories/documentationStyles.ts +2 -10
  68. package/src/stories/tokenUtils.ts +259 -0
  69. package/src/types/primevue-toasteventbus.d.ts +14 -0
  70. package/tsconfig.json +1 -0
  71. package/.lintstagedrc.json +0 -4
@@ -1,29 +1,27 @@
1
- import type { Args, Meta, StoryObj } from '@storybook/vue3'
1
+ import type { Args, Meta, StoryObj } from '@storybook/vue3-vite'
2
2
 
3
3
  import CpAlert from '@/components/CpAlert.vue'
4
4
 
5
- import {
6
- docCellStyle,
7
- docLabelStyle,
8
- docPageStyle,
9
- docRowColumnStyle,
10
- docSectionStyle,
11
- docTitleStyle,
12
- } from '@/stories/documentationStyles'
5
+ import { docCellStyle, docLabelStyle, docRowColumnStyle } from '@/stories/documentationStyles'
6
+
7
+ const alertColors = ['neutral', 'accent', 'success', 'warning', 'error'] as const
8
+ const alertTypes = ['expanded', 'inline'] as const
9
+
10
+ const alertStackStyle = `${docCellStyle} width: 100%; min-width: 420px;`
13
11
 
14
12
  const meta = {
15
- title: 'Feedback/CpAlert',
13
+ title: 'Molecules/CpAlert',
16
14
  component: CpAlert,
17
15
  argTypes: {
18
16
  color: {
19
17
  control: 'select',
20
- options: ['neutral', 'accent', 'success', 'warning', 'error'],
18
+ options: alertColors,
21
19
  description: 'The color variant of the alert',
22
20
  },
23
21
  type: {
24
22
  control: 'select',
25
- options: ['expanded', 'inline'],
26
- description: 'The type of the alert',
23
+ options: alertTypes,
24
+ description: 'The layout type of the alert',
27
25
  },
28
26
  title: {
29
27
  control: 'text',
@@ -31,16 +29,16 @@ const meta = {
31
29
  },
32
30
  content: {
33
31
  control: 'text',
34
- description: 'The text content of the alert',
32
+ description: 'The text content of the alert (expanded type only)',
35
33
  },
36
34
  icon: {
37
35
  control: 'select',
38
36
  options: ['', 'info', 'check', 'alert-triangle', 'x-octagon', 'bell', 'star'],
39
- description: 'Custom icon override',
37
+ description: 'Custom icon override. Defaults to the color-specific icon when empty.',
40
38
  },
41
39
  isClosable: {
42
40
  control: 'boolean',
43
- description: 'Whether the alert can be closed',
41
+ description: 'Whether the alert shows a close button',
44
42
  },
45
43
  primaryActionLabel: {
46
44
  control: 'text',
@@ -66,169 +64,208 @@ const defaultRender = (args: Args) => ({
66
64
  template: defaultTemplate,
67
65
  })
68
66
 
69
- export const Documentation: Story = {
70
- args: {},
67
+ /**
68
+ * Default alert with a neutral color, expanded layout, a title and a content
69
+ * message. Use the controls to experiment with each prop in isolation.
70
+ */
71
+ export const Default: Story = {
72
+ args: {
73
+ color: 'neutral',
74
+ type: 'expanded',
75
+ title: 'Alert title',
76
+ content: 'This is an informational alert message.',
77
+ isClosable: false,
78
+ icon: undefined,
79
+ primaryActionLabel: undefined,
80
+ secondaryActionLabel: undefined,
81
+ },
82
+ render: defaultRender,
83
+ }
84
+
85
+ /* -------------------------------------------------------------------------- */
86
+ /* Colors */
87
+ /* -------------------------------------------------------------------------- */
88
+
89
+ /**
90
+ * Every semantic color available for the alert, stacked vertically.
91
+ */
92
+ export const Colors: Story = {
93
+ parameters: { controls: { disable: true } },
71
94
  render: () => ({
72
95
  components: { CpAlert },
73
- setup: () => ({}),
96
+ setup() {
97
+ return { alertColors, docRowColumnStyle, alertStackStyle, docLabelStyle }
98
+ },
74
99
  template: `
75
- <div>
76
- <div style="${docPageStyle}">
77
- <h1 style="margin: 0 0 32px 0; font-size: 28px; font-weight: 700; color: #111;">CpAlert</h1>
100
+ <div :style="docRowColumnStyle">
101
+ <div v-for="color in alertColors" :key="color" :style="alertStackStyle">
102
+ <span :style="docLabelStyle">{{ color }}</span>
103
+ <CpAlert
104
+ :color="color"
105
+ :title="color.charAt(0).toUpperCase() + color.slice(1) + ' alert'"
106
+ content="This is an informational alert message."
107
+ />
108
+ </div>
109
+ </div>
110
+ `,
111
+ }),
112
+ }
78
113
 
79
- <section style="${docSectionStyle}">
80
- <h2 style="${docTitleStyle}">Color</h2>
81
- <div style="${docRowColumnStyle}">
82
- <div style="${docCellStyle}">
83
- <span style="${docLabelStyle}">neutral</span>
84
- <CpAlert color="neutral" title="Neutral alert" content="This is a neutral informational message." is-closable />
85
- </div>
86
- <div style="${docCellStyle}">
87
- <span style="${docLabelStyle}">accent</span>
88
- <CpAlert color="accent" title="Accent alert" content="This is an accent informational message." is-closable />
89
- </div>
90
- <div style="${docCellStyle}">
91
- <span style="${docLabelStyle}">success</span>
92
- <CpAlert color="success" title="Success alert" content="The operation completed successfully." is-closable />
93
- </div>
94
- <div style="${docCellStyle}">
95
- <span style="${docLabelStyle}">warning</span>
96
- <CpAlert color="warning" title="Warning alert" content="Please review before proceeding." is-closable />
97
- </div>
98
- <div style="${docCellStyle}">
99
- <span style="${docLabelStyle}">error</span>
100
- <CpAlert color="error" title="Error alert" content="Something went wrong. Please try again." is-closable />
101
- </div>
102
- </div>
103
- </section>
114
+ /* -------------------------------------------------------------------------- */
115
+ /* Layout types */
116
+ /* -------------------------------------------------------------------------- */
104
117
 
105
- <section style="${docSectionStyle}">
106
- <h2 style="${docTitleStyle}">Type</h2>
107
- <div style="${docRowColumnStyle}">
108
- <div style="${docCellStyle}">
109
- <span style="${docLabelStyle}">Expanded (default)</span>
110
- <CpAlert color="neutral" title="Neutral alert" content="This is a neutral informational message." is-closable />
111
- </div>
112
- <div style="${docCellStyle}">
113
- <CpAlert color="accent" title="Accent alert" content="This is an accent informational message." is-closable />
114
- </div>
115
- <div style="${docCellStyle}">
116
- <CpAlert color="success" title="Success alert" content="The operation completed successfully." is-closable />
117
- </div>
118
- <div style="${docCellStyle}">
119
- <CpAlert color="warning" title="Warning alert" content="Please review before proceeding." is-closable />
120
- </div>
121
- <div style="${docCellStyle}">
122
- <CpAlert color="error" title="Error alert" content="Something went wrong. Please try again." is-closable />
123
- </div>
124
- <div style="${docCellStyle}">
125
- <span style="${docLabelStyle}">inline</span>
126
- <CpAlert color="neutral" type="inline" title="Neutral alert" is-closable />
127
- </div>
128
- <div style="${docCellStyle}">
129
- <CpAlert color="accent" type="inline" title="Accent alert" is-closable />
130
- </div>
131
- <div style="${docCellStyle}">
132
- <CpAlert color="success" type="inline" title="Success alert" is-closable />
133
- </div>
134
- <div style="${docCellStyle}">
135
- <CpAlert color="warning" type="inline" title="Warning alert" is-closable />
136
- </div>
137
- <div style="${docCellStyle}">
138
- <CpAlert color="error" type="inline" title="Error alert" is-closable />
139
- </div>
140
- </div>
141
- </section>
118
+ /**
119
+ * `expanded` stacks the title, content and actions vertically. `inline` keeps
120
+ * them on a single line and hides the content area — best for short messages.
121
+ */
122
+ export const Types: Story = {
123
+ parameters: { controls: { disable: true } },
124
+ render: () => ({
125
+ components: { CpAlert },
126
+ setup() {
127
+ return { alertTypes, docRowColumnStyle, alertStackStyle, docLabelStyle }
128
+ },
129
+ template: `
130
+ <div :style="docRowColumnStyle">
131
+ <div v-for="type in alertTypes" :key="type" :style="alertStackStyle">
132
+ <span :style="docLabelStyle">{{ type }}</span>
133
+ <CpAlert
134
+ color="accent"
135
+ :type="type"
136
+ title="Alert title"
137
+ content="This is an informational alert message."
138
+ primary-action-label="Action"
139
+ />
140
+ </div>
141
+ </div>
142
+ `,
143
+ }),
144
+ }
142
145
 
143
- <section style="${docSectionStyle}">
144
- <h2 style="${docTitleStyle}">Text only</h2>
145
- <div style="${docRowColumnStyle}">
146
- <div style="${docCellStyle}">
147
- <CpAlert color="accent" content="This is an accent informational message." is-closable />
148
- </div>
149
- </div>
150
- </section>
146
+ /* -------------------------------------------------------------------------- */
147
+ /* Content combinations */
148
+ /* -------------------------------------------------------------------------- */
151
149
 
152
- <section style="${docSectionStyle}">
153
- <h2 style="${docTitleStyle}">is-closable</h2>
154
- <div style="${docRowColumnStyle}">
155
- <div style="${docCellStyle}">
156
- <span style="${docLabelStyle}">false</span>
157
- <CpAlert color="accent" title="Not closable" content="This alert cannot be dismissed." @on-close="console.log('alert closed')" />
158
- </div>
159
- <div style="${docCellStyle}">
160
- <span style="${docLabelStyle}">true on expanded</span>
161
- <CpAlert color="accent" title="Closable" content="This alert can be dismissed with the close button." :is-closable="true" @on-close="console.log('alert closed')" />
162
- </div>
163
- <div style="${docCellStyle}">
164
- <span style="${docLabelStyle}">true on inline</span>
165
- <CpAlert color="accent" type="inline" title="Closable" :is-closable="true" @on-close="console.log('alert closed')" />
166
- </div>
167
- </div>
168
- </section>
150
+ /**
151
+ * The three supported content combinations: title only, content only, and
152
+ * both title and content.
153
+ */
154
+ export const ContentLayouts: Story = {
155
+ parameters: { controls: { disable: true } },
156
+ render: () => ({
157
+ components: { CpAlert },
158
+ setup() {
159
+ return { docRowColumnStyle, alertStackStyle, docLabelStyle }
160
+ },
161
+ template: `
162
+ <div :style="docRowColumnStyle">
163
+ <div :style="alertStackStyle">
164
+ <span :style="docLabelStyle">Title only</span>
165
+ <CpAlert color="accent" title="Title only" />
166
+ </div>
167
+ <div :style="alertStackStyle">
168
+ <span :style="docLabelStyle">Content only</span>
169
+ <CpAlert color="accent" content="Only a description, without a title on top." />
170
+ </div>
171
+ <div :style="alertStackStyle">
172
+ <span :style="docLabelStyle">Title and content</span>
173
+ <CpAlert
174
+ color="accent"
175
+ title="Title and content"
176
+ content="The full layout with both title and description."
177
+ />
178
+ </div>
179
+ </div>
180
+ `,
181
+ }),
182
+ }
169
183
 
170
- <section style="${docSectionStyle}">
171
- <h2 style="${docTitleStyle}">Actions</h2>
172
- <div style="${docRowColumnStyle}">
173
- <div style="${docCellStyle}">
174
- <span style="${docLabelStyle}">without actions</span>
175
- <CpAlert color="accent" title="Without actions" />
176
- </div>
177
- <div style="${docCellStyle}">
178
- <span style="${docLabelStyle}">primary only</span>
179
- <CpAlert color="accent" title="With primary action" content="This alert has a primary action button." primary-action-label="Confirm" is-closable @primary-action-click="console.log('primary action clicked')" />
180
- </div>
181
- <div style="${docCellStyle}">
182
- <CpAlert color="accent" title="With primary action" type="inline" primary-action-label="Confirm" is-closable @primary-action-click="console.log('primary action clicked')" />
183
- </div>
184
- <div style="${docCellStyle}">
185
- <span style="${docLabelStyle}">primary + secondary</span>
186
- <CpAlert color="accent" title="With both actions" content="This alert has primary and secondary action buttons." primary-action-label="Confirm" secondary-action-label="Cancel" is-closable @primary-action-click="console.log('primary action clicked')" @secondary-action-click="console.log('secondary action clicked')" />
187
- </div>
188
- </div>
189
- </section>
184
+ /* -------------------------------------------------------------------------- */
185
+ /* Dismiss & actions */
186
+ /* -------------------------------------------------------------------------- */
190
187
 
191
- <section style="${docSectionStyle}">
192
- <h2 style="${docTitleStyle}">Custom icon</h2>
193
- <div style="${docRowColumnStyle}">
194
- <div style="${docCellStyle}">
195
- <span style="${docLabelStyle}">default icon (auto from color)</span>
196
- <CpAlert color="success" title="Default icon" content="Icon is derived from the color prop." />
197
- </div>
198
- <div style="${docCellStyle}">
199
- <span style="${docLabelStyle}">custom icon override</span>
200
- <CpAlert color="success" icon="star" title="Custom icon" content="Icon is overridden with a star." />
201
- </div>
202
- </div>
203
- </section>
188
+ /**
189
+ * All dismiss and action affordances shown side by side: closable, primary
190
+ * action, secondary action, and both actions together.
191
+ */
192
+ export const Actions: Story = {
193
+ parameters: { controls: { disable: true } },
194
+ render: () => ({
195
+ components: { CpAlert },
196
+ setup() {
197
+ return { docRowColumnStyle, alertStackStyle, docLabelStyle }
198
+ },
199
+ template: `
200
+ <div :style="docRowColumnStyle">
201
+ <div :style="alertStackStyle">
202
+ <span :style="docLabelStyle">Closable</span>
203
+ <CpAlert
204
+ color="accent"
205
+ title="Closable alert"
206
+ content="Click the × to dismiss."
207
+ :is-closable="true"
208
+ />
209
+ </div>
210
+ <div :style="alertStackStyle">
211
+ <span :style="docLabelStyle">Primary action</span>
212
+ <CpAlert
213
+ color="accent"
214
+ title="Action required"
215
+ content="Use the primary action to move forward."
216
+ primary-action-label="Confirm"
217
+ />
218
+ </div>
219
+ <div :style="alertStackStyle">
220
+ <span :style="docLabelStyle">Secondary action</span>
221
+ <CpAlert
222
+ color="accent"
223
+ title="Optional action"
224
+ content="The secondary action is visually less prominent."
225
+ secondary-action-label="Learn more"
226
+ />
227
+ </div>
228
+ <div :style="alertStackStyle">
229
+ <span :style="docLabelStyle">Both actions</span>
230
+ <CpAlert
231
+ color="accent"
232
+ title="Choose what to do"
233
+ content="Two actions are shown side by side."
234
+ primary-action-label="Confirm"
235
+ secondary-action-label="Cancel"
236
+ />
204
237
  </div>
205
238
  </div>
206
239
  `,
207
240
  }),
208
- parameters: {
209
- controls: { disable: true },
210
- docs: {
211
- source: {
212
- code: null,
213
- },
214
- },
215
- },
216
241
  }
217
242
 
218
- export const Default: Story = {
243
+ /* -------------------------------------------------------------------------- */
244
+ /* Icon */
245
+ /* -------------------------------------------------------------------------- */
246
+
247
+ /**
248
+ * Override the default color-specific icon with any icon name.
249
+ */
250
+ export const CustomIcon: Story = {
219
251
  args: {
220
- color: 'neutral',
221
- type: 'expanded',
222
- title: 'Alert title',
223
- content: 'This is an informational alert message.',
224
- isClosable: false,
225
- icon: undefined,
226
- primaryActionLabel: undefined,
227
- secondaryActionLabel: undefined,
252
+ ...Default.args,
253
+ color: 'accent',
254
+ title: 'Custom icon',
255
+ content: 'Any icon from the design system can replace the default one.',
256
+ icon: 'bell',
228
257
  },
229
258
  render: defaultRender,
230
259
  }
231
260
 
261
+ /* -------------------------------------------------------------------------- */
262
+ /* Slots */
263
+ /* -------------------------------------------------------------------------- */
264
+
265
+ /**
266
+ * Customize every part of the alert using slots: `icon`, `title`, default
267
+ * (content), `primary-action` and `secondary-action`.
268
+ */
232
269
  export const WithSlots: Story = {
233
270
  args: {
234
271
  color: 'accent',