@hyvor/design 2.0.18 → 2.1.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/dist/cloud/CloudContext/CloudContext.svelte +0 -9
- package/dist/cloud/CloudContext/cloudContextState.svelte.d.ts +7 -0
- package/dist/components/Callout/Callout.svelte +2 -1
- package/dist/components/ColorPicker/ColorPicker.svelte.d.ts +1 -1
- package/dist/components/Loader/Loader.svelte.d.ts +1 -1
- package/dist/marketing/Docs/Docs.svelte +371 -15
- package/dist/marketing/Docs/Docs.svelte.d.ts +5 -2
- package/dist/marketing/Docs/{Content/DocsImage.svelte → DocsImage.svelte} +1 -1
- package/dist/marketing/Docs/NavItem.svelte +96 -0
- package/dist/marketing/Docs/{Nav/NavItem.svelte.d.ts → NavItem.svelte.d.ts} +5 -2
- package/dist/marketing/Docs/OpenApi/OpenApi.svelte +144 -0
- package/dist/marketing/Docs/OpenApi/OpenApi.svelte.d.ts +7 -0
- package/dist/marketing/Docs/OpenApi/Operation.svelte +147 -0
- package/dist/marketing/Docs/OpenApi/Operation.svelte.d.ts +9 -0
- package/dist/marketing/Docs/OpenApi/ParamsTable.svelte +57 -0
- package/dist/marketing/Docs/OpenApi/ParamsTable.svelte.d.ts +8 -0
- package/dist/marketing/Docs/OpenApi/SchemaFields.svelte +141 -0
- package/dist/marketing/Docs/OpenApi/SchemaFields.svelte.d.ts +9 -0
- package/dist/marketing/Docs/OpenApi/openapi.d.ts +106 -0
- package/dist/marketing/Docs/OpenApi/openapi.js +267 -0
- package/dist/marketing/Docs/Sidebar/Sidebar.svelte +1 -3
- package/dist/marketing/Docs/fulldocs.d.ts +17 -0
- package/dist/marketing/Docs/fulldocs.js +106 -0
- package/dist/marketing/Docs/types.d.ts +23 -0
- package/dist/marketing/Docs/types.js +1 -0
- package/dist/marketing/index.d.ts +3 -6
- package/dist/marketing/index.js +2 -6
- package/package.json +2 -3
- package/dist/marketing/Docs/Content/Content.svelte +0 -181
- package/dist/marketing/Docs/Content/Content.svelte.d.ts +0 -6
- package/dist/marketing/Docs/Nav/Nav.svelte +0 -156
- package/dist/marketing/Docs/Nav/Nav.svelte.d.ts +0 -6
- package/dist/marketing/Docs/Nav/NavCategory.svelte +0 -49
- package/dist/marketing/Docs/Nav/NavCategory.svelte.d.ts +0 -9
- package/dist/marketing/Docs/Nav/NavItem.svelte +0 -39
- package/dist/marketing/track/track.d.ts +0 -22
- package/dist/marketing/track/track.js +0 -70
- /package/dist/marketing/Docs/{Content/DocsImage.svelte.d.ts → DocsImage.svelte.d.ts} +0 -0
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { dereference } from '@apidevtools/json-schema-ref-parser';
|
|
2
|
+
// @apidevtools/json-schema-ref-parser calls Buffer.isBuffer(...) internally to detect
|
|
3
|
+
// binary/text input, even when we hand it an already-parsed plain JS object - it never
|
|
4
|
+
// actually needs a real Buffer for that case, so a minimal shim is enough to stop it
|
|
5
|
+
// throwing "Buffer is not defined" in the browser.
|
|
6
|
+
const globalWithBuffer = globalThis;
|
|
7
|
+
if (typeof globalWithBuffer.Buffer === 'undefined') {
|
|
8
|
+
globalWithBuffer.Buffer = { isBuffer: () => false };
|
|
9
|
+
}
|
|
10
|
+
const HTTP_METHODS = [
|
|
11
|
+
'get',
|
|
12
|
+
'put',
|
|
13
|
+
'post',
|
|
14
|
+
'delete',
|
|
15
|
+
'options',
|
|
16
|
+
'head',
|
|
17
|
+
'patch',
|
|
18
|
+
'trace'
|
|
19
|
+
];
|
|
20
|
+
export async function loadOpenApi(path) {
|
|
21
|
+
// fetch the JSON ourselves and dereference the in-memory object, rather than handing
|
|
22
|
+
// the library a URL - its HTTP resolver relies on Node's Buffer, which isn't available
|
|
23
|
+
// in the browser
|
|
24
|
+
const response = await fetch(path);
|
|
25
|
+
if (!response.ok) {
|
|
26
|
+
throw new Error(`Failed to fetch ${path}: ${response.status} ${response.statusText}`);
|
|
27
|
+
}
|
|
28
|
+
const schema = await response.json();
|
|
29
|
+
const doc = (await dereference(schema));
|
|
30
|
+
// $RefParser resolves every occurrence of the same $ref to the exact same object
|
|
31
|
+
// instance, so object identity can be used to recognize a named schema wherever
|
|
32
|
+
// it shows up in the tree.
|
|
33
|
+
const schemaNames = new Map();
|
|
34
|
+
for (const [name, s] of Object.entries(doc.components?.schemas ?? {})) {
|
|
35
|
+
if (s && typeof s === 'object')
|
|
36
|
+
schemaNames.set(s, name);
|
|
37
|
+
}
|
|
38
|
+
return { doc, schemaNames };
|
|
39
|
+
}
|
|
40
|
+
function slugify(text) {
|
|
41
|
+
return text
|
|
42
|
+
.toLowerCase()
|
|
43
|
+
.replace(/[{}]/g, '')
|
|
44
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
45
|
+
.replace(/(^-|-$)/g, '');
|
|
46
|
+
}
|
|
47
|
+
// finds path segments that are common to every path in the doc (eg. "api", "console")
|
|
48
|
+
// so that grouping/titles can ignore that shared, uninformative prefix
|
|
49
|
+
function commonSegmentPrefix(paths) {
|
|
50
|
+
const segmentLists = paths.map((p) => p.split('/').filter(Boolean));
|
|
51
|
+
if (segmentLists.length === 0)
|
|
52
|
+
return [];
|
|
53
|
+
const prefix = [];
|
|
54
|
+
const first = segmentLists[0];
|
|
55
|
+
for (let i = 0; i < first.length; i++) {
|
|
56
|
+
const segment = first[i];
|
|
57
|
+
if (segment.startsWith('{'))
|
|
58
|
+
break;
|
|
59
|
+
if (segmentLists.every((segments) => segments[i] === segment)) {
|
|
60
|
+
prefix.push(segment);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return prefix;
|
|
67
|
+
}
|
|
68
|
+
export function titleCase(segment) {
|
|
69
|
+
const overrides = { api: 'API', id: 'ID', url: 'URL' };
|
|
70
|
+
return segment
|
|
71
|
+
.split('-')
|
|
72
|
+
.map((word) => overrides[word] ?? word.charAt(0).toUpperCase() + word.slice(1))
|
|
73
|
+
.join(' ');
|
|
74
|
+
}
|
|
75
|
+
export function groupOperations(doc) {
|
|
76
|
+
const paths = Object.keys(doc.paths ?? {});
|
|
77
|
+
const prefix = commonSegmentPrefix(paths);
|
|
78
|
+
const groups = new Map();
|
|
79
|
+
for (const path of paths) {
|
|
80
|
+
const item = doc.paths[path];
|
|
81
|
+
const segments = path.split('/').filter(Boolean);
|
|
82
|
+
const rest = segments.slice(prefix.length);
|
|
83
|
+
const groupSegment = rest.find((s) => !s.startsWith('{')) ?? rest[0] ?? path;
|
|
84
|
+
const groupKey = groupSegment;
|
|
85
|
+
if (!groups.has(groupKey)) {
|
|
86
|
+
groups.set(groupKey, {
|
|
87
|
+
key: groupKey,
|
|
88
|
+
title: titleCase(groupKey),
|
|
89
|
+
operations: []
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
for (const method of HTTP_METHODS) {
|
|
93
|
+
const op = item[method];
|
|
94
|
+
if (!op)
|
|
95
|
+
continue;
|
|
96
|
+
const parameters = op.parameters ?? [];
|
|
97
|
+
const content = op.requestBody?.content?.['application/json'];
|
|
98
|
+
let response;
|
|
99
|
+
const responses = op.responses ?? {};
|
|
100
|
+
const responseEntry = responses['200'] ?? responses['201'] ?? responses['default'];
|
|
101
|
+
const responseContent = responseEntry?.content?.['application/json'];
|
|
102
|
+
if (responseEntry && (responseEntry.description || responseContent?.schema)) {
|
|
103
|
+
response = { description: responseEntry.description, schema: responseContent?.schema };
|
|
104
|
+
}
|
|
105
|
+
groups.get(groupKey).operations.push({
|
|
106
|
+
id: slugify(`${method}-${path}`),
|
|
107
|
+
method,
|
|
108
|
+
path,
|
|
109
|
+
operationId: op.operationId,
|
|
110
|
+
summary: op.summary,
|
|
111
|
+
description: op.description,
|
|
112
|
+
pathParams: parameters.filter((p) => p.in === 'path'),
|
|
113
|
+
queryParams: parameters.filter((p) => p.in === 'query'),
|
|
114
|
+
headerParams: parameters.filter((p) => p.in === 'header'),
|
|
115
|
+
requestBodySchema: content?.schema,
|
|
116
|
+
requestBodyRequired: op.requestBody?.required ?? false,
|
|
117
|
+
response
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return Array.from(groups.values()).filter((g) => g.operations.length > 0);
|
|
122
|
+
}
|
|
123
|
+
export function methodColor(method) {
|
|
124
|
+
switch (method) {
|
|
125
|
+
case 'get':
|
|
126
|
+
return 'blue';
|
|
127
|
+
case 'post':
|
|
128
|
+
return 'green';
|
|
129
|
+
case 'patch':
|
|
130
|
+
case 'put':
|
|
131
|
+
return 'orange';
|
|
132
|
+
case 'delete':
|
|
133
|
+
return 'red';
|
|
134
|
+
default:
|
|
135
|
+
return 'default';
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
export function describeType(schema, schemaNames) {
|
|
139
|
+
if (!schema)
|
|
140
|
+
return 'any';
|
|
141
|
+
// named object schemas (eg. "SendingProfileObject") are shown by name rather than
|
|
142
|
+
// inlined as a generic "object" - scalars/enums keep showing their literal values
|
|
143
|
+
if (schema.type === 'object' && schemaNames?.has(schema)) {
|
|
144
|
+
return schemaNames.get(schema);
|
|
145
|
+
}
|
|
146
|
+
if (schema.oneOf?.length)
|
|
147
|
+
return schema.oneOf.map((s) => describeType(s, schemaNames)).join(' | ');
|
|
148
|
+
if (schema.anyOf?.length)
|
|
149
|
+
return schema.anyOf.map((s) => describeType(s, schemaNames)).join(' | ');
|
|
150
|
+
if (schema.allOf?.length)
|
|
151
|
+
return schema.allOf.map((s) => describeType(s, schemaNames)).join(' & ');
|
|
152
|
+
if (schema.enum)
|
|
153
|
+
return schema.enum.map((v) => JSON.stringify(v)).join(' | ');
|
|
154
|
+
if (schema.type === 'array') {
|
|
155
|
+
return `${describeType(schema.items, schemaNames)}[]`;
|
|
156
|
+
}
|
|
157
|
+
if (schema.type === 'object') {
|
|
158
|
+
if (schema.additionalProperties && typeof schema.additionalProperties === 'object') {
|
|
159
|
+
return `object<string, ${describeType(schema.additionalProperties, schemaNames)}>`;
|
|
160
|
+
}
|
|
161
|
+
return 'object';
|
|
162
|
+
}
|
|
163
|
+
return schema.type ?? 'any';
|
|
164
|
+
}
|
|
165
|
+
// unwraps a top-level "array of X" schema (eg. a `SendingProfileObject[]` response) so
|
|
166
|
+
// callers can render the item schema's fields directly, with the array-ness shown separately
|
|
167
|
+
export function unwrapArraySchema(schema) {
|
|
168
|
+
if (schema.type === 'array' && schema.items) {
|
|
169
|
+
return { isArray: true, itemSchema: schema.items };
|
|
170
|
+
}
|
|
171
|
+
return { isArray: false, itemSchema: schema };
|
|
172
|
+
}
|
|
173
|
+
const STRING_EXAMPLES = [
|
|
174
|
+
[/e-?mail/i, 'jane@example.com'],
|
|
175
|
+
[/subdomain/i, 'my-newsletter'],
|
|
176
|
+
[/domain/i, 'example.com'],
|
|
177
|
+
[/^(website|.*url|.*logo)$/i, 'https://example.com'],
|
|
178
|
+
[/name/i, 'My List'],
|
|
179
|
+
[/^id$/i, '123']
|
|
180
|
+
];
|
|
181
|
+
function stringExample(propName, schema) {
|
|
182
|
+
if (schema.format === 'date-time')
|
|
183
|
+
return new Date().toISOString();
|
|
184
|
+
for (const [pattern, example] of STRING_EXAMPLES) {
|
|
185
|
+
if (pattern.test(propName))
|
|
186
|
+
return example;
|
|
187
|
+
}
|
|
188
|
+
return 'string';
|
|
189
|
+
}
|
|
190
|
+
export function exampleValue(schema, propName = '') {
|
|
191
|
+
if (!schema)
|
|
192
|
+
return null;
|
|
193
|
+
if (schema.example !== undefined)
|
|
194
|
+
return schema.example;
|
|
195
|
+
if (schema.default !== undefined)
|
|
196
|
+
return schema.default;
|
|
197
|
+
if (schema.enum?.length)
|
|
198
|
+
return schema.enum[0];
|
|
199
|
+
if (schema.oneOf?.length)
|
|
200
|
+
return exampleValue(schema.oneOf[0], propName);
|
|
201
|
+
if (schema.anyOf?.length)
|
|
202
|
+
return exampleValue(schema.anyOf[0], propName);
|
|
203
|
+
if (schema.allOf?.length)
|
|
204
|
+
return exampleValue(schema.allOf[schema.allOf.length - 1], propName);
|
|
205
|
+
switch (schema.type) {
|
|
206
|
+
case 'object': {
|
|
207
|
+
const props = schema.properties ?? {};
|
|
208
|
+
const keys = schema.required?.length ? schema.required : Object.keys(props);
|
|
209
|
+
if (keys.length) {
|
|
210
|
+
const obj = {};
|
|
211
|
+
for (const key of keys) {
|
|
212
|
+
obj[key] = exampleValue(props[key], key);
|
|
213
|
+
}
|
|
214
|
+
return obj;
|
|
215
|
+
}
|
|
216
|
+
if (schema.additionalProperties && typeof schema.additionalProperties === 'object') {
|
|
217
|
+
return { key: exampleValue(schema.additionalProperties, 'key') };
|
|
218
|
+
}
|
|
219
|
+
return {};
|
|
220
|
+
}
|
|
221
|
+
case 'array':
|
|
222
|
+
return [exampleValue(schema.items, propName)];
|
|
223
|
+
case 'integer':
|
|
224
|
+
case 'number':
|
|
225
|
+
return 0;
|
|
226
|
+
case 'boolean':
|
|
227
|
+
return true;
|
|
228
|
+
case 'string':
|
|
229
|
+
return stringExample(propName, schema);
|
|
230
|
+
default:
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
export function paramExample(param) {
|
|
235
|
+
const value = exampleValue(param.schema, param.name);
|
|
236
|
+
return value === null || value === undefined ? 'value' : String(value);
|
|
237
|
+
}
|
|
238
|
+
export function buildUrl(baseUrl, operation) {
|
|
239
|
+
let path = operation.path;
|
|
240
|
+
for (const param of operation.pathParams) {
|
|
241
|
+
path = path.replace(`{${param.name}}`, encodeURIComponent(paramExample(param)));
|
|
242
|
+
}
|
|
243
|
+
const query = operation.queryParams
|
|
244
|
+
.map((p) => `${encodeURIComponent(p.name)}=${encodeURIComponent(paramExample(p))}`)
|
|
245
|
+
.join('&');
|
|
246
|
+
const url = baseUrl.replace(/\/$/, '') + path;
|
|
247
|
+
return query ? `${url}?${query}` : url;
|
|
248
|
+
}
|
|
249
|
+
export function buildCurl(operation, baseUrl) {
|
|
250
|
+
const url = buildUrl(baseUrl, operation);
|
|
251
|
+
const lines = [`curl -X ${operation.method.toUpperCase()} '${url}' \\`];
|
|
252
|
+
lines.push(` -H 'Authorization: Bearer YOUR_API_KEY' \\`);
|
|
253
|
+
for (const param of operation.headerParams) {
|
|
254
|
+
lines.push(` -H '${param.name}: ${paramExample(param)}' \\`);
|
|
255
|
+
}
|
|
256
|
+
if (operation.requestBodySchema) {
|
|
257
|
+
lines.push(` -H 'Content-Type: application/json' \\`);
|
|
258
|
+
const body = exampleValue(operation.requestBodySchema);
|
|
259
|
+
const json = JSON.stringify(body, null, 2);
|
|
260
|
+
lines.push(` -d '${json}'`);
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
// remove the trailing continuation backslash of the last header line
|
|
264
|
+
lines[lines.length - 1] = lines[lines.length - 1].replace(/\s*\\$/, '');
|
|
265
|
+
}
|
|
266
|
+
return lines.join('\n');
|
|
267
|
+
}
|
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
<style>
|
|
10
10
|
.sidebar {
|
|
11
11
|
width: 220px;
|
|
12
|
-
top: var(--header-height, 0);
|
|
13
|
-
padding: 25px 0;
|
|
12
|
+
top: calc(var(--header-height, 0) + 15px);
|
|
14
13
|
position: sticky;
|
|
15
14
|
flex-shrink: 0;
|
|
16
15
|
align-self: flex-start;
|
|
@@ -22,7 +21,6 @@
|
|
|
22
21
|
position: relative;
|
|
23
22
|
top: initial;
|
|
24
23
|
padding: 0 15px;
|
|
25
|
-
margin-bottom: 20px;
|
|
26
24
|
width: 100%;
|
|
27
25
|
}
|
|
28
26
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { NavSectionConfig, NavConfig, NavPageConfig, NavSubSectionConfig } from './types.js';
|
|
2
|
+
export declare function loadDocsPage(config: {
|
|
3
|
+
basepath?: string;
|
|
4
|
+
rootName?: string;
|
|
5
|
+
sections: NavSectionConfig[];
|
|
6
|
+
slug: string;
|
|
7
|
+
}): {
|
|
8
|
+
basepath: string;
|
|
9
|
+
rootName: string;
|
|
10
|
+
sections: NavSectionConfig[];
|
|
11
|
+
slug: string;
|
|
12
|
+
page: NavPageConfig;
|
|
13
|
+
};
|
|
14
|
+
export declare function getPageFromSections(sections: NavSectionConfig[], slug: string): NavPageConfig | undefined;
|
|
15
|
+
export declare function getPageFromNavs(navs: NavConfig[], slug: string): NavPageConfig | undefined;
|
|
16
|
+
export declare function getSubSectionPathForSlug(sections: NavSectionConfig[], slug: string): NavSubSectionConfig[] | undefined;
|
|
17
|
+
export declare function getFirstPageSlug(sections: NavSectionConfig[]): string | undefined;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { error } from '@sveltejs/kit';
|
|
2
|
+
// for docs, create a /docs/[[slug]]/+page.svelte and +page.ts files
|
|
3
|
+
// add this to +page.ts in the load function
|
|
4
|
+
// return loadDocsPage(sections, slug);
|
|
5
|
+
export function loadDocsPage(config) {
|
|
6
|
+
const { basepath = '/', rootName = 'Docs', sections, slug } = config;
|
|
7
|
+
const page = getPageFromSections(sections, slug);
|
|
8
|
+
if (!page) {
|
|
9
|
+
error(404, `Page not found for slug: ${slug}`);
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
basepath,
|
|
13
|
+
rootName,
|
|
14
|
+
sections,
|
|
15
|
+
slug,
|
|
16
|
+
page
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export function getPageFromSections(sections, slug) {
|
|
20
|
+
for (const section of sections) {
|
|
21
|
+
const page = getPageFromNavs(section.navs, slug);
|
|
22
|
+
if (page) {
|
|
23
|
+
return page;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export function getPageFromNavs(navs, slug) {
|
|
28
|
+
for (const nav of navs) {
|
|
29
|
+
if (nav.type === 'page' && nav.slug === slug) {
|
|
30
|
+
return nav;
|
|
31
|
+
}
|
|
32
|
+
else if (nav.type === 'folding-section') {
|
|
33
|
+
const page = getPageFromNavs(nav.navs, slug);
|
|
34
|
+
if (page) {
|
|
35
|
+
return page;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else if (nav.type === 'sub-section') {
|
|
39
|
+
const page = getPageFromSections(nav.sections, slug);
|
|
40
|
+
if (page) {
|
|
41
|
+
return page;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// returns the chain of sub-sections that need to be opened to reach the page
|
|
47
|
+
// with the given slug, e.g. [subSectionA, subSectionB] means subSectionA is
|
|
48
|
+
// open, and within it, subSectionB is open. returns undefined if the slug
|
|
49
|
+
// isn't found under the given sections.
|
|
50
|
+
export function getSubSectionPathForSlug(sections, slug) {
|
|
51
|
+
for (const section of sections) {
|
|
52
|
+
const path = getSubSectionPathForSlugInNavs(section.navs, slug);
|
|
53
|
+
if (path) {
|
|
54
|
+
return path;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function getSubSectionPathForSlugInNavs(navs, slug) {
|
|
59
|
+
for (const nav of navs) {
|
|
60
|
+
if (nav.type === 'page' && nav.slug === slug) {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
else if (nav.type === 'folding-section') {
|
|
64
|
+
const path = getSubSectionPathForSlugInNavs(nav.navs, slug);
|
|
65
|
+
if (path) {
|
|
66
|
+
return path;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else if (nav.type === 'sub-section') {
|
|
70
|
+
const path = getSubSectionPathForSlug(nav.sections, slug);
|
|
71
|
+
if (path) {
|
|
72
|
+
return [nav, ...path];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// returns the slug of the first page found (in traversal order) under the
|
|
78
|
+
// given sections. used to know where a sub-section link or breadcrumb item
|
|
79
|
+
// should navigate to.
|
|
80
|
+
export function getFirstPageSlug(sections) {
|
|
81
|
+
for (const section of sections) {
|
|
82
|
+
const slug = getFirstPageSlugInNavs(section.navs);
|
|
83
|
+
if (slug !== undefined) {
|
|
84
|
+
return slug;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function getFirstPageSlugInNavs(navs) {
|
|
89
|
+
for (const nav of navs) {
|
|
90
|
+
if (nav.type === 'page') {
|
|
91
|
+
return nav.slug;
|
|
92
|
+
}
|
|
93
|
+
else if (nav.type === 'folding-section') {
|
|
94
|
+
const slug = getFirstPageSlugInNavs(nav.navs);
|
|
95
|
+
if (slug !== undefined) {
|
|
96
|
+
return slug;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else if (nav.type === 'sub-section') {
|
|
100
|
+
const slug = getFirstPageSlug(nav.sections);
|
|
101
|
+
if (slug !== undefined) {
|
|
102
|
+
return slug;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Component } from 'svelte';
|
|
2
|
+
export interface NavSectionConfig {
|
|
3
|
+
name?: string;
|
|
4
|
+
navs: NavConfig[];
|
|
5
|
+
}
|
|
6
|
+
export type NavConfig = NavPageConfig | NavFoldingSectionConfig | NavSubSectionConfig;
|
|
7
|
+
export interface NavPageConfig {
|
|
8
|
+
type: 'page';
|
|
9
|
+
name: string;
|
|
10
|
+
slug: string;
|
|
11
|
+
content: Component;
|
|
12
|
+
wide?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface NavFoldingSectionConfig {
|
|
15
|
+
type: 'folding-section';
|
|
16
|
+
name: string;
|
|
17
|
+
navs: NavConfig[];
|
|
18
|
+
}
|
|
19
|
+
export interface NavSubSectionConfig {
|
|
20
|
+
type: 'sub-section';
|
|
21
|
+
name: string;
|
|
22
|
+
sections: NavSectionConfig[];
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -2,12 +2,9 @@ export { default as Accordion } from './DetailsAccordion/DetailsAccordion.svelte
|
|
|
2
2
|
export { default as Header } from './Header/Header.svelte';
|
|
3
3
|
export { default as Container } from './Container/Container.svelte';
|
|
4
4
|
export { default as Docs } from './Docs/Docs.svelte';
|
|
5
|
-
export { default as
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export { default as DocsContent } from './Docs/Content/Content.svelte';
|
|
9
|
-
export { default as DocsImage } from './Docs/Content/DocsImage.svelte';
|
|
5
|
+
export { default as DocsImage } from './Docs/DocsImage.svelte';
|
|
6
|
+
export { loadDocsPage } from './Docs/fulldocs.js';
|
|
7
|
+
export type { NavSectionConfig, NavConfig, NavPageConfig, NavFoldingSectionConfig, NavSubSectionConfig } from './Docs/types.js';
|
|
10
8
|
export { default as Footer } from './Footer/Footer.svelte';
|
|
11
9
|
export { default as FooterLinkList } from './Footer/FooterLinkList.svelte';
|
|
12
10
|
export { default as Document } from './Document/Document.svelte';
|
|
13
|
-
export { default as track } from './track/track.js';
|
package/dist/marketing/index.js
CHANGED
|
@@ -2,12 +2,8 @@ export { default as Accordion } from './DetailsAccordion/DetailsAccordion.svelte
|
|
|
2
2
|
export { default as Header } from './Header/Header.svelte';
|
|
3
3
|
export { default as Container } from './Container/Container.svelte';
|
|
4
4
|
export { default as Docs } from './Docs/Docs.svelte';
|
|
5
|
-
export { default as
|
|
6
|
-
export {
|
|
7
|
-
export { default as DocsNavCategory } from './Docs/Nav/NavCategory.svelte';
|
|
8
|
-
export { default as DocsContent } from './Docs/Content/Content.svelte';
|
|
9
|
-
export { default as DocsImage } from './Docs/Content/DocsImage.svelte';
|
|
5
|
+
export { default as DocsImage } from './Docs/DocsImage.svelte';
|
|
6
|
+
export { loadDocsPage } from './Docs/fulldocs.js';
|
|
10
7
|
export { default as Footer } from './Footer/Footer.svelte';
|
|
11
8
|
export { default as FooterLinkList } from './Footer/FooterLinkList.svelte';
|
|
12
9
|
export { default as Document } from './Document/Document.svelte';
|
|
13
|
-
export { default as track } from './track/track.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyvor/design",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"private": false,
|
|
6
6
|
"repository": {
|
|
@@ -58,10 +58,9 @@
|
|
|
58
58
|
"vite": "^7.3"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
+
"@apidevtools/json-schema-ref-parser": "^15.5.1",
|
|
61
62
|
"@fontsource/readex-pro": "^5.2.11",
|
|
62
63
|
"@hyvor/icons": "^1.1.1",
|
|
63
|
-
"@openpanel/sdk": "^1.0.4",
|
|
64
|
-
"@openpanel/web": "^1.0.7",
|
|
65
64
|
"deepmerge-ts": "^7.1.5",
|
|
66
65
|
"emojibase-data": "^17.0.0",
|
|
67
66
|
"intl-messageformat": "^11.1.2",
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import Box from '../../../components/Box/Box.svelte';
|
|
3
|
-
import { page } from '$app/stores';
|
|
4
|
-
import { onMount } from 'svelte';
|
|
5
|
-
interface Props {
|
|
6
|
-
children?: import('svelte').Snippet;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
let { children }: Props = $props();
|
|
10
|
-
|
|
11
|
-
function linkifyHeadings() {
|
|
12
|
-
var hs = document.querySelectorAll('h2[id],h3[id],h4[id]');
|
|
13
|
-
for (var i = 0; i < hs.length; i++) {
|
|
14
|
-
var h = hs[i];
|
|
15
|
-
|
|
16
|
-
var icon = document.createElement('a');
|
|
17
|
-
icon.className = 'heading-anchor-link';
|
|
18
|
-
icon.innerHTML =
|
|
19
|
-
'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" class="bi bi-link-45deg" viewBox="0 0 16 16"><path d="M4.715 6.542 3.343 7.914a3 3 0 1 0 4.243 4.243l1.828-1.829A3 3 0 0 0 8.586 5.5L8 6.086a1.002 1.002 0 0 0-.154.199 2 2 0 0 1 .861 3.337L6.88 11.45a2 2 0 1 1-2.83-2.83l.793-.792a4.018 4.018 0 0 1-.128-1.287z"/><path d="M6.586 4.672A3 3 0 0 0 7.414 9.5l.775-.776a2 2 0 0 1-.896-3.346L9.12 3.55a2 2 0 1 1 2.83 2.83l-.793.792c.112.42.155.855.128 1.287l1.372-1.372a3 3 0 1 0-4.243-4.243L6.586 4.672z"/></svg>';
|
|
20
|
-
icon.tabIndex = -1;
|
|
21
|
-
h.appendChild(icon);
|
|
22
|
-
|
|
23
|
-
var id = h.getAttribute('id');
|
|
24
|
-
var link = document.createElement('a');
|
|
25
|
-
link.className = 'heading-anchor';
|
|
26
|
-
link.setAttribute('href', '#' + id);
|
|
27
|
-
link.innerHTML = h.innerHTML;
|
|
28
|
-
h.innerHTML = link.outerHTML;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
onMount(() => {
|
|
33
|
-
const unsubscribe = page.subscribe(() => {
|
|
34
|
-
linkifyHeadings();
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
return () => {
|
|
38
|
-
unsubscribe();
|
|
39
|
-
};
|
|
40
|
-
});
|
|
41
|
-
</script>
|
|
42
|
-
|
|
43
|
-
<div class="content-wrap">
|
|
44
|
-
<Box>
|
|
45
|
-
<content>
|
|
46
|
-
{@render children?.()}
|
|
47
|
-
</content>
|
|
48
|
-
</Box>
|
|
49
|
-
</div>
|
|
50
|
-
|
|
51
|
-
<style>.content-wrap {
|
|
52
|
-
flex: 1;
|
|
53
|
-
padding: 25px 0;
|
|
54
|
-
margin: 0 15px;
|
|
55
|
-
min-width: 0;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
content {
|
|
59
|
-
display: block;
|
|
60
|
-
padding: 30px 50px;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
content :global(p),
|
|
64
|
-
content :global(li) {
|
|
65
|
-
line-height: var(--line-height-content);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
content :global(h1:first-child) {
|
|
69
|
-
margin-top: 0;
|
|
70
|
-
font-size: 36px;
|
|
71
|
-
font-weight: 600;
|
|
72
|
-
letter-spacing: -0.03em;
|
|
73
|
-
margin: 0 0 30px;
|
|
74
|
-
position: relative;
|
|
75
|
-
display: table;
|
|
76
|
-
}
|
|
77
|
-
content :global(h1:first-child):after {
|
|
78
|
-
position: absolute;
|
|
79
|
-
content: "";
|
|
80
|
-
bottom: -13px;
|
|
81
|
-
left: 0px;
|
|
82
|
-
width: 30%;
|
|
83
|
-
height: 3px;
|
|
84
|
-
background: var(--accent);
|
|
85
|
-
margin-top: 10px;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
content :global(a:not(.no-link-color a)) {
|
|
89
|
-
color: var(--link);
|
|
90
|
-
text-decoration: underline;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
content :global(li) {
|
|
94
|
-
margin-bottom: 8px;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
content :global(ul) {
|
|
98
|
-
margin-top: 8px;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
content :global(.table) {
|
|
102
|
-
margin: 20px 0;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
content :global(code) {
|
|
106
|
-
font-size: 14px;
|
|
107
|
-
padding: 0.2em 0.4em;
|
|
108
|
-
display: inline-block;
|
|
109
|
-
background-color: #f4f2f0;
|
|
110
|
-
color: #905;
|
|
111
|
-
font-family: inherit;
|
|
112
|
-
border-radius: 4px;
|
|
113
|
-
line-height: normal;
|
|
114
|
-
font-weight: 400;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
:global(:root.dark) content :global(code) {
|
|
118
|
-
background-color: #282c34;
|
|
119
|
-
color: #e06c75;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
content :global(a.heading-anchor-link) {
|
|
123
|
-
position: absolute;
|
|
124
|
-
right: 100%;
|
|
125
|
-
margin-right: 7px;
|
|
126
|
-
opacity: 0;
|
|
127
|
-
top: 50%;
|
|
128
|
-
transform: translateY(-50%);
|
|
129
|
-
display: inline-flex;
|
|
130
|
-
align-items: center;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
content :global(h1),
|
|
134
|
-
content :global(h2),
|
|
135
|
-
content :global(h3),
|
|
136
|
-
content :global(h4),
|
|
137
|
-
content :global(h5),
|
|
138
|
-
content :global(h6) {
|
|
139
|
-
position: relative;
|
|
140
|
-
margin: 20px 0;
|
|
141
|
-
}
|
|
142
|
-
content :global(h1) {
|
|
143
|
-
font-size: 2em;
|
|
144
|
-
}
|
|
145
|
-
content :global(h2) {
|
|
146
|
-
font-size: 1.5em;
|
|
147
|
-
}
|
|
148
|
-
content :global(h3) {
|
|
149
|
-
font-size: 1.3em;
|
|
150
|
-
}
|
|
151
|
-
content :global(h4) {
|
|
152
|
-
font-size: 1.2em;
|
|
153
|
-
}
|
|
154
|
-
content :global(h5) {
|
|
155
|
-
font-size: 1.1em;
|
|
156
|
-
}
|
|
157
|
-
content :global(h6) {
|
|
158
|
-
font-size: 1em;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
content :global(.heading-anchor:hover + .heading-anchor-link) {
|
|
162
|
-
opacity: 1;
|
|
163
|
-
}
|
|
164
|
-
content :global(h2 a:not(.heading-anchor-link)),
|
|
165
|
-
content :global(h3 a:not(.heading-anchor-link)),
|
|
166
|
-
content :global(h4 a:not(.heading-anchor-link)),
|
|
167
|
-
content :global(h5 a:not(.heading-anchor-link)),
|
|
168
|
-
content :global(h6 a:not(.heading-anchor-link)) {
|
|
169
|
-
text-decoration: none;
|
|
170
|
-
color: inherit;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
@media (max-width: 992px) {
|
|
174
|
-
.content-wrap {
|
|
175
|
-
padding-top: 0;
|
|
176
|
-
order: 2;
|
|
177
|
-
}
|
|
178
|
-
content {
|
|
179
|
-
padding: 20px 25px;
|
|
180
|
-
}
|
|
181
|
-
}</style>
|