@knapsack/types 5.0.0--canary.6593.4738696.0 → 5.0.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.
- package/.lintstagedrc.mjs +2 -2
- package/CHANGELOG.md +174 -0
- package/convert-types-to-json-schemas.ts +3 -1
- package/dist/acd-test-fixtures/empty.d.ts +1 -1
- package/dist/acd-test-fixtures/empty.d.ts.map +1 -1
- package/dist/acd-test-fixtures/index.js.map +1 -1
- package/dist/acd-test-fixtures/index.mjs.map +1 -1
- package/dist/api-routes.js.map +1 -1
- package/dist/api-routes.mjs.map +1 -1
- package/dist/app-client-data/blocks.d.ts +2 -1
- package/dist/app-client-data/blocks.d.ts.map +1 -1
- package/dist/app-client-data/blocks.settings.d.ts +2 -2
- package/dist/app-client-data/blocks.settings.d.ts.map +1 -1
- package/dist/app-client-data/design-tokens-types/token-data.d.ts +7 -7
- package/dist/app-client-data/design-tokens-types/token-data.d.ts.map +1 -1
- package/dist/app-client-data/design-tokens-types/token-definitions.d.ts.map +1 -1
- package/dist/app-client-data/design-tokens-types/token-src-value-info.d.ts +2 -2
- package/dist/app-client-data/design-tokens-types/token-src-value-info.d.ts.map +1 -1
- package/dist/app-client-data/design-tokens-types/token-src.d.ts +3 -3
- package/dist/app-client-data/design-tokens-types/token-src.d.ts.map +1 -1
- package/dist/app-client-data/index.d.ts +14 -6
- package/dist/app-client-data/index.d.ts.map +1 -1
- package/dist/app-client-data/page.d.ts +0 -6
- package/dist/app-client-data/page.d.ts.map +1 -1
- package/dist/app-client-data/page.header.d.ts +1 -1
- package/dist/app-client-data/page.header.d.ts.map +1 -1
- package/dist/app-client-data/patterns.d.ts +74 -0
- package/dist/app-client-data/patterns.d.ts.map +1 -1
- package/dist/app-client-data/types-to-json-schemas.d.ts.map +1 -1
- package/dist/app-client-data/validation.test.d.ts +2 -0
- package/dist/app-client-data/validation.test.d.ts.map +1 -0
- package/dist/app-client-data-migrations/4.1.7-demos.d.ts.map +1 -1
- package/dist/app-client-data-migrations/migration.types.d.ts +1 -1
- package/dist/app-client-data-migrations/migration.types.d.ts.map +1 -1
- package/dist/app-client-data-v3/index.d.ts +1 -1
- package/dist/app-client-data-v3/index.d.ts.map +1 -1
- package/dist/app-client-data-v3/page.header.d.ts +1 -1
- package/dist/app-client-data-v3/page.header.d.ts.map +1 -1
- package/dist/app-client-data-v3/types-to-json-schemas.d.ts.map +1 -1
- package/dist/app-sections.d.ts +2 -1
- package/dist/app-sections.d.ts.map +1 -1
- package/dist/app-sections.js +1 -1
- package/dist/app-sections.js.map +1 -1
- package/dist/app-sections.mjs +1 -1
- package/dist/app-sections.mjs.map +1 -1
- package/dist/changes.js.map +1 -1
- package/dist/changes.mjs.map +1 -1
- package/dist/color-config.d.ts +1 -1
- package/dist/color-config.d.ts.map +1 -1
- package/dist/color-config.js +1 -1
- package/dist/color-config.js.map +1 -1
- package/dist/color-config.mjs +1 -1
- package/dist/color-config.mjs.map +1 -1
- package/dist/e2e-session-config.d.ts +20 -0
- package/dist/e2e-session-config.d.ts.map +1 -0
- package/dist/e2e-session-config.js +2 -0
- package/dist/e2e-session-config.js.map +1 -0
- package/dist/e2e-session-config.mjs +2 -0
- package/dist/e2e-session-config.mjs.map +1 -0
- package/dist/git-providers.js.map +1 -1
- package/dist/git-providers.mjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/intercepts.d.ts +1 -1
- package/dist/intercepts.d.ts.map +1 -1
- package/dist/json-schema.js.map +1 -1
- package/dist/json-schema.mjs.map +1 -1
- package/dist/misc.d.ts +2 -2
- package/dist/misc.d.ts.map +1 -1
- package/dist/nav-customization-config.d.ts +3 -3
- package/dist/nav-customization-config.d.ts.map +1 -1
- package/dist/nav-customization-config.js +1 -1
- package/dist/nav-customization-config.js.map +1 -1
- package/dist/nav-customization-config.mjs +1 -1
- package/dist/nav-customization-config.mjs.map +1 -1
- package/dist/renderer-client-types.js.map +1 -1
- package/dist/renderer-client-types.mjs.map +1 -1
- package/dist/renderers.d.ts +28 -0
- package/dist/renderers.d.ts.map +1 -1
- package/dist/renderers.js +1 -1
- package/dist/renderers.js.map +1 -1
- package/dist/renderers.mjs +1 -1
- package/dist/renderers.mjs.map +1 -1
- package/dist/renderers.test.d.ts +2 -0
- package/dist/renderers.test.d.ts.map +1 -0
- package/dist/typography-config.d.ts +2 -2
- package/dist/typography-config.d.ts.map +1 -1
- package/dist/typography-config.js +1 -1
- package/dist/typography-config.js.map +1 -1
- package/dist/typography-config.mjs +1 -1
- package/dist/typography-config.mjs.map +1 -1
- package/dist/ui-config.d.ts +5 -5
- package/dist/ui-config.d.ts.map +1 -1
- package/dist/ui-config.js +1 -1
- package/dist/ui-config.js.map +1 -1
- package/dist/ui-config.mjs +1 -1
- package/dist/ui-config.mjs.map +1 -1
- package/dist/user-roles.d.ts +1 -0
- package/dist/user-roles.d.ts.map +1 -1
- package/dist/user-roles.js +1 -1
- package/dist/user-roles.js.map +1 -1
- package/dist/user-roles.mjs +1 -1
- package/dist/user-roles.mjs.map +1 -1
- package/dist/web-sockets.js.map +1 -1
- package/dist/web-sockets.mjs.map +1 -1
- package/package.json +16 -18
- package/vitest.config.mjs +1 -2
- package/.eslintrc.js +0 -6
- package/ava.config.cjs +0 -3
- package/dist/app-client-data/validation.vtest.d.ts +0 -2
- package/dist/app-client-data/validation.vtest.d.ts.map +0 -1
- package/dist/cypress-session-config.d.ts +0 -20
- package/dist/cypress-session-config.d.ts.map +0 -1
- package/dist/cypress-session-config.js +0 -2
- package/dist/cypress-session-config.js.map +0 -1
- package/dist/cypress-session-config.mjs +0 -2
- package/dist/cypress-session-config.mjs.map +0 -1
- package/dist/renderers.vitest.d.ts +0 -2
- package/dist/renderers.vitest.d.ts.map +0 -1
- package/dist/renderers.vitest.js +0 -451
- package/dist/renderers.vitest.js.map +0 -1
- package/dist/renderers.vitest.mjs +0 -451
- package/dist/renderers.vitest.mjs.map +0 -1
package/dist/renderers.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/renderers.ts"],"names":["rendererIds","CodeSrcUserConfigSchema","z","val","isTemplateInfoWithCodeSrcPath","info","__name","createTemplateInfoId","t","addIdToTemplateInfo","normalizeTemplateInfo","rendererId","alias","path","convertTemplateInfoToOldWay"],"mappings":"oBAAA,IAAA,CAAA,CAAA,MAAA,CAAA,cAAA,CAAA,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA,CAAA,CAAA,CAAA,MAAA,CAAA,CAAA,KAAA,CAAA,CAAA,CAAA,YAAA,CAAA,IAAA,CAAA,CAAA,CAgBO,IAAMA,EAAc,CACzB,KAAA,CAAO,OACP,CAAA,GAAA,CAAK,MACL,gBAAkB,CAAA,gBAAA,CAClB,IAAM,CAAA,MAAA,CACN,IAAK,KACL,CAAA,OAAA,CAAS,SACT,CAAA,IAAA,CAAM,MACR,CAAA,CAuCaC,CAA0BC,CAAAA,CAAAA,CAAE,aAAa,CACpD,IAAA,CAAMA,CACH,CAAA,MAAA,GACA,QACC,CAAA,gGACF,CACF,CAAA,MAAA,CAAQA,EACL,MAAmCC,CAAAA,CAAAA,EAC3B,OAAOA,CAAAA,EAAQ,UACvB,CAAA,CACA,QAAS,EAAA,CACT,SAAS,oDAAoD,CAClE,CAAC,EA4DM,SAASC,CACdC,CAAAA,CAAAA,CACqC,CACrC,OAAO,gBAAiBA,CAC1B,CAJgBC,CAAAF,CAAAA,CAAAA,CAAA,iCAWT,SAASG,CAAAA,CAAqBC,CAAiC,CAAA,CACpE,OAAQA,CAAE,CAAA,UAAA,EACR,KAAK,UACL,KAAK,OAAA,CACH,OAAO,CAAA,EAAGA,EAAE,UAAU,CAAA,GAAA,EAAMA,CAAE,CAAA,WAAW,CACvCA,GAAAA,EAAAA,CAAAA,CAAE,UAAc,EAAA,SAClB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M,CAAwBD,qBAAAA,EAAAA,CAAU,EAAE,CACtD,CACF,CACF,CAAA,GAGF,CA3CgBL,CAAAI,CAAAA,CAAAA,CAAA,yBA0DT,SAASI,CAAAA,CAA4BT,CAG1C,CAAA,CACA,OAAQA,CAAK,CAAA,UAAA,EACX,KAAK,QACL,KAAK,SAAA,CACH,OAAO,CACL,IAAMA,CAAAA,CAAAA,CAAK,WACX,CAAA,KAAA,CAAOA,EAAK,UACd,CAAA,CACF,KAAK,KAAA,CACL,KAAK,MACL,CAAA,KAAK,KACH,CAAA,OAAO,CACL,IAAMA,CAAAA,CAAAA,CAAK,WACb,CAAA,CACF,KAAK,MAAA,CACH,OAAO,CACL,MAAOA,CAAK,CAAA,aACd,CACF,CAAA,KAAK,iBACH,OAAO,CACL,KAAOA,CAAAA,CAAAA,CAAK,WACd,CACF,CAAA,QAAS,CAEP,MAAM,IAAI,KAAA,CAAM,0BAA0B,IAAK,CAAA,SAAA,CAAUA,CAAI,CAAC,EAAE,CAClE,CACF,CACF,CA9BgBC,EAAAQ,CAAA,CAAA,6BAAA,CAAA","file":"renderers.mjs","sourcesContent":["import { z } from 'zod';\nimport type {\n PathPackage,\n PathPackageSubPath,\n PathRelative,\n Branded,\n} from './re-exports';\nimport type {\n KnapsackPatternTemplate,\n TemplateDemo,\n TemplateRendererMeta,\n KsSpecMeta,\n KsTemplateSpec,\n} from './app-client-data/patterns';\nimport type { Simplify } from './type-utils';\n\nexport const rendererIds = {\n react: 'react',\n vue: 'vue',\n 'web-components': 'web-components',\n twig: 'twig',\n hbs: 'hbs',\n angular: 'angular',\n html: 'html',\n} as const;\n\n/**\n * The ID of a renderer, e.g. 'react', 'vue', 'angular', etc.\n * On Pattern Templates, this will match up to `templateLanguageId` to identify which renderer to use.\n * @see {KnapsackPatternTemplate['templateLanguageId']}\n */\nexport type RendererId = keyof typeof rendererIds;\nexport type CodeSrc =\n | {\n type: 'package';\n path: PathPackage;\n pathFromOutputDir: PathPackage;\n pkgName: PathPackage;\n rendererId: RendererId;\n }\n | {\n type: 'package-sub-path';\n path: PathPackageSubPath;\n pathFromOutputDir: PathPackageSubPath;\n pkgName: PathPackage;\n subPath: PathRelative;\n rendererId: RendererId;\n }\n | {\n type: 'relative-from-data-dir';\n rendererId: RendererId;\n path: PathRelative;\n pathFromOutputDir: PathRelative;\n };\n\nexport type CodeSrcUserConfig = {\n /**\n * Can contain glob patterns, relative paths, absolute paths, package paths, or package sub-paths\n */\n path: string;\n filter?: (path: string) => boolean;\n};\n\nexport const CodeSrcUserConfigSchema = z.strictObject({\n path: z\n .string()\n .describe(\n 'Can contain glob patterns, relative paths, absolute paths, package paths, or package sub-paths',\n ),\n filter: z\n .custom<(path: string) => boolean>((val) => {\n return typeof val === 'function';\n })\n .optional()\n .describe('A function that takes a path and returns a boolean'),\n});\n\nexport type TemplateInfoId = Branded<string, 'TemplateInfoId'>;\n\nexport type TemplateInfo<TheRendererId extends RendererId = RendererId> =\n Extract<\n | {\n rendererId: 'react';\n codeSrcPath: CodeSrc['path'];\n /**\n * Name of the export. If it's the default export, this will be `'default'`.\n */\n exportName: string;\n }\n | {\n rendererId: 'vue';\n codeSrcPath: CodeSrc['path'];\n }\n | {\n rendererId: 'web-components';\n elementName: string;\n }\n | {\n rendererId: 'angular';\n codeSrcPath: CodeSrc['path'];\n /**\n * Name of the export. If it's the default export, this will be `'default'`.\n */\n exportName: string;\n }\n | {\n rendererId: 'html';\n codeSrcPath: CodeSrc['path'];\n }\n | {\n rendererId: 'twig';\n namespacePath: string;\n }\n | {\n rendererId: 'hbs';\n codeSrcPath: CodeSrc['path'];\n },\n { rendererId: TheRendererId }\n >;\n\nexport type TemplateInfoWithId<TheRendererId extends RendererId = RendererId> =\n Extract<\n Simplify<\n TemplateInfo<TheRendererId> & {\n id: TemplateInfoId;\n }\n >,\n { rendererId: TheRendererId }\n >;\n\nexport type TemplateInfoWithCodeSrcPath = Extract<\n TemplateInfo,\n { codeSrcPath: string }\n>;\n\nexport function isTemplateInfoWithCodeSrcPath(\n info: TemplateInfo,\n): info is TemplateInfoWithCodeSrcPath {\n return 'codeSrcPath' in info;\n}\n\n/**\n * Create a unique ID for a template info\n * This is used to identify the template info by a single unique string\n * @returns A unique ID for the template info\n */\nexport function createTemplateInfoId(t: TemplateInfo): TemplateInfoId {\n switch (t.rendererId) {\n case 'angular':\n case 'react':\n return `${t.rendererId}---${t.codeSrcPath}---${\n t.exportName || 'default'\n }` as TemplateInfoId;\n case 'web-components':\n return `${t.rendererId}---${t.elementName}` as TemplateInfoId;\n case 'twig':\n return `${t.rendererId}---${t.namespacePath}` as TemplateInfoId;\n case 'vue':\n case 'hbs':\n case 'html':\n return `${t.rendererId}---${t.codeSrcPath}` as TemplateInfoId;\n default: {\n const _: never = t;\n throw new Error(`Invalid template info: ${JSON.stringify(t)}`);\n }\n }\n}\n\nexport function addIdToTemplateInfo<TheRendererId extends RendererId>(\n t: TemplateInfo<TheRendererId>,\n): TemplateInfoWithId<TheRendererId> {\n return {\n ...t,\n id: createTemplateInfoId(t),\n };\n}\n\n/**\n * Converts old way of specifying template info (`path` & `alias`) to new way {@link TemplateInfo}\n * @see {@link convertTemplateInfoToOldWay} for the reverse\n */\nexport function normalizeTemplateInfo<TheRendererId extends RendererId>({\n rendererId,\n alias,\n path,\n}: {\n rendererId: TheRendererId;\n path?: CodeSrc['path'];\n alias?: string;\n}): TemplateInfo<TheRendererId> {\n const info = ((): TemplateInfo => {\n switch (rendererId) {\n case 'react':\n case 'angular':\n return {\n rendererId,\n codeSrcPath: path,\n exportName: alias || 'default',\n };\n case 'vue':\n case 'hbs':\n case 'html':\n return {\n rendererId,\n codeSrcPath: path,\n };\n case 'twig':\n return {\n rendererId,\n namespacePath: alias,\n };\n case 'web-components':\n return {\n rendererId,\n elementName: alias,\n };\n default: {\n const _: never = rendererId;\n throw new Error(`Invalid renderer ID: ${rendererId}`);\n }\n }\n })();\n\n return info as TemplateInfo<TheRendererId>;\n}\n\nexport type RendererTemplateConfig = {\n templateInfo: TemplateInfo;\n /**\n * If it's stored here, it's never inferred\n */\n spec?: KsTemplateSpec<false | undefined>;\n specMeta?: KsSpecMeta;\n};\n\n/**\n * Converts new way of specifying template info {@link TemplateInfo} to old way (`path` & `alias`)\n * @see {@link normalizeTemplateInfo} for the reverse\n */\nexport function convertTemplateInfoToOldWay(info: TemplateInfo): {\n path?: string;\n alias?: string;\n} {\n switch (info.rendererId) {\n case 'react':\n case 'angular':\n return {\n path: info.codeSrcPath,\n alias: info.exportName,\n };\n case 'hbs':\n case 'html':\n case 'vue':\n return {\n path: info.codeSrcPath,\n };\n case 'twig':\n return {\n alias: info.namespacePath,\n };\n case 'web-components':\n return {\n alias: info.elementName,\n };\n default: {\n const _: never = info;\n throw new Error(`Invalid template info: ${JSON.stringify(info)}`);\n }\n }\n}\n\nexport type RendererDiscovery<TheRendererId extends RendererId> = {\n rendererId: TheRendererId;\n meta: TemplateRendererMeta;\n codeSrcsByPath: Record<CodeSrc['path'], CodeSrc>;\n templates: TemplateInfoWithId<TheRendererId>[];\n};\n\n/**\n * Results of rendering a pattern\n */\nexport type KsRenderResults = {\n ok: boolean;\n html: string;\n usage?: string;\n templateLanguage?: string;\n message?: string;\n};\n\nexport type KsRenderApiResults = KsRenderResults & {\n wrappedHtml: string;\n};\nexport type TemplateSuggestion = {\n path: string;\n alias?: string;\n connected?: boolean;\n};\n\nexport type TemplateSuggestionsGetFn = (opt: {\n rendererId: RendererId;\n newPath?: string;\n state: ContentStateForRendering;\n}) => Promise<{\n suggestions: TemplateSuggestion[];\n}>;\n\n/**\n * Aliases for package paths\n * Example:\n * ```js\n * {\n * 'my-pkg': '../path/to/my-pkg',\n * }\n * ```\n */\nexport type PkgPathAliases = Record<string, string>;\n\nexport type ContentStateForRendering = {\n /**\n * Patterns by ID\n */\n patterns: {\n [patternId: string]: {\n id: string;\n templates: Pick<\n KnapsackPatternTemplate,\n 'alias' | 'path' | 'templateLanguageId' | 'spec' | 'id' | 'title'\n >[];\n templateDemos: Array<\n TemplateDemo & {\n templateId: string;\n templateLanguageId: RendererId;\n }\n >;\n };\n };\n};\n\nexport type TemplateUse = {\n patternId: string;\n patternTitle: string;\n templateId: string;\n templateTitle: string;\n};\n\nexport type PathWithTemplates = {\n path: string;\n templates: {\n id: TemplateInfoId;\n templateInfo: TemplateInfoWithId;\n use: TemplateUse;\n suggestion: TemplateSuggestion;\n }[];\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/renderers.ts"],"names":["rendererIds","CodeSrcUserConfigSchema","z","val","isTemplateInfoWithCodeSrcPath","info","__name","createTemplateInfoId","t","addIdToTemplateInfo","normalizeTemplateInfo","rendererId","alias","path","convertTemplateInfoToOldWay","metaForIosRenderer","metaForAndroidRenderer","rendererIdsForNativeMobile","isRendererIdForNativeMobile","isTemplateInfoForNativeMobile","templateInfo"],"mappings":"qGAgBO,IAAMA,CAAAA,CAAc,CACzB,KAAA,CAAO,OAAA,CACP,GAAA,CAAK,KAAA,CACL,gBAAA,CAAkB,gBAAA,CAClB,KAAM,MAAA,CACN,GAAA,CAAK,KAAA,CACL,OAAA,CAAS,SAAA,CACT,IAAA,CAAM,MAAA,CACN,GAAA,CAAK,KAAA,CACL,OAAA,CAAS,SACX,CAAA,CAuCaC,CAAAA,CAA0BC,CAAAA,CAAE,aAAa,CACpD,IAAA,CAAMA,CAAAA,CACH,MAAA,EAAO,CACP,QAAA,CACC,gGACF,CAAA,CACF,MAAA,CAAQA,CAAAA,CACL,MAAA,CAAmCC,CAAAA,EAC3B,OAAOA,CAAAA,EAAQ,UACvB,CAAA,CACA,QAAA,EAAS,CACT,QAAA,CAAS,oDAAoD,CAClE,CAAC,EA6EM,SAASC,CAAAA,CACdC,CAAAA,CACqC,CACrC,OAAO,aAAA,GAAiBA,CAC1B,CAJgBC,CAAAA,CAAAF,CAAAA,CAAA,+BAAA,CAAA,CAWT,SAASG,CAAAA,CAAqBC,EAAiC,CACpE,OAAQA,CAAAA,CAAE,UAAA,EACR,KAAK,UACL,KAAK,OAAA,C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AA,CAAAY,EAAA,6BAAA,CAAA,CAQT,SAASC,CAAAA,CACdC,CAAAA,CAIA,CACA,OAAOF,CAAAA,CAA4BE,CAAAA,CAAa,UAAU,CAC5D,CAPgBd,CAAAA,CAAAa,CAAAA,CAAA,+BAAA,CAAA","file":"renderers.mjs","sourcesContent":["import { z } from 'zod';\nimport type {\n PathPackage,\n PathPackageSubPath,\n PathRelative,\n Branded,\n} from './re-exports';\nimport type {\n KnapsackPatternTemplate,\n TemplateDemo,\n TemplateRendererMeta,\n KsSpecMeta,\n KsTemplateSpec,\n} from './app-client-data/patterns';\nimport type { Simplify } from './type-utils';\n\nexport const rendererIds = {\n react: 'react',\n vue: 'vue',\n 'web-components': 'web-components',\n twig: 'twig',\n hbs: 'hbs',\n angular: 'angular',\n html: 'html',\n ios: 'ios',\n android: 'android',\n} as const;\n\n/**\n * The ID of a renderer, e.g. 'react', 'vue', 'angular', etc.\n * On Pattern Templates, this will match up to `templateLanguageId` to identify which renderer to use.\n * @see {KnapsackPatternTemplate['templateLanguageId']}\n */\nexport type RendererId = keyof typeof rendererIds;\nexport type CodeSrc =\n | {\n type: 'package';\n path: PathPackage;\n pathFromOutputDir: PathPackage;\n pkgName: PathPackage;\n rendererId: RendererId;\n }\n | {\n type: 'package-sub-path';\n path: PathPackageSubPath;\n pathFromOutputDir: PathPackageSubPath;\n pkgName: PathPackage;\n subPath: PathRelative;\n rendererId: RendererId;\n }\n | {\n type: 'relative-from-data-dir';\n rendererId: RendererId;\n path: PathRelative;\n pathFromOutputDir: PathRelative;\n };\n\nexport type CodeSrcUserConfig = {\n /**\n * Can contain glob patterns, relative paths, absolute paths, package paths, or package sub-paths\n */\n path: string;\n filter?: (path: string) => boolean;\n};\n\nexport const CodeSrcUserConfigSchema = z.strictObject({\n path: z\n .string()\n .describe(\n 'Can contain glob patterns, relative paths, absolute paths, package paths, or package sub-paths',\n ),\n filter: z\n .custom<(path: string) => boolean>((val) => {\n return typeof val === 'function';\n })\n .optional()\n .describe('A function that takes a path and returns a boolean'),\n});\n\nexport type TemplateInfoId = Branded<string, 'TemplateInfoId'>;\n\nexport type TemplateInfo<TheRendererId extends RendererId = RendererId> =\n Extract<\n | {\n rendererId: 'react';\n codeSrcPath: CodeSrc['path'];\n /**\n * Name of the export. If it's the default export, this will be `'default'`.\n */\n exportName: string;\n }\n | {\n rendererId: 'vue';\n codeSrcPath: CodeSrc['path'];\n }\n | {\n rendererId: 'web-components';\n elementName: string;\n }\n | {\n rendererId: 'angular';\n codeSrcPath: CodeSrc['path'];\n /**\n * Name of the export. If it's the default export, this will be `'default'`.\n */\n exportName: string;\n }\n | {\n rendererId: 'html';\n codeSrcPath: CodeSrc['path'];\n }\n | {\n rendererId: 'twig';\n namespacePath: string;\n }\n | {\n rendererId: 'hbs';\n codeSrcPath: CodeSrc['path'];\n }\n | {\n rendererId: 'ios';\n /** The library name that exports out several symbols/components */\n moduleName: PathPackage;\n /** The exported name of the component */\n symbolName: string;\n }\n | {\n rendererId: 'android';\n /**\n * The library name that exports out several classes/components\n * Example: `com.google.android.material`\n */\n packageName: PathPackage;\n /** The exported name of the component */\n componentName: string;\n },\n { rendererId: TheRendererId }\n >;\n\nexport type TemplateInfoWithId<TheRendererId extends RendererId = RendererId> =\n Extract<\n Simplify<\n TemplateInfo<TheRendererId> & {\n id: TemplateInfoId;\n }\n >,\n { rendererId: TheRendererId }\n >;\n\nexport type TemplateInfoWithCodeSrcPath = Extract<\n TemplateInfo,\n { codeSrcPath: string }\n>;\n\nexport function isTemplateInfoWithCodeSrcPath(\n info: TemplateInfo,\n): info is TemplateInfoWithCodeSrcPath {\n return 'codeSrcPath' in info;\n}\n\n/**\n * Create a unique ID for a template info\n * This is used to identify the template info by a single unique string\n * @returns A unique ID for the template info\n */\nexport function createTemplateInfoId(t: TemplateInfo): TemplateInfoId {\n switch (t.rendererId) {\n case 'angular':\n case 'react':\n return `${t.rendererId}---${t.codeSrcPath}---${\n t.exportName || 'default'\n }` as TemplateInfoId;\n case 'web-components':\n return `${t.rendererId}---${t.elementName}` as TemplateInfoId;\n case 'twig':\n return `${t.rendererId}---${t.namespacePath}` as TemplateInfoId;\n case 'vue':\n case 'hbs':\n case 'html':\n return `${t.rendererId}---${t.codeSrcPath}` as TemplateInfoId;\n case 'ios':\n return `${t.rendererId}---${t.moduleName}---${t.symbolName}` as TemplateInfoId;\n case 'android':\n return `${t.rendererId}---${t.packageName}---${t.componentName}` as TemplateInfoId;\n default: {\n const _: never = t;\n throw new Error(`Invalid template info: ${JSON.stringify(t)}`);\n }\n }\n}\n\nexport function addIdToTemplateInfo<TheRendererId extends RendererId>(\n t: TemplateInfo<TheRendererId>,\n): TemplateInfoWithId<TheRendererId> {\n return {\n ...t,\n id: createTemplateInfoId(t),\n };\n}\n\n/**\n * Converts old way of specifying template info (`path` & `alias`) to new way {@link TemplateInfo}\n * @see {@link convertTemplateInfoToOldWay} for the reverse\n */\nexport function normalizeTemplateInfo<TheRendererId extends RendererId>({\n rendererId,\n alias,\n path,\n}: {\n rendererId: TheRendererId;\n path?: CodeSrc['path'];\n alias?: string;\n}): TemplateInfo<TheRendererId> {\n const info = ((): TemplateInfo => {\n switch (rendererId) {\n case 'react':\n case 'angular':\n return {\n rendererId,\n codeSrcPath: path,\n exportName: alias || 'default',\n };\n case 'vue':\n case 'hbs':\n case 'html':\n return {\n rendererId,\n codeSrcPath: path,\n };\n case 'twig':\n return {\n rendererId,\n namespacePath: alias,\n };\n case 'web-components':\n return {\n rendererId,\n elementName: alias,\n };\n // @TOOD: Just speculation for ios/android for now\n case 'ios':\n return {\n rendererId,\n moduleName: path as PathPackage,\n symbolName: alias,\n };\n case 'android':\n return {\n rendererId,\n packageName: path as PathPackage,\n componentName: alias,\n };\n default: {\n const _: never = rendererId;\n throw new Error(`Invalid renderer ID: ${rendererId}`);\n }\n }\n })();\n\n return info as TemplateInfo<TheRendererId>;\n}\n\nexport type RendererTemplateConfig = {\n templateInfo: TemplateInfo;\n /**\n * If it's stored here, it's never inferred\n */\n spec?: KsTemplateSpec<false | undefined>;\n specMeta?: KsSpecMeta;\n};\n\n/**\n * Converts new way of specifying template info {@link TemplateInfo} to old way (`path` & `alias`)\n * @see {@link normalizeTemplateInfo} for the reverse\n */\nexport function convertTemplateInfoToOldWay(info: TemplateInfo): {\n path?: string;\n alias?: string;\n} {\n switch (info.rendererId) {\n case 'react':\n case 'angular':\n return {\n path: info.codeSrcPath,\n alias: info.exportName,\n };\n case 'hbs':\n case 'html':\n case 'vue':\n return {\n path: info.codeSrcPath,\n };\n case 'twig':\n return {\n alias: info.namespacePath,\n };\n case 'web-components':\n return {\n alias: info.elementName,\n };\n case 'ios':\n return {\n path: info.moduleName,\n alias: info.symbolName,\n };\n case 'android':\n return {\n path: info.packageName,\n alias: info.componentName,\n };\n default: {\n const _: never = info;\n throw new Error(`Invalid template info: ${JSON.stringify(info)}`);\n }\n }\n}\n\nexport type RendererDiscovery<TheRendererId extends RendererId> = {\n rendererId: TheRendererId;\n meta: TemplateRendererMeta;\n codeSrcsByPath: Record<CodeSrc['path'], CodeSrc>;\n templates: TemplateInfoWithId<TheRendererId>[];\n};\n\n/**\n * Results of rendering a pattern\n */\nexport type KsRenderResults = {\n ok: boolean;\n html: string;\n usage?: string;\n templateLanguage?: string;\n message?: string;\n};\n\nexport type KsRenderApiResults = KsRenderResults & {\n wrappedHtml: string;\n};\nexport type TemplateSuggestion = {\n path: string;\n alias?: string;\n connected?: boolean;\n};\n\nexport type TemplateSuggestionsGetFn = (opt: {\n rendererId: RendererId;\n newPath?: string;\n state: ContentStateForRendering;\n}) => Promise<{\n suggestions: TemplateSuggestion[];\n}>;\n\n/**\n * Aliases for package paths\n * Example:\n * ```js\n * {\n * 'my-pkg': '../path/to/my-pkg',\n * }\n * ```\n */\nexport type PkgPathAliases = Record<string, string>;\n\nexport type ContentStateForRendering = {\n /**\n * Patterns by ID\n */\n patterns: {\n [patternId: string]: {\n id: string;\n templates: Pick<\n KnapsackPatternTemplate,\n 'alias' | 'path' | 'templateLanguageId' | 'spec' | 'id' | 'title'\n >[];\n templateDemos: Array<\n TemplateDemo & {\n templateId: string;\n templateLanguageId: RendererId;\n }\n >;\n };\n };\n};\n\nexport type TemplateUse = {\n patternId: string;\n patternTitle: string;\n templateId: string;\n templateTitle: string;\n};\n\nexport type PathWithTemplates = {\n path: string;\n templates: {\n id: TemplateInfoId;\n templateInfo: TemplateInfoWithId;\n use: TemplateUse;\n suggestion: TemplateSuggestion;\n }[];\n};\n\nexport const metaForIosRenderer: TemplateRendererMeta = {\n id: rendererIds.ios,\n title: 'iOS',\n aliasUse: 'required',\n aliasTitle: 'Symbol Name',\n aliasDescription: 'The synchronized name of the iOS symbol.',\n enableDataDemos: true,\n enableTemplateDemos: false,\n hasTemplateImgSupport: true,\n hasSlotsSupport: false,\n hasSlotOptionsSupport: false,\n hasInferSpecSupport: true,\n hasTemplateSuggestionsSupport: true,\n};\n\nexport const metaForAndroidRenderer: TemplateRendererMeta = {\n id: rendererIds.android,\n title: 'Android',\n aliasUse: 'required',\n aliasTitle: 'Component Name',\n aliasDescription: 'The synchronized name of the Android component.',\n enableDataDemos: true,\n enableTemplateDemos: false,\n hasSlotsSupport: false,\n hasSlotOptionsSupport: false,\n hasTemplateImgSupport: true,\n hasInferSpecSupport: true,\n hasTemplateSuggestionsSupport: true,\n};\n\nexport const rendererIdsForNativeMobile = [\n rendererIds.ios,\n rendererIds.android,\n] as const satisfies RendererId[];\n\nexport type RendererIdsForNativeMobile =\n (typeof rendererIdsForNativeMobile)[number];\n\nexport function isRendererIdForNativeMobile(\n rendererId: string,\n): rendererId is RendererIdsForNativeMobile {\n return rendererIdsForNativeMobile.includes(\n rendererId as RendererIdsForNativeMobile,\n );\n}\n\nexport function isTemplateInfoForNativeMobile(\n templateInfo: TemplateInfo,\n): templateInfo is Extract<\n TemplateInfo,\n { rendererId: RendererIdsForNativeMobile }\n> {\n return isRendererIdForNativeMobile(templateInfo.rendererId);\n}\n\nexport type TemplateInfoForNativeMobile = Extract<\n TemplateInfo,\n { rendererId: RendererIdsForNativeMobile }\n>;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderers.test.d.ts","sourceRoot":"","sources":["../src/renderers.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Describe } from 'superstruct';
|
|
2
|
-
import { ColorConfig } from './color-config';
|
|
1
|
+
import { type Describe } from 'superstruct';
|
|
2
|
+
import { type ColorConfig } from './color-config';
|
|
3
3
|
export declare const HeadingLevels: readonly ["h1", "h2", "h3", "h4", "h5", "h6"];
|
|
4
4
|
export type HeadingLevel = (typeof HeadingLevels)[number];
|
|
5
5
|
export type FontSizeConfigVal = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typography-config.d.ts","sourceRoot":"","sources":["../src/typography-config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"typography-config.d.ts","sourceRoot":"","sources":["../src/typography-config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,QAAQ,EAYd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,WAAW,EAAqB,MAAM,gBAAgB,CAAC;AAErE,eAAO,MAAM,aAAa,+CAAgD,CAAC;AAC3E,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1D,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,IAAI,GAAG,KAAK,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,iBAAiB,CAG9D,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,CAAC;AAE7C,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,cAAc,CAGxD,CAAC;AAEH,oBAAY,qBAAqB;IAC/B,KAAK,UAAU;IACf,IAAI,SAA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AEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,SAAS,CAAC,EAAE,WAAW,CAAC;IAExB,aAAa,CAAC,EAAE,MAAM,OAAO,cAAc,CAAC;IAE5C,WAAW,CAAC,EAAE,MAAM,OAAO,aAAa,CAAC;CAC1C,CAAC;AAEF,MAAM,WAAW,oBAAoB;IACnC,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,UAAU,CAAC,EAAE,WAAW,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,OAAO,cAAc,CAAC;IAC5C,WAAW,CAAC,EAAE,MAAM,OAAO,aAAa,CAAC;CAC1C;AAED,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,oBAAoB,CAqBpE,CAAC;AAEH,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,cAAc,CAGxD,CAAC;AAEH,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,gBAAgB,CAuB5D,CAAC;AAKH,eAAO,MAAM,YAAY;;;;;;;;CAQf,CAAC;AAEX,eAAO,MAAM,cAAc;;;;;;;;;;CAUjB,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,MAAM,OAAO,cAAc,CAAC;AAC3D,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,gBAAgB,CAAC,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var superstruct=require('superstruct'),k=require('color-string');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var k__default=/*#__PURE__*/_interopDefault(k);var F=Object.defineProperty;var
|
|
1
|
+
'use strict';var superstruct=require('superstruct'),k=require('color-string');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var k__default=/*#__PURE__*/_interopDefault(k);var F=Object.defineProperty;var x=(r,d)=>F(r,"name",{value:d,configurable:true});function T(r){if(typeof r!="string")return false;try{return !!k__default.default.get(r)}catch{return false}}x(T,"isColor");var w=superstruct.define("ColorStringStruct",r=>typeof r=="string"&&T(r)),c=superstruct.union([superstruct.type({type:superstruct.literal("value"),colorValue:w}),superstruct.type({type:superstruct.literal("design-token"),tokenName:superstruct.string()})]);superstruct.type({type:superstruct.literal("design-token"),tokenName:superstruct.string()});var I=["h1","h2","h3","h4","h5","h6"],u=superstruct.object({unit:superstruct.enums(["rem","px"]),value:superstruct.number()}),h=superstruct.union([superstruct.string(),superstruct.number()]),V=(y=>(y.woff2="woff2",y.woff="woff",y))(V||{}),v=superstruct.enums(["woff2","woff"]),N=superstruct.type({format:v,type:superstruct.literal("url"),path:superstruct.string()}),J=superstruct.type({family:superstruct.optional(superstruct.string()),weight:superstruct.optional(superstruct.union([h,superstruct.size(superstruct.array(h),2)])),src:superstruct.optional(superstruct.array(N)),style:superstruct.optional(superstruct.string()),display:superstruct.optional(superstruct.enums(["auto","block","swap","fallback","optional"])),variationSettings:superstruct.optional(superstruct.string()),unicodeRange:superstruct.optional(superstruct.string())}),H=(l=>(l.inherit="As typed",l.capitalize="Capitalize",l.lowercase="Lowercase",l.uppercase="Uppercase",l))(H||{}),P=(n=>(n["ultra-condensed"]="Ultra-condensed",n["extra-condensed"]="Extra-condensed",n.condensed="Condensed",n["semi-condensed"]="Semi-condensed",n.normal="Normal",n["semi-expanded"]="Semi-expanded",n.expanded="Expanded",n["extra-expanded"]="Extra-expanded",n["ultra-expanded"]="Ultra-expanded",n))(P||{}),K=superstruct.type({fontWeight:superstruct.optional(superstruct.union([superstruct.string(),superstruct.number()])),textColor:superstruct.optional(c),hoverColor:superstruct.optional(c),underline:superstruct.optional(superstruct.boolean()),textTransform:superstruct.optional(superstruct.enums(["inherit","capitalize","lowercase","uppercase"])),fontStretch:superstruct.optional(superstruct.enums(["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded"]))}),U=superstruct.type({min:u,max:superstruct.optional(u)}),O=superstruct.type({fontSize:superstruct.optional(U),lineHeight:superstruct.optional(superstruct.union([superstruct.string(),superstruct.number()])),fontWeight:superstruct.optional(superstruct.union([superstruct.string(),superstruct.number()])),letterSpacing:superstruct.optional(superstruct.string()),fontFamily:superstruct.optional(superstruct.string()),textColor:superstruct.optional(c),textTransform:superstruct.optional(superstruct.enums(["inherit","capitalize","lowercase","uppercase"])),fontStretch:superstruct.optional(superstruct.enums(["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded"]))}),o={},S={},Q={pageTitle:o,pageDescription:o,headingLarge:o,headingMedium:o,headingSmall:o,bodyText:o,link:S},Y={pageTitle:o,pageDescription:o,headingXLarge:o,headingLarge:o,headingMedium:o,headingSmall:o,headingXSmall:o,bodyText:o,link:S};exports.FontFaceConfigStruct=J;exports.FontFaceFormatsEnumStruct=v;exports.FontFaceSourceFormats=V;exports.FontFaceSourceStruct=N;exports.FontFaceWeightStruct=h;exports.FontSizeConfigStruct=U;exports.FontSizeConfigValStruct=u;exports.FontStretches=P;exports.HeadingLevels=I;exports.TextTransforms=H;exports.TypographyConfigStruct=O;exports.TypographyLinkConfigStruct=K;exports.pageElements=Q;exports.pageElementsV2=Y;//# sourceMappingURL=typography-config.js.map
|
|
2
2
|
//# sourceMappingURL=typography-config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/color-config.ts","../src/typography-config.ts"],"names":["isColor","color","colorString","__name","ColorStringStruct","define","value","ColorConfigStruct","union","type","literal","string","HeadingLevels","FontSizeConfigValStruct","object","enums","number","FontFaceWeightStruct","FontFaceSourceFormats","FontFaceFormatsEnumStruct","FontFaceSourceStruct","FontFaceConfigStruct","optional","size","array","TextTransforms","FontStretches","TypographyLinkConfigStruct","boolean","FontSizeConfigStruct","TypographyConfigStruct","pageElementConfig","pageLinkElementConfig","pageElements","pageElementsV2"],"mappings":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,aAAeM,CAAAA,oBAAAA,CAASX,kBAAO,EAAC,CAChC,CAAA,UAAA,CAAYW,qBAASX,kBAAO,EAAC,CAC7B,CAAA,SAAA,CAAWW,oBAASf,CAAAA,CAAiB,EACrC,aAAee,CAAAA,oBAAAA,CACbP,iBAAM,CAAA,CAAC,SAAW,CAAA,YAAA,CAAc,WAAa,CAAA,WAAW,CAAC,CAC3D,CACA,CAAA,WAAA,CAAaO,oBACXP,CAAAA,iBAAAA,CAAM,CACJ,iBACA,CAAA,iBAAA,CACA,WACA,CAAA,gBAAA,CACA,QACA,CAAA,eAAA,CACA,WACA,gBACA,CAAA,gBACF,CAAC,CACH,CACF,CAAC,EAEKgB,CAAsC,CAAA,EACtCC,CAAAA,CAAAA,CAA8C,EAAC,CAExCC,CAAe,CAAA,CAC1B,SAAWF,CAAAA,CAAAA,CACX,eAAiBA,CAAAA,CAAAA,CACjB,YAAcA,CAAAA,CAAAA,CACd,cAAeA,CACf,CAAA,YAAA,CAAcA,CACd,CAAA,QAAA,CAAUA,CACV,CAAA,IAAA,CAAMC,CACR,CAAA,CAEaE,CAAiB,CAAA,CAC5B,SAAWH,CAAAA,CAAAA,CACX,eAAiBA,CAAAA,CAAAA,CACjB,cAAeA,CACf,CAAA,YAAA,CAAcA,CACd,CAAA,aAAA,CAAeA,CACf,CAAA,YAAA,CAAcA,CACd,CAAA,aAAA,CAAeA,CACf,CAAA,QAAA,CAAUA,CACV,CAAA,IAAA,CAAMC,CACR","file":"typography-config.js","sourcesContent":["import colorString from 'color-string';\nimport { define, Describe, literal, string, type, union } from 'superstruct'; // https://docs.superstructjs.org\n\n/** Use `import { isColor } from '@knapsack/color-utils'` if you can, need to duplicate this logic due to dep cycle */\nfunction isColor(color: unknown): color is string {\n if (typeof color !== 'string') return false;\n try {\n return !!colorString.get(color);\n } catch (e) {\n return false;\n }\n}\n\nexport type ColorTokenConfig = {\n type: 'design-token';\n /** Will be **either** `-` (old) or `.` (new) separated */\n tokenName: string;\n};\nexport type ColorConfig =\n | { type: 'value'; colorValue: string }\n | ColorTokenConfig;\n\nexport const ColorStringStruct = define<string>(\n 'ColorStringStruct',\n (value) => typeof value === 'string' && isColor(value),\n);\n\nexport const ColorConfigStruct: Describe<ColorConfig> = union([\n type({\n type: literal('value'),\n colorValue: ColorStringStruct,\n }),\n type({\n type: literal('design-token'),\n tokenName: string(),\n }),\n]);\n\n// so we can check if an object is not just a ColorConfig but specifically a token\nexport const ColorTokenConfigStruct: Describe<ColorTokenConfig> = type({\n type: literal('design-token'),\n tokenName: string(),\n});\n","import {\n Describe,\n string,\n type,\n union,\n number,\n enums,\n optional,\n literal,\n array,\n size,\n boolean,\n object,\n} from 'superstruct'; // https://docs.superstructjs.org\nimport { ColorConfig, ColorConfigStruct } from './color-config';\n\nexport const HeadingLevels = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] as const;\nexport type HeadingLevel = (typeof HeadingLevels)[number];\n\nexport type FontSizeConfigVal = {\n unit: 'px' | 'rem';\n value: number;\n};\n\nexport const FontSizeConfigValStruct: Describe<FontSizeConfigVal> = object({\n unit: enums(['rem', 'px']),\n value: number(),\n});\n\nexport type FontFaceWeight = number | string;\n\nexport const FontFaceWeightStruct: Describe<FontFaceWeight> = union([\n string(),\n number(),\n]);\n\nexport enum FontFaceSourceFormats {\n woff2 = 'woff2',\n woff = 'woff',\n}\n\nexport type FontFaceSource = {\n /**\n * Note: if /when we eventually add 'local' type support, format isn't used!\n */\n format: keyof typeof FontFaceSourceFormats;\n type: 'url';\n path: string;\n};\n\nexport const FontFaceFormatsEnumStruct = enums(['woff2', 'woff']);\n\nexport const FontFaceSourceStruct: Describe<FontFaceSource> = type({\n format: FontFaceFormatsEnumStruct,\n type: literal('url'),\n path: string(),\n});\n\nexport type FontFaceConfig = {\n /**\n * registered name of the custom font\n *\n * MDN Docs on {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-family @font-face's font-family property}\n */\n family?: string;\n\n /**\n * number between 1 and 1000.\n *\n * note: since two weights are allowed (with variable fonts), this type is an\n * optional array for easy parsing down the road.\n *\n * MDN Docs on {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-weight @font-face's font-weight property}.\n */\n weight?: FontFaceWeight | FontFaceWeight[];\n\n /**\n * the collection of urls / paths pointing to font files\n *\n * MDN Docs on {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/src @font-face's src property}.\n */\n src?: FontFaceSource[];\n\n /**\n * the style of the custom font (ex. normal or italic)\n *\n * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-style See MDN docs on font-style}.\n */\n style?: string;\n\n // @todo: implement these later\n // display?: 'auto' | 'block' | 'swap' | 'fallback' | 'optional';\n // variationSettings?: string;\n // unicodeRange?: string; // or ideally, URange; //\n // see https://drafts.csswg.org/css-syntax-3/#urange-syntax and\n // https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/unicode-range\n};\n\nexport const FontFaceConfigStruct: Describe<FontFaceConfig> = type({\n family: optional(string()),\n weight: optional(\n union([FontFaceWeightStruct, size(array(FontFaceWeightStruct), 2)]),\n ),\n src: optional(array(FontFaceSourceStruct)),\n style: optional(string()),\n display: optional(enums(['auto', 'block', 'swap', 'fallback', 'optional'])),\n variationSettings: optional(string()),\n unicodeRange: optional(string()),\n});\n\nexport type FontSizeConfig = {\n min: FontSizeConfigVal;\n max?: FontSizeConfigVal;\n};\n\nexport enum TextTransforms {\n inherit = 'As typed',\n capitalize = 'Capitalize',\n lowercase = 'Lowercase',\n uppercase = 'Uppercase',\n}\n\nexport enum FontStretches {\n 'ultra-condensed' = 'Ultra-condensed',\n 'extra-condensed' = 'Extra-condensed',\n condensed = 'Condensed',\n 'semi-condensed' = 'Semi-condensed',\n normal = 'Normal',\n 'semi-expanded' = 'Semi-expanded',\n expanded = 'Expanded',\n 'extra-expanded' = 'Extra-expanded',\n 'ultra-expanded' = 'Ultra-expanded',\n}\n\nexport type TypographyConfig = {\n /**\n * min / max height used to future-proof way of supporting responsive typography\n */\n fontSize?: FontSizeConfig;\n\n /**\n * reminder: line-heights can also be unitless!\n */\n lineHeight?: string | number;\n fontWeight?: FontFaceWeight;\n\n /**\n * note: letter-spacing can't be unitless, unit required!\n */\n letterSpacing?: string;\n\n /**\n * if not specified, Knapsack default font, otherwise should allow for a stack of font strings + fallbacks (including the names of custom registered fonts)\n */\n fontFamily?: string;\n\n textColor?: ColorConfig;\n\n textTransform?: keyof typeof TextTransforms;\n\n fontStretch?: keyof typeof FontStretches;\n};\n\nexport interface TypographyLinkConfig {\n fontWeight?: FontFaceWeight;\n textColor?: ColorConfig;\n hoverColor?: ColorConfig;\n underline?: boolean;\n textTransform?: keyof typeof TextTransforms;\n fontStretch?: keyof typeof FontStretches;\n}\n\nexport const TypographyLinkConfigStruct: Describe<TypographyLinkConfig> = type({\n fontWeight: optional(union([string(), number()])),\n textColor: optional(ColorConfigStruct),\n hoverColor: optional(ColorConfigStruct),\n underline: optional(boolean()),\n textTransform: optional(\n enums(['inherit', 'capitalize', 'lowercase', 'uppercase']),\n ),\n fontStretch: optional(\n enums([\n 'ultra-condensed',\n 'extra-condensed',\n 'condensed',\n 'semi-condensed',\n 'normal',\n 'semi-expanded',\n 'expanded',\n 'extra-expanded',\n 'ultra-expanded',\n ]),\n ),\n});\n\nexport const FontSizeConfigStruct: Describe<FontSizeConfig> = type({\n min: FontSizeConfigValStruct,\n max: optional(FontSizeConfigValStruct),\n});\n\nexport const TypographyConfigStruct: Describe<TypographyConfig> = type({\n fontSize: optional(FontSizeConfigStruct),\n lineHeight: optional(union([string(), number()])),\n fontWeight: optional(union([string(), number()])),\n letterSpacing: optional(string()),\n fontFamily: optional(string()),\n textColor: optional(ColorConfigStruct),\n textTransform: optional(\n enums(['inherit', 'capitalize', 'lowercase', 'uppercase']),\n ),\n fontStretch: optional(\n enums([\n 'ultra-condensed',\n 'extra-condensed',\n 'condensed',\n 'semi-condensed',\n 'normal',\n 'semi-expanded',\n 'expanded',\n 'extra-expanded',\n 'ultra-expanded',\n ]),\n ),\n});\n\nconst pageElementConfig: TypographyConfig = {};\nconst pageLinkElementConfig: TypographyLinkConfig = {};\n\nexport const pageElements = {\n pageTitle: pageElementConfig,\n pageDescription: pageElementConfig,\n headingLarge: pageElementConfig,\n headingMedium: pageElementConfig,\n headingSmall: pageElementConfig,\n bodyText: pageElementConfig,\n link: pageLinkElementConfig,\n} as const;\n\nexport const pageElementsV2 = {\n pageTitle: pageElementConfig,\n pageDescription: pageElementConfig,\n headingXLarge: pageElementConfig,\n headingLarge: pageElementConfig,\n headingMedium: pageElementConfig,\n headingSmall: pageElementConfig,\n headingXSmall: pageElementConfig,\n bodyText: pageElementConfig,\n link: pageLinkElementConfig,\n} as const;\n\nexport type PageElementNames = keyof typeof pageElementsV2;\nexport type PageElementConfig = (typeof pageElementsV2)[PageElementNames];\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/color-config.ts","../src/typography-config.ts"],"names":["isColor","color","colorString","__name","ColorStringStruct","define","value","ColorConfigStruct","union","type","literal","string","HeadingLevels","FontSizeConfigValStruct","object","enums","number","FontFaceWeightStruct","FontFaceSourceFormats","FontFaceFormatsEnumStruct","FontFaceSourceStruct","FontFaceConfigStruct","optional","size","array","TextTransforms","FontStretches","TypographyLinkConfigStruct","boolean","FontSizeConfigStruct","TypographyConfigStruct","pageElementConfig","pageLinkElementConfig","pageElements","pageElementsV2"],"mappings":"+QAWA,SAASA,CAAAA,CAAQC,CAAAA,CAAiC,CAChD,GAAI,OAAOA,CAAAA,EAAU,QAAA,CAAU,OAAO,MAAA,CACtC,GAAI,CACF,OAAO,CAAC,CAACC,kBAAAA,CAAY,GAAA,CAAID,CAAK,CAChC,CAAA,KAAY,CACV,OAAO,MACT,CACF,CAPSE,EAAAH,CAAAA,CAAA,SAAA,CAAA,CAkBF,IAAMI,CAAAA,CAAoBC,kBAAAA,CAC/B,mBAAA,CACCC,GAAU,OAAOA,CAAAA,EAAU,QAAA,EAAYN,CAAAA,CAAQM,CAAK,CACvD,C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A,eAAA,CACA,WACA,gBAAA,CACA,gBACF,CAAC,CACH,CACF,CAAC,EAEKgB,CAAAA,CAAsC,EAAC,CACvCC,CAAAA,CAA8C,EAAC,CAExCC,CAAAA,CAAe,CAC1B,SAAA,CAAWF,CAAAA,CACX,eAAA,CAAiBA,CAAAA,CACjB,YAAA,CAAcA,CAAAA,CACd,cAAeA,CAAAA,CACf,YAAA,CAAcA,CAAAA,CACd,QAAA,CAAUA,CAAAA,CACV,IAAA,CAAMC,CACR,CAAA,CAEaE,CAAAA,CAAiB,CAC5B,SAAA,CAAWH,CAAAA,CACX,eAAA,CAAiBA,CAAAA,CACjB,cAAeA,CAAAA,CACf,YAAA,CAAcA,CAAAA,CACd,aAAA,CAAeA,CAAAA,CACf,YAAA,CAAcA,CAAAA,CACd,aAAA,CAAeA,CAAAA,CACf,QAAA,CAAUA,CAAAA,CACV,IAAA,CAAMC,CACR","file":"typography-config.js","sourcesContent":["import colorString from 'color-string';\nimport {\n define,\n type Describe,\n literal,\n string,\n type,\n union,\n} from 'superstruct'; // https://docs.superstructjs.org\n\n/** Use `import { isColor } from '@knapsack/color-utils'` if you can, need to duplicate this logic due to dep cycle */\nfunction isColor(color: unknown): color is string {\n if (typeof color !== 'string') return false;\n try {\n return !!colorString.get(color);\n } catch (e) {\n return false;\n }\n}\n\nexport type ColorTokenConfig = {\n type: 'design-token';\n /** Will be **either** `-` (old) or `.` (new) separated */\n tokenName: string;\n};\nexport type ColorConfig =\n | { type: 'value'; colorValue: string }\n | ColorTokenConfig;\n\nexport const ColorStringStruct = define<string>(\n 'ColorStringStruct',\n (value) => typeof value === 'string' && isColor(value),\n);\n\nexport const ColorConfigStruct: Describe<ColorConfig> = union([\n type({\n type: literal('value'),\n colorValue: ColorStringStruct,\n }),\n type({\n type: literal('design-token'),\n tokenName: string(),\n }),\n]);\n\n// so we can check if an object is not just a ColorConfig but specifically a token\nexport const ColorTokenConfigStruct: Describe<ColorTokenConfig> = type({\n type: literal('design-token'),\n tokenName: string(),\n});\n","import {\n type Describe,\n string,\n type,\n union,\n number,\n enums,\n optional,\n literal,\n array,\n size,\n boolean,\n object,\n} from 'superstruct'; // https://docs.superstructjs.org\nimport { type ColorConfig, ColorConfigStruct } from './color-config';\n\nexport const HeadingLevels = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] as const;\nexport type HeadingLevel = (typeof HeadingLevels)[number];\n\nexport type FontSizeConfigVal = {\n unit: 'px' | 'rem';\n value: number;\n};\n\nexport const FontSizeConfigValStruct: Describe<FontSizeConfigVal> = object({\n unit: enums(['rem', 'px']),\n value: number(),\n});\n\nexport type FontFaceWeight = number | string;\n\nexport const FontFaceWeightStruct: Describe<FontFaceWeight> = union([\n string(),\n number(),\n]);\n\nexport enum FontFaceSourceFormats {\n woff2 = 'woff2',\n woff = 'woff',\n}\n\nexport type FontFaceSource = {\n /**\n * Note: if /when we eventually add 'local' type support, format isn't used!\n */\n format: keyof typeof FontFaceSourceFormats;\n type: 'url';\n path: string;\n};\n\nexport const FontFaceFormatsEnumStruct = enums(['woff2', 'woff']);\n\nexport const FontFaceSourceStruct: Describe<FontFaceSource> = type({\n format: FontFaceFormatsEnumStruct,\n type: literal('url'),\n path: string(),\n});\n\nexport type FontFaceConfig = {\n /**\n * registered name of the custom font\n *\n * MDN Docs on {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-family @font-face's font-family property}\n */\n family?: string;\n\n /**\n * number between 1 and 1000.\n *\n * note: since two weights are allowed (with variable fonts), this type is an\n * optional array for easy parsing down the road.\n *\n * MDN Docs on {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-weight @font-face's font-weight property}.\n */\n weight?: FontFaceWeight | FontFaceWeight[];\n\n /**\n * the collection of urls / paths pointing to font files\n *\n * MDN Docs on {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/src @font-face's src property}.\n */\n src?: FontFaceSource[];\n\n /**\n * the style of the custom font (ex. normal or italic)\n *\n * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-style See MDN docs on font-style}.\n */\n style?: string;\n\n // @todo: implement these later\n // display?: 'auto' | 'block' | 'swap' | 'fallback' | 'optional';\n // variationSettings?: string;\n // unicodeRange?: string; // or ideally, URange; //\n // see https://drafts.csswg.org/css-syntax-3/#urange-syntax and\n // https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/unicode-range\n};\n\nexport const FontFaceConfigStruct: Describe<FontFaceConfig> = type({\n family: optional(string()),\n weight: optional(\n union([FontFaceWeightStruct, size(array(FontFaceWeightStruct), 2)]),\n ),\n src: optional(array(FontFaceSourceStruct)),\n style: optional(string()),\n display: optional(enums(['auto', 'block', 'swap', 'fallback', 'optional'])),\n variationSettings: optional(string()),\n unicodeRange: optional(string()),\n});\n\nexport type FontSizeConfig = {\n min: FontSizeConfigVal;\n max?: FontSizeConfigVal;\n};\n\nexport enum TextTransforms {\n inherit = 'As typed',\n capitalize = 'Capitalize',\n lowercase = 'Lowercase',\n uppercase = 'Uppercase',\n}\n\nexport enum FontStretches {\n 'ultra-condensed' = 'Ultra-condensed',\n 'extra-condensed' = 'Extra-condensed',\n condensed = 'Condensed',\n 'semi-condensed' = 'Semi-condensed',\n normal = 'Normal',\n 'semi-expanded' = 'Semi-expanded',\n expanded = 'Expanded',\n 'extra-expanded' = 'Extra-expanded',\n 'ultra-expanded' = 'Ultra-expanded',\n}\n\nexport type TypographyConfig = {\n /**\n * min / max height used to future-proof way of supporting responsive typography\n */\n fontSize?: FontSizeConfig;\n\n /**\n * reminder: line-heights can also be unitless!\n */\n lineHeight?: string | number;\n fontWeight?: FontFaceWeight;\n\n /**\n * note: letter-spacing can't be unitless, unit required!\n */\n letterSpacing?: string;\n\n /**\n * if not specified, Knapsack default font, otherwise should allow for a stack of font strings + fallbacks (including the names of custom registered fonts)\n */\n fontFamily?: string;\n\n textColor?: ColorConfig;\n\n textTransform?: keyof typeof TextTransforms;\n\n fontStretch?: keyof typeof FontStretches;\n};\n\nexport interface TypographyLinkConfig {\n fontWeight?: FontFaceWeight;\n textColor?: ColorConfig;\n hoverColor?: ColorConfig;\n underline?: boolean;\n textTransform?: keyof typeof TextTransforms;\n fontStretch?: keyof typeof FontStretches;\n}\n\nexport const TypographyLinkConfigStruct: Describe<TypographyLinkConfig> = type({\n fontWeight: optional(union([string(), number()])),\n textColor: optional(ColorConfigStruct),\n hoverColor: optional(ColorConfigStruct),\n underline: optional(boolean()),\n textTransform: optional(\n enums(['inherit', 'capitalize', 'lowercase', 'uppercase']),\n ),\n fontStretch: optional(\n enums([\n 'ultra-condensed',\n 'extra-condensed',\n 'condensed',\n 'semi-condensed',\n 'normal',\n 'semi-expanded',\n 'expanded',\n 'extra-expanded',\n 'ultra-expanded',\n ]),\n ),\n});\n\nexport const FontSizeConfigStruct: Describe<FontSizeConfig> = type({\n min: FontSizeConfigValStruct,\n max: optional(FontSizeConfigValStruct),\n});\n\nexport const TypographyConfigStruct: Describe<TypographyConfig> = type({\n fontSize: optional(FontSizeConfigStruct),\n lineHeight: optional(union([string(), number()])),\n fontWeight: optional(union([string(), number()])),\n letterSpacing: optional(string()),\n fontFamily: optional(string()),\n textColor: optional(ColorConfigStruct),\n textTransform: optional(\n enums(['inherit', 'capitalize', 'lowercase', 'uppercase']),\n ),\n fontStretch: optional(\n enums([\n 'ultra-condensed',\n 'extra-condensed',\n 'condensed',\n 'semi-condensed',\n 'normal',\n 'semi-expanded',\n 'expanded',\n 'extra-expanded',\n 'ultra-expanded',\n ]),\n ),\n});\n\nconst pageElementConfig: TypographyConfig = {};\nconst pageLinkElementConfig: TypographyLinkConfig = {};\n\nexport const pageElements = {\n pageTitle: pageElementConfig,\n pageDescription: pageElementConfig,\n headingLarge: pageElementConfig,\n headingMedium: pageElementConfig,\n headingSmall: pageElementConfig,\n bodyText: pageElementConfig,\n link: pageLinkElementConfig,\n} as const;\n\nexport const pageElementsV2 = {\n pageTitle: pageElementConfig,\n pageDescription: pageElementConfig,\n headingXLarge: pageElementConfig,\n headingLarge: pageElementConfig,\n headingMedium: pageElementConfig,\n headingSmall: pageElementConfig,\n headingXSmall: pageElementConfig,\n bodyText: pageElementConfig,\n link: pageLinkElementConfig,\n} as const;\n\nexport type PageElementNames = keyof typeof pageElementsV2;\nexport type PageElementConfig = (typeof pageElementsV2)[PageElementNames];\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {define,union,type,literal,string,object,number,enums,optional,array,size,boolean}from'superstruct';import k from'color-string';var F=Object.defineProperty;var
|
|
1
|
+
import {define,union,type,literal,string,object,number,enums,optional,array,size,boolean}from'superstruct';import k from'color-string';var F=Object.defineProperty;var x=(r,d)=>F(r,"name",{value:d,configurable:true});function T(r){if(typeof r!="string")return false;try{return !!k.get(r)}catch{return false}}x(T,"isColor");var w=define("ColorStringStruct",r=>typeof r=="string"&&T(r)),c=union([type({type:literal("value"),colorValue:w}),type({type:literal("design-token"),tokenName:string()})]);type({type:literal("design-token"),tokenName:string()});var I=["h1","h2","h3","h4","h5","h6"],u=object({unit:enums(["rem","px"]),value:number()}),h=union([string(),number()]),V=(y=>(y.woff2="woff2",y.woff="woff",y))(V||{}),v=enums(["woff2","woff"]),N=type({format:v,type:literal("url"),path:string()}),J=type({family:optional(string()),weight:optional(union([h,size(array(h),2)])),src:optional(array(N)),style:optional(string()),display:optional(enums(["auto","block","swap","fallback","optional"])),variationSettings:optional(string()),unicodeRange:optional(string())}),H=(l=>(l.inherit="As typed",l.capitalize="Capitalize",l.lowercase="Lowercase",l.uppercase="Uppercase",l))(H||{}),P=(n=>(n["ultra-condensed"]="Ultra-condensed",n["extra-condensed"]="Extra-condensed",n.condensed="Condensed",n["semi-condensed"]="Semi-condensed",n.normal="Normal",n["semi-expanded"]="Semi-expanded",n.expanded="Expanded",n["extra-expanded"]="Extra-expanded",n["ultra-expanded"]="Ultra-expanded",n))(P||{}),K=type({fontWeight:optional(union([string(),number()])),textColor:optional(c),hoverColor:optional(c),underline:optional(boolean()),textTransform:optional(enums(["inherit","capitalize","lowercase","uppercase"])),fontStretch:optional(enums(["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded"]))}),U=type({min:u,max:optional(u)}),O=type({fontSize:optional(U),lineHeight:optional(union([string(),number()])),fontWeight:optional(union([string(),number()])),letterSpacing:optional(string()),fontFamily:optional(string()),textColor:optional(c),textTransform:optional(enums(["inherit","capitalize","lowercase","uppercase"])),fontStretch:optional(enums(["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded"]))}),o={},S={},Q={pageTitle:o,pageDescription:o,headingLarge:o,headingMedium:o,headingSmall:o,bodyText:o,link:S},Y={pageTitle:o,pageDescription:o,headingXLarge:o,headingLarge:o,headingMedium:o,headingSmall:o,headingXSmall:o,bodyText:o,link:S};export{J as FontFaceConfigStruct,v as FontFaceFormatsEnumStruct,V as FontFaceSourceFormats,N as FontFaceSourceStruct,h as FontFaceWeightStruct,U as FontSizeConfigStruct,u as FontSizeConfigValStruct,P as FontStretches,I as HeadingLevels,H as TextTransforms,O as TypographyConfigStruct,K as TypographyLinkConfigStruct,Q as pageElements,Y as pageElementsV2};//# sourceMappingURL=typography-config.mjs.map
|
|
2
2
|
//# sourceMappingURL=typography-config.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/color-config.ts","../src/typography-config.ts"],"names":["isColor","color","colorString","__name","ColorStringStruct","define","value","ColorConfigStruct","union","type","literal","string","HeadingLevels","FontSizeConfigValStruct","object","enums","number","FontFaceWeightStruct","FontFaceSourceFormats","FontFaceFormatsEnumStruct","FontFaceSourceStruct","FontFaceConfigStruct","optional","size","array","TextTransforms","FontStretches","TypographyLinkConfigStruct","boolean","FontSizeConfigStruct","TypographyConfigStruct","pageElementConfig","pageLinkElementConfig","pageElements","pageElementsV2"],"mappings":"wNAIA,SAASA,CAAQC,CAAAA,CAAAA,CAAiC,CAChD,GAAI,OAAOA,CAAU,EAAA,QAAA,CAAU,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,KAAM,CAAA,CAAC,SAAW,CAAA,YAAA,CAAc,WAAa,CAAA,WAAW,CAAC,CAC3D,CACA,CAAA,WAAA,CAAaO,QACXP,CAAAA,KAAAA,CAAM,CACJ,iBACA,CAAA,iBAAA,CACA,WACA,CAAA,gBAAA,CACA,QACA,CAAA,eAAA,CACA,WACA,gBACA,CAAA,gBACF,CAAC,CACH,CACF,CAAC,EAEKgB,CAAsC,CAAA,EACtCC,CAAAA,CAAAA,CAA8C,EAAC,CAExCC,CAAe,CAAA,CAC1B,SAAWF,CAAAA,CAAAA,CACX,eAAiBA,CAAAA,CAAAA,CACjB,YAAcA,CAAAA,CAAAA,CACd,cAAeA,CACf,CAAA,YAAA,CAAcA,CACd,CAAA,QAAA,CAAUA,CACV,CAAA,IAAA,CAAMC,CACR,CAAA,CAEaE,CAAiB,CAAA,CAC5B,SAAWH,CAAAA,CAAAA,CACX,eAAiBA,CAAAA,CAAAA,CACjB,cAAeA,CACf,CAAA,YAAA,CAAcA,CACd,CAAA,aAAA,CAAeA,CACf,CAAA,YAAA,CAAcA,CACd,CAAA,aAAA,CAAeA,CACf,CAAA,QAAA,CAAUA,CACV,CAAA,IAAA,CAAMC,CACR","file":"typography-config.mjs","sourcesContent":["import colorString from 'color-string';\nimport { define, Describe, literal, string, type, union } from 'superstruct'; // https://docs.superstructjs.org\n\n/** Use `import { isColor } from '@knapsack/color-utils'` if you can, need to duplicate this logic due to dep cycle */\nfunction isColor(color: unknown): color is string {\n if (typeof color !== 'string') return false;\n try {\n return !!colorString.get(color);\n } catch (e) {\n return false;\n }\n}\n\nexport type ColorTokenConfig = {\n type: 'design-token';\n /** Will be **either** `-` (old) or `.` (new) separated */\n tokenName: string;\n};\nexport type ColorConfig =\n | { type: 'value'; colorValue: string }\n | ColorTokenConfig;\n\nexport const ColorStringStruct = define<string>(\n 'ColorStringStruct',\n (value) => typeof value === 'string' && isColor(value),\n);\n\nexport const ColorConfigStruct: Describe<ColorConfig> = union([\n type({\n type: literal('value'),\n colorValue: ColorStringStruct,\n }),\n type({\n type: literal('design-token'),\n tokenName: string(),\n }),\n]);\n\n// so we can check if an object is not just a ColorConfig but specifically a token\nexport const ColorTokenConfigStruct: Describe<ColorTokenConfig> = type({\n type: literal('design-token'),\n tokenName: string(),\n});\n","import {\n Describe,\n string,\n type,\n union,\n number,\n enums,\n optional,\n literal,\n array,\n size,\n boolean,\n object,\n} from 'superstruct'; // https://docs.superstructjs.org\nimport { ColorConfig, ColorConfigStruct } from './color-config';\n\nexport const HeadingLevels = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] as const;\nexport type HeadingLevel = (typeof HeadingLevels)[number];\n\nexport type FontSizeConfigVal = {\n unit: 'px' | 'rem';\n value: number;\n};\n\nexport const FontSizeConfigValStruct: Describe<FontSizeConfigVal> = object({\n unit: enums(['rem', 'px']),\n value: number(),\n});\n\nexport type FontFaceWeight = number | string;\n\nexport const FontFaceWeightStruct: Describe<FontFaceWeight> = union([\n string(),\n number(),\n]);\n\nexport enum FontFaceSourceFormats {\n woff2 = 'woff2',\n woff = 'woff',\n}\n\nexport type FontFaceSource = {\n /**\n * Note: if /when we eventually add 'local' type support, format isn't used!\n */\n format: keyof typeof FontFaceSourceFormats;\n type: 'url';\n path: string;\n};\n\nexport const FontFaceFormatsEnumStruct = enums(['woff2', 'woff']);\n\nexport const FontFaceSourceStruct: Describe<FontFaceSource> = type({\n format: FontFaceFormatsEnumStruct,\n type: literal('url'),\n path: string(),\n});\n\nexport type FontFaceConfig = {\n /**\n * registered name of the custom font\n *\n * MDN Docs on {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-family @font-face's font-family property}\n */\n family?: string;\n\n /**\n * number between 1 and 1000.\n *\n * note: since two weights are allowed (with variable fonts), this type is an\n * optional array for easy parsing down the road.\n *\n * MDN Docs on {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-weight @font-face's font-weight property}.\n */\n weight?: FontFaceWeight | FontFaceWeight[];\n\n /**\n * the collection of urls / paths pointing to font files\n *\n * MDN Docs on {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/src @font-face's src property}.\n */\n src?: FontFaceSource[];\n\n /**\n * the style of the custom font (ex. normal or italic)\n *\n * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-style See MDN docs on font-style}.\n */\n style?: string;\n\n // @todo: implement these later\n // display?: 'auto' | 'block' | 'swap' | 'fallback' | 'optional';\n // variationSettings?: string;\n // unicodeRange?: string; // or ideally, URange; //\n // see https://drafts.csswg.org/css-syntax-3/#urange-syntax and\n // https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/unicode-range\n};\n\nexport const FontFaceConfigStruct: Describe<FontFaceConfig> = type({\n family: optional(string()),\n weight: optional(\n union([FontFaceWeightStruct, size(array(FontFaceWeightStruct), 2)]),\n ),\n src: optional(array(FontFaceSourceStruct)),\n style: optional(string()),\n display: optional(enums(['auto', 'block', 'swap', 'fallback', 'optional'])),\n variationSettings: optional(string()),\n unicodeRange: optional(string()),\n});\n\nexport type FontSizeConfig = {\n min: FontSizeConfigVal;\n max?: FontSizeConfigVal;\n};\n\nexport enum TextTransforms {\n inherit = 'As typed',\n capitalize = 'Capitalize',\n lowercase = 'Lowercase',\n uppercase = 'Uppercase',\n}\n\nexport enum FontStretches {\n 'ultra-condensed' = 'Ultra-condensed',\n 'extra-condensed' = 'Extra-condensed',\n condensed = 'Condensed',\n 'semi-condensed' = 'Semi-condensed',\n normal = 'Normal',\n 'semi-expanded' = 'Semi-expanded',\n expanded = 'Expanded',\n 'extra-expanded' = 'Extra-expanded',\n 'ultra-expanded' = 'Ultra-expanded',\n}\n\nexport type TypographyConfig = {\n /**\n * min / max height used to future-proof way of supporting responsive typography\n */\n fontSize?: FontSizeConfig;\n\n /**\n * reminder: line-heights can also be unitless!\n */\n lineHeight?: string | number;\n fontWeight?: FontFaceWeight;\n\n /**\n * note: letter-spacing can't be unitless, unit required!\n */\n letterSpacing?: string;\n\n /**\n * if not specified, Knapsack default font, otherwise should allow for a stack of font strings + fallbacks (including the names of custom registered fonts)\n */\n fontFamily?: string;\n\n textColor?: ColorConfig;\n\n textTransform?: keyof typeof TextTransforms;\n\n fontStretch?: keyof typeof FontStretches;\n};\n\nexport interface TypographyLinkConfig {\n fontWeight?: FontFaceWeight;\n textColor?: ColorConfig;\n hoverColor?: ColorConfig;\n underline?: boolean;\n textTransform?: keyof typeof TextTransforms;\n fontStretch?: keyof typeof FontStretches;\n}\n\nexport const TypographyLinkConfigStruct: Describe<TypographyLinkConfig> = type({\n fontWeight: optional(union([string(), number()])),\n textColor: optional(ColorConfigStruct),\n hoverColor: optional(ColorConfigStruct),\n underline: optional(boolean()),\n textTransform: optional(\n enums(['inherit', 'capitalize', 'lowercase', 'uppercase']),\n ),\n fontStretch: optional(\n enums([\n 'ultra-condensed',\n 'extra-condensed',\n 'condensed',\n 'semi-condensed',\n 'normal',\n 'semi-expanded',\n 'expanded',\n 'extra-expanded',\n 'ultra-expanded',\n ]),\n ),\n});\n\nexport const FontSizeConfigStruct: Describe<FontSizeConfig> = type({\n min: FontSizeConfigValStruct,\n max: optional(FontSizeConfigValStruct),\n});\n\nexport const TypographyConfigStruct: Describe<TypographyConfig> = type({\n fontSize: optional(FontSizeConfigStruct),\n lineHeight: optional(union([string(), number()])),\n fontWeight: optional(union([string(), number()])),\n letterSpacing: optional(string()),\n fontFamily: optional(string()),\n textColor: optional(ColorConfigStruct),\n textTransform: optional(\n enums(['inherit', 'capitalize', 'lowercase', 'uppercase']),\n ),\n fontStretch: optional(\n enums([\n 'ultra-condensed',\n 'extra-condensed',\n 'condensed',\n 'semi-condensed',\n 'normal',\n 'semi-expanded',\n 'expanded',\n 'extra-expanded',\n 'ultra-expanded',\n ]),\n ),\n});\n\nconst pageElementConfig: TypographyConfig = {};\nconst pageLinkElementConfig: TypographyLinkConfig = {};\n\nexport const pageElements = {\n pageTitle: pageElementConfig,\n pageDescription: pageElementConfig,\n headingLarge: pageElementConfig,\n headingMedium: pageElementConfig,\n headingSmall: pageElementConfig,\n bodyText: pageElementConfig,\n link: pageLinkElementConfig,\n} as const;\n\nexport const pageElementsV2 = {\n pageTitle: pageElementConfig,\n pageDescription: pageElementConfig,\n headingXLarge: pageElementConfig,\n headingLarge: pageElementConfig,\n headingMedium: pageElementConfig,\n headingSmall: pageElementConfig,\n headingXSmall: pageElementConfig,\n bodyText: pageElementConfig,\n link: pageLinkElementConfig,\n} as const;\n\nexport type PageElementNames = keyof typeof pageElementsV2;\nexport type PageElementConfig = (typeof pageElementsV2)[PageElementNames];\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/color-config.ts","../src/typography-config.ts"],"names":["isColor","color","colorString","__name","ColorStringStruct","define","value","ColorConfigStruct","union","type","literal","string","HeadingLevels","FontSizeConfigValStruct","object","enums","number","FontFaceWeightStruct","FontFaceSourceFormats","FontFaceFormatsEnumStruct","FontFaceSourceStruct","FontFaceConfigStruct","optional","size","array","TextTransforms","FontStretches","TypographyLinkConfigStruct","boolean","FontSizeConfigStruct","TypographyConfigStruct","pageElementConfig","pageLinkElementConfig","pageElements","pageElementsV2"],"mappings":"wNAWA,SAASA,CAAAA,CAAQC,CAAAA,CAAiC,CAChD,GAAI,OAAOA,CAAAA,EAAU,QAAA,CAAU,OAAO,MAAA,CACtC,GAAI,CACF,OAAO,CAAC,CAACC,CAAAA,CAAY,GAAA,CAAID,CAAK,CAChC,CAAA,KAAY,CACV,OAAO,MACT,CACF,CAPSE,EAAAH,CAAAA,CAAA,SAAA,CAAA,CAkBF,IAAMI,CAAAA,CAAoBC,MAAAA,CAC/B,mBAAA,CACCC,GAAU,OAAOA,CAAAA,EAAU,QAAA,EAAYN,CAAAA,CAAQM,CAAK,CACvD,CAAA,CAEaC,CAAAA,CAA2CC,KAAAA,CAAM,CAC5DC,IAAAA,CAAK,CACH,IAAA,CAAMC,OAAAA,CAAQ,OAAO,CAAA,CACrB,UAAA,CAAYN,CACd,CAAC,CAAA,CACDK,IAAAA,CAAK,CACH,IAAA,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A,CACd,QAAA,CAAUA,CAAAA,CACV,IAAA,CAAMC,CACR,CAAA,CAEaE,CAAAA,CAAiB,CAC5B,SAAA,CAAWH,CAAAA,CACX,eAAA,CAAiBA,CAAAA,CACjB,cAAeA,CAAAA,CACf,YAAA,CAAcA,CAAAA,CACd,aAAA,CAAeA,CAAAA,CACf,YAAA,CAAcA,CAAAA,CACd,aAAA,CAAeA,CAAAA,CACf,QAAA,CAAUA,CAAAA,CACV,IAAA,CAAMC,CACR","file":"typography-config.mjs","sourcesContent":["import colorString from 'color-string';\nimport {\n define,\n type Describe,\n literal,\n string,\n type,\n union,\n} from 'superstruct'; // https://docs.superstructjs.org\n\n/** Use `import { isColor } from '@knapsack/color-utils'` if you can, need to duplicate this logic due to dep cycle */\nfunction isColor(color: unknown): color is string {\n if (typeof color !== 'string') return false;\n try {\n return !!colorString.get(color);\n } catch (e) {\n return false;\n }\n}\n\nexport type ColorTokenConfig = {\n type: 'design-token';\n /** Will be **either** `-` (old) or `.` (new) separated */\n tokenName: string;\n};\nexport type ColorConfig =\n | { type: 'value'; colorValue: string }\n | ColorTokenConfig;\n\nexport const ColorStringStruct = define<string>(\n 'ColorStringStruct',\n (value) => typeof value === 'string' && isColor(value),\n);\n\nexport const ColorConfigStruct: Describe<ColorConfig> = union([\n type({\n type: literal('value'),\n colorValue: ColorStringStruct,\n }),\n type({\n type: literal('design-token'),\n tokenName: string(),\n }),\n]);\n\n// so we can check if an object is not just a ColorConfig but specifically a token\nexport const ColorTokenConfigStruct: Describe<ColorTokenConfig> = type({\n type: literal('design-token'),\n tokenName: string(),\n});\n","import {\n type Describe,\n string,\n type,\n union,\n number,\n enums,\n optional,\n literal,\n array,\n size,\n boolean,\n object,\n} from 'superstruct'; // https://docs.superstructjs.org\nimport { type ColorConfig, ColorConfigStruct } from './color-config';\n\nexport const HeadingLevels = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] as const;\nexport type HeadingLevel = (typeof HeadingLevels)[number];\n\nexport type FontSizeConfigVal = {\n unit: 'px' | 'rem';\n value: number;\n};\n\nexport const FontSizeConfigValStruct: Describe<FontSizeConfigVal> = object({\n unit: enums(['rem', 'px']),\n value: number(),\n});\n\nexport type FontFaceWeight = number | string;\n\nexport const FontFaceWeightStruct: Describe<FontFaceWeight> = union([\n string(),\n number(),\n]);\n\nexport enum FontFaceSourceFormats {\n woff2 = 'woff2',\n woff = 'woff',\n}\n\nexport type FontFaceSource = {\n /**\n * Note: if /when we eventually add 'local' type support, format isn't used!\n */\n format: keyof typeof FontFaceSourceFormats;\n type: 'url';\n path: string;\n};\n\nexport const FontFaceFormatsEnumStruct = enums(['woff2', 'woff']);\n\nexport const FontFaceSourceStruct: Describe<FontFaceSource> = type({\n format: FontFaceFormatsEnumStruct,\n type: literal('url'),\n path: string(),\n});\n\nexport type FontFaceConfig = {\n /**\n * registered name of the custom font\n *\n * MDN Docs on {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-family @font-face's font-family property}\n */\n family?: string;\n\n /**\n * number between 1 and 1000.\n *\n * note: since two weights are allowed (with variable fonts), this type is an\n * optional array for easy parsing down the road.\n *\n * MDN Docs on {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-weight @font-face's font-weight property}.\n */\n weight?: FontFaceWeight | FontFaceWeight[];\n\n /**\n * the collection of urls / paths pointing to font files\n *\n * MDN Docs on {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/src @font-face's src property}.\n */\n src?: FontFaceSource[];\n\n /**\n * the style of the custom font (ex. normal or italic)\n *\n * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-style See MDN docs on font-style}.\n */\n style?: string;\n\n // @todo: implement these later\n // display?: 'auto' | 'block' | 'swap' | 'fallback' | 'optional';\n // variationSettings?: string;\n // unicodeRange?: string; // or ideally, URange; //\n // see https://drafts.csswg.org/css-syntax-3/#urange-syntax and\n // https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/unicode-range\n};\n\nexport const FontFaceConfigStruct: Describe<FontFaceConfig> = type({\n family: optional(string()),\n weight: optional(\n union([FontFaceWeightStruct, size(array(FontFaceWeightStruct), 2)]),\n ),\n src: optional(array(FontFaceSourceStruct)),\n style: optional(string()),\n display: optional(enums(['auto', 'block', 'swap', 'fallback', 'optional'])),\n variationSettings: optional(string()),\n unicodeRange: optional(string()),\n});\n\nexport type FontSizeConfig = {\n min: FontSizeConfigVal;\n max?: FontSizeConfigVal;\n};\n\nexport enum TextTransforms {\n inherit = 'As typed',\n capitalize = 'Capitalize',\n lowercase = 'Lowercase',\n uppercase = 'Uppercase',\n}\n\nexport enum FontStretches {\n 'ultra-condensed' = 'Ultra-condensed',\n 'extra-condensed' = 'Extra-condensed',\n condensed = 'Condensed',\n 'semi-condensed' = 'Semi-condensed',\n normal = 'Normal',\n 'semi-expanded' = 'Semi-expanded',\n expanded = 'Expanded',\n 'extra-expanded' = 'Extra-expanded',\n 'ultra-expanded' = 'Ultra-expanded',\n}\n\nexport type TypographyConfig = {\n /**\n * min / max height used to future-proof way of supporting responsive typography\n */\n fontSize?: FontSizeConfig;\n\n /**\n * reminder: line-heights can also be unitless!\n */\n lineHeight?: string | number;\n fontWeight?: FontFaceWeight;\n\n /**\n * note: letter-spacing can't be unitless, unit required!\n */\n letterSpacing?: string;\n\n /**\n * if not specified, Knapsack default font, otherwise should allow for a stack of font strings + fallbacks (including the names of custom registered fonts)\n */\n fontFamily?: string;\n\n textColor?: ColorConfig;\n\n textTransform?: keyof typeof TextTransforms;\n\n fontStretch?: keyof typeof FontStretches;\n};\n\nexport interface TypographyLinkConfig {\n fontWeight?: FontFaceWeight;\n textColor?: ColorConfig;\n hoverColor?: ColorConfig;\n underline?: boolean;\n textTransform?: keyof typeof TextTransforms;\n fontStretch?: keyof typeof FontStretches;\n}\n\nexport const TypographyLinkConfigStruct: Describe<TypographyLinkConfig> = type({\n fontWeight: optional(union([string(), number()])),\n textColor: optional(ColorConfigStruct),\n hoverColor: optional(ColorConfigStruct),\n underline: optional(boolean()),\n textTransform: optional(\n enums(['inherit', 'capitalize', 'lowercase', 'uppercase']),\n ),\n fontStretch: optional(\n enums([\n 'ultra-condensed',\n 'extra-condensed',\n 'condensed',\n 'semi-condensed',\n 'normal',\n 'semi-expanded',\n 'expanded',\n 'extra-expanded',\n 'ultra-expanded',\n ]),\n ),\n});\n\nexport const FontSizeConfigStruct: Describe<FontSizeConfig> = type({\n min: FontSizeConfigValStruct,\n max: optional(FontSizeConfigValStruct),\n});\n\nexport const TypographyConfigStruct: Describe<TypographyConfig> = type({\n fontSize: optional(FontSizeConfigStruct),\n lineHeight: optional(union([string(), number()])),\n fontWeight: optional(union([string(), number()])),\n letterSpacing: optional(string()),\n fontFamily: optional(string()),\n textColor: optional(ColorConfigStruct),\n textTransform: optional(\n enums(['inherit', 'capitalize', 'lowercase', 'uppercase']),\n ),\n fontStretch: optional(\n enums([\n 'ultra-condensed',\n 'extra-condensed',\n 'condensed',\n 'semi-condensed',\n 'normal',\n 'semi-expanded',\n 'expanded',\n 'extra-expanded',\n 'ultra-expanded',\n ]),\n ),\n});\n\nconst pageElementConfig: TypographyConfig = {};\nconst pageLinkElementConfig: TypographyLinkConfig = {};\n\nexport const pageElements = {\n pageTitle: pageElementConfig,\n pageDescription: pageElementConfig,\n headingLarge: pageElementConfig,\n headingMedium: pageElementConfig,\n headingSmall: pageElementConfig,\n bodyText: pageElementConfig,\n link: pageLinkElementConfig,\n} as const;\n\nexport const pageElementsV2 = {\n pageTitle: pageElementConfig,\n pageDescription: pageElementConfig,\n headingXLarge: pageElementConfig,\n headingLarge: pageElementConfig,\n headingMedium: pageElementConfig,\n headingSmall: pageElementConfig,\n headingXSmall: pageElementConfig,\n bodyText: pageElementConfig,\n link: pageLinkElementConfig,\n} as const;\n\nexport type PageElementNames = keyof typeof pageElementsV2;\nexport type PageElementConfig = (typeof pageElementsV2)[PageElementNames];\n"]}
|
package/dist/ui-config.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Describe } from 'superstruct';
|
|
2
|
-
import { ExpandRecursively } from '@knapsack/utils';
|
|
3
|
-
import { ColorConfig } from './color-config';
|
|
4
|
-
import { FontFaceConfig, pageElements, pageElementsV2 } from './typography-config';
|
|
5
|
-
import { customizableNavElements } from './nav-customization-config';
|
|
1
|
+
import { type Describe } from 'superstruct';
|
|
2
|
+
import { type ExpandRecursively } from '@knapsack/utils';
|
|
3
|
+
import { type ColorConfig } from './color-config';
|
|
4
|
+
import { type FontFaceConfig, type pageElements, type pageElementsV2 } from './typography-config';
|
|
5
|
+
import { type customizableNavElements } from './nav-customization-config';
|
|
6
6
|
export type UiConfigV1 = {
|
|
7
7
|
version: 1;
|
|
8
8
|
oldSillySidebarBgColor: string;
|
package/dist/ui-config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui-config.d.ts","sourceRoot":"","sources":["../src/ui-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,
|
|
1
|
+
{"version":3,"file":"ui-config.d.ts","sourceRoot":"","sources":["../src/ui-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,QAAQ,EAOd,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EACL,KAAK,WAAW,EAGjB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAEL,KAAK,cAAc,EAGnB,KAAK,YAAY,EACjB,KAAK,cAAc,EACpB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,KAAK,uBAAuB,EAI7B,MAAM,4BAA4B,CAAC;AAEpC,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,CAAC,CAAC;IACX,sBAAsB,EAAE,MAAM,CAAC;CAChC,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,UAAU,CAGhD,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,C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AM,MAAM,WAAW,GAAG,iBAAiB,CAAC,YAAY,CAAC,CAAC;AAE1D,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAwBlD,CAAC;AAEH,MAAM,MAAM,gBAAgB,GACxB,OAAO,gBAAgB,CAAC,IAAI,GAC5B,OAAO,gBAAgB,CAAC,IAAI,GAC5B,OAAO,gBAAgB,CAAC,IAAI,GAC5B,OAAO,gBAAgB,CAAC,IAAI,GAC5B,OAAO,gBAAgB,CAAC,IAAI,GAC5B,OAAO,gBAAgB,CAAC,IAAI,GAC5B,OAAO,gBAAgB,CAAC,IAAI,GAC5B,OAAO,gBAAgB,CAAC,IAAI,GAC5B,OAAO,gBAAgB,CAAC,IAAI,GAC5B,OAAO,iBAAiB,CAAC,IAAI,CAAC;AAGlC,MAAM,MAAM,QAAQ,GAAG,WAAW,CAAC;AACnC,eAAO,MAAM,cAAc,EAAE,OAAO,iBAAqC,CAAC;AAE1E,MAAM,MAAM,eAAe,GAAG,MAAM,QAAQ,CAAC,YAAY,CAAC,CAAC,YAAY,CAAC,CAAC"}
|
package/dist/ui-config.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var superstruct=require('superstruct'),w=require('color-string');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var w__default=/*#__PURE__*/_interopDefault(w);var P=Object.defineProperty;var N=(
|
|
1
|
+
'use strict';var superstruct=require('superstruct'),w=require('color-string');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var w__default=/*#__PURE__*/_interopDefault(w);var P=Object.defineProperty;var N=(g,F)=>P(g,"name",{value:F,configurable:true});function _(g){if(typeof g!="string")return false;try{return !!w__default.default.get(g)}catch{return false}}N(_,"isColor");var f=superstruct.define("ColorStringStruct",g=>typeof g=="string"&&_(g)),t=superstruct.union([superstruct.type({type:superstruct.literal("value"),colorValue:f}),superstruct.type({type:superstruct.literal("design-token"),tokenName:superstruct.string()})]);superstruct.type({type:superstruct.literal("design-token"),tokenName:superstruct.string()});var D=superstruct.object({unit:superstruct.enums(["rem","px"]),value:superstruct.number()}),L=superstruct.union([superstruct.string(),superstruct.number()]);var O=superstruct.enums(["woff2","woff"]),H=superstruct.type({format:O,type:superstruct.literal("url"),path:superstruct.string()}),C=superstruct.type({family:superstruct.optional(superstruct.string()),weight:superstruct.optional(superstruct.union([L,superstruct.size(superstruct.array(L),2)])),src:superstruct.optional(superstruct.array(H)),style:superstruct.optional(superstruct.string()),display:superstruct.optional(superstruct.enums(["auto","block","swap","fallback","optional"])),variationSettings:superstruct.optional(superstruct.string()),unicodeRange:superstruct.optional(superstruct.string())});var c=superstruct.type({fontWeight:superstruct.optional(superstruct.union([superstruct.string(),superstruct.number()])),textColor:superstruct.optional(t),hoverColor:superstruct.optional(t),underline:superstruct.optional(superstruct.boolean()),textTransform:superstruct.optional(superstruct.enums(["inherit","capitalize","lowercase","uppercase"])),fontStretch:superstruct.optional(superstruct.enums(["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded"]))}),X=superstruct.type({min:D,max:superstruct.optional(D)}),o=superstruct.type({fontSize:superstruct.optional(X),lineHeight:superstruct.optional(superstruct.union([superstruct.string(),superstruct.number()])),fontWeight:superstruct.optional(superstruct.union([superstruct.string(),superstruct.number()])),letterSpacing:superstruct.optional(superstruct.string()),fontFamily:superstruct.optional(superstruct.string()),textColor:superstruct.optional(t),textTransform:superstruct.optional(superstruct.enums(["inherit","capitalize","lowercase","uppercase"])),fontStretch:superstruct.optional(superstruct.enums(["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded"]))});var l=superstruct.union([o,superstruct.type({accentColor:superstruct.optional(t)})]),u=superstruct.union([l,superstruct.type({hoverColor:superstruct.optional(t),backgroundColor:superstruct.optional(t)})]),x=superstruct.union([l,superstruct.type({backgroundColor:superstruct.optional(t)})]);var se=superstruct.object({version:superstruct.literal(1),oldSillySidebarBgColor:f}),le=superstruct.object({version:superstruct.literal(2),anotherSillySidebarBgColor:f}),Ce=superstruct.object({version:superstruct.literal(3),sidebarBgColor:f}),ce=superstruct.object({version:superstruct.literal(4),primaryColor:t,darkColor:t,lightColor:t,enableSidebarIcons:superstruct.optional(superstruct.defaulted(superstruct.boolean(),true))}),fe=superstruct.object({version:superstruct.literal(5),primaryColor:t,darkColor:t,lightColor:t,linkColor:t,enableSidebarIcons:superstruct.optional(superstruct.defaulted(superstruct.boolean(),true))}),me=superstruct.object({version:superstruct.literal(6),primaryColor:t,darkColor:t,lightColor:t,linkColor:t,enableSidebarIcons:superstruct.optional(superstruct.defaulted(superstruct.boolean(),true)),appearance:superstruct.type({customFonts:superstruct.optional(superstruct.array(C)),pageElements:superstruct.type({pageTitle:superstruct.optional(o),pageDescription:superstruct.optional(o),headingLarge:superstruct.optional(o),headingMedium:superstruct.optional(o),headingSmall:superstruct.optional(o),bodyText:superstruct.optional(o),link:superstruct.optional(c)})})}),ye=superstruct.object({version:superstruct.literal(7),primaryColor:t,darkColor:t,lightColor:t,linkColor:t,enableSidebarIcons:superstruct.optional(superstruct.defaulted(superstruct.boolean(),true)),appearance:superstruct.type({customFonts:superstruct.optional(superstruct.array(C)),navigation:superstruct.optional(superstruct.type({primaryNav:superstruct.optional(u),secondaryNav:superstruct.optional(x),tabs:superstruct.optional(l)})),pageElements:superstruct.type({pageTitle:superstruct.optional(o),pageDescription:superstruct.optional(o),headingLarge:superstruct.optional(o),headingMedium:superstruct.optional(o),headingSmall:superstruct.optional(o),bodyText:superstruct.optional(o),link:superstruct.optional(c)})})}),de=superstruct.object({version:superstruct.literal(8),primaryColor:t,darkColor:t,lightColor:t,linkColor:t,appearance:superstruct.type({customFonts:superstruct.optional(superstruct.array(C)),navigation:superstruct.optional(superstruct.type({primaryNav:superstruct.optional(u),secondaryNav:superstruct.optional(x),tabs:superstruct.optional(l)})),pageElements:superstruct.type({pageTitle:superstruct.optional(o),pageDescription:superstruct.optional(o),headingLarge:superstruct.optional(o),headingMedium:superstruct.optional(o),headingSmall:superstruct.optional(o),bodyText:superstruct.optional(o),link:superstruct.optional(c)})})}),ue=superstruct.object({version:superstruct.literal(9),appearance:superstruct.type({customFonts:superstruct.optional(superstruct.array(C)),navigation:superstruct.optional(superstruct.type({primaryNav:superstruct.optional(u),secondaryNav:superstruct.optional(x),tabs:superstruct.optional(l)})),pageElements:superstruct.type({pageTitle:superstruct.optional(o),pageDescription:superstruct.optional(o),headingLarge:superstruct.optional(o),headingMedium:superstruct.optional(o),headingSmall:superstruct.optional(o),bodyText:superstruct.optional(o),link:superstruct.optional(c)})})}),j=superstruct.object({version:superstruct.literal(10),appearance:superstruct.type({customFonts:superstruct.optional(superstruct.array(C)),navigation:superstruct.optional(superstruct.type({primaryNav:superstruct.optional(u),secondaryNav:superstruct.optional(x),tabs:superstruct.optional(l)})),pageElements:superstruct.type({pageTitle:superstruct.optional(o),pageDescription:superstruct.optional(o),headingXLarge:superstruct.optional(o),headingLarge:superstruct.optional(o),headingMedium:superstruct.optional(o),headingSmall:superstruct.optional(o),headingXSmall:superstruct.optional(o),bodyText:superstruct.optional(o),link:superstruct.optional(c)})})}),xe=j;exports.UiConfigStruct=xe;exports.UiConfigV10Struct=j;exports.UiConfigV1Struct=se;exports.UiConfigV2Struct=le;exports.UiConfigV3Struct=Ce;exports.UiConfigV4Struct=ce;exports.UiConfigV5Struct=fe;exports.UiConfigV6Struct=me;exports.UiConfigV7Struct=ye;exports.UiConfigV8Struct=de;exports.UiConfigV9Struct=ue;//# sourceMappingURL=ui-config.js.map
|
|
2
2
|
//# sourceMappingURL=ui-config.js.map
|
package/dist/ui-config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/color-config.ts","../src/typography-config.ts","../src/nav-customization-config.ts","../src/ui-config.ts"],"names":["isColor","color","colorString","__name","ColorStringStruct","define","value","ColorConfigStruct","union","type","literal","string","FontSizeConfigValStruct","object","enums","number","FontFaceWeightStruct","FontFaceFormatsEnumStruct","FontFaceSourceStruct","FontFaceConfigStruct","optional","size","array","TypographyLinkConfigStruct","boolean","FontSizeConfigStruct","TypographyConfigStruct","NavCustomizationConfigStruct","PrimaryNavCustomizationConfigStruct","SecondaryNavCustomizationConfigStruct","UiConfigV1Struct","UiConfigV2Struct","UiConfigV3Struct","UiConfigV4Struct","defaulted","UiConfigV5Struct","UiConfigV6Struct","UiConfigV7Struct","UiConfigV8Struct","UiConfigV9Struct","UiConfigV10Struct","UiConfigStruct"],"mappings":"+QAIA,SAASA,CAAQC,CAAAA,CAAAA,CAAiC,CAChD,GAAI,OAAOA,CAAU,EAAA,QAAA,CAAU,OAAO,MAAA,CACtC,GAAI,CACF,OAAO,CAAC,CAACC,kBAAY,CAAA,GAAA,CAAID,CAAK,CAChC,CAAA,KAAY,CACV,OAAO,MACT,CACF,CAPSE,CAAAH,CAAAA,CAAAA,CAAA,SAkBF,CAAA,CAAA,IAAMI,CAAoBC,CAAAA,kBAAAA,CAC/B,oBACCC,CAAU,EAAA,OAAOA,CAAU,EAAA,QAAA,EAAYN,CAAQM,CAAAA,CAAK,CACvD,CAEaC,CAAAA,CAAAA,CAA2CC,iBAAM,CAAA,CAC5DC,gBAAK,CAAA,CACH,KAAMC,mBAAQ,CAAA,OAAO,CACrB,CAAA,UAAA,CAAYN,CACd,CAAC,EACDK,gBAAK,CAAA,CACH,IAAMC,CAAAA,mBAAAA,CAAQ,cAAc,CAAA,CAC5B,UAAWC,kBAAO,EACpB,CAAC,CACH,CAAC,CAAA,CAGiEF,gBAAK,CAAA,CACrE,IAAMC,CAAAA,mBAAAA,CAAQ,cAAc,CAAA,CAC5B,SAAWC,CAAAA,kBAAAA,EACb,CAAC,EClBM,IAAMC,CAAuDC,CAAAA,kBAAAA,CAAO,CACzE,IAAA,CAAMC,iBAAM,CAAA,CAAC,MAAO,IAAI,CAAC,CACzB,CAAA,KAAA,CAAOC,kBAAO,EAChB,CAAC,CAIYC,CAAAA,CAAAA,CAAiDR,iBAAM,CA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,CAAsB,CAAA,CAChD,cAAeN,oBAASM,CAAAA,CAAsB,CAC9C,CAAA,YAAA,CAAcN,oBAASM,CAAAA,CAAsB,EAC7C,aAAeN,CAAAA,oBAAAA,CAASM,CAAsB,CAAA,CAC9C,YAAcN,CAAAA,oBAAAA,CAASM,CAAsB,CAC7C,CAAA,aAAA,CAAeN,oBAASM,CAAAA,CAAsB,CAC9C,CAAA,QAAA,CAAUN,qBAASM,CAAsB,CAAA,CACzC,IAAMN,CAAAA,oBAAAA,CAASG,CAA0B,CAC3C,CAAC,CACH,CAAC,CACH,CAAC,CAAA,CAgBYkB,EAA2CD,CAAAA","file":"ui-config.js","sourcesContent":["import colorString from 'color-string';\nimport { define, Describe, literal, string, type, union } from 'superstruct'; // https://docs.superstructjs.org\n\n/** Use `import { isColor } from '@knapsack/color-utils'` if you can, need to duplicate this logic due to dep cycle */\nfunction isColor(color: unknown): color is string {\n if (typeof color !== 'string') return false;\n try {\n return !!colorString.get(color);\n } catch (e) {\n return false;\n }\n}\n\nexport type ColorTokenConfig = {\n type: 'design-token';\n /** Will be **either** `-` (old) or `.` (new) separated */\n tokenName: string;\n};\nexport type ColorConfig =\n | { type: 'value'; colorValue: string }\n | ColorTokenConfig;\n\nexport const ColorStringStruct = define<string>(\n 'ColorStringStruct',\n (value) => typeof value === 'string' && isColor(value),\n);\n\nexport const ColorConfigStruct: Describe<ColorConfig> = union([\n type({\n type: literal('value'),\n colorValue: ColorStringStruct,\n }),\n type({\n type: literal('design-token'),\n tokenName: string(),\n }),\n]);\n\n// so we can check if an object is not just a ColorConfig but specifically a token\nexport const ColorTokenConfigStruct: Describe<ColorTokenConfig> = type({\n type: literal('design-token'),\n tokenName: string(),\n});\n","import {\n Describe,\n string,\n type,\n union,\n number,\n enums,\n optional,\n literal,\n array,\n size,\n boolean,\n object,\n} from 'superstruct'; // https://docs.superstructjs.org\nimport { ColorConfig, ColorConfigStruct } from './color-config';\n\nexport const HeadingLevels = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] as const;\nexport type HeadingLevel = (typeof HeadingLevels)[number];\n\nexport type FontSizeConfigVal = {\n unit: 'px' | 'rem';\n value: number;\n};\n\nexport const FontSizeConfigValStruct: Describe<FontSizeConfigVal> = object({\n unit: enums(['rem', 'px']),\n value: number(),\n});\n\nexport type FontFaceWeight = number | string;\n\nexport const FontFaceWeightStruct: Describe<FontFaceWeight> = union([\n string(),\n number(),\n]);\n\nexport enum FontFaceSourceFormats {\n woff2 = 'woff2',\n woff = 'woff',\n}\n\nexport type FontFaceSource = {\n /**\n * Note: if /when we eventually add 'local' type support, format isn't used!\n */\n format: keyof typeof FontFaceSourceFormats;\n type: 'url';\n path: string;\n};\n\nexport const FontFaceFormatsEnumStruct = enums(['woff2', 'woff']);\n\nexport const FontFaceSourceStruct: Describe<FontFaceSource> = type({\n format: FontFaceFormatsEnumStruct,\n type: literal('url'),\n path: string(),\n});\n\nexport type FontFaceConfig = {\n /**\n * registered name of the custom font\n *\n * MDN Docs on {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-family @font-face's font-family property}\n */\n family?: string;\n\n /**\n * number between 1 and 1000.\n *\n * note: since two weights are allowed (with variable fonts), this type is an\n * optional array for easy parsing down the road.\n *\n * MDN Docs on {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-weight @font-face's font-weight property}.\n */\n weight?: FontFaceWeight | FontFaceWeight[];\n\n /**\n * the collection of urls / paths pointing to font files\n *\n * MDN Docs on {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/src @font-face's src property}.\n */\n src?: FontFaceSource[];\n\n /**\n * the style of the custom font (ex. normal or italic)\n *\n * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-style See MDN docs on font-style}.\n */\n style?: string;\n\n // @todo: implement these later\n // display?: 'auto' | 'block' | 'swap' | 'fallback' | 'optional';\n // variationSettings?: string;\n // unicodeRange?: string; // or ideally, URange; //\n // see https://drafts.csswg.org/css-syntax-3/#urange-syntax and\n // https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/unicode-range\n};\n\nexport const FontFaceConfigStruct: Describe<FontFaceConfig> = type({\n family: optional(string()),\n weight: optional(\n union([FontFaceWeightStruct, size(array(FontFaceWeightStruct), 2)]),\n ),\n src: optional(array(FontFaceSourceStruct)),\n style: optional(string()),\n display: optional(enums(['auto', 'block', 'swap', 'fallback', 'optional'])),\n variationSettings: optional(string()),\n unicodeRange: optional(string()),\n});\n\nexport type FontSizeConfig = {\n min: FontSizeConfigVal;\n max?: FontSizeConfigVal;\n};\n\nexport enum TextTransforms {\n inherit = 'As typed',\n capitalize = 'Capitalize',\n lowercase = 'Lowercase',\n uppercase = 'Uppercase',\n}\n\nexport enum FontStretches {\n 'ultra-condensed' = 'Ultra-condensed',\n 'extra-condensed' = 'Extra-condensed',\n condensed = 'Condensed',\n 'semi-condensed' = 'Semi-condensed',\n normal = 'Normal',\n 'semi-expanded' = 'Semi-expanded',\n expanded = 'Expanded',\n 'extra-expanded' = 'Extra-expanded',\n 'ultra-expanded' = 'Ultra-expanded',\n}\n\nexport type TypographyConfig = {\n /**\n * min / max height used to future-proof way of supporting responsive typography\n */\n fontSize?: FontSizeConfig;\n\n /**\n * reminder: line-heights can also be unitless!\n */\n lineHeight?: string | number;\n fontWeight?: FontFaceWeight;\n\n /**\n * note: letter-spacing can't be unitless, unit required!\n */\n letterSpacing?: string;\n\n /**\n * if not specified, Knapsack default font, otherwise should allow for a stack of font strings + fallbacks (including the names of custom registered fonts)\n */\n fontFamily?: string;\n\n textColor?: ColorConfig;\n\n textTransform?: keyof typeof TextTransforms;\n\n fontStretch?: keyof typeof FontStretches;\n};\n\nexport interface TypographyLinkConfig {\n fontWeight?: FontFaceWeight;\n textColor?: ColorConfig;\n hoverColor?: ColorConfig;\n underline?: boolean;\n textTransform?: keyof typeof TextTransforms;\n fontStretch?: keyof typeof FontStretches;\n}\n\nexport const TypographyLinkConfigStruct: Describe<TypographyLinkConfig> = type({\n fontWeight: optional(union([string(), number()])),\n textColor: optional(ColorConfigStruct),\n hoverColor: optional(ColorConfigStruct),\n underline: optional(boolean()),\n textTransform: optional(\n enums(['inherit', 'capitalize', 'lowercase', 'uppercase']),\n ),\n fontStretch: optional(\n enums([\n 'ultra-condensed',\n 'extra-condensed',\n 'condensed',\n 'semi-condensed',\n 'normal',\n 'semi-expanded',\n 'expanded',\n 'extra-expanded',\n 'ultra-expanded',\n ]),\n ),\n});\n\nexport const FontSizeConfigStruct: Describe<FontSizeConfig> = type({\n min: FontSizeConfigValStruct,\n max: optional(FontSizeConfigValStruct),\n});\n\nexport const TypographyConfigStruct: Describe<TypographyConfig> = type({\n fontSize: optional(FontSizeConfigStruct),\n lineHeight: optional(union([string(), number()])),\n fontWeight: optional(union([string(), number()])),\n letterSpacing: optional(string()),\n fontFamily: optional(string()),\n textColor: optional(ColorConfigStruct),\n textTransform: optional(\n enums(['inherit', 'capitalize', 'lowercase', 'uppercase']),\n ),\n fontStretch: optional(\n enums([\n 'ultra-condensed',\n 'extra-condensed',\n 'condensed',\n 'semi-condensed',\n 'normal',\n 'semi-expanded',\n 'expanded',\n 'extra-expanded',\n 'ultra-expanded',\n ]),\n ),\n});\n\nconst pageElementConfig: TypographyConfig = {};\nconst pageLinkElementConfig: TypographyLinkConfig = {};\n\nexport const pageElements = {\n pageTitle: pageElementConfig,\n pageDescription: pageElementConfig,\n headingLarge: pageElementConfig,\n headingMedium: pageElementConfig,\n headingSmall: pageElementConfig,\n bodyText: pageElementConfig,\n link: pageLinkElementConfig,\n} as const;\n\nexport const pageElementsV2 = {\n pageTitle: pageElementConfig,\n pageDescription: pageElementConfig,\n headingXLarge: pageElementConfig,\n headingLarge: pageElementConfig,\n headingMedium: pageElementConfig,\n headingSmall: pageElementConfig,\n headingXSmall: pageElementConfig,\n bodyText: pageElementConfig,\n link: pageLinkElementConfig,\n} as const;\n\nexport type PageElementNames = keyof typeof pageElementsV2;\nexport type PageElementConfig = (typeof pageElementsV2)[PageElementNames];\n","import { Describe, type, union, optional } from 'superstruct'; // https://docs.superstructjs.org\nimport { ColorConfig, ColorConfigStruct } from './color-config';\nimport { TypographyConfig, TypographyConfigStruct } from './typography-config';\n\nexport interface NavCustomizationConfig extends TypographyConfig {\n accentColor?: ColorConfig;\n}\n\nexport interface PrimaryNavCustomizationConfig extends NavCustomizationConfig {\n hoverColor?: ColorConfig;\n backgroundColor?: ColorConfig;\n}\n\nexport type SecondaryNavCustomizationConfig = Omit<\n PrimaryNavCustomizationConfig,\n 'hoverColor'\n>;\n\nexport const NavCustomizationConfigStruct: Describe<NavCustomizationConfig> =\n union([\n TypographyConfigStruct,\n type({\n accentColor: optional(ColorConfigStruct),\n }),\n ]);\n\n// hoverColor: optional(ColorConfigStruct),\nexport const PrimaryNavCustomizationConfigStruct: Describe<PrimaryNavCustomizationConfig> =\n union([\n NavCustomizationConfigStruct,\n type({\n hoverColor: optional(ColorConfigStruct),\n backgroundColor: optional(ColorConfigStruct),\n }),\n ]);\n\nexport const SecondaryNavCustomizationConfigStruct: Describe<SecondaryNavCustomizationConfig> =\n union([\n NavCustomizationConfigStruct,\n type({\n backgroundColor: optional(ColorConfigStruct),\n }),\n ]);\n\nconst navCustomizationConfig: NavCustomizationConfig = {};\nconst secondaryNavCustomizationConfig: SecondaryNavCustomizationConfig = {};\nconst primaryNavCustomizationConfig: PrimaryNavCustomizationConfig = {};\n\nexport const customizableNavElements = {\n primaryNav: primaryNavCustomizationConfig,\n secondaryNav: secondaryNavCustomizationConfig,\n tabs: navCustomizationConfig,\n} as const;\n\nexport type CustomizableNavElementNames = keyof typeof customizableNavElements;\nexport type CustomizableNavElementConfig =\n (typeof customizableNavElements)[CustomizableNavElementNames];\n","import {\n type,\n Describe,\n literal,\n optional,\n defaulted,\n boolean,\n array,\n object,\n} from 'superstruct';\n\nimport { ExpandRecursively } from '@knapsack/utils';\n\nimport {\n ColorConfig,\n ColorConfigStruct,\n ColorStringStruct,\n} from './color-config';\n\nimport {\n FontFaceConfigStruct,\n FontFaceConfig,\n TypographyConfigStruct,\n TypographyLinkConfigStruct,\n pageElements,\n pageElementsV2,\n} from './typography-config';\n\nimport {\n customizableNavElements,\n NavCustomizationConfigStruct,\n PrimaryNavCustomizationConfigStruct,\n SecondaryNavCustomizationConfigStruct,\n} from './nav-customization-config';\n\nexport type UiConfigV1 = {\n version: 1;\n oldSillySidebarBgColor: string;\n};\n\nexport const UiConfigV1Struct: Describe<UiConfigV1> = object({\n version: literal(1),\n oldSillySidebarBgColor: ColorStringStruct,\n});\n\nexport type UiConfigV2 = {\n version: 2;\n anotherSillySidebarBgColor: string;\n};\n\nexport const UiConfigV2Struct: Describe<UiConfigV2> = object({\n version: literal(2),\n anotherSillySidebarBgColor: ColorStringStruct,\n});\n\nexport type UiConfigV3 = {\n version: 3;\n sidebarBgColor: string;\n};\n\nexport const UiConfigV3Struct: Describe<UiConfigV3> = object({\n version: literal(3),\n sidebarBgColor: ColorStringStruct,\n});\n\nexport type UiConfigV4 = {\n version: 4;\n primaryColor: ColorConfig;\n darkColor: ColorConfig;\n lightColor: ColorConfig;\n enableSidebarIcons?: boolean;\n};\nexport const UiConfigV4Struct: Describe<UiConfigV4> = object({\n version: literal(4),\n primaryColor: ColorConfigStruct,\n darkColor: ColorConfigStruct,\n lightColor: ColorConfigStruct,\n enableSidebarIcons: optional(defaulted(boolean(), true)),\n});\n\nexport type UiConfigV5 = {\n version: 5;\n primaryColor: ColorConfig;\n darkColor: ColorConfig;\n lightColor: ColorConfig;\n linkColor: ColorConfig;\n enableSidebarIcons: boolean;\n};\nexport const UiConfigV5Struct: Describe<UiConfigV5> = object({\n version: literal(5),\n primaryColor: ColorConfigStruct,\n darkColor: ColorConfigStruct,\n lightColor: ColorConfigStruct,\n linkColor: ColorConfigStruct,\n enableSidebarIcons: optional(defaulted(boolean(), true)),\n});\n\nexport interface _UiConfigV6 extends Omit<UiConfigV5, 'version'> {\n version: 6;\n appearance: {\n customFonts?: FontFaceConfig[];\n pageElements: typeof pageElements;\n };\n}\n\n// ExpandRecursively needed to avoid \"Type 'UiConfigV6' is not assignable to type 'Record<string, unknown>'.\" error\nexport type UiConfigV6 = ExpandRecursively<_UiConfigV6>;\n\nexport const UiConfigV6Struct: Describe<UiConfigV6> = object({\n version: literal(6),\n primaryColor: ColorConfigStruct,\n darkColor: ColorConfigStruct,\n lightColor: ColorConfigStruct,\n linkColor: ColorConfigStruct,\n enableSidebarIcons: optional(defaulted(boolean(), true)),\n\n appearance: type({\n customFonts: optional(array(FontFaceConfigStruct)),\n pageElements: type({\n pageTitle: optional(TypographyConfigStruct),\n pageDescription: optional(TypographyConfigStruct),\n headingLarge: optional(TypographyConfigStruct),\n headingMedium: optional(TypographyConfigStruct),\n headingSmall: optional(TypographyConfigStruct),\n bodyText: optional(TypographyConfigStruct),\n link: optional(TypographyLinkConfigStruct),\n }),\n }),\n});\n\nexport interface _UiConfigV7 extends Omit<UiConfigV6, 'version'> {\n version: 7;\n appearance: {\n navigation?: typeof customizableNavElements;\n customFonts?: UiConfigV6['appearance']['customFonts'];\n pageElements: UiConfigV6['appearance']['pageElements'];\n };\n}\n\n// ExpandRecursively needed to avoid \"Type 'UiConfig7' is not assignable to type 'Record<string, unknown>'.\" error in ui-config.xstate.ts\nexport type UiConfigV7 = ExpandRecursively<_UiConfigV7>;\n\nexport const UiConfigV7Struct: Describe<UiConfigV7> = object({\n version: literal(7),\n primaryColor: ColorConfigStruct,\n darkColor: ColorConfigStruct,\n lightColor: ColorConfigStruct,\n linkColor: ColorConfigStruct,\n enableSidebarIcons: optional(defaulted(boolean(), true)),\n\n appearance: type({\n customFonts: optional(array(FontFaceConfigStruct)),\n navigation: optional(\n type({\n primaryNav: optional(PrimaryNavCustomizationConfigStruct),\n secondaryNav: optional(SecondaryNavCustomizationConfigStruct),\n tabs: optional(NavCustomizationConfigStruct),\n }),\n ),\n pageElements: type({\n pageTitle: optional(TypographyConfigStruct),\n pageDescription: optional(TypographyConfigStruct),\n headingLarge: optional(TypographyConfigStruct),\n headingMedium: optional(TypographyConfigStruct),\n headingSmall: optional(TypographyConfigStruct),\n bodyText: optional(TypographyConfigStruct),\n link: optional(TypographyLinkConfigStruct),\n }),\n }),\n});\n\nexport interface _UiConfigV8\n extends Omit<UiConfigV7, 'version' | 'enableSidebarIcons'> {\n version: 8;\n}\n\n// ExpandRecursively needed to avoid \"Type 'UiConfig8' is not assignable to type 'Record<string, unknown>'.\" error in ui-config.xstate.ts\n// TODO: move this to @knapsack/types\nexport type UiConfigV8 = ExpandRecursively<_UiConfigV8>;\n\nexport const UiConfigV8Struct: Describe<UiConfigV8> = object({\n version: literal(8),\n primaryColor: ColorConfigStruct,\n darkColor: ColorConfigStruct,\n lightColor: ColorConfigStruct,\n linkColor: ColorConfigStruct,\n\n appearance: type({\n customFonts: optional(array(FontFaceConfigStruct)),\n navigation: optional(\n type({\n primaryNav: optional(PrimaryNavCustomizationConfigStruct),\n secondaryNav: optional(SecondaryNavCustomizationConfigStruct),\n tabs: optional(NavCustomizationConfigStruct),\n }),\n ),\n pageElements: type({\n pageTitle: optional(TypographyConfigStruct),\n pageDescription: optional(TypographyConfigStruct),\n headingLarge: optional(TypographyConfigStruct),\n headingMedium: optional(TypographyConfigStruct),\n headingSmall: optional(TypographyConfigStruct),\n bodyText: optional(TypographyConfigStruct),\n link: optional(TypographyLinkConfigStruct),\n }),\n }),\n});\n\nexport interface _UiConfigV9\n extends Omit<\n UiConfigV8,\n 'version' | 'primaryColor' | 'darkColor' | 'lightColor' | 'linkColor'\n > {\n version: 9;\n}\nexport type UiConfigV9 = ExpandRecursively<_UiConfigV9>;\n\nexport const UiConfigV9Struct: Describe<UiConfigV9> = object({\n version: literal(9),\n\n appearance: type({\n customFonts: optional(array(FontFaceConfigStruct)),\n navigation: optional(\n type({\n primaryNav: optional(PrimaryNavCustomizationConfigStruct),\n secondaryNav: optional(SecondaryNavCustomizationConfigStruct),\n tabs: optional(NavCustomizationConfigStruct),\n }),\n ),\n pageElements: type({\n pageTitle: optional(TypographyConfigStruct),\n pageDescription: optional(TypographyConfigStruct),\n headingLarge: optional(TypographyConfigStruct),\n headingMedium: optional(TypographyConfigStruct),\n headingSmall: optional(TypographyConfigStruct),\n bodyText: optional(TypographyConfigStruct),\n link: optional(TypographyLinkConfigStruct),\n }),\n }),\n});\n\nexport interface _UiConfigV10 extends Omit<UiConfigV9, 'version'> {\n version: 10;\n appearance: {\n navigation?: UiConfigV9['appearance']['navigation'];\n customFonts?: UiConfigV9['appearance']['customFonts'];\n pageElements: typeof pageElementsV2;\n };\n}\nexport type UiConfigV10 = ExpandRecursively<_UiConfigV10>;\n\nexport const UiConfigV10Struct: Describe<UiConfigV10> = object({\n version: literal(10),\n\n appearance: type({\n customFonts: optional(array(FontFaceConfigStruct)),\n navigation: optional(\n type({\n primaryNav: optional(PrimaryNavCustomizationConfigStruct),\n secondaryNav: optional(SecondaryNavCustomizationConfigStruct),\n tabs: optional(NavCustomizationConfigStruct),\n }),\n ),\n pageElements: type({\n pageTitle: optional(TypographyConfigStruct),\n pageDescription: optional(TypographyConfigStruct),\n headingXLarge: optional(TypographyConfigStruct),\n headingLarge: optional(TypographyConfigStruct),\n headingMedium: optional(TypographyConfigStruct),\n headingSmall: optional(TypographyConfigStruct),\n headingXSmall: optional(TypographyConfigStruct),\n bodyText: optional(TypographyConfigStruct),\n link: optional(TypographyLinkConfigStruct),\n }),\n }),\n});\n\nexport type UiConfigVersions =\n | typeof UiConfigV1Struct.TYPE\n | typeof UiConfigV2Struct.TYPE\n | typeof UiConfigV3Struct.TYPE\n | typeof UiConfigV4Struct.TYPE\n | typeof UiConfigV5Struct.TYPE\n | typeof UiConfigV6Struct.TYPE\n | typeof UiConfigV7Struct.TYPE\n | typeof UiConfigV8Struct.TYPE\n | typeof UiConfigV9Struct.TYPE\n | typeof UiConfigV10Struct.TYPE;\n\n// ALIASES FOR LATEST VERSIONS\nexport type UiConfig = UiConfigV10;\nexport const UiConfigStruct: typeof UiConfigV10Struct = UiConfigV10Struct;\n\nexport type NavElementNames = keyof UiConfig['appearance']['navigation'];\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/color-config.ts","../src/typography-config.ts","../src/nav-customization-config.ts","../src/ui-config.ts"],"names":["isColor","color","colorString","__name","ColorStringStruct","define","value","ColorConfigStruct","union","type","literal","string","FontSizeConfigValStruct","object","enums","number","FontFaceWeightStruct","FontFaceFormatsEnumStruct","FontFaceSourceStruct","FontFaceConfigStruct","optional","size","array","TypographyLinkConfigStruct","boolean","FontSizeConfigStruct","TypographyConfigStruct","NavCustomizationConfigStruct","PrimaryNavCustomizationConfigStruct","SecondaryNavCustomizationConfigStruct","UiConfigV1Struct","UiConfigV2Struct","UiConfigV3Struct","UiConfigV4Struct","defaulted","UiConfigV5Struct","UiConfigV6Struct","UiConfigV7Struct","UiConfigV8Struct","UiConfigV9Struct","UiConfigV10Struct","UiConfigStruct"],"mappings":"+QAWA,SAASA,CAAAA,CAAQC,CAAAA,CAAiC,CAChD,GAAI,OAAOA,CAAAA,EAAU,QAAA,CAAU,OAAO,MAAA,CACtC,GAAI,CACF,OAAO,CAAC,CAACC,kBAAAA,CAAY,GAAA,CAAID,CAAK,CAChC,CAAA,KAAY,CACV,OAAO,MACT,CACF,CAPSE,CAAAA,CAAAH,CAAAA,CAAA,SAAA,CAAA,CAkBF,IAAMI,CAAAA,CAAoBC,kBAAAA,CAC/B,oBACCC,CAAAA,EAAU,OAAOA,CAAAA,EAAU,QAAA,EAAYN,CAAAA,CAAQM,CAAK,CACvD,CAAA,CAEaC,CAAAA,CAA2CC,iBAAAA,CAAM,CAC5DC,gBAAAA,CAAK,CACH,KAAMC,mBAAAA,CAAQ,OAAO,CAAA,CACrB,UAAA,CAAYN,CACd,CAAC,EACDK,gBAAAA,CAAK,CACH,IAAA,CAAMC,mBAAAA,CAAQ,cAAc,CAAA,CAC5B,UAAWC,kBAAAA,EACb,CAAC,CACH,CAAC,CAAA,CAGiEF,gBAAAA,CAAK,CACrE,IAAA,CAAMC,mBAAAA,CAAQ,cAAc,CAA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,CAAcR,qBAASS,CAAqC,CAAA,CAC5D,IAAA,CAAMT,oBAAAA,CAASO,CAA4B,CAC7C,CAAC,CACH,CAAA,CACA,YAAA,CAAclB,gBAAAA,CAAK,CACjB,SAAA,CAAWW,qBAASM,CAAsB,CAAA,CAC1C,eAAA,CAAiBN,oBAAAA,CAASM,CAAsB,CAAA,CAChD,cAAeN,oBAAAA,CAASM,CAAsB,CAAA,CAC9C,YAAA,CAAcN,oBAAAA,CAASM,CAAsB,EAC7C,aAAA,CAAeN,oBAAAA,CAASM,CAAsB,CAAA,CAC9C,YAAA,CAAcN,oBAAAA,CAASM,CAAsB,CAAA,CAC7C,aAAA,CAAeN,oBAAAA,CAASM,CAAsB,CAAA,CAC9C,QAAA,CAAUN,qBAASM,CAAsB,CAAA,CACzC,IAAA,CAAMN,oBAAAA,CAASG,CAA0B,CAC3C,CAAC,CACH,CAAC,CACH,CAAC,CAAA,CAgBYkB,EAAAA,CAA2CD","file":"ui-config.js","sourcesContent":["import colorString from 'color-string';\nimport {\n define,\n type Describe,\n literal,\n string,\n type,\n union,\n} from 'superstruct'; // https://docs.superstructjs.org\n\n/** Use `import { isColor } from '@knapsack/color-utils'` if you can, need to duplicate this logic due to dep cycle */\nfunction isColor(color: unknown): color is string {\n if (typeof color !== 'string') return false;\n try {\n return !!colorString.get(color);\n } catch (e) {\n return false;\n }\n}\n\nexport type ColorTokenConfig = {\n type: 'design-token';\n /** Will be **either** `-` (old) or `.` (new) separated */\n tokenName: string;\n};\nexport type ColorConfig =\n | { type: 'value'; colorValue: string }\n | ColorTokenConfig;\n\nexport const ColorStringStruct = define<string>(\n 'ColorStringStruct',\n (value) => typeof value === 'string' && isColor(value),\n);\n\nexport const ColorConfigStruct: Describe<ColorConfig> = union([\n type({\n type: literal('value'),\n colorValue: ColorStringStruct,\n }),\n type({\n type: literal('design-token'),\n tokenName: string(),\n }),\n]);\n\n// so we can check if an object is not just a ColorConfig but specifically a token\nexport const ColorTokenConfigStruct: Describe<ColorTokenConfig> = type({\n type: literal('design-token'),\n tokenName: string(),\n});\n","import {\n type Describe,\n string,\n type,\n union,\n number,\n enums,\n optional,\n literal,\n array,\n size,\n boolean,\n object,\n} from 'superstruct'; // https://docs.superstructjs.org\nimport { type ColorConfig, ColorConfigStruct } from './color-config';\n\nexport const HeadingLevels = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] as const;\nexport type HeadingLevel = (typeof HeadingLevels)[number];\n\nexport type FontSizeConfigVal = {\n unit: 'px' | 'rem';\n value: number;\n};\n\nexport const FontSizeConfigValStruct: Describe<FontSizeConfigVal> = object({\n unit: enums(['rem', 'px']),\n value: number(),\n});\n\nexport type FontFaceWeight = number | string;\n\nexport const FontFaceWeightStruct: Describe<FontFaceWeight> = union([\n string(),\n number(),\n]);\n\nexport enum FontFaceSourceFormats {\n woff2 = 'woff2',\n woff = 'woff',\n}\n\nexport type FontFaceSource = {\n /**\n * Note: if /when we eventually add 'local' type support, format isn't used!\n */\n format: keyof typeof FontFaceSourceFormats;\n type: 'url';\n path: string;\n};\n\nexport const FontFaceFormatsEnumStruct = enums(['woff2', 'woff']);\n\nexport const FontFaceSourceStruct: Describe<FontFaceSource> = type({\n format: FontFaceFormatsEnumStruct,\n type: literal('url'),\n path: string(),\n});\n\nexport type FontFaceConfig = {\n /**\n * registered name of the custom font\n *\n * MDN Docs on {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-family @font-face's font-family property}\n */\n family?: string;\n\n /**\n * number between 1 and 1000.\n *\n * note: since two weights are allowed (with variable fonts), this type is an\n * optional array for easy parsing down the road.\n *\n * MDN Docs on {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-weight @font-face's font-weight property}.\n */\n weight?: FontFaceWeight | FontFaceWeight[];\n\n /**\n * the collection of urls / paths pointing to font files\n *\n * MDN Docs on {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/src @font-face's src property}.\n */\n src?: FontFaceSource[];\n\n /**\n * the style of the custom font (ex. normal or italic)\n *\n * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-style See MDN docs on font-style}.\n */\n style?: string;\n\n // @todo: implement these later\n // display?: 'auto' | 'block' | 'swap' | 'fallback' | 'optional';\n // variationSettings?: string;\n // unicodeRange?: string; // or ideally, URange; //\n // see https://drafts.csswg.org/css-syntax-3/#urange-syntax and\n // https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/unicode-range\n};\n\nexport const FontFaceConfigStruct: Describe<FontFaceConfig> = type({\n family: optional(string()),\n weight: optional(\n union([FontFaceWeightStruct, size(array(FontFaceWeightStruct), 2)]),\n ),\n src: optional(array(FontFaceSourceStruct)),\n style: optional(string()),\n display: optional(enums(['auto', 'block', 'swap', 'fallback', 'optional'])),\n variationSettings: optional(string()),\n unicodeRange: optional(string()),\n});\n\nexport type FontSizeConfig = {\n min: FontSizeConfigVal;\n max?: FontSizeConfigVal;\n};\n\nexport enum TextTransforms {\n inherit = 'As typed',\n capitalize = 'Capitalize',\n lowercase = 'Lowercase',\n uppercase = 'Uppercase',\n}\n\nexport enum FontStretches {\n 'ultra-condensed' = 'Ultra-condensed',\n 'extra-condensed' = 'Extra-condensed',\n condensed = 'Condensed',\n 'semi-condensed' = 'Semi-condensed',\n normal = 'Normal',\n 'semi-expanded' = 'Semi-expanded',\n expanded = 'Expanded',\n 'extra-expanded' = 'Extra-expanded',\n 'ultra-expanded' = 'Ultra-expanded',\n}\n\nexport type TypographyConfig = {\n /**\n * min / max height used to future-proof way of supporting responsive typography\n */\n fontSize?: FontSizeConfig;\n\n /**\n * reminder: line-heights can also be unitless!\n */\n lineHeight?: string | number;\n fontWeight?: FontFaceWeight;\n\n /**\n * note: letter-spacing can't be unitless, unit required!\n */\n letterSpacing?: string;\n\n /**\n * if not specified, Knapsack default font, otherwise should allow for a stack of font strings + fallbacks (including the names of custom registered fonts)\n */\n fontFamily?: string;\n\n textColor?: ColorConfig;\n\n textTransform?: keyof typeof TextTransforms;\n\n fontStretch?: keyof typeof FontStretches;\n};\n\nexport interface TypographyLinkConfig {\n fontWeight?: FontFaceWeight;\n textColor?: ColorConfig;\n hoverColor?: ColorConfig;\n underline?: boolean;\n textTransform?: keyof typeof TextTransforms;\n fontStretch?: keyof typeof FontStretches;\n}\n\nexport const TypographyLinkConfigStruct: Describe<TypographyLinkConfig> = type({\n fontWeight: optional(union([string(), number()])),\n textColor: optional(ColorConfigStruct),\n hoverColor: optional(ColorConfigStruct),\n underline: optional(boolean()),\n textTransform: optional(\n enums(['inherit', 'capitalize', 'lowercase', 'uppercase']),\n ),\n fontStretch: optional(\n enums([\n 'ultra-condensed',\n 'extra-condensed',\n 'condensed',\n 'semi-condensed',\n 'normal',\n 'semi-expanded',\n 'expanded',\n 'extra-expanded',\n 'ultra-expanded',\n ]),\n ),\n});\n\nexport const FontSizeConfigStruct: Describe<FontSizeConfig> = type({\n min: FontSizeConfigValStruct,\n max: optional(FontSizeConfigValStruct),\n});\n\nexport const TypographyConfigStruct: Describe<TypographyConfig> = type({\n fontSize: optional(FontSizeConfigStruct),\n lineHeight: optional(union([string(), number()])),\n fontWeight: optional(union([string(), number()])),\n letterSpacing: optional(string()),\n fontFamily: optional(string()),\n textColor: optional(ColorConfigStruct),\n textTransform: optional(\n enums(['inherit', 'capitalize', 'lowercase', 'uppercase']),\n ),\n fontStretch: optional(\n enums([\n 'ultra-condensed',\n 'extra-condensed',\n 'condensed',\n 'semi-condensed',\n 'normal',\n 'semi-expanded',\n 'expanded',\n 'extra-expanded',\n 'ultra-expanded',\n ]),\n ),\n});\n\nconst pageElementConfig: TypographyConfig = {};\nconst pageLinkElementConfig: TypographyLinkConfig = {};\n\nexport const pageElements = {\n pageTitle: pageElementConfig,\n pageDescription: pageElementConfig,\n headingLarge: pageElementConfig,\n headingMedium: pageElementConfig,\n headingSmall: pageElementConfig,\n bodyText: pageElementConfig,\n link: pageLinkElementConfig,\n} as const;\n\nexport const pageElementsV2 = {\n pageTitle: pageElementConfig,\n pageDescription: pageElementConfig,\n headingXLarge: pageElementConfig,\n headingLarge: pageElementConfig,\n headingMedium: pageElementConfig,\n headingSmall: pageElementConfig,\n headingXSmall: pageElementConfig,\n bodyText: pageElementConfig,\n link: pageLinkElementConfig,\n} as const;\n\nexport type PageElementNames = keyof typeof pageElementsV2;\nexport type PageElementConfig = (typeof pageElementsV2)[PageElementNames];\n","import { type Describe, type, union, optional } from 'superstruct'; // https://docs.superstructjs.org\nimport { type ColorConfig, ColorConfigStruct } from './color-config';\nimport {\n type TypographyConfig,\n TypographyConfigStruct,\n} from './typography-config';\n\nexport interface NavCustomizationConfig extends TypographyConfig {\n accentColor?: ColorConfig;\n}\n\nexport interface PrimaryNavCustomizationConfig extends NavCustomizationConfig {\n hoverColor?: ColorConfig;\n backgroundColor?: ColorConfig;\n}\n\nexport type SecondaryNavCustomizationConfig = Omit<\n PrimaryNavCustomizationConfig,\n 'hoverColor'\n>;\n\nexport const NavCustomizationConfigStruct: Describe<NavCustomizationConfig> =\n union([\n TypographyConfigStruct,\n type({\n accentColor: optional(ColorConfigStruct),\n }),\n ]);\n\n// hoverColor: optional(ColorConfigStruct),\nexport const PrimaryNavCustomizationConfigStruct: Describe<PrimaryNavCustomizationConfig> =\n union([\n NavCustomizationConfigStruct,\n type({\n hoverColor: optional(ColorConfigStruct),\n backgroundColor: optional(ColorConfigStruct),\n }),\n ]);\n\nexport const SecondaryNavCustomizationConfigStruct: Describe<SecondaryNavCustomizationConfig> =\n union([\n NavCustomizationConfigStruct,\n type({\n backgroundColor: optional(ColorConfigStruct),\n }),\n ]);\n\nconst navCustomizationConfig: NavCustomizationConfig = {};\nconst secondaryNavCustomizationConfig: SecondaryNavCustomizationConfig = {};\nconst primaryNavCustomizationConfig: PrimaryNavCustomizationConfig = {};\n\nexport const customizableNavElements = {\n primaryNav: primaryNavCustomizationConfig,\n secondaryNav: secondaryNavCustomizationConfig,\n tabs: navCustomizationConfig,\n} as const;\n\nexport type CustomizableNavElementNames = keyof typeof customizableNavElements;\nexport type CustomizableNavElementConfig =\n (typeof customizableNavElements)[CustomizableNavElementNames];\n","import {\n type,\n type Describe,\n literal,\n optional,\n defaulted,\n boolean,\n array,\n object,\n} from 'superstruct';\n\nimport { type ExpandRecursively } from '@knapsack/utils';\n\nimport {\n type ColorConfig,\n ColorConfigStruct,\n ColorStringStruct,\n} from './color-config';\n\nimport {\n FontFaceConfigStruct,\n type FontFaceConfig,\n TypographyConfigStruct,\n TypographyLinkConfigStruct,\n type pageElements,\n type pageElementsV2,\n} from './typography-config';\n\nimport {\n type customizableNavElements,\n NavCustomizationConfigStruct,\n PrimaryNavCustomizationConfigStruct,\n SecondaryNavCustomizationConfigStruct,\n} from './nav-customization-config';\n\nexport type UiConfigV1 = {\n version: 1;\n oldSillySidebarBgColor: string;\n};\n\nexport const UiConfigV1Struct: Describe<UiConfigV1> = object({\n version: literal(1),\n oldSillySidebarBgColor: ColorStringStruct,\n});\n\nexport type UiConfigV2 = {\n version: 2;\n anotherSillySidebarBgColor: string;\n};\n\nexport const UiConfigV2Struct: Describe<UiConfigV2> = object({\n version: literal(2),\n anotherSillySidebarBgColor: ColorStringStruct,\n});\n\nexport type UiConfigV3 = {\n version: 3;\n sidebarBgColor: string;\n};\n\nexport const UiConfigV3Struct: Describe<UiConfigV3> = object({\n version: literal(3),\n sidebarBgColor: ColorStringStruct,\n});\n\nexport type UiConfigV4 = {\n version: 4;\n primaryColor: ColorConfig;\n darkColor: ColorConfig;\n lightColor: ColorConfig;\n enableSidebarIcons?: boolean;\n};\nexport const UiConfigV4Struct: Describe<UiConfigV4> = object({\n version: literal(4),\n primaryColor: ColorConfigStruct,\n darkColor: ColorConfigStruct,\n lightColor: ColorConfigStruct,\n enableSidebarIcons: optional(defaulted(boolean(), true)),\n});\n\nexport type UiConfigV5 = {\n version: 5;\n primaryColor: ColorConfig;\n darkColor: ColorConfig;\n lightColor: ColorConfig;\n linkColor: ColorConfig;\n enableSidebarIcons: boolean;\n};\nexport const UiConfigV5Struct: Describe<UiConfigV5> = object({\n version: literal(5),\n primaryColor: ColorConfigStruct,\n darkColor: ColorConfigStruct,\n lightColor: ColorConfigStruct,\n linkColor: ColorConfigStruct,\n enableSidebarIcons: optional(defaulted(boolean(), true)),\n});\n\nexport interface _UiConfigV6 extends Omit<UiConfigV5, 'version'> {\n version: 6;\n appearance: {\n customFonts?: FontFaceConfig[];\n pageElements: typeof pageElements;\n };\n}\n\n// ExpandRecursively needed to avoid \"Type 'UiConfigV6' is not assignable to type 'Record<string, unknown>'.\" error\nexport type UiConfigV6 = ExpandRecursively<_UiConfigV6>;\n\nexport const UiConfigV6Struct: Describe<UiConfigV6> = object({\n version: literal(6),\n primaryColor: ColorConfigStruct,\n darkColor: ColorConfigStruct,\n lightColor: ColorConfigStruct,\n linkColor: ColorConfigStruct,\n enableSidebarIcons: optional(defaulted(boolean(), true)),\n\n appearance: type({\n customFonts: optional(array(FontFaceConfigStruct)),\n pageElements: type({\n pageTitle: optional(TypographyConfigStruct),\n pageDescription: optional(TypographyConfigStruct),\n headingLarge: optional(TypographyConfigStruct),\n headingMedium: optional(TypographyConfigStruct),\n headingSmall: optional(TypographyConfigStruct),\n bodyText: optional(TypographyConfigStruct),\n link: optional(TypographyLinkConfigStruct),\n }),\n }),\n});\n\nexport interface _UiConfigV7 extends Omit<UiConfigV6, 'version'> {\n version: 7;\n appearance: {\n navigation?: typeof customizableNavElements;\n customFonts?: UiConfigV6['appearance']['customFonts'];\n pageElements: UiConfigV6['appearance']['pageElements'];\n };\n}\n\n// ExpandRecursively needed to avoid \"Type 'UiConfig7' is not assignable to type 'Record<string, unknown>'.\" error in ui-config.xstate.ts\nexport type UiConfigV7 = ExpandRecursively<_UiConfigV7>;\n\nexport const UiConfigV7Struct: Describe<UiConfigV7> = object({\n version: literal(7),\n primaryColor: ColorConfigStruct,\n darkColor: ColorConfigStruct,\n lightColor: ColorConfigStruct,\n linkColor: ColorConfigStruct,\n enableSidebarIcons: optional(defaulted(boolean(), true)),\n\n appearance: type({\n customFonts: optional(array(FontFaceConfigStruct)),\n navigation: optional(\n type({\n primaryNav: optional(PrimaryNavCustomizationConfigStruct),\n secondaryNav: optional(SecondaryNavCustomizationConfigStruct),\n tabs: optional(NavCustomizationConfigStruct),\n }),\n ),\n pageElements: type({\n pageTitle: optional(TypographyConfigStruct),\n pageDescription: optional(TypographyConfigStruct),\n headingLarge: optional(TypographyConfigStruct),\n headingMedium: optional(TypographyConfigStruct),\n headingSmall: optional(TypographyConfigStruct),\n bodyText: optional(TypographyConfigStruct),\n link: optional(TypographyLinkConfigStruct),\n }),\n }),\n});\n\nexport interface _UiConfigV8 extends Omit<\n UiConfigV7,\n 'version' | 'enableSidebarIcons'\n> {\n version: 8;\n}\n\n// ExpandRecursively needed to avoid \"Type 'UiConfig8' is not assignable to type 'Record<string, unknown>'.\" error in ui-config.xstate.ts\n// TODO: move this to @knapsack/types\nexport type UiConfigV8 = ExpandRecursively<_UiConfigV8>;\n\nexport const UiConfigV8Struct: Describe<UiConfigV8> = object({\n version: literal(8),\n primaryColor: ColorConfigStruct,\n darkColor: ColorConfigStruct,\n lightColor: ColorConfigStruct,\n linkColor: ColorConfigStruct,\n\n appearance: type({\n customFonts: optional(array(FontFaceConfigStruct)),\n navigation: optional(\n type({\n primaryNav: optional(PrimaryNavCustomizationConfigStruct),\n secondaryNav: optional(SecondaryNavCustomizationConfigStruct),\n tabs: optional(NavCustomizationConfigStruct),\n }),\n ),\n pageElements: type({\n pageTitle: optional(TypographyConfigStruct),\n pageDescription: optional(TypographyConfigStruct),\n headingLarge: optional(TypographyConfigStruct),\n headingMedium: optional(TypographyConfigStruct),\n headingSmall: optional(TypographyConfigStruct),\n bodyText: optional(TypographyConfigStruct),\n link: optional(TypographyLinkConfigStruct),\n }),\n }),\n});\n\nexport interface _UiConfigV9 extends Omit<\n UiConfigV8,\n 'version' | 'primaryColor' | 'darkColor' | 'lightColor' | 'linkColor'\n> {\n version: 9;\n}\nexport type UiConfigV9 = ExpandRecursively<_UiConfigV9>;\n\nexport const UiConfigV9Struct: Describe<UiConfigV9> = object({\n version: literal(9),\n\n appearance: type({\n customFonts: optional(array(FontFaceConfigStruct)),\n navigation: optional(\n type({\n primaryNav: optional(PrimaryNavCustomizationConfigStruct),\n secondaryNav: optional(SecondaryNavCustomizationConfigStruct),\n tabs: optional(NavCustomizationConfigStruct),\n }),\n ),\n pageElements: type({\n pageTitle: optional(TypographyConfigStruct),\n pageDescription: optional(TypographyConfigStruct),\n headingLarge: optional(TypographyConfigStruct),\n headingMedium: optional(TypographyConfigStruct),\n headingSmall: optional(TypographyConfigStruct),\n bodyText: optional(TypographyConfigStruct),\n link: optional(TypographyLinkConfigStruct),\n }),\n }),\n});\n\nexport interface _UiConfigV10 extends Omit<UiConfigV9, 'version'> {\n version: 10;\n appearance: {\n navigation?: UiConfigV9['appearance']['navigation'];\n customFonts?: UiConfigV9['appearance']['customFonts'];\n pageElements: typeof pageElementsV2;\n };\n}\nexport type UiConfigV10 = ExpandRecursively<_UiConfigV10>;\n\nexport const UiConfigV10Struct: Describe<UiConfigV10> = object({\n version: literal(10),\n\n appearance: type({\n customFonts: optional(array(FontFaceConfigStruct)),\n navigation: optional(\n type({\n primaryNav: optional(PrimaryNavCustomizationConfigStruct),\n secondaryNav: optional(SecondaryNavCustomizationConfigStruct),\n tabs: optional(NavCustomizationConfigStruct),\n }),\n ),\n pageElements: type({\n pageTitle: optional(TypographyConfigStruct),\n pageDescription: optional(TypographyConfigStruct),\n headingXLarge: optional(TypographyConfigStruct),\n headingLarge: optional(TypographyConfigStruct),\n headingMedium: optional(TypographyConfigStruct),\n headingSmall: optional(TypographyConfigStruct),\n headingXSmall: optional(TypographyConfigStruct),\n bodyText: optional(TypographyConfigStruct),\n link: optional(TypographyLinkConfigStruct),\n }),\n }),\n});\n\nexport type UiConfigVersions =\n | typeof UiConfigV1Struct.TYPE\n | typeof UiConfigV2Struct.TYPE\n | typeof UiConfigV3Struct.TYPE\n | typeof UiConfigV4Struct.TYPE\n | typeof UiConfigV5Struct.TYPE\n | typeof UiConfigV6Struct.TYPE\n | typeof UiConfigV7Struct.TYPE\n | typeof UiConfigV8Struct.TYPE\n | typeof UiConfigV9Struct.TYPE\n | typeof UiConfigV10Struct.TYPE;\n\n// ALIASES FOR LATEST VERSIONS\nexport type UiConfig = UiConfigV10;\nexport const UiConfigStruct: typeof UiConfigV10Struct = UiConfigV10Struct;\n\nexport type NavElementNames = keyof UiConfig['appearance']['navigation'];\n"]}
|
package/dist/ui-config.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {define,union,type,literal,string,object,number,enums,optional,array,size,boolean,defaulted}from'superstruct';import w from'color-string';var P=Object.defineProperty;var N=(
|
|
1
|
+
import {define,union,type,literal,string,object,number,enums,optional,array,size,boolean,defaulted}from'superstruct';import w from'color-string';var P=Object.defineProperty;var N=(g,F)=>P(g,"name",{value:F,configurable:true});function _(g){if(typeof g!="string")return false;try{return !!w.get(g)}catch{return false}}N(_,"isColor");var f=define("ColorStringStruct",g=>typeof g=="string"&&_(g)),t=union([type({type:literal("value"),colorValue:f}),type({type:literal("design-token"),tokenName:string()})]);type({type:literal("design-token"),tokenName:string()});var D=object({unit:enums(["rem","px"]),value:number()}),L=union([string(),number()]);var O=enums(["woff2","woff"]),H=type({format:O,type:literal("url"),path:string()}),C=type({family:optional(string()),weight:optional(union([L,size(array(L),2)])),src:optional(array(H)),style:optional(string()),display:optional(enums(["auto","block","swap","fallback","optional"])),variationSettings:optional(string()),unicodeRange:optional(string())});var c=type({fontWeight:optional(union([string(),number()])),textColor:optional(t),hoverColor:optional(t),underline:optional(boolean()),textTransform:optional(enums(["inherit","capitalize","lowercase","uppercase"])),fontStretch:optional(enums(["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded"]))}),X=type({min:D,max:optional(D)}),o=type({fontSize:optional(X),lineHeight:optional(union([string(),number()])),fontWeight:optional(union([string(),number()])),letterSpacing:optional(string()),fontFamily:optional(string()),textColor:optional(t),textTransform:optional(enums(["inherit","capitalize","lowercase","uppercase"])),fontStretch:optional(enums(["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded"]))});var l=union([o,type({accentColor:optional(t)})]),u=union([l,type({hoverColor:optional(t),backgroundColor:optional(t)})]),x=union([l,type({backgroundColor:optional(t)})]);var se=object({version:literal(1),oldSillySidebarBgColor:f}),le=object({version:literal(2),anotherSillySidebarBgColor:f}),Ce=object({version:literal(3),sidebarBgColor:f}),ce=object({version:literal(4),primaryColor:t,darkColor:t,lightColor:t,enableSidebarIcons:optional(defaulted(boolean(),true))}),fe=object({version:literal(5),primaryColor:t,darkColor:t,lightColor:t,linkColor:t,enableSidebarIcons:optional(defaulted(boolean(),true))}),me=object({version:literal(6),primaryColor:t,darkColor:t,lightColor:t,linkColor:t,enableSidebarIcons:optional(defaulted(boolean(),true)),appearance:type({customFonts:optional(array(C)),pageElements:type({pageTitle:optional(o),pageDescription:optional(o),headingLarge:optional(o),headingMedium:optional(o),headingSmall:optional(o),bodyText:optional(o),link:optional(c)})})}),ye=object({version:literal(7),primaryColor:t,darkColor:t,lightColor:t,linkColor:t,enableSidebarIcons:optional(defaulted(boolean(),true)),appearance:type({customFonts:optional(array(C)),navigation:optional(type({primaryNav:optional(u),secondaryNav:optional(x),tabs:optional(l)})),pageElements:type({pageTitle:optional(o),pageDescription:optional(o),headingLarge:optional(o),headingMedium:optional(o),headingSmall:optional(o),bodyText:optional(o),link:optional(c)})})}),de=object({version:literal(8),primaryColor:t,darkColor:t,lightColor:t,linkColor:t,appearance:type({customFonts:optional(array(C)),navigation:optional(type({primaryNav:optional(u),secondaryNav:optional(x),tabs:optional(l)})),pageElements:type({pageTitle:optional(o),pageDescription:optional(o),headingLarge:optional(o),headingMedium:optional(o),headingSmall:optional(o),bodyText:optional(o),link:optional(c)})})}),ue=object({version:literal(9),appearance:type({customFonts:optional(array(C)),navigation:optional(type({primaryNav:optional(u),secondaryNav:optional(x),tabs:optional(l)})),pageElements:type({pageTitle:optional(o),pageDescription:optional(o),headingLarge:optional(o),headingMedium:optional(o),headingSmall:optional(o),bodyText:optional(o),link:optional(c)})})}),j=object({version:literal(10),appearance:type({customFonts:optional(array(C)),navigation:optional(type({primaryNav:optional(u),secondaryNav:optional(x),tabs:optional(l)})),pageElements:type({pageTitle:optional(o),pageDescription:optional(o),headingXLarge:optional(o),headingLarge:optional(o),headingMedium:optional(o),headingSmall:optional(o),headingXSmall:optional(o),bodyText:optional(o),link:optional(c)})})}),xe=j;export{xe as UiConfigStruct,j as UiConfigV10Struct,se as UiConfigV1Struct,le as UiConfigV2Struct,Ce as UiConfigV3Struct,ce as UiConfigV4Struct,fe as UiConfigV5Struct,me as UiConfigV6Struct,ye as UiConfigV7Struct,de as UiConfigV8Struct,ue as UiConfigV9Struct};//# sourceMappingURL=ui-config.mjs.map
|
|
2
2
|
//# sourceMappingURL=ui-config.mjs.map
|