fds-vue-core 2.1.10 → 2.1.15

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/components.d.ts +5 -3
  2. package/dist/fds-vue-core.cjs.js +174 -79
  3. package/dist/fds-vue-core.cjs.js.map +1 -1
  4. package/dist/fds-vue-core.es.js +175 -80
  5. package/dist/fds-vue-core.es.js.map +1 -1
  6. package/package.json +12 -12
  7. package/src/components/Blocks/FdsBlockAlert/FdsBlockAlert.stories.ts +60 -33
  8. package/src/components/Blocks/FdsBlockAlert/FdsBlockAlert.vue +5 -1
  9. package/src/components/Blocks/FdsBlockContent/FdsBlockContent.stories.ts +44 -41
  10. package/src/components/Blocks/FdsBlockExpander/FdsBlockExpander.stories.ts +33 -30
  11. package/src/components/Blocks/FdsBlockExpander/FdsBlockExpander.vue +51 -16
  12. package/src/components/Blocks/FdsBlockExpander/types.ts +2 -0
  13. package/src/components/Blocks/FdsBlockInfo/FdsBlockInfo.stories.ts +42 -39
  14. package/src/components/Blocks/FdsBlockLink/FdsBlockLink.stories.ts +42 -39
  15. package/src/components/Blocks/FdsBlockLink/FdsBlockLink.vue +13 -1
  16. package/src/components/Blocks/FdsBlockLink/types.ts +2 -0
  17. package/src/components/Buttons/ButtonBaseProps.ts +5 -0
  18. package/src/components/Buttons/FdsButtonCopy/FdsButtonCopy.stories.ts +1 -1
  19. package/src/components/Buttons/FdsButtonCopy/types.ts +1 -0
  20. package/src/components/Buttons/FdsButtonDownload/FdsButtonDownload.stories.ts +4 -4
  21. package/src/components/Buttons/FdsButtonDownload/FdsButtonDownload.vue +14 -16
  22. package/src/components/Buttons/FdsButtonDownload/types.ts +22 -0
  23. package/src/components/Buttons/FdsButtonIcon/FdsButtonIcon.stories.ts +2 -2
  24. package/src/components/Buttons/FdsButtonIcon/FdsButtonIcon.vue +1 -1
  25. package/src/components/Buttons/FdsButtonIcon/types.ts +1 -0
  26. package/src/components/Buttons/FdsButtonMinor/FdsButtonMinor.stories.ts +2 -2
  27. package/src/components/Buttons/FdsButtonMinor/FdsButtonMinor.vue +4 -1
  28. package/src/components/Buttons/FdsButtonPrimary/FdsButtonPrimary.stories.ts +4 -4
  29. package/src/components/Buttons/FdsButtonSecondary/FdsButtonSecondary.stories.ts +2 -2
  30. package/src/components/Buttons/FdsButtonSecondary/FdsButtonSecondary.vue +1 -1
  31. package/src/components/FdsIcon/FdsIcon.stories.ts +1 -1
  32. package/src/components/FdsModal/FdsModal.stories.ts +7 -7
  33. package/src/components/FdsModal/FdsModal.vue +6 -1
  34. package/src/components/FdsModal/types.ts +1 -0
  35. package/src/components/FdsPagination/FdsPagination.stories.ts +5 -5
  36. package/src/components/FdsPagination/types.ts +3 -0
  37. package/src/components/FdsSearchSelect/FdsSearchSelect.stories.ts +9 -9
  38. package/src/components/FdsSearchSelect/FdsSearchSelect.vue +7 -30
  39. package/src/components/FdsSearchSelect/types.ts +7 -0
  40. package/src/components/FdsSpinner/FdsSpinner.stories.ts +1 -1
  41. package/src/components/FdsSticker/FdsSticker.stories.ts +23 -20
  42. package/src/components/FdsSticker/FdsSticker.vue +6 -5
  43. package/src/components/FdsTreeView/FdsTreeView.stories.ts +1 -1
  44. package/src/components/FdsTreeView/types.ts +4 -1
  45. package/src/components/FdsTruncatedText/FdsTruncatedText.stories.ts +4 -4
  46. package/src/components/FdsTruncatedText/FdsTruncatedText.vue +6 -7
  47. package/src/components/Form/FdsCheckbox/FdsCheckbox.stories.ts +4 -4
  48. package/src/components/Form/FdsCheckbox/FdsCheckbox.vue +6 -6
  49. package/src/components/Form/FdsCheckbox/types.ts +2 -0
  50. package/src/components/Form/FdsInput/FdsInput.stories.ts +5 -5
  51. package/src/components/Form/FdsInput/FdsInput.vue +14 -19
  52. package/src/components/Form/FdsInput/types.ts +4 -0
  53. package/src/components/Form/FdsRadio/FdsRadio.stories.ts +1 -1
  54. package/src/components/Form/FdsRadio/FdsRadio.vue +6 -6
  55. package/src/components/Form/FdsRadio/types.ts +1 -0
  56. package/src/components/Form/FdsSelect/FdsSelect.stories.ts +4 -4
  57. package/src/components/Form/FdsSelect/FdsSelect.vue +5 -1
  58. package/src/components/Form/FdsTextarea/FdsTextarea.stories.ts +2 -2
  59. package/src/components/Table/FdsTable/FdsTable.stories.ts +3 -3
  60. package/src/components/Table/FdsTableHead/FdsTableHead.stories.ts +6 -6
  61. package/src/components/Table/FdsTableHead/FdsTableHead.vue +9 -15
  62. package/src/components/Table/FdsTableHead/types.ts +1 -0
  63. package/src/components/Tabs/FdsTabs/FdsTabs.stories.ts +9 -9
  64. package/src/components/Tabs/FdsTabs/FdsTabs.vue +5 -1
  65. package/src/components/Tabs/FdsTabsItem/FdsTabsItem.vue +26 -2
  66. package/src/components/Tabs/FdsTabsItem/types.ts +2 -0
  67. package/src/components/Typography/FdsText/FdsText.stories.ts +14 -14
  68. package/src/components/Typography/FdsText/FdsText.vue +18 -2
  69. package/src/components/Typography/FdsText/types.ts +1 -0
  70. package/src/index.ts +1 -1
  71. package/src/.DS_Store +0 -0
@@ -56,7 +56,7 @@ const sampleData = [
56
56
  ]
57
57
 
58
58
  export const Default: Story = {
59
- render: (args) => ({
59
+ render: (args: Story['args']) => ({
60
60
  components: { FdsTable, FdsTableHead },
61
61
  setup: () => ({ args, sampleData }),
62
62
  template: `
@@ -93,7 +93,7 @@ export const Default: Story = {
93
93
 
94
94
  export const Bordered: Story = {
95
95
  args: { bordered: true },
96
- render: (args) => ({
96
+ render: (args: Story['args']) => ({
97
97
  components: { FdsTable, FdsTableHead },
98
98
  setup: () => ({ args, sampleData }),
99
99
  template: `
@@ -130,7 +130,7 @@ export const Bordered: Story = {
130
130
 
131
131
  export const Compact: Story = {
132
132
  args: { compact: true },
133
- render: (args) => ({
133
+ render: (args: Story['args']) => ({
134
134
  components: { FdsTable, FdsTableHead },
135
135
  setup: () => ({ args, sampleData }),
136
136
  template: `
@@ -21,7 +21,7 @@ export default meta
21
21
  type Story = StoryObj<typeof meta>
22
22
 
23
23
  export const Default: Story = {
24
- render: (args) => ({
24
+ render: (args: Story['args']) => ({
25
25
  components: { FdsTableHead },
26
26
  setup: () => ({ args }),
27
27
  template: `
@@ -42,7 +42,7 @@ export const Default: Story = {
42
42
  }
43
43
 
44
44
  export const Sortable: Story = {
45
- render: (args) => ({
45
+ render: (args: Story['args']) => ({
46
46
  components: { FdsTableHead },
47
47
  setup: () => ({ args }),
48
48
  template: `
@@ -64,7 +64,7 @@ export const Sortable: Story = {
64
64
 
65
65
  export const SortedAsc: Story = {
66
66
  args: { icon: 'ascending' },
67
- render: (args) => ({
67
+ render: (args: Story['args']) => ({
68
68
  components: { FdsTableHead },
69
69
  setup: () => ({ args }),
70
70
  template: `
@@ -86,7 +86,7 @@ export const SortedAsc: Story = {
86
86
 
87
87
  export const SortedDesc: Story = {
88
88
  args: { icon: 'descending' },
89
- render: (args) => ({
89
+ render: (args: Story['args']) => ({
90
90
  components: { FdsTableHead },
91
91
  setup: () => ({ args }),
92
92
  template: `
@@ -108,7 +108,7 @@ export const SortedDesc: Story = {
108
108
 
109
109
  export const CenterAligned: Story = {
110
110
  args: { align: 'center' },
111
- render: (args) => ({
111
+ render: (args: Story['args']) => ({
112
112
  components: { FdsTableHead },
113
113
  setup: () => ({ args }),
114
114
  template: `
@@ -130,7 +130,7 @@ export const CenterAligned: Story = {
130
130
 
131
131
  export const RightAligned: Story = {
132
132
  args: { align: 'right' },
133
- render: (args) => ({
133
+ render: (args: Story['args']) => ({
134
134
  components: { FdsTableHead },
135
135
  setup: () => ({ args }),
136
136
  template: `
@@ -1,6 +1,6 @@
1
1
  <script setup lang="ts">
2
+ import { computed, type Slot } from 'vue'
2
3
  import { useHasSlot } from '../../../composables/useHasSlots'
3
- import { computed } from 'vue'
4
4
  import FdsIcon from '../../FdsIcon/FdsIcon.vue'
5
5
  import type { FdsTableHeadProps } from './types'
6
6
 
@@ -25,28 +25,22 @@ const iconName = computed(() => props.icon)
25
25
 
26
26
  defineEmits<{
27
27
  (e: 'sort'): void
28
+ (e: 'click', ev: MouseEvent): void
29
+ }>()
30
+
31
+ defineSlots<{
32
+ default?: Slot
28
33
  }>()
29
34
  </script>
30
35
 
31
36
  <template>
32
37
  <th class="fds-table-head">
33
- <button
34
- v-if="iconName"
35
- :class="headerClasses"
36
- @click="$emit('sort')"
37
- >
38
+ <button v-if="iconName" :class="headerClasses" @click="$emit('sort')">
38
39
  <span v-if="hasSlot"><slot /></span>
39
40
  <span v-else>{{ heading }}</span>
40
- <FdsIcon
41
- :name="iconName"
42
- size="24px"
43
- class="fill-blue-500"
44
- />
41
+ <FdsIcon :name="iconName" size="24px" class="fill-blue-500" />
45
42
  </button>
46
- <div
47
- v-else
48
- :class="headerClasses"
49
- >
43
+ <div v-else :class="headerClasses">
50
44
  <span v-if="hasSlot"><slot /></span>
51
45
  <span v-else>{{ heading }}</span>
52
46
  </div>
@@ -2,4 +2,5 @@ export interface FdsTableHeadProps {
2
2
  heading?: string
3
3
  align?: 'left' | 'center' | 'right'
4
4
  icon?: 'sort' | 'ascending' | 'descending'
5
+ onClick?: () => void
5
6
  }
@@ -1,6 +1,6 @@
1
1
  import type { Meta, StoryObj } from '@storybook/vue3'
2
- import FdsTabs from './FdsTabs.vue'
3
2
  import FdsTabsItem from '../FdsTabsItem/FdsTabsItem.vue'
3
+ import FdsTabs from './FdsTabs.vue'
4
4
 
5
5
  const meta: Meta<typeof FdsTabs> = {
6
6
  title: 'FDS/FdsTabs',
@@ -33,7 +33,7 @@ const tabsTransform = (storyContext: { args?: { block?: boolean; variant?: strin
33
33
  }
34
34
 
35
35
  export const Default: Story = {
36
- render: (args) => ({
36
+ render: (args: Story['args']) => ({
37
37
  components: { FdsTabs, FdsTabsItem },
38
38
  setup: () => ({ args }),
39
39
  template: `
@@ -54,7 +54,7 @@ export const Default: Story = {
54
54
  }
55
55
 
56
56
  export const Secondary: Story = {
57
- render: (args) => ({
57
+ render: (args: Story['args']) => ({
58
58
  components: { FdsTabs, FdsTabsItem },
59
59
  setup: () => ({ args }),
60
60
  template: `
@@ -84,7 +84,7 @@ export const Secondary: Story = {
84
84
  }
85
85
 
86
86
  export const Block: Story = {
87
- render: (args) => ({
87
+ render: (args: Story['args']) => ({
88
88
  components: { FdsTabs, FdsTabsItem },
89
89
  setup: () => ({ args }),
90
90
  template: `
@@ -114,7 +114,7 @@ export const Block: Story = {
114
114
  }
115
115
 
116
116
  export const WithDisabled: Story = {
117
- render: (args) => ({
117
+ render: (args: Story['args']) => ({
118
118
  components: { FdsTabs, FdsTabsItem },
119
119
  setup: () => ({ args }),
120
120
  template: `
@@ -139,7 +139,7 @@ export const WithDisabled: Story = {
139
139
  }
140
140
 
141
141
  export const WithRouterLinks: Story = {
142
- render: (args) => ({
142
+ render: (args: Story['args']) => ({
143
143
  components: { FdsTabs, FdsTabsItem },
144
144
  setup: () => ({ args }),
145
145
  template: `
@@ -166,7 +166,7 @@ export const WithRouterLinks: Story = {
166
166
  }
167
167
 
168
168
  export const WithExactMatch: Story = {
169
- render: (args) => ({
169
+ render: (args: Story['args']) => ({
170
170
  components: { FdsTabs, FdsTabsItem },
171
171
  setup: () => ({ args }),
172
172
  template: `
@@ -193,7 +193,7 @@ export const WithExactMatch: Story = {
193
193
  }
194
194
 
195
195
  export const WithAnchorLinks: Story = {
196
- render: (args) => ({
196
+ render: (args: Story['args']) => ({
197
197
  components: { FdsTabs, FdsTabsItem },
198
198
  setup: () => ({ args }),
199
199
  template: `
@@ -220,7 +220,7 @@ export const WithAnchorLinks: Story = {
220
220
  }
221
221
 
222
222
  export const WithButtons: Story = {
223
- render: (args) => ({
223
+ render: (args: Story['args']) => ({
224
224
  components: { FdsTabs, FdsTabsItem },
225
225
  setup: () => ({ args }),
226
226
  template: `
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { computed, provide } from 'vue'
2
+ import { computed, provide, type Slot } from 'vue'
3
3
  import type { FdsTabsProps } from './types'
4
4
 
5
5
  const props = withDefaults(defineProps<FdsTabsProps>(), {
@@ -18,6 +18,10 @@ const tabsClasses = computed(() => [
18
18
 
19
19
  provide('tabsVariant', props.variant)
20
20
  provide('tabsBlock', props.block)
21
+
22
+ defineSlots<{
23
+ default?: Slot
24
+ }>()
21
25
  </script>
22
26
 
23
27
  <template>
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { computed, getCurrentInstance, inject, useAttrs } from 'vue'
2
+ import { computed, getCurrentInstance, inject, useAttrs, type Slot } from 'vue'
3
3
  import type { FdsTabsItemProps } from './types'
4
4
 
5
5
  defineOptions({
@@ -8,6 +8,24 @@ defineOptions({
8
8
 
9
9
  const attrs = useAttrs()
10
10
 
11
+ const emit = defineEmits<{
12
+ (e: 'click', ev: MouseEvent): void
13
+ }>()
14
+
15
+ const onClick = (ev: MouseEvent) => {
16
+ if (props.disabled) {
17
+ ev.preventDefault()
18
+ return
19
+ }
20
+ emit('click', ev)
21
+ }
22
+
23
+ const handleClick = (ev: MouseEvent) => {
24
+ if (componentType.value === 'button' && !props.disabled) {
25
+ onClick(ev)
26
+ }
27
+ }
28
+
11
29
  // Try to get route from vue-router if available
12
30
  const instance = getCurrentInstance()
13
31
  const route = computed(() => {
@@ -109,6 +127,10 @@ const variantClasses = computed(() => {
109
127
  const disabledClasses = computed(() => (props.disabled ? 'cursor-not-allowed pointer-events-none opacity-35' : ''))
110
128
 
111
129
  const buttonClasses = computed(() => [...baseClasses.value, ...variantClasses.value, disabledClasses.value])
130
+
131
+ defineSlots<{
132
+ default?: Slot
133
+ }>()
112
134
  </script>
113
135
 
114
136
  <template>
@@ -119,7 +141,9 @@ const buttonClasses = computed(() => [...baseClasses.value, ...variantClasses.va
119
141
  :disabled="componentType === 'button' ? disabled : undefined"
120
142
  :aria-disabled="disabled"
121
143
  :aria-current="isActive ? 'page' : undefined"
144
+ @click="handleClick"
122
145
  >
123
- <slot>{{ label }}</slot>
146
+ {{ label }}
147
+ <slot></slot>
124
148
  </component>
125
149
  </template>
@@ -13,4 +13,6 @@ export interface FdsTabsItemProps {
13
13
  disabled?: boolean
14
14
  /** Tab label text */
15
15
  label?: string
16
+ /** Click handler */
17
+ onClick?: ((ev: MouseEvent) => void) | Array<(ev: MouseEvent) => void>
16
18
  }
@@ -1,10 +1,23 @@
1
1
  import type { Meta, StoryObj } from '@storybook/vue3'
2
2
  import FdsText from './FdsText.vue'
3
3
 
4
+ const textTransform = (_src: string, storyContext: { args?: { type?: string } }) => {
5
+ const args = storyContext?.args || {}
6
+ const attrsStr = args.type && args.type !== 'default' ? ` type="${args.type}"` : ''
7
+ return `<FdsText${attrsStr}>Text content</FdsText>`
8
+ }
9
+
4
10
  const meta: Meta<typeof FdsText> = {
5
11
  title: 'FDS/Typography/FdsText',
6
12
  component: FdsText,
7
13
  tags: ['autodocs'],
14
+ parameters: {
15
+ docs: {
16
+ source: {
17
+ transform: textTransform,
18
+ },
19
+ },
20
+ },
8
21
  argTypes: {
9
22
  type: { control: { type: 'radio' }, options: ['default', 'lead', 'meta'] },
10
23
  },
@@ -16,25 +29,12 @@ const meta: Meta<typeof FdsText> = {
16
29
  export default meta
17
30
  type Story = StoryObj<typeof meta>
18
31
 
19
- const textTransform = (storyContext: { args?: { type?: string } }) => {
20
- const args = storyContext?.args || {}
21
- const attrsStr = args.type && args.type !== 'default' ? ` type="${args.type}"` : ''
22
- return `<FdsText${attrsStr}>Text content</FdsText>`
23
- }
24
-
25
32
  export const Default: Story = {
26
- render: (args) => ({
33
+ render: (args: Story['args']) => ({
27
34
  components: { FdsText },
28
35
  setup: () => ({ args }),
29
36
  template: `<FdsText :type="args.type">Text content</FdsText>`,
30
37
  }),
31
- parameters: {
32
- docs: {
33
- source: {
34
- transform: textTransform,
35
- },
36
- },
37
- },
38
38
  }
39
39
 
40
40
  export const Lead: Story = {
@@ -1,9 +1,16 @@
1
1
  <script setup lang="ts">
2
- import { computed } from 'vue'
2
+ import { computed, useAttrs, type Slot } from 'vue'
3
3
  import type { FdsTextProps } from './types'
4
4
 
5
+ defineOptions({
6
+ inheritAttrs: false,
7
+ })
8
+
9
+ const attrs = useAttrs()
10
+
5
11
  const props = withDefaults(defineProps<FdsTextProps>(), {
6
12
  type: 'default',
13
+ dataTestid: undefined,
7
14
  })
8
15
 
9
16
  const textClasses = computed(() => {
@@ -19,10 +26,19 @@ const textClasses = computed(() => {
19
26
 
20
27
  return baseClasses
21
28
  })
29
+
30
+ const spanAttrs = computed(() => ({
31
+ ...attrs,
32
+ 'data-testid': props.dataTestid,
33
+ }))
34
+
35
+ defineSlots<{
36
+ default?: Slot
37
+ }>()
22
38
  </script>
23
39
 
24
40
  <template>
25
- <span :class="textClasses">
41
+ <span v-bind="spanAttrs" :class="textClasses">
26
42
  <slot />
27
43
  </span>
28
44
  </template>
@@ -1,3 +1,4 @@
1
1
  export interface FdsTextProps {
2
2
  type?: 'default' | 'lead' | 'meta'
3
+ dataTestid?: string
3
4
  }
package/src/index.ts CHANGED
@@ -129,6 +129,7 @@ export type { FdsNodeShape, FdsTreeNode, FdsTreeViewProps, FdsTreeViewStyles } f
129
129
  // Button component types
130
130
  export type { FdsButtonBaseProps } from './components/Buttons/ButtonBaseProps'
131
131
  export type { FdsCopyButtonProps } from './components/Buttons/FdsButtonCopy/types'
132
+ export type { DownloadOptions, FdsButtonDownloadProps } from './components/Buttons/FdsButtonDownload/types'
132
133
  export type { FdsIconButtonProps } from './components/Buttons/FdsButtonIcon/types'
133
134
 
134
135
  // Button components that use FdsButtonBaseProps
@@ -136,7 +137,6 @@ import type { FdsButtonBaseProps } from './components/Buttons/ButtonBaseProps'
136
137
  export type FdsButtonPrimaryProps = FdsButtonBaseProps
137
138
  export type FdsButtonSecondaryProps = FdsButtonBaseProps
138
139
  export type FdsButtonMinorProps = FdsButtonBaseProps
139
- export type FdsButtonDownloadProps = FdsButtonBaseProps
140
140
 
141
141
  // Form component types
142
142
  export type { FdsCheckboxProps } from './components/Form/FdsCheckbox/types'
package/src/.DS_Store DELETED
Binary file