From 926da261fe1ef41a9f3b78eb73fa2531069fbdc4 Mon Sep 17 00:00:00 2001 From: StyleShit <32631382+StyleShit@users.noreply.github.com> Date: Thu, 25 Jun 2026 09:04:26 +0300 Subject: [PATCH 1/4] chore(design-system): add `defineTemplate()` function for better type safety [AR-72145] --- .../ds-button-v3/ds-button-v3.figma.ts | 5 +++-- .../ds-modal/figma/ds-modal-content.figma.ts | 5 +++-- .../ds-modal/figma/ds-modal-footer.figma.ts | 5 +++-- .../ds-modal/figma/ds-modal-header.figma.ts | 5 +++-- .../ds-modal/figma/ds-modal.figma.ts | 5 +++-- .../ds-status-badge-v2.figma.ts | 5 +++-- .../ds-text-input/ds-text-input.figma.ts | 5 +++-- .../src/utils/define-figma-template.ts | 18 ++++++++++++++++++ 8 files changed, 39 insertions(+), 14 deletions(-) create mode 100644 packages/design-system/src/utils/define-figma-template.ts diff --git a/packages/design-system/src/components/ds-button-v3/ds-button-v3.figma.ts b/packages/design-system/src/components/ds-button-v3/ds-button-v3.figma.ts index 706a8a3ac..447148596 100644 --- a/packages/design-system/src/components/ds-button-v3/ds-button-v3.figma.ts +++ b/packages/design-system/src/components/ds-button-v3/ds-button-v3.figma.ts @@ -2,6 +2,7 @@ // source=https://github.com/drivenets/design-system/tree/main/packages/design-system/src/components/ds-button-v3 // component=DsButtonV3 import figma from 'figma'; +import { defineFigmaTemplate } from '../../utils/define-figma-template'; const instance = figma.selectedInstance; @@ -34,7 +35,7 @@ const showIcon = structure.type === 'INSTANCE' ? structure.getBoolean('Show icon const labelNode = instance.findText('Button', { traverseInstances: true }); const label = labelNode.type === 'TEXT' ? labelNode.textContent : 'Button'; -export default { +export default defineFigmaTemplate({ example: iconOnly ? figma.code`` : showIcon @@ -43,4 +44,4 @@ export default { imports: ["import { DsButtonV3 } from '@drivenets/design-system'"], id: 'ds-button-v3', metadata: { nestable: true }, -}; +}); diff --git a/packages/design-system/src/components/ds-modal/figma/ds-modal-content.figma.ts b/packages/design-system/src/components/ds-modal/figma/ds-modal-content.figma.ts index d06317303..114a3ad6f 100644 --- a/packages/design-system/src/components/ds-modal/figma/ds-modal-content.figma.ts +++ b/packages/design-system/src/components/ds-modal/figma/ds-modal-content.figma.ts @@ -5,14 +5,15 @@ // `DAP_modal-content_v02` maps to `DsModal.Body`. Its freeform `Modal content slot` // becomes the body children. import figma from 'figma'; +import { defineFigmaTemplate } from '../../../utils/define-figma-template'; const instance = figma.selectedInstance; const content = instance.getSlot('Modal content slot'); -export default { +export default defineFigmaTemplate({ example: figma.code`${content}`, imports: ["import { DsModal } from '@drivenets/design-system'"], id: 'ds-modal-content', metadata: { nestable: true }, -}; +}); diff --git a/packages/design-system/src/components/ds-modal/figma/ds-modal-footer.figma.ts b/packages/design-system/src/components/ds-modal/figma/ds-modal-footer.figma.ts index 71fb4e4b1..15e49b006 100644 --- a/packages/design-system/src/components/ds-modal/figma/ds-modal-footer.figma.ts +++ b/packages/design-system/src/components/ds-modal/figma/ds-modal-footer.figma.ts @@ -6,14 +6,15 @@ // `right side buttons` slot resolves its `DAP_Button_v03` instances via the // existing `ds-button-v3` Code Connect. import figma from 'figma'; +import { defineFigmaTemplate } from '../../../utils/define-figma-template'; const instance = figma.selectedInstance; const rightButtons = instance.getSlot('right side buttons'); -export default { +export default defineFigmaTemplate({ example: figma.code`${rightButtons}`, imports: ["import { DsModal } from '@drivenets/design-system'"], id: 'ds-modal-footer', metadata: { nestable: true }, -}; +}); diff --git a/packages/design-system/src/components/ds-modal/figma/ds-modal-header.figma.ts b/packages/design-system/src/components/ds-modal/figma/ds-modal-header.figma.ts index 49db89d6f..d213983fc 100644 --- a/packages/design-system/src/components/ds-modal/figma/ds-modal-header.figma.ts +++ b/packages/design-system/src/components/ds-modal/figma/ds-modal-header.figma.ts @@ -7,15 +7,16 @@ // booleans (status badge, description, tags, etc.) have no code-component prop and // are omitted. import figma from 'figma'; +import { defineFigmaTemplate } from '../../../utils/define-figma-template'; const instance = figma.selectedInstance; const titleNode = instance.findText('Left side', { traverseInstances: true }); const title = titleNode.type === 'TEXT' ? titleNode.textContent : 'Modal title'; -export default { +export default defineFigmaTemplate({ example: figma.code`${title}`, imports: ["import { DsModal } from '@drivenets/design-system'"], id: 'ds-modal-header', metadata: { nestable: true }, -}; +}); diff --git a/packages/design-system/src/components/ds-modal/figma/ds-modal.figma.ts b/packages/design-system/src/components/ds-modal/figma/ds-modal.figma.ts index 6a427dda1..c8d120564 100644 --- a/packages/design-system/src/components/ds-modal/figma/ds-modal.figma.ts +++ b/packages/design-system/src/components/ds-modal/figma/ds-modal.figma.ts @@ -7,6 +7,7 @@ // so swapped variants stay in sync. The `Type` variant (confirmation/form) has no // `DsModal` prop equivalent — both render the same composition. import figma from 'figma'; +import { defineFigmaTemplate } from '../../../utils/define-figma-template'; const instance = figma.selectedInstance; @@ -28,9 +29,9 @@ if (footer.type === 'INSTANCE') { footerCode = footer.executeTemplate().example; } -export default { +export default defineFigmaTemplate({ example: figma.code` {}}>${headerCode}${contentCode}${footerCode}`, imports: ["import { DsModal } from '@drivenets/design-system'"], id: 'ds-modal', metadata: { nestable: false }, -}; +}); diff --git a/packages/design-system/src/components/ds-status-badge-v2/ds-status-badge-v2.figma.ts b/packages/design-system/src/components/ds-status-badge-v2/ds-status-badge-v2.figma.ts index 1b58e2763..c494140cd 100644 --- a/packages/design-system/src/components/ds-status-badge-v2/ds-status-badge-v2.figma.ts +++ b/packages/design-system/src/components/ds-status-badge-v2/ds-status-badge-v2.figma.ts @@ -2,6 +2,7 @@ // source=https://github.com/drivenets/design-system/tree/main/packages/design-system/src/components/ds-status-badge-v2 // component=DsStatusBadgeV2 import figma from 'figma'; +import { defineFigmaTemplate } from '../../utils/define-figma-template'; const instance = figma.selectedInstance; @@ -28,7 +29,7 @@ const structure = instance.getEnum('structure', { const labelNode = instance.findText('Active', { traverseInstances: true }); const label = labelNode.type === 'TEXT' ? labelNode.textContent : 'Active'; -export default { +export default defineFigmaTemplate({ example: structure === 'icon-only' ? figma.code`` @@ -38,4 +39,4 @@ export default { imports: ["import { DsStatusBadgeV2 } from '@drivenets/design-system'"], id: 'ds-status-badge-v2', metadata: { nestable: true }, -}; +}); diff --git a/packages/design-system/src/components/ds-text-input/ds-text-input.figma.ts b/packages/design-system/src/components/ds-text-input/ds-text-input.figma.ts index d16b166f2..aede7c6e7 100644 --- a/packages/design-system/src/components/ds-text-input/ds-text-input.figma.ts +++ b/packages/design-system/src/components/ds-text-input/ds-text-input.figma.ts @@ -8,6 +8,7 @@ // Password -> DsPasswordInput // Standard/Error/Read -> DsTextInput import figma from 'figma'; +import { defineFigmaTemplate } from '../../utils/define-figma-template'; const instance = figma.selectedInstance; @@ -41,7 +42,7 @@ const sizeAttr = size === 'small' ? 'size="small"' : ''; const componentName = type === 'number' ? 'DsNumberInput' : type === 'password' ? 'DsPasswordInput' : 'DsTextInput'; -export default { +export default defineFigmaTemplate({ example: type === 'number' ? figma.code`` @@ -51,4 +52,4 @@ export default { imports: [`import { ${componentName} } from '@drivenets/design-system'`], id: 'ds-text-input', metadata: { nestable: true }, -}; +}); diff --git a/packages/design-system/src/utils/define-figma-template.ts b/packages/design-system/src/utils/define-figma-template.ts new file mode 100644 index 000000000..8e6b30b7b --- /dev/null +++ b/packages/design-system/src/utils/define-figma-template.ts @@ -0,0 +1,18 @@ +import type figma from 'figma'; + +type FigmaTemplate = { + id: Id; + imports: [Import]; + example: figma.TemplateStringResult; + metadata?: Omit; +}; + +type Id = `ds-${string}`; + +type Import = `import { ${string} } from '@drivenets/design-system'`; + +// Internal function for typing Figma Code Connect templates. +// Temporary solution until https://github.com/figma/code-connect/issues/403 is resolved. +export function defineFigmaTemplate(template: T): T { + return template; +} From eae8bf54d7e7e7db68ef44b796aa59c4e2ad0a02 Mon Sep 17 00:00:00 2001 From: StyleShit <32631382+StyleShit@users.noreply.github.com> Date: Sun, 28 Jun 2026 08:39:37 +0300 Subject: [PATCH 2/4] wip --- .../ds-button-v3/ds-button-v3.figma.ts | 2 +- .../ds-card/figma/ds-card-content.figma.ts | 2 +- .../ds-card/figma/ds-card-footer.figma.ts | 2 +- .../ds-card/figma/ds-card-header.figma.ts | 2 +- .../components/ds-card/figma/ds-card.figma.ts | 2 +- .../ds-date-picker/ds-date-picker.figma.ts | 4 ++-- .../ds-form-control/ds-form-control.figma.ts | 2 +- .../ds-modal/figma/ds-modal-content.figma.ts | 5 ++--- .../ds-modal/figma/ds-modal-footer.figma.ts | 5 ++--- .../ds-modal/figma/ds-modal-header.figma.ts | 5 ++--- .../ds-modal/figma/ds-modal.figma.ts | 5 ++--- .../components/ds-select/ds-select.figma.ts | 2 +- .../ds-split-button/ds-split-button.figma.ts | 2 +- .../ds-status-badge-v2.figma.ts | 5 ++--- .../figma/ds-table-expandable.figma.ts | 2 +- .../ds-table/figma/ds-table.figma.ts | 2 +- .../ds-text-input/ds-text-input.figma.ts | 2 +- .../ds-time-picker/ds-time-picker.figma.ts | 4 ++-- .../src/utils/define-figma-template.ts | 18 ------------------ packages/design-system/tsconfig.json | 2 +- packages/design-system/types/figma.d.ts | 16 ++++++++++++++++ 21 files changed, 42 insertions(+), 49 deletions(-) delete mode 100644 packages/design-system/src/utils/define-figma-template.ts create mode 100644 packages/design-system/types/figma.d.ts diff --git a/packages/design-system/src/components/ds-button-v3/ds-button-v3.figma.ts b/packages/design-system/src/components/ds-button-v3/ds-button-v3.figma.ts index 9e1e4d7d3..7caaace48 100644 --- a/packages/design-system/src/components/ds-button-v3/ds-button-v3.figma.ts +++ b/packages/design-system/src/components/ds-button-v3/ds-button-v3.figma.ts @@ -96,4 +96,4 @@ export default { imports: ["import { DsButtonV3 } from '@drivenets/design-system'"], id: 'ds-button-v3', metadata: { nestable: true }, -}; +} satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-card/figma/ds-card-content.figma.ts b/packages/design-system/src/components/ds-card/figma/ds-card-content.figma.ts index a84634387..38c75f6e2 100644 --- a/packages/design-system/src/components/ds-card/figma/ds-card-content.figma.ts +++ b/packages/design-system/src/components/ds-card/figma/ds-card-content.figma.ts @@ -12,4 +12,4 @@ export default { imports: ["import { DsCard } from '@drivenets/design-system'"], id: 'ds-card-content', metadata: { nestable: true }, -}; +} satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-card/figma/ds-card-footer.figma.ts b/packages/design-system/src/components/ds-card/figma/ds-card-footer.figma.ts index f463b5870..efe51eb79 100644 --- a/packages/design-system/src/components/ds-card/figma/ds-card-footer.figma.ts +++ b/packages/design-system/src/components/ds-card/figma/ds-card-footer.figma.ts @@ -12,4 +12,4 @@ export default { imports: ["import { DsCard } from '@drivenets/design-system'"], id: 'ds-card-footer', metadata: { nestable: true }, -}; +} satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-card/figma/ds-card-header.figma.ts b/packages/design-system/src/components/ds-card/figma/ds-card-header.figma.ts index 9df45ea07..83d37e386 100644 --- a/packages/design-system/src/components/ds-card/figma/ds-card-header.figma.ts +++ b/packages/design-system/src/components/ds-card/figma/ds-card-header.figma.ts @@ -12,4 +12,4 @@ export default { imports: ["import { DsCard } from '@drivenets/design-system'"], id: 'ds-card-header', metadata: { nestable: true }, -}; +} satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-card/figma/ds-card.figma.ts b/packages/design-system/src/components/ds-card/figma/ds-card.figma.ts index 7417c5be9..44d31f99c 100644 --- a/packages/design-system/src/components/ds-card/figma/ds-card.figma.ts +++ b/packages/design-system/src/components/ds-card/figma/ds-card.figma.ts @@ -69,4 +69,4 @@ export default { imports: ["import { DsCard } from '@drivenets/design-system'"], id: 'ds-card', metadata: { nestable: false }, -}; +} satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-date-picker/ds-date-picker.figma.ts b/packages/design-system/src/components/ds-date-picker/ds-date-picker.figma.ts index 0529078f3..325ef5ae2 100644 --- a/packages/design-system/src/components/ds-date-picker/ds-date-picker.figma.ts +++ b/packages/design-system/src/components/ds-date-picker/ds-date-picker.figma.ts @@ -13,7 +13,7 @@ export default { example: figma.code`const [value, setValue] = useState(null); `, - imports: ["import { useState } from 'react'", "import { DsDatePicker } from '@drivenets/design-system'"], + imports: ["import { DsDatePicker } from '@drivenets/design-system'", "import { useState } from 'react'"], id: 'ds-date-picker', metadata: { nestable: true, props: { fcMember: 'DatePicker', fcProps: '' } }, -}; +} satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-form-control/ds-form-control.figma.ts b/packages/design-system/src/components/ds-form-control/ds-form-control.figma.ts index bd93164ed..c490bf4d6 100644 --- a/packages/design-system/src/components/ds-form-control/ds-form-control.figma.ts +++ b/packages/design-system/src/components/ds-form-control/ds-form-control.figma.ts @@ -73,4 +73,4 @@ export default { imports: ["import { DsFormControl } from '@drivenets/design-system'"], id: 'ds-form-control', metadata: { nestable: false }, -}; +} satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-modal/figma/ds-modal-content.figma.ts b/packages/design-system/src/components/ds-modal/figma/ds-modal-content.figma.ts index 114a3ad6f..d4dd53e1c 100644 --- a/packages/design-system/src/components/ds-modal/figma/ds-modal-content.figma.ts +++ b/packages/design-system/src/components/ds-modal/figma/ds-modal-content.figma.ts @@ -5,15 +5,14 @@ // `DAP_modal-content_v02` maps to `DsModal.Body`. Its freeform `Modal content slot` // becomes the body children. import figma from 'figma'; -import { defineFigmaTemplate } from '../../../utils/define-figma-template'; const instance = figma.selectedInstance; const content = instance.getSlot('Modal content slot'); -export default defineFigmaTemplate({ +export default { example: figma.code`${content}`, imports: ["import { DsModal } from '@drivenets/design-system'"], id: 'ds-modal-content', metadata: { nestable: true }, -}); +} satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-modal/figma/ds-modal-footer.figma.ts b/packages/design-system/src/components/ds-modal/figma/ds-modal-footer.figma.ts index 15e49b006..a4be6f663 100644 --- a/packages/design-system/src/components/ds-modal/figma/ds-modal-footer.figma.ts +++ b/packages/design-system/src/components/ds-modal/figma/ds-modal-footer.figma.ts @@ -6,15 +6,14 @@ // `right side buttons` slot resolves its `DAP_Button_v03` instances via the // existing `ds-button-v3` Code Connect. import figma from 'figma'; -import { defineFigmaTemplate } from '../../../utils/define-figma-template'; const instance = figma.selectedInstance; const rightButtons = instance.getSlot('right side buttons'); -export default defineFigmaTemplate({ +export default { example: figma.code`${rightButtons}`, imports: ["import { DsModal } from '@drivenets/design-system'"], id: 'ds-modal-footer', metadata: { nestable: true }, -}); +} satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-modal/figma/ds-modal-header.figma.ts b/packages/design-system/src/components/ds-modal/figma/ds-modal-header.figma.ts index d213983fc..ea72d0b41 100644 --- a/packages/design-system/src/components/ds-modal/figma/ds-modal-header.figma.ts +++ b/packages/design-system/src/components/ds-modal/figma/ds-modal-header.figma.ts @@ -7,16 +7,15 @@ // booleans (status badge, description, tags, etc.) have no code-component prop and // are omitted. import figma from 'figma'; -import { defineFigmaTemplate } from '../../../utils/define-figma-template'; const instance = figma.selectedInstance; const titleNode = instance.findText('Left side', { traverseInstances: true }); const title = titleNode.type === 'TEXT' ? titleNode.textContent : 'Modal title'; -export default defineFigmaTemplate({ +export default { example: figma.code`${title}`, imports: ["import { DsModal } from '@drivenets/design-system'"], id: 'ds-modal-header', metadata: { nestable: true }, -}); +} satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-modal/figma/ds-modal.figma.ts b/packages/design-system/src/components/ds-modal/figma/ds-modal.figma.ts index c8d120564..d58fd24a2 100644 --- a/packages/design-system/src/components/ds-modal/figma/ds-modal.figma.ts +++ b/packages/design-system/src/components/ds-modal/figma/ds-modal.figma.ts @@ -7,7 +7,6 @@ // so swapped variants stay in sync. The `Type` variant (confirmation/form) has no // `DsModal` prop equivalent — both render the same composition. import figma from 'figma'; -import { defineFigmaTemplate } from '../../../utils/define-figma-template'; const instance = figma.selectedInstance; @@ -29,9 +28,9 @@ if (footer.type === 'INSTANCE') { footerCode = footer.executeTemplate().example; } -export default defineFigmaTemplate({ +export default { example: figma.code` {}}>${headerCode}${contentCode}${footerCode}`, imports: ["import { DsModal } from '@drivenets/design-system'"], id: 'ds-modal', metadata: { nestable: false }, -}); +} satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-select/ds-select.figma.ts b/packages/design-system/src/components/ds-select/ds-select.figma.ts index ba0a9b45c..cfe690945 100644 --- a/packages/design-system/src/components/ds-select/ds-select.figma.ts +++ b/packages/design-system/src/components/ds-select/ds-select.figma.ts @@ -50,4 +50,4 @@ export default { imports: ["import { DsSelect } from '@drivenets/design-system'"], id: 'ds-select', metadata: { nestable: true, props: { fcMember: 'Select', fcProps: attrs } }, -}; +} satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-split-button/ds-split-button.figma.ts b/packages/design-system/src/components/ds-split-button/ds-split-button.figma.ts index 678d89048..516001e1f 100644 --- a/packages/design-system/src/components/ds-split-button/ds-split-button.figma.ts +++ b/packages/design-system/src/components/ds-split-button/ds-split-button.figma.ts @@ -92,4 +92,4 @@ export default { imports: ["import { DsSplitButton } from '@drivenets/design-system'"], id: 'ds-split-button', metadata: { nestable: false }, -}; +} satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-status-badge-v2/ds-status-badge-v2.figma.ts b/packages/design-system/src/components/ds-status-badge-v2/ds-status-badge-v2.figma.ts index c494140cd..fa9c6e0ef 100644 --- a/packages/design-system/src/components/ds-status-badge-v2/ds-status-badge-v2.figma.ts +++ b/packages/design-system/src/components/ds-status-badge-v2/ds-status-badge-v2.figma.ts @@ -2,7 +2,6 @@ // source=https://github.com/drivenets/design-system/tree/main/packages/design-system/src/components/ds-status-badge-v2 // component=DsStatusBadgeV2 import figma from 'figma'; -import { defineFigmaTemplate } from '../../utils/define-figma-template'; const instance = figma.selectedInstance; @@ -29,7 +28,7 @@ const structure = instance.getEnum('structure', { const labelNode = instance.findText('Active', { traverseInstances: true }); const label = labelNode.type === 'TEXT' ? labelNode.textContent : 'Active'; -export default defineFigmaTemplate({ +export default { example: structure === 'icon-only' ? figma.code`` @@ -39,4 +38,4 @@ export default defineFigmaTemplate({ imports: ["import { DsStatusBadgeV2 } from '@drivenets/design-system'"], id: 'ds-status-badge-v2', metadata: { nestable: true }, -}); +} satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-table/figma/ds-table-expandable.figma.ts b/packages/design-system/src/components/ds-table/figma/ds-table-expandable.figma.ts index 9b937b527..e7c761d77 100644 --- a/packages/design-system/src/components/ds-table/figma/ds-table-expandable.figma.ts +++ b/packages/design-system/src/components/ds-table/figma/ds-table-expandable.figma.ts @@ -14,4 +14,4 @@ export default { imports: ["import { DsTable } from '@drivenets/design-system'"], id: 'ds-table-expandable', metadata: { nestable: false }, -}; +} satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-table/figma/ds-table.figma.ts b/packages/design-system/src/components/ds-table/figma/ds-table.figma.ts index 7cca833c1..4df9bce42 100644 --- a/packages/design-system/src/components/ds-table/figma/ds-table.figma.ts +++ b/packages/design-system/src/components/ds-table/figma/ds-table.figma.ts @@ -13,4 +13,4 @@ export default { imports: ["import { DsTable } from '@drivenets/design-system'"], id: 'ds-table', metadata: { nestable: false }, -}; +} satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-text-input/ds-text-input.figma.ts b/packages/design-system/src/components/ds-text-input/ds-text-input.figma.ts index 263bbc964..bede0e161 100644 --- a/packages/design-system/src/components/ds-text-input/ds-text-input.figma.ts +++ b/packages/design-system/src/components/ds-text-input/ds-text-input.figma.ts @@ -57,4 +57,4 @@ export default { imports: [`import { ${componentName} } from '@drivenets/design-system'`], id: 'ds-text-input', metadata: { nestable: true, props: { fcMember, fcProps } }, -}; +} satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-time-picker/ds-time-picker.figma.ts b/packages/design-system/src/components/ds-time-picker/ds-time-picker.figma.ts index 102283b9a..1b5429f9e 100644 --- a/packages/design-system/src/components/ds-time-picker/ds-time-picker.figma.ts +++ b/packages/design-system/src/components/ds-time-picker/ds-time-picker.figma.ts @@ -12,7 +12,7 @@ export default { example: figma.code`const [value, setValue] = useState(null); `, - imports: ["import { useState } from 'react'", "import { DsTimePicker } from '@drivenets/design-system'"], + imports: ["import { DsTimePicker } from '@drivenets/design-system'", "import { useState } from 'react'"], id: 'ds-time-picker', metadata: { nestable: true, props: { fcMember: 'TimePicker', fcProps: '' } }, -}; +} satisfies figma.Template; diff --git a/packages/design-system/src/utils/define-figma-template.ts b/packages/design-system/src/utils/define-figma-template.ts deleted file mode 100644 index 8e6b30b7b..000000000 --- a/packages/design-system/src/utils/define-figma-template.ts +++ /dev/null @@ -1,18 +0,0 @@ -import type figma from 'figma'; - -type FigmaTemplate = { - id: Id; - imports: [Import]; - example: figma.TemplateStringResult; - metadata?: Omit; -}; - -type Id = `ds-${string}`; - -type Import = `import { ${string} } from '@drivenets/design-system'`; - -// Internal function for typing Figma Code Connect templates. -// Temporary solution until https://github.com/figma/code-connect/issues/403 is resolved. -export function defineFigmaTemplate(template: T): T { - return template; -} diff --git a/packages/design-system/tsconfig.json b/packages/design-system/tsconfig.json index 0a960c9a7..6d47a23a1 100644 --- a/packages/design-system/tsconfig.json +++ b/packages/design-system/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDirs": ["./", "./.scss-dts"], - "types": ["vite/client", "@figma/code-connect/figma-types"], + "types": ["vite/client", "@figma/code-connect/figma-types", "./types/figma.d.ts"], "plugins": [{ "name": "typescript-plugin-css-modules" }] }, "include": ["**/*", ".storybook/**/*"] diff --git a/packages/design-system/types/figma.d.ts b/packages/design-system/types/figma.d.ts new file mode 100644 index 000000000..b75db6525 --- /dev/null +++ b/packages/design-system/types/figma.d.ts @@ -0,0 +1,16 @@ +import type figma from 'figma'; + +// Internal type for Figma Code Connect templates. +// Temporary solution until https://github.com/figma/code-connect/issues/403 is resolved. +declare module 'figma' { + export interface Template { + id: Id; + imports: [DsImport, ...string[]]; + example: figma.TemplateStringResult; + metadata?: Omit; + } + + type Id = `ds-${string}`; + + type DsImport = `import { ${string} } from '@drivenets/design-system'`; +} From 513816164b2993a80b7f6d298f0cc026c281d8bb Mon Sep 17 00:00:00 2001 From: StyleShit <32631382+StyleShit@users.noreply.github.com> Date: Sun, 28 Jun 2026 08:42:04 +0300 Subject: [PATCH 3/4] wip --- .../src/components/ds-button-v3/ds-button-v3.figma.ts | 2 +- .../src/components/ds-card/figma/ds-card-content.figma.ts | 2 +- .../src/components/ds-card/figma/ds-card-footer.figma.ts | 2 +- .../src/components/ds-card/figma/ds-card-header.figma.ts | 2 +- .../src/components/ds-card/figma/ds-card.figma.ts | 2 +- .../src/components/ds-date-picker/ds-date-picker.figma.ts | 2 +- .../src/components/ds-form-control/ds-form-control.figma.ts | 2 +- .../ds-icon/figma/ds-icon-material.figma.batch.ts | 2 +- .../components/ds-icon/figma/ds-icon-special.figma.batch.ts | 2 +- .../src/components/ds-modal/figma/ds-modal-content.figma.ts | 2 +- .../src/components/ds-modal/figma/ds-modal-footer.figma.ts | 2 +- .../src/components/ds-modal/figma/ds-modal-header.figma.ts | 2 +- .../src/components/ds-modal/figma/ds-modal.figma.ts | 2 +- .../src/components/ds-select/ds-select.figma.ts | 2 +- .../src/components/ds-split-button/ds-split-button.figma.ts | 2 +- .../ds-status-badge-v2/ds-status-badge-v2.figma.ts | 2 +- .../components/ds-table/figma/ds-table-expandable.figma.ts | 2 +- .../src/components/ds-table/figma/ds-table.figma.ts | 2 +- .../src/components/ds-text-input/ds-text-input.figma.ts | 2 +- .../src/components/ds-time-picker/ds-time-picker.figma.ts | 2 +- packages/design-system/types/figma.d.ts | 6 ++++-- 21 files changed, 24 insertions(+), 22 deletions(-) diff --git a/packages/design-system/src/components/ds-button-v3/ds-button-v3.figma.ts b/packages/design-system/src/components/ds-button-v3/ds-button-v3.figma.ts index 7caaace48..9f1cb9bdc 100644 --- a/packages/design-system/src/components/ds-button-v3/ds-button-v3.figma.ts +++ b/packages/design-system/src/components/ds-button-v3/ds-button-v3.figma.ts @@ -93,7 +93,7 @@ export default { : showIcon && icon ? figma.code`${label}` : figma.code`${label}`, - imports: ["import { DsButtonV3 } from '@drivenets/design-system'"], + imports: ["import { DsButtonV3 } from '@drivenets/design-system';"], id: 'ds-button-v3', metadata: { nestable: true }, } satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-card/figma/ds-card-content.figma.ts b/packages/design-system/src/components/ds-card/figma/ds-card-content.figma.ts index 38c75f6e2..639b59685 100644 --- a/packages/design-system/src/components/ds-card/figma/ds-card-content.figma.ts +++ b/packages/design-system/src/components/ds-card/figma/ds-card-content.figma.ts @@ -9,7 +9,7 @@ import figma from 'figma'; export default { example: figma.code`Card content`, - imports: ["import { DsCard } from '@drivenets/design-system'"], + imports: ["import { DsCard } from '@drivenets/design-system';"], id: 'ds-card-content', metadata: { nestable: true }, } satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-card/figma/ds-card-footer.figma.ts b/packages/design-system/src/components/ds-card/figma/ds-card-footer.figma.ts index efe51eb79..fc51e0ba1 100644 --- a/packages/design-system/src/components/ds-card/figma/ds-card-footer.figma.ts +++ b/packages/design-system/src/components/ds-card/figma/ds-card-footer.figma.ts @@ -9,7 +9,7 @@ import figma from 'figma'; export default { example: figma.code`Card footer`, - imports: ["import { DsCard } from '@drivenets/design-system'"], + imports: ["import { DsCard } from '@drivenets/design-system';"], id: 'ds-card-footer', metadata: { nestable: true }, } satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-card/figma/ds-card-header.figma.ts b/packages/design-system/src/components/ds-card/figma/ds-card-header.figma.ts index 83d37e386..80e917379 100644 --- a/packages/design-system/src/components/ds-card/figma/ds-card-header.figma.ts +++ b/packages/design-system/src/components/ds-card/figma/ds-card-header.figma.ts @@ -9,7 +9,7 @@ import figma from 'figma'; export default { example: figma.code`Card title`, - imports: ["import { DsCard } from '@drivenets/design-system'"], + imports: ["import { DsCard } from '@drivenets/design-system';"], id: 'ds-card-header', metadata: { nestable: true }, } satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-card/figma/ds-card.figma.ts b/packages/design-system/src/components/ds-card/figma/ds-card.figma.ts index 44d31f99c..89f1bb004 100644 --- a/packages/design-system/src/components/ds-card/figma/ds-card.figma.ts +++ b/packages/design-system/src/components/ds-card/figma/ds-card.figma.ts @@ -66,7 +66,7 @@ if (footer.type === 'INSTANCE') { export default { example: figma.code`${headerCode}${contentCode}${footerCode}`, - imports: ["import { DsCard } from '@drivenets/design-system'"], + imports: ["import { DsCard } from '@drivenets/design-system';"], id: 'ds-card', metadata: { nestable: false }, } satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-date-picker/ds-date-picker.figma.ts b/packages/design-system/src/components/ds-date-picker/ds-date-picker.figma.ts index 325ef5ae2..d3a6e774b 100644 --- a/packages/design-system/src/components/ds-date-picker/ds-date-picker.figma.ts +++ b/packages/design-system/src/components/ds-date-picker/ds-date-picker.figma.ts @@ -13,7 +13,7 @@ export default { example: figma.code`const [value, setValue] = useState(null); `, - imports: ["import { DsDatePicker } from '@drivenets/design-system'", "import { useState } from 'react'"], + imports: ["import { DsDatePicker } from '@drivenets/design-system';", "import { useState } from 'react';"], id: 'ds-date-picker', metadata: { nestable: true, props: { fcMember: 'DatePicker', fcProps: '' } }, } satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-form-control/ds-form-control.figma.ts b/packages/design-system/src/components/ds-form-control/ds-form-control.figma.ts index c490bf4d6..ff59228fe 100644 --- a/packages/design-system/src/components/ds-form-control/ds-form-control.figma.ts +++ b/packages/design-system/src/components/ds-form-control/ds-form-control.figma.ts @@ -70,7 +70,7 @@ const formControlAttrs = [labelAttr, requiredAttr, hideLabelAttr, statusAttr, me export default { example: figma.code`${description}${child}`, - imports: ["import { DsFormControl } from '@drivenets/design-system'"], + imports: ["import { DsFormControl } from '@drivenets/design-system';"], id: 'ds-form-control', metadata: { nestable: false }, } satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-icon/figma/ds-icon-material.figma.batch.ts b/packages/design-system/src/components/ds-icon/figma/ds-icon-material.figma.batch.ts index 3a723f74c..614f466a4 100644 --- a/packages/design-system/src/components/ds-icon/figma/ds-icon-material.figma.batch.ts +++ b/packages/design-system/src/components/ds-icon/figma/ds-icon-material.figma.batch.ts @@ -4,7 +4,7 @@ const batch = figma.batch as { icon: string; filled: boolean; id: string }; export default { example: figma.code``, - imports: ["import { DsIcon } from '@drivenets/design-system'"], + imports: ["import { DsIcon } from '@drivenets/design-system';"], id: batch.id, metadata: { nestable: true, props: { icon: batch.icon } }, }; diff --git a/packages/design-system/src/components/ds-icon/figma/ds-icon-special.figma.batch.ts b/packages/design-system/src/components/ds-icon/figma/ds-icon-special.figma.batch.ts index 27e8758be..4684c7245 100644 --- a/packages/design-system/src/components/ds-icon/figma/ds-icon-special.figma.batch.ts +++ b/packages/design-system/src/components/ds-icon/figma/ds-icon-special.figma.batch.ts @@ -12,7 +12,7 @@ export default { example: icon ? figma.code`` : figma.code`{/* This icon is not available in @drivenets/design-system */}`, - imports: ["import { DsIcon } from '@drivenets/design-system'"], + imports: ["import { DsIcon } from '@drivenets/design-system';"], id: batch.id, metadata: { nestable: true, props: { icon } }, }; diff --git a/packages/design-system/src/components/ds-modal/figma/ds-modal-content.figma.ts b/packages/design-system/src/components/ds-modal/figma/ds-modal-content.figma.ts index d4dd53e1c..97a00a078 100644 --- a/packages/design-system/src/components/ds-modal/figma/ds-modal-content.figma.ts +++ b/packages/design-system/src/components/ds-modal/figma/ds-modal-content.figma.ts @@ -12,7 +12,7 @@ const content = instance.getSlot('Modal content slot'); export default { example: figma.code`${content}`, - imports: ["import { DsModal } from '@drivenets/design-system'"], + imports: ["import { DsModal } from '@drivenets/design-system';"], id: 'ds-modal-content', metadata: { nestable: true }, } satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-modal/figma/ds-modal-footer.figma.ts b/packages/design-system/src/components/ds-modal/figma/ds-modal-footer.figma.ts index a4be6f663..834ea62b7 100644 --- a/packages/design-system/src/components/ds-modal/figma/ds-modal-footer.figma.ts +++ b/packages/design-system/src/components/ds-modal/figma/ds-modal-footer.figma.ts @@ -13,7 +13,7 @@ const rightButtons = instance.getSlot('right side buttons'); export default { example: figma.code`${rightButtons}`, - imports: ["import { DsModal } from '@drivenets/design-system'"], + imports: ["import { DsModal } from '@drivenets/design-system';"], id: 'ds-modal-footer', metadata: { nestable: true }, } satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-modal/figma/ds-modal-header.figma.ts b/packages/design-system/src/components/ds-modal/figma/ds-modal-header.figma.ts index ea72d0b41..dae07279e 100644 --- a/packages/design-system/src/components/ds-modal/figma/ds-modal-header.figma.ts +++ b/packages/design-system/src/components/ds-modal/figma/ds-modal-header.figma.ts @@ -15,7 +15,7 @@ const title = titleNode.type === 'TEXT' ? titleNode.textContent : 'Modal title'; export default { example: figma.code`${title}`, - imports: ["import { DsModal } from '@drivenets/design-system'"], + imports: ["import { DsModal } from '@drivenets/design-system';"], id: 'ds-modal-header', metadata: { nestable: true }, } satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-modal/figma/ds-modal.figma.ts b/packages/design-system/src/components/ds-modal/figma/ds-modal.figma.ts index d58fd24a2..3d5c7c69a 100644 --- a/packages/design-system/src/components/ds-modal/figma/ds-modal.figma.ts +++ b/packages/design-system/src/components/ds-modal/figma/ds-modal.figma.ts @@ -30,7 +30,7 @@ if (footer.type === 'INSTANCE') { export default { example: figma.code` {}}>${headerCode}${contentCode}${footerCode}`, - imports: ["import { DsModal } from '@drivenets/design-system'"], + imports: ["import { DsModal } from '@drivenets/design-system';"], id: 'ds-modal', metadata: { nestable: false }, } satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-select/ds-select.figma.ts b/packages/design-system/src/components/ds-select/ds-select.figma.ts index cfe690945..798468c2a 100644 --- a/packages/design-system/src/components/ds-select/ds-select.figma.ts +++ b/packages/design-system/src/components/ds-select/ds-select.figma.ts @@ -47,7 +47,7 @@ const attrs = [ export default { example: figma.code``, - imports: ["import { DsSelect } from '@drivenets/design-system'"], + imports: ["import { DsSelect } from '@drivenets/design-system';"], id: 'ds-select', metadata: { nestable: true, props: { fcMember: 'Select', fcProps: attrs } }, } satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-split-button/ds-split-button.figma.ts b/packages/design-system/src/components/ds-split-button/ds-split-button.figma.ts index 516001e1f..13156be1c 100644 --- a/packages/design-system/src/components/ds-split-button/ds-split-button.figma.ts +++ b/packages/design-system/src/components/ds-split-button/ds-split-button.figma.ts @@ -89,7 +89,7 @@ const buttonProps = [ export default { example: figma.code``, - imports: ["import { DsSplitButton } from '@drivenets/design-system'"], + imports: ["import { DsSplitButton } from '@drivenets/design-system';"], id: 'ds-split-button', metadata: { nestable: false }, } satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-status-badge-v2/ds-status-badge-v2.figma.ts b/packages/design-system/src/components/ds-status-badge-v2/ds-status-badge-v2.figma.ts index fa9c6e0ef..a9141149e 100644 --- a/packages/design-system/src/components/ds-status-badge-v2/ds-status-badge-v2.figma.ts +++ b/packages/design-system/src/components/ds-status-badge-v2/ds-status-badge-v2.figma.ts @@ -35,7 +35,7 @@ export default { : structure === 'text-only' ? figma.code`` : figma.code``, - imports: ["import { DsStatusBadgeV2 } from '@drivenets/design-system'"], + imports: ["import { DsStatusBadgeV2 } from '@drivenets/design-system';"], id: 'ds-status-badge-v2', metadata: { nestable: true }, } satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-table/figma/ds-table-expandable.figma.ts b/packages/design-system/src/components/ds-table/figma/ds-table-expandable.figma.ts index e7c761d77..82c38109b 100644 --- a/packages/design-system/src/components/ds-table/figma/ds-table-expandable.figma.ts +++ b/packages/design-system/src/components/ds-table/figma/ds-table-expandable.figma.ts @@ -11,7 +11,7 @@ import figma from 'figma'; export default { example: figma.code` null} />`, - imports: ["import { DsTable } from '@drivenets/design-system'"], + imports: ["import { DsTable } from '@drivenets/design-system';"], id: 'ds-table-expandable', metadata: { nestable: false }, } satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-table/figma/ds-table.figma.ts b/packages/design-system/src/components/ds-table/figma/ds-table.figma.ts index 4df9bce42..1ebfd96dc 100644 --- a/packages/design-system/src/components/ds-table/figma/ds-table.figma.ts +++ b/packages/design-system/src/components/ds-table/figma/ds-table.figma.ts @@ -10,7 +10,7 @@ import figma from 'figma'; export default { example: figma.code``, - imports: ["import { DsTable } from '@drivenets/design-system'"], + imports: ["import { DsTable } from '@drivenets/design-system';"], id: 'ds-table', metadata: { nestable: false }, } satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-text-input/ds-text-input.figma.ts b/packages/design-system/src/components/ds-text-input/ds-text-input.figma.ts index bede0e161..88c32cf7f 100644 --- a/packages/design-system/src/components/ds-text-input/ds-text-input.figma.ts +++ b/packages/design-system/src/components/ds-text-input/ds-text-input.figma.ts @@ -54,7 +54,7 @@ export default { : type === 'password' ? figma.code`` : figma.code``, - imports: [`import { ${componentName} } from '@drivenets/design-system'`], + imports: [`import { ${componentName} } from '@drivenets/design-system';`], id: 'ds-text-input', metadata: { nestable: true, props: { fcMember, fcProps } }, } satisfies figma.Template; diff --git a/packages/design-system/src/components/ds-time-picker/ds-time-picker.figma.ts b/packages/design-system/src/components/ds-time-picker/ds-time-picker.figma.ts index 1b5429f9e..25838783c 100644 --- a/packages/design-system/src/components/ds-time-picker/ds-time-picker.figma.ts +++ b/packages/design-system/src/components/ds-time-picker/ds-time-picker.figma.ts @@ -12,7 +12,7 @@ export default { example: figma.code`const [value, setValue] = useState(null); `, - imports: ["import { DsTimePicker } from '@drivenets/design-system'", "import { useState } from 'react'"], + imports: ["import { DsTimePicker } from '@drivenets/design-system';", "import { useState } from 'react';"], id: 'ds-time-picker', metadata: { nestable: true, props: { fcMember: 'TimePicker', fcProps: '' } }, } satisfies figma.Template; diff --git a/packages/design-system/types/figma.d.ts b/packages/design-system/types/figma.d.ts index b75db6525..3e82b5e5a 100644 --- a/packages/design-system/types/figma.d.ts +++ b/packages/design-system/types/figma.d.ts @@ -5,12 +5,14 @@ import type figma from 'figma'; declare module 'figma' { export interface Template { id: Id; - imports: [DsImport, ...string[]]; + imports: [DsImport, ...AnyImport[]]; example: figma.TemplateStringResult; metadata?: Omit; } type Id = `ds-${string}`; - type DsImport = `import { ${string} } from '@drivenets/design-system'`; + type DsImport = `import { ${string} } from '@drivenets/design-system';`; + + type AnyImport = `import ${string} from '${string}';`; } From 128bc6e6e559283b5bf141b79182a5f40a9bb7e4 Mon Sep 17 00:00:00 2001 From: StyleShit <32631382+StyleShit@users.noreply.github.com> Date: Sun, 28 Jun 2026 08:58:38 +0300 Subject: [PATCH 4/4] wip --- knip.json | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/knip.json b/knip.json index 196a6b684..64163e747 100644 --- a/knip.json +++ b/knip.json @@ -1,10 +1,11 @@ { "$schema": "https://unpkg.com/knip@5/schema.json", "ignore": [ - "**/*.figma.ts", - "**/*.figma.batch.ts", - "**/*.scss", - "**/simple-file-upload-adapter.ts", + "./packages/design-system/**/*.scss", + "./packages/design-system/**/*.figma.ts", + "./packages/design-system/**/*.figma.batch.ts", + "./packages/design-system/types/**/figma.d.ts", + "./packages/design-system/src/components/ds-file-upload/stories/adapters/simple-file-upload-adapter.ts", "./packages/eslint-plugin-internal/src/rules/__tests__/fixtures/*.ts" ], "ignoreExportsUsedInFile": {