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": { 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..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 a84634387..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 f463b5870..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 9df45ea07..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 7417c5be9..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 0529078f3..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 { 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..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 d06317303..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 71fb4e4b1..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 49db89d6f..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 6a427dda1..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 ba0a9b45c..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 678d89048..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 1b58e2763..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 9b937b527..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 7cca833c1..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 263bbc964..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 102283b9a..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 { 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/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..3e82b5e5a --- /dev/null +++ b/packages/design-system/types/figma.d.ts @@ -0,0 +1,18 @@ +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, ...AnyImport[]]; + example: figma.TemplateStringResult; + metadata?: Omit; + } + + type Id = `ds-${string}`; + + type DsImport = `import { ${string} } from '@drivenets/design-system';`; + + type AnyImport = `import ${string} from '${string}';`; +}