@purestack/ts-components 1.1.7 → 1.1.9
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/ts-components.d.mts +2 -1
- package/dist/ts-components.d.mts.map +1 -1
- package/dist/ts-components.mjs +118 -64
- package/dist/ts-components.mjs.map +1 -1
- package/package.json +9 -9
- package/src/standard/btn/btn.ts +4 -4
- package/src/standard/classicLogo/classicLogo.ts +14 -6
- package/src/standard/composer/composer.ts +29 -14
- package/src/standard/composer/emailHtmlPolicy.ts +4 -1
- package/src/standard/consent/consent.ts +7 -5
- package/src/standard/form/form.ts +6 -4
- package/src/standard/logo/logo.ts +43 -12
- package/src/standard/modal/modal.ts +2 -2
- package/src/standard/navMenu/navMenu.ts +7 -7
- package/src/standard/pageLinks/pageLinks.ts +4 -4
- package/src/standard/pageScript/pageScript.ts +6 -9
- package/src/standard/pageToc/pageToc.ts +5 -9
- package/src/standard/searchBox/searchBox.ts +4 -4
- package/src/standard/signIn/signIn.ts +2 -2
- package/src/standard/tabs/tabs.ts +5 -3
- package/src/standard/tabs/tabsStyle.ts +9 -5
- package/src/standard/topBar/topBar.ts +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@purestack/ts-components",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9",
|
|
4
4
|
"packageManager": "yarn@4.9.2",
|
|
5
5
|
"module": "./dist/ts-components.mjs",
|
|
6
6
|
"types": "./dist/ts-components.d.mts",
|
|
@@ -46,16 +46,16 @@
|
|
|
46
46
|
"test": "vitest"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@purestack/ts-minidom": "^1.1.
|
|
50
|
-
"@purestack/ts-render": "^1.1.
|
|
49
|
+
"@purestack/ts-minidom": "^1.1.9",
|
|
50
|
+
"@purestack/ts-render": "^1.1.9"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@purestack/ts-common": "^1.1.
|
|
54
|
-
"@purestack/ts-css": "^1.1.
|
|
55
|
-
"@purestack/ts-page-scripts": "^1.1.
|
|
56
|
-
"@purestack/ts-style": "^1.1.
|
|
57
|
-
"@purestack/ts-util": "^1.1.
|
|
58
|
-
"regor": "^1.7.
|
|
53
|
+
"@purestack/ts-common": "^1.1.9",
|
|
54
|
+
"@purestack/ts-css": "^1.1.9",
|
|
55
|
+
"@purestack/ts-page-scripts": "^1.1.9",
|
|
56
|
+
"@purestack/ts-style": "^1.1.9",
|
|
57
|
+
"@purestack/ts-util": "^1.1.9",
|
|
58
|
+
"regor": "^1.7.4"
|
|
59
59
|
},
|
|
60
60
|
"regorComponents": [
|
|
61
61
|
"AlertBox",
|
package/src/standard/btn/btn.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type PageContext, tryResolvePageContext } from '@purestack/ts-common'
|
|
2
2
|
import type { SemanticTone } from '@purestack/ts-style'
|
|
3
3
|
import {
|
|
4
4
|
type ComputedRef,
|
|
@@ -104,7 +104,7 @@ function defineButtonLinkComponent() {
|
|
|
104
104
|
'iconOnly',
|
|
105
105
|
'ariaLabel',
|
|
106
106
|
],
|
|
107
|
-
context: (head) => resolveBtnLink(head.props,
|
|
107
|
+
context: (head) => resolveBtnLink(head.props, tryResolvePageContext(head)),
|
|
108
108
|
})
|
|
109
109
|
}
|
|
110
110
|
|
|
@@ -132,7 +132,7 @@ function resolveBtn(props: Btn): Btn {
|
|
|
132
132
|
|
|
133
133
|
function resolveBtnLink(
|
|
134
134
|
props: BtnLink,
|
|
135
|
-
context:
|
|
135
|
+
context: PageContext | undefined,
|
|
136
136
|
): BtnLink {
|
|
137
137
|
return {
|
|
138
138
|
...props,
|
|
@@ -176,7 +176,7 @@ function resolveShowEndIcon(props: BtnBase) {
|
|
|
176
176
|
return hasIcon && unref(props.iconPosition) === 'end'
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
-
function resolveButtonHref(props: BtnLink, context:
|
|
179
|
+
function resolveButtonHref(props: BtnLink, context: PageContext | undefined) {
|
|
180
180
|
const value = unref(props.href)
|
|
181
181
|
const href = typeof value === 'string' ? value.trim() : undefined
|
|
182
182
|
return href ? (context?.resolvePublicHref(href) ?? href) : undefined
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type ClassicLogoConfig,
|
|
3
|
-
type
|
|
4
|
-
|
|
3
|
+
type PageContext,
|
|
4
|
+
tryResolvePageContext,
|
|
5
5
|
} from '@purestack/ts-common'
|
|
6
6
|
import {
|
|
7
7
|
getCurrentThemePaletteVar,
|
|
@@ -19,8 +19,16 @@ import {
|
|
|
19
19
|
} from 'regor'
|
|
20
20
|
|
|
21
21
|
const logoTemplate = html`<div class="classic-logo" :style="logo.layoutStyle">
|
|
22
|
-
<a
|
|
23
|
-
|
|
22
|
+
<a
|
|
23
|
+
class="classic-logo__link"
|
|
24
|
+
:href="logo.href === null ? undefined : (logo.href ?? '/')"
|
|
25
|
+
:aria-label="logo.ariaLabel"
|
|
26
|
+
>
|
|
27
|
+
<span
|
|
28
|
+
class="classic-logo__glyph"
|
|
29
|
+
:style="logo.glyphStyle"
|
|
30
|
+
aria-hidden="true"
|
|
31
|
+
>
|
|
24
32
|
<Icon :name="logo.icon" r-if="logo.icon"/>
|
|
25
33
|
<span class="classic-logo__glyph-mark" r-else></span>
|
|
26
34
|
</span>
|
|
@@ -105,7 +113,7 @@ interface ResolvedClassicLogo {
|
|
|
105
113
|
|
|
106
114
|
function resolveClassicLogo(
|
|
107
115
|
props: Partial<ClassicLogoConfig>,
|
|
108
|
-
context:
|
|
116
|
+
context: PageContext | undefined,
|
|
109
117
|
): ResolvedClassicLogo {
|
|
110
118
|
const brand = props.brand
|
|
111
119
|
const letterColors = props.letterColors
|
|
@@ -416,7 +424,7 @@ function defineClassicLogoComponent() {
|
|
|
416
424
|
Object.entries(direct).filter(([, value]) => value !== undefined),
|
|
417
425
|
),
|
|
418
426
|
}
|
|
419
|
-
return resolveClassicLogo(options,
|
|
427
|
+
return resolveClassicLogo(options, tryResolvePageContext(head))
|
|
420
428
|
}),
|
|
421
429
|
}),
|
|
422
430
|
})
|
|
@@ -65,7 +65,9 @@ export interface Composer {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
const composerTemplate = html`<div class="composer-field">
|
|
68
|
-
<span class="composer-field__label" r-if="label"
|
|
68
|
+
<span class="composer-field__label" r-if="label"
|
|
69
|
+
>{{ label }}</span
|
|
70
|
+
>
|
|
69
71
|
<div class="composer" :class="classes">
|
|
70
72
|
<div class="composer__toolbar" role="toolbar" aria-label="Composer tools">
|
|
71
73
|
<button
|
|
@@ -74,7 +76,8 @@ const composerTemplate = html`<div class="composer-field">
|
|
|
74
76
|
title="Bold"
|
|
75
77
|
aria-label="Bold"
|
|
76
78
|
:disabled="disabled"
|
|
77
|
-
@click="format('bold')"
|
|
79
|
+
@click="format('bold')"
|
|
80
|
+
>
|
|
78
81
|
<Icon name="lucide:bold"/>
|
|
79
82
|
</button>
|
|
80
83
|
<button
|
|
@@ -83,7 +86,8 @@ const composerTemplate = html`<div class="composer-field">
|
|
|
83
86
|
title="Italic"
|
|
84
87
|
aria-label="Italic"
|
|
85
88
|
:disabled="disabled"
|
|
86
|
-
@click="format('italic')"
|
|
89
|
+
@click="format('italic')"
|
|
90
|
+
>
|
|
87
91
|
<Icon name="lucide:italic"/>
|
|
88
92
|
</button>
|
|
89
93
|
<button
|
|
@@ -92,7 +96,8 @@ const composerTemplate = html`<div class="composer-field">
|
|
|
92
96
|
title="Underline"
|
|
93
97
|
aria-label="Underline"
|
|
94
98
|
:disabled="disabled"
|
|
95
|
-
@click="format('underline')"
|
|
99
|
+
@click="format('underline')"
|
|
100
|
+
>
|
|
96
101
|
<Icon name="lucide:underline"/>
|
|
97
102
|
</button>
|
|
98
103
|
<span class="composer__divider" aria-hidden="true"></span>
|
|
@@ -102,7 +107,8 @@ const composerTemplate = html`<div class="composer-field">
|
|
|
102
107
|
title="Align left"
|
|
103
108
|
aria-label="Align left"
|
|
104
109
|
:disabled="disabled"
|
|
105
|
-
@click="format('justifyLeft')"
|
|
110
|
+
@click="format('justifyLeft')"
|
|
111
|
+
>
|
|
106
112
|
<Icon name="tabler:align-left"/>
|
|
107
113
|
</button>
|
|
108
114
|
<button
|
|
@@ -111,7 +117,8 @@ const composerTemplate = html`<div class="composer-field">
|
|
|
111
117
|
title="Align center"
|
|
112
118
|
aria-label="Align center"
|
|
113
119
|
:disabled="disabled"
|
|
114
|
-
@click="format('justifyCenter')"
|
|
120
|
+
@click="format('justifyCenter')"
|
|
121
|
+
>
|
|
115
122
|
<Icon name="tabler:align-center"/>
|
|
116
123
|
</button>
|
|
117
124
|
<button
|
|
@@ -120,7 +127,8 @@ const composerTemplate = html`<div class="composer-field">
|
|
|
120
127
|
title="Align right"
|
|
121
128
|
aria-label="Align right"
|
|
122
129
|
:disabled="disabled"
|
|
123
|
-
@click="format('justifyRight')"
|
|
130
|
+
@click="format('justifyRight')"
|
|
131
|
+
>
|
|
124
132
|
<Icon name="tabler:align-right"/>
|
|
125
133
|
</button>
|
|
126
134
|
<span class="composer__divider" aria-hidden="true"></span>
|
|
@@ -130,7 +138,8 @@ const composerTemplate = html`<div class="composer-field">
|
|
|
130
138
|
title="Bulleted list"
|
|
131
139
|
aria-label="Bulleted list"
|
|
132
140
|
:disabled="disabled"
|
|
133
|
-
@click="format('insertUnorderedList')"
|
|
141
|
+
@click="format('insertUnorderedList')"
|
|
142
|
+
>
|
|
134
143
|
<Icon name="lucide:list"/>
|
|
135
144
|
</button>
|
|
136
145
|
<button
|
|
@@ -139,7 +148,8 @@ const composerTemplate = html`<div class="composer-field">
|
|
|
139
148
|
title="Numbered list"
|
|
140
149
|
aria-label="Numbered list"
|
|
141
150
|
:disabled="disabled"
|
|
142
|
-
@click="format('insertOrderedList')"
|
|
151
|
+
@click="format('insertOrderedList')"
|
|
152
|
+
>
|
|
143
153
|
<Icon name="lucide:list-ordered"/>
|
|
144
154
|
</button>
|
|
145
155
|
<button
|
|
@@ -148,7 +158,8 @@ const composerTemplate = html`<div class="composer-field">
|
|
|
148
158
|
title="Link"
|
|
149
159
|
aria-label="Link"
|
|
150
160
|
:disabled="disabled"
|
|
151
|
-
@click="createLink"
|
|
161
|
+
@click="createLink"
|
|
162
|
+
>
|
|
152
163
|
<Icon name="lucide:link"/>
|
|
153
164
|
</button>
|
|
154
165
|
<span class="composer__divider" aria-hidden="true"></span>
|
|
@@ -158,7 +169,8 @@ const composerTemplate = html`<div class="composer-field">
|
|
|
158
169
|
title="Clear formatting"
|
|
159
170
|
aria-label="Clear formatting"
|
|
160
171
|
:disabled="disabled"
|
|
161
|
-
@click="format('removeFormat')"
|
|
172
|
+
@click="format('removeFormat')"
|
|
173
|
+
>
|
|
162
174
|
<Icon name="lucide:eraser"/>
|
|
163
175
|
</button>
|
|
164
176
|
<button
|
|
@@ -168,7 +180,8 @@ const composerTemplate = html`<div class="composer-field">
|
|
|
168
180
|
aria-label="HTML source"
|
|
169
181
|
:aria-pressed="sourceMode ? 'true' : 'false'"
|
|
170
182
|
:disabled="disabled"
|
|
171
|
-
@click="toggleSourceMode"
|
|
183
|
+
@click="toggleSourceMode"
|
|
184
|
+
>
|
|
172
185
|
<Icon name="lucide:code"/>
|
|
173
186
|
</button>
|
|
174
187
|
</div>
|
|
@@ -187,7 +200,8 @@ const composerTemplate = html`<div class="composer-field">
|
|
|
187
200
|
@input="handleInput"
|
|
188
201
|
@paste="handlePaste"
|
|
189
202
|
@dragover="handleDragOver"
|
|
190
|
-
@drop="handleDrop"
|
|
203
|
+
@drop="handleDrop"
|
|
204
|
+
></div>
|
|
191
205
|
<textarea
|
|
192
206
|
r-if="sourceMode"
|
|
193
207
|
:id="sourceId"
|
|
@@ -198,7 +212,8 @@ const composerTemplate = html`<div class="composer-field">
|
|
|
198
212
|
:aria-label="label || placeholder || 'Message body source'"
|
|
199
213
|
spellcheck="false"
|
|
200
214
|
:value="sourceHtml"
|
|
201
|
-
@input="handleSourceInput"
|
|
215
|
+
@input="handleSourceInput"
|
|
216
|
+
></textarea>
|
|
202
217
|
</div>
|
|
203
218
|
</div>
|
|
204
219
|
</div>`
|
|
@@ -432,7 +432,10 @@ export function normalizeEmailContentId(value: string) {
|
|
|
432
432
|
}
|
|
433
433
|
|
|
434
434
|
function stripImportant(value: string) {
|
|
435
|
-
|
|
435
|
+
const trimmed = value.trim()
|
|
436
|
+
return trimmed.slice(-10).toLowerCase() === '!important'
|
|
437
|
+
? trimmed.slice(0, -10).trimEnd()
|
|
438
|
+
: trimmed
|
|
436
439
|
}
|
|
437
440
|
|
|
438
441
|
function isSafeCssValue(value: string) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
ConsentCategory,
|
|
3
3
|
ConsentConfig,
|
|
4
|
-
|
|
4
|
+
PageContext,
|
|
5
5
|
} from '@purestack/ts-common'
|
|
6
|
-
import {
|
|
6
|
+
import { resolvePageContext } from '@purestack/ts-common'
|
|
7
7
|
import type { SemanticTone } from '@purestack/ts-style'
|
|
8
8
|
import { defineComponent, html, type RefOrValue } from 'regor'
|
|
9
9
|
import type {
|
|
@@ -115,7 +115,9 @@ const consentTemplate = html`<section class="consent" data-consent-root r-if="en
|
|
|
115
115
|
</Flex>
|
|
116
116
|
|
|
117
117
|
<Flex align="center" wrap="true">
|
|
118
|
-
<Btn tone="accent" data-consent-action="save">
|
|
118
|
+
<Btn tone="accent" data-consent-action="save">
|
|
119
|
+
{{ saveLabel }}
|
|
120
|
+
</Btn>
|
|
119
121
|
<Btn tone="accent" data-consent-action="accept-all">
|
|
120
122
|
{{ acceptAllLabel }}
|
|
121
123
|
</Btn>
|
|
@@ -142,12 +144,12 @@ const consentTemplate = html`<section class="consent" data-consent-root r-if="en
|
|
|
142
144
|
function defineConsentComponent() {
|
|
143
145
|
return defineComponent<Consent>(consentTemplate, {
|
|
144
146
|
props: ['tone', 'variant', 'variantMode'],
|
|
145
|
-
context: (head) => resolveConsent(
|
|
147
|
+
context: (head) => resolveConsent(resolvePageContext(head), head.props),
|
|
146
148
|
})
|
|
147
149
|
}
|
|
148
150
|
|
|
149
151
|
function resolveConsent(
|
|
150
|
-
context:
|
|
152
|
+
context: PageContext,
|
|
151
153
|
props: Partial<Consent>,
|
|
152
154
|
): Consent {
|
|
153
155
|
const consent = context.site.consent
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { tryResolvePageContext } from '@purestack/ts-common'
|
|
2
2
|
import type { SemanticTone } from '@purestack/ts-style'
|
|
3
3
|
import {
|
|
4
4
|
type ComponentHead,
|
|
@@ -73,7 +73,9 @@ const formAssistLinkTemplate = html`<a
|
|
|
73
73
|
{{ label }}
|
|
74
74
|
</a>`
|
|
75
75
|
|
|
76
|
-
const formSubmitTemplate = html`<Btn type="submit" :tone="tone" :variant="variant"
|
|
76
|
+
const formSubmitTemplate = html`<Btn type="submit" :tone="tone" :variant="variant"
|
|
77
|
+
>{{ label }}</Btn
|
|
78
|
+
>`
|
|
77
79
|
|
|
78
80
|
const formDividerTemplate = html`<div class="form-block__divider" :data-label="label"></div>`
|
|
79
81
|
|
|
@@ -154,7 +156,7 @@ function resolveAppForm(head: ComponentHead<AppForm>): AppForm {
|
|
|
154
156
|
function resolvePublicAction(head: ComponentHead<AppForm>) {
|
|
155
157
|
const action = unref(head.props.action)
|
|
156
158
|
if (!action) return action
|
|
157
|
-
return
|
|
159
|
+
return tryResolvePageContext(head)?.resolvePublicHref(action) ?? action
|
|
158
160
|
}
|
|
159
161
|
|
|
160
162
|
function resolveFormAssistLink(
|
|
@@ -184,7 +186,7 @@ function resolvePublicHref(
|
|
|
184
186
|
head: ComponentHead<FormAssistLink>,
|
|
185
187
|
) {
|
|
186
188
|
if (!href) return undefined
|
|
187
|
-
return
|
|
189
|
+
return tryResolvePageContext(head)?.resolvePublicHref(href) ?? href
|
|
188
190
|
}
|
|
189
191
|
|
|
190
192
|
function resolveFormSubmit(head: ComponentHead<FormSubmit>): FormSubmit {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type LogoConfig,
|
|
3
|
-
type
|
|
4
|
-
|
|
3
|
+
type PageContext,
|
|
4
|
+
tryResolvePageContext,
|
|
5
5
|
} from '@purestack/ts-common'
|
|
6
6
|
import {
|
|
7
7
|
getSemanticToneClass,
|
|
@@ -33,21 +33,52 @@ export interface SiteLogo extends ReactiveLogoOptions {
|
|
|
33
33
|
initials?: ComputedRef<string>
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
const logoTemplate = html`<a
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
const logoTemplate = html`<a
|
|
37
|
+
class="site-logo"
|
|
38
|
+
:class="classes"
|
|
39
|
+
:style="logoStyle"
|
|
40
|
+
:href="resolvedHref"
|
|
41
|
+
:role="resolvedHref ? undefined : 'img'"
|
|
42
|
+
:aria-label="accessibleName"
|
|
43
|
+
>
|
|
44
|
+
<span
|
|
45
|
+
class="site-logo__mark"
|
|
46
|
+
r-if="options.layout !== 'wordmark'"
|
|
47
|
+
aria-hidden="true"
|
|
48
|
+
>
|
|
39
49
|
<slot name="mark">
|
|
40
50
|
<span class="site-logo__images" r-if="resolvedImage">
|
|
41
|
-
<img
|
|
42
|
-
|
|
51
|
+
<img
|
|
52
|
+
class="site-logo__image"
|
|
53
|
+
:class="{ 'site-logo__image--light': resolvedDarkImage }"
|
|
54
|
+
:src="resolvedImage"
|
|
55
|
+
alt=""
|
|
56
|
+
decoding="async"/>
|
|
57
|
+
<img
|
|
58
|
+
class="site-logo__image site-logo__image--dark"
|
|
59
|
+
r-if="resolvedDarkImage"
|
|
60
|
+
:src="resolvedDarkImage"
|
|
61
|
+
alt=""
|
|
62
|
+
decoding="async"/>
|
|
43
63
|
</span>
|
|
44
64
|
<Icon r-else-if="options.icon" :name="options.icon"/>
|
|
45
65
|
<span class="site-logo__monogram" r-else>{{ initials }}</span>
|
|
46
66
|
</slot>
|
|
47
67
|
</span>
|
|
48
|
-
<span
|
|
49
|
-
|
|
50
|
-
|
|
68
|
+
<span
|
|
69
|
+
class="site-logo__copy"
|
|
70
|
+
r-if="options.layout !== 'mark'"
|
|
71
|
+
aria-hidden="true"
|
|
72
|
+
>
|
|
73
|
+
<span class="site-logo__name"
|
|
74
|
+
><span class="site-logo__brand">{{ options.brand }}</span
|
|
75
|
+
><span class="site-logo__suffix" r-if="options.suffix"
|
|
76
|
+
>{{ options.suffix }}</span
|
|
77
|
+
></span
|
|
78
|
+
>
|
|
79
|
+
<span class="site-logo__subtitle" r-if="options.subtitle"
|
|
80
|
+
>{{ options.subtitle }}</span
|
|
81
|
+
>
|
|
51
82
|
</span>
|
|
52
83
|
</a>`
|
|
53
84
|
|
|
@@ -78,7 +109,7 @@ const logoProps = [
|
|
|
78
109
|
'gap',
|
|
79
110
|
] as const satisfies readonly (keyof LogoConfig)[]
|
|
80
111
|
|
|
81
|
-
function resolveSiteLogo(props: SiteLogo, context?:
|
|
112
|
+
function resolveSiteLogo(props: SiteLogo, context?: PageContext): SiteLogo {
|
|
82
113
|
const options = computed<LogoConfig>(() => {
|
|
83
114
|
const config = flatten(unref(props.config) ?? {}) as Partial<LogoConfig>
|
|
84
115
|
const read = <K extends keyof LogoConfig>(
|
|
@@ -186,7 +217,7 @@ export function defineLogoComponents() {
|
|
|
186
217
|
siteLogo: defineComponent<SiteLogo>(logoTemplate, {
|
|
187
218
|
props: ['config', ...logoProps],
|
|
188
219
|
context: (head) =>
|
|
189
|
-
resolveSiteLogo(head.props,
|
|
220
|
+
resolveSiteLogo(head.props, tryResolvePageContext(head)),
|
|
190
221
|
}),
|
|
191
222
|
}
|
|
192
223
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { tryResolvePageContext } from '@purestack/ts-common'
|
|
2
2
|
import type { SemanticTone } from '@purestack/ts-style'
|
|
3
3
|
import {
|
|
4
4
|
type ComponentHead,
|
|
@@ -167,5 +167,5 @@ function resolveModalRootClass(props: Modal) {
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
function markModalRuntimeEmbed(head: ComponentHead<Modal>) {
|
|
170
|
-
|
|
170
|
+
tryResolvePageContext(head)?.recordRuntimeEmbed('modal', 'head')
|
|
171
171
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type NavItem,
|
|
3
|
-
type
|
|
4
|
-
|
|
3
|
+
type PageContext,
|
|
4
|
+
tryResolvePageContext,
|
|
5
5
|
} from '@purestack/ts-common'
|
|
6
6
|
import type { SemanticTone } from '@purestack/ts-style'
|
|
7
7
|
import { urlNormalizer } from '@purestack/ts-util'
|
|
@@ -109,8 +109,8 @@ const navMenuTemplate = html`<nav
|
|
|
109
109
|
r-if="resolvedSignInEnabled"
|
|
110
110
|
class="nav__account"
|
|
111
111
|
:enabled="resolvedSignInEnabled"
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
:signedIn="signInSignedIn"
|
|
113
|
+
:avatarSrc="signInAvatarSrc"
|
|
114
114
|
:avatarAlt="signInAvatarAlt"/>
|
|
115
115
|
<button
|
|
116
116
|
class="nav__panel-toggle tone-fill-surface-all tone-text-surface-all tone-border-surface-all"
|
|
@@ -152,7 +152,7 @@ const navMenuTemplate = html`<nav
|
|
|
152
152
|
</script>
|
|
153
153
|
</nav>`
|
|
154
154
|
|
|
155
|
-
function resolveNavItems(context?:
|
|
155
|
+
function resolveNavItems(context?: PageContext): NavItem[] {
|
|
156
156
|
const items = context?.navigation?.items ?? []
|
|
157
157
|
if (items.length > 0) return items
|
|
158
158
|
return context?.navigation?.global ?? []
|
|
@@ -160,7 +160,7 @@ function resolveNavItems(context?: TsSsgContext): NavItem[] {
|
|
|
160
160
|
|
|
161
161
|
function resolveCurrentPath(
|
|
162
162
|
currentUrl: string | undefined,
|
|
163
|
-
context?:
|
|
163
|
+
context?: PageContext,
|
|
164
164
|
): string | undefined {
|
|
165
165
|
const fromProp = urlNormalizer.normalizeInternalPath(currentUrl)
|
|
166
166
|
if (fromProp) return fromProp
|
|
@@ -250,7 +250,7 @@ function defineNavMenuComponent() {
|
|
|
250
250
|
'signInAvatarAlt',
|
|
251
251
|
],
|
|
252
252
|
context: (head) => {
|
|
253
|
-
const context =
|
|
253
|
+
const context = tryResolvePageContext(head)
|
|
254
254
|
const props = head.props
|
|
255
255
|
return {
|
|
256
256
|
...props,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
PageContext,
|
|
2
3
|
PageNavigationLink,
|
|
3
4
|
PageNavigationLinks,
|
|
4
|
-
TsSsgContext,
|
|
5
5
|
} from '@purestack/ts-common'
|
|
6
|
-
import {
|
|
6
|
+
import { resolvePageContext } from '@purestack/ts-common'
|
|
7
7
|
import { defineComponent, html } from 'regor'
|
|
8
8
|
|
|
9
9
|
export interface PageLinks extends PageNavigationLinks {
|
|
@@ -59,7 +59,7 @@ const pageLinksTemplate = html`<Grid
|
|
|
59
59
|
|
|
60
60
|
function resolvePageLinks(
|
|
61
61
|
props: PageLinks,
|
|
62
|
-
context:
|
|
62
|
+
context: PageContext | undefined,
|
|
63
63
|
): PageLinks {
|
|
64
64
|
const previous = props.previous ?? context?.navigation?.pageLinks?.previous
|
|
65
65
|
const next = props.next ?? context?.navigation?.pageLinks?.next
|
|
@@ -80,7 +80,7 @@ function resolvePageLink(link: PageNavigationLink | undefined) {
|
|
|
80
80
|
function definePageLinksComponent() {
|
|
81
81
|
return defineComponent<PageLinks>(pageLinksTemplate, {
|
|
82
82
|
props: ['previous', 'next'],
|
|
83
|
-
context: (head) => resolvePageLinks(head.props,
|
|
83
|
+
context: (head) => resolvePageLinks(head.props, resolvePageContext(head)),
|
|
84
84
|
})
|
|
85
85
|
}
|
|
86
86
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolvePageContext } from '@purestack/ts-common'
|
|
2
2
|
import {
|
|
3
3
|
dirnamePosix,
|
|
4
4
|
joinPosix,
|
|
@@ -41,10 +41,7 @@ const pageScriptTemplate = html`<script
|
|
|
41
41
|
:nomodule="noModule"
|
|
42
42
|
></script>`
|
|
43
43
|
|
|
44
|
-
const regorAppTemplate = html`<App><PageScript
|
|
45
|
-
:src="src"
|
|
46
|
-
:sourceRelPath="sourceRelPath"
|
|
47
|
-
/></App>`
|
|
44
|
+
const regorAppTemplate = html`<App><PageScript :src="src" :sourceRelPath="sourceRelPath"/></App>`
|
|
48
45
|
|
|
49
46
|
function definePageScriptComponent() {
|
|
50
47
|
return defineComponent<PageScript>(pageScriptTemplate, {
|
|
@@ -84,16 +81,16 @@ export function defineScriptComponents() {
|
|
|
84
81
|
|
|
85
82
|
function resolvePageScript(head: ComponentHead<PageScript>): PageScript {
|
|
86
83
|
const props = flatten(head.props)
|
|
87
|
-
const
|
|
84
|
+
const pageContext = resolvePageContext(head)
|
|
88
85
|
const ownerRelPath =
|
|
89
|
-
toOptionalString(props.sourceRelPath) ??
|
|
86
|
+
toOptionalString(props.sourceRelPath) ?? pageContext.pageInfo.relPath
|
|
90
87
|
const src = resolveScriptSrc(
|
|
91
88
|
props.src,
|
|
92
89
|
ownerRelPath,
|
|
93
90
|
(sourceRelPath) => {
|
|
94
|
-
|
|
91
|
+
pageContext.recordScriptEntrypoint(sourceRelPath)
|
|
95
92
|
},
|
|
96
|
-
|
|
93
|
+
pageContext.resolveScriptPublicPath,
|
|
97
94
|
)
|
|
98
95
|
return {
|
|
99
96
|
...props,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
1
|
+
import type { PageContext, PageOutlineItem } from '@purestack/ts-common'
|
|
2
|
+
import { resolvePageContext } from '@purestack/ts-common'
|
|
3
3
|
import type { SemanticTone } from '@purestack/ts-style'
|
|
4
4
|
import {
|
|
5
5
|
type ComputedRef,
|
|
@@ -33,11 +33,7 @@ export interface PageTocItem extends PageOutlineItem {
|
|
|
33
33
|
children?: PageTocItem[]
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
const pageTocTemplate = html`<nav
|
|
37
|
-
class="page-toc"
|
|
38
|
-
:class="classes"
|
|
39
|
-
aria-label="On this page"
|
|
40
|
-
>
|
|
36
|
+
const pageTocTemplate = html`<nav class="page-toc" :class="classes" aria-label="On this page">
|
|
41
37
|
<button
|
|
42
38
|
class="page-toc__panel-toggle tone-fill-button-all tone-text-button-all tone-border-button-all"
|
|
43
39
|
type="button"
|
|
@@ -120,7 +116,7 @@ function omitSingleDocumentHeading(items: PageOutlineItem[]) {
|
|
|
120
116
|
return item.children ?? []
|
|
121
117
|
}
|
|
122
118
|
|
|
123
|
-
function resolveItems(props: PageToc, context:
|
|
119
|
+
function resolveItems(props: PageToc, context: PageContext | undefined) {
|
|
124
120
|
const items = unref(props.outline) ?? context?.outline ?? []
|
|
125
121
|
return toPageTocItems(omitSingleDocumentHeading(items))
|
|
126
122
|
}
|
|
@@ -135,7 +131,7 @@ function definePageTocComponent() {
|
|
|
135
131
|
return defineComponent<PageToc>(pageTocTemplate, {
|
|
136
132
|
props: ['outline', 'title', 'tone', 'variant', 'variantMode'],
|
|
137
133
|
context: (head) => {
|
|
138
|
-
const context =
|
|
134
|
+
const context = resolvePageContext(head)
|
|
139
135
|
return {
|
|
140
136
|
title: resolveTitle(head.props),
|
|
141
137
|
classes: computed(() =>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PageContext } from '@purestack/ts-common'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { resolvePageContext } from '@purestack/ts-common'
|
|
4
4
|
import type { SemanticTone } from '@purestack/ts-style'
|
|
5
5
|
import { defineComponent, html, type RefOrValue } from 'regor'
|
|
6
6
|
import type { ComponentVariant } from '../componentVariant'
|
|
@@ -36,7 +36,7 @@ function defineSearchBoxComponent() {
|
|
|
36
36
|
context: (head) => ({
|
|
37
37
|
tone: head.props.tone,
|
|
38
38
|
variant: head.props.variant,
|
|
39
|
-
placeholder: resolveSearchPlaceholder(
|
|
39
|
+
placeholder: resolveSearchPlaceholder(resolvePageContext(head)),
|
|
40
40
|
}),
|
|
41
41
|
})
|
|
42
42
|
}
|
|
@@ -45,7 +45,7 @@ export function defineSearchComponents() {
|
|
|
45
45
|
return { searchBox: defineSearchBoxComponent() }
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
function resolveSearchPlaceholder(context:
|
|
48
|
+
function resolveSearchPlaceholder(context: PageContext): string {
|
|
49
49
|
const title = context?.site?.siteTitle
|
|
50
50
|
if (typeof title !== 'string') return 'Search'
|
|
51
51
|
const trimmed = title.trim()
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { tryResolvePageContext } from '@purestack/ts-common'
|
|
2
2
|
import type { SemanticTone } from '@purestack/ts-style'
|
|
3
3
|
import {
|
|
4
4
|
type ComputedRef,
|
|
@@ -159,7 +159,7 @@ export function defineSignInComponents() {
|
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
function resolveSignIn(props: SignIn, head: unknown): SignIn {
|
|
162
|
-
const auth =
|
|
162
|
+
const auth = tryResolvePageContext(head)?.site?.auth
|
|
163
163
|
return {
|
|
164
164
|
...props,
|
|
165
165
|
authEnabled: computed(() => unref(props.enabled) ?? auth?.enabled === true),
|