@purestack/ts-components 1.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.
Files changed (106) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +10 -0
  3. package/dist/ts-components.d.mts +1662 -0
  4. package/dist/ts-components.d.mts.map +1 -0
  5. package/dist/ts-components.mjs +9200 -0
  6. package/dist/ts-components.mjs.map +1 -0
  7. package/package.json +130 -0
  8. package/src/defineComponents.ts +87 -0
  9. package/src/index.ts +270 -0
  10. package/src/registerStyles.ts +63 -0
  11. package/src/standard/alertBox/alertBox.ts +64 -0
  12. package/src/standard/autoId.ts +25 -0
  13. package/src/standard/badge/badge.ts +41 -0
  14. package/src/standard/badge/badgeStyle.ts +21 -0
  15. package/src/standard/barChart/barChart.ts +338 -0
  16. package/src/standard/barChart/barChartStyle.ts +81 -0
  17. package/src/standard/btn/btn.ts +191 -0
  18. package/src/standard/btn/btnStyle.ts +59 -0
  19. package/src/standard/btnGroup/btnGroup.ts +208 -0
  20. package/src/standard/btnGroup/btnGroupStyle.ts +85 -0
  21. package/src/standard/chart/cartesianChart.ts +99 -0
  22. package/src/standard/chart/chartDefaults.ts +25 -0
  23. package/src/standard/chart/chartUtils.ts +84 -0
  24. package/src/standard/classicLogo/classicLogo.ts +429 -0
  25. package/src/standard/classicLogo/classicLogoStyle.ts +292 -0
  26. package/src/standard/componentVariant.ts +153 -0
  27. package/src/standard/composer/composer.ts +1035 -0
  28. package/src/standard/composer/composerCanvasInitialStyle.ts +225 -0
  29. package/src/standard/composer/composerCanvasRevertStyle.ts +14 -0
  30. package/src/standard/composer/composerCanvasSharedStyle.ts +60 -0
  31. package/src/standard/composer/composerCanvasStyleTypes.ts +8 -0
  32. package/src/standard/composer/composerCanvasThemeStyle.ts +53 -0
  33. package/src/standard/composer/composerStyle.ts +156 -0
  34. package/src/standard/composer/emailHtmlPolicy.ts +474 -0
  35. package/src/standard/consent/consent.ts +173 -0
  36. package/src/standard/consent/consentStyle.ts +44 -0
  37. package/src/standard/contactForm/contactForm.ts +135 -0
  38. package/src/standard/contactForm/contactFormStyle.ts +116 -0
  39. package/src/standard/doughnutChart/doughnutChart.ts +527 -0
  40. package/src/standard/doughnutChart/doughnutChartStyle.ts +64 -0
  41. package/src/standard/dropFiles/dropFiles.ts +480 -0
  42. package/src/standard/dropFiles/dropFilesStyle.ts +171 -0
  43. package/src/standard/expandablePanel/expandablePanel.ts +106 -0
  44. package/src/standard/expandablePanel/expandablePanelStyle.ts +56 -0
  45. package/src/standard/flex/flex.ts +269 -0
  46. package/src/standard/flex/flexStyle.ts +556 -0
  47. package/src/standard/footer/footer.ts +93 -0
  48. package/src/standard/footer/footerStyle.ts +39 -0
  49. package/src/standard/form/autoCompleteInput.ts +567 -0
  50. package/src/standard/form/form.ts +205 -0
  51. package/src/standard/form/formCheck.ts +96 -0
  52. package/src/standard/form/formInputField.ts +184 -0
  53. package/src/standard/form/formSelectField.ts +152 -0
  54. package/src/standard/form/formStyle.ts +585 -0
  55. package/src/standard/form/multiAutoCompleteInput.ts +880 -0
  56. package/src/standard/grid/grid.ts +177 -0
  57. package/src/standard/grid/gridStyle.ts +56 -0
  58. package/src/standard/icon/icon.ts +96 -0
  59. package/src/standard/icon/iconStyle.ts +50 -0
  60. package/src/standard/landing/codeShowcase.ts +54 -0
  61. package/src/standard/landing/comparisonColumn.ts +30 -0
  62. package/src/standard/landing/comparisonFeature.ts +22 -0
  63. package/src/standard/landing/comparisonTable.ts +38 -0
  64. package/src/standard/landing/ctaSection.ts +59 -0
  65. package/src/standard/landing/featureCard.ts +41 -0
  66. package/src/standard/landing/landing.ts +52 -0
  67. package/src/standard/landing/landingBand.ts +217 -0
  68. package/src/standard/landing/landingSection.ts +43 -0
  69. package/src/standard/landing/landingTypes.ts +141 -0
  70. package/src/standard/landing/metricItem.ts +25 -0
  71. package/src/standard/landing/metricStrip.ts +20 -0
  72. package/src/standard/lineChart/lineChart.ts +462 -0
  73. package/src/standard/lineChart/lineChartStyle.ts +91 -0
  74. package/src/standard/logo/logo.ts +192 -0
  75. package/src/standard/logo/logoStyle.ts +164 -0
  76. package/src/standard/modal/modal.ts +171 -0
  77. package/src/standard/modal/modalStore.ts +154 -0
  78. package/src/standard/modal/modalStyle.ts +190 -0
  79. package/src/standard/navMenu/navMenu.ts +278 -0
  80. package/src/standard/navMenu/navMenuStyle.ts +323 -0
  81. package/src/standard/pageLinks/pageLinks.ts +90 -0
  82. package/src/standard/pageScript/pageScript.ts +155 -0
  83. package/src/standard/pageToc/pageToc.ts +154 -0
  84. package/src/standard/pageToc/pageTocStyle.ts +372 -0
  85. package/src/standard/panel/panel.ts +55 -0
  86. package/src/standard/panel/panelStyle.ts +15 -0
  87. package/src/standard/pricing/pricing.ts +146 -0
  88. package/src/standard/searchBox/searchBox.ts +54 -0
  89. package/src/standard/searchBox/searchBoxStyle.ts +180 -0
  90. package/src/standard/sectionHeader/sectionHeader.ts +99 -0
  91. package/src/standard/signIn/signIn.ts +167 -0
  92. package/src/standard/signIn/signInStyle.ts +70 -0
  93. package/src/standard/tabs/tabs.ts +193 -0
  94. package/src/standard/tabs/tabsStyle.ts +231 -0
  95. package/src/standard/themeToggle/themeToggle.ts +33 -0
  96. package/src/standard/themeToggle/themeToggleStyle.ts +88 -0
  97. package/src/standard/toast/toastHost.ts +42 -0
  98. package/src/standard/toast/toastStore.ts +50 -0
  99. package/src/standard/topBar/topBar.ts +101 -0
  100. package/src/standard/topBar/topBarStyle.ts +169 -0
  101. package/src/standard/virtualList/variableVirtualTable.ts +371 -0
  102. package/src/standard/virtualList/virtualList.ts +423 -0
  103. package/src/standard/virtualList/virtualListStyle.ts +34 -0
  104. package/src/standard/virtualList/virtualTable.ts +179 -0
  105. package/src/standard/virtualList/virtualTableStyle.ts +24 -0
  106. package/tsconfig.json +23 -0
@@ -0,0 +1,106 @@
1
+ import type { SemanticTone } from '@purestack/ts-style'
2
+ import {
3
+ type ComputedRef,
4
+ computed,
5
+ defineComponent,
6
+ html,
7
+ type RefOrValue,
8
+ } from 'regor'
9
+ import {
10
+ type ComponentVariant,
11
+ resolveComponentClasses,
12
+ } from '../componentVariant'
13
+
14
+ export interface ExpandablePanel {
15
+ title?: RefOrValue<string>
16
+ description?: RefOrValue<string>
17
+ meta?: RefOrValue<string>
18
+ badge?: RefOrValue<string>
19
+ icon?: RefOrValue<string>
20
+ tone?: RefOrValue<SemanticTone>
21
+ variant?: RefOrValue<ComponentVariant>
22
+ summaryVariant?: RefOrValue<ComponentVariant>
23
+ open?: RefOrValue<boolean>
24
+ classes?: ComputedRef<string>
25
+ summaryClasses?: ComputedRef<string>
26
+ }
27
+
28
+ const expandablePanelTemplate = html`<details class="expandable-panel gap-0" :class="classes" :open="open">
29
+ <Flex
30
+ container="summary"
31
+ align="center"
32
+ class="expandable-panel__summary cursor-pointer p-4"
33
+ :class="summaryClasses"
34
+ >
35
+ <slot name="summary">
36
+ <IconFrame
37
+ :name="icon"
38
+ r-if="icon"
39
+ :variant="summaryVariant"
40
+ variantMode="stateless"/>
41
+ <Flex align="center" wrap="true" class="flex-1 gap-2">
42
+ <span class="fw-700 min-w-0 lh-0" r-if="title">{{ title }}</span>
43
+ <Badge :tone="tone" r-if="badge">{{ badge }}</Badge>
44
+ <span class="fs-sm w-full lh-0" r-if="description">
45
+ {{ description }}
46
+ </span>
47
+ </Flex>
48
+ <Flex align="center" justify="center" class="flex-none">
49
+ <span class="fw-600" r-if="meta"> {{ meta }} </span>
50
+ <IconFrame
51
+ class="expandable-panel__chevron rounded-pill"
52
+ name="iconoir:nav-arrow-down"
53
+ :variant="summaryVariant"
54
+ variantMode="stateless"/>
55
+ </Flex>
56
+ </slot>
57
+ </Flex>
58
+ <div class="expandable-panel__body p-4 bt-0"><slot></slot></div>
59
+ </details>`
60
+
61
+ function defineExpandablePanelComponent() {
62
+ return defineComponent<ExpandablePanel>(expandablePanelTemplate, {
63
+ props: [
64
+ 'title',
65
+ 'description',
66
+ 'meta',
67
+ 'badge',
68
+ 'icon',
69
+ 'tone',
70
+ 'variant',
71
+ 'summaryVariant',
72
+ 'open',
73
+ ],
74
+ context: (head) => resolveExpandablePanel(head.props),
75
+ })
76
+ }
77
+
78
+ export function defineExpandablePanelComponents() {
79
+ return {
80
+ expandablePanel: defineExpandablePanelComponent(),
81
+ }
82
+ }
83
+
84
+ function resolveExpandablePanel(props: ExpandablePanel): ExpandablePanel {
85
+ return {
86
+ ...props,
87
+ classes: computed(() =>
88
+ resolveComponentClasses(props, {
89
+ defaultVariant: 'surface',
90
+ defaultVariantMode: 'stateless',
91
+ }),
92
+ ),
93
+ summaryClasses: computed(() =>
94
+ resolveComponentClasses(
95
+ {
96
+ tone: props.tone,
97
+ variant: props.summaryVariant,
98
+ },
99
+ {
100
+ defaultVariant: 'surface',
101
+ defaultVariantMode: 'stateful',
102
+ },
103
+ ),
104
+ ),
105
+ }
106
+ }
@@ -0,0 +1,56 @@
1
+ import {
2
+ styleBuilder,
3
+ type ThemeMode,
4
+ type ThemePalette,
5
+ themes,
6
+ } from '@purestack/ts-style'
7
+
8
+ export function registerExpandablePanelStyles() {
9
+ themes.forEach((theme, palette) => {
10
+ registerExpandablePanelShellStyles(theme, palette)
11
+ registerExpandablePanelSummaryStyles(theme, palette)
12
+ })
13
+ }
14
+
15
+ function registerExpandablePanelShellStyles(
16
+ theme: ThemeMode,
17
+ palette: ThemePalette,
18
+ ) {
19
+ styleBuilder
20
+ .select('.expandable-panel', theme)
21
+ .boxShadow(palette.effect.panelShadow)
22
+ .padding('0')
23
+ .overflow('hidden')
24
+ .transition(
25
+ 'border-color 180ms ease, box-shadow 180ms ease, background 180ms ease',
26
+ )
27
+
28
+ styleBuilder
29
+ .select('.expandable-panel[open]', theme)
30
+ .boxShadow(palette.effect.panelShadowStrong)
31
+ }
32
+
33
+ function registerExpandablePanelSummaryStyles(
34
+ theme: ThemeMode,
35
+ palette: ThemePalette,
36
+ ) {
37
+ styleBuilder
38
+ .select('.expandable-panel[open] .expandable-panel__summary', theme)
39
+ .borderBottomLeftRadius('0 !important')
40
+ .borderBottomRightRadius('0 !important')
41
+
42
+ styleBuilder
43
+ .select('.expandable-panel__summary:focus-visible', theme)
44
+ .outline(`2px solid ${palette.current.border.focus}`)
45
+ .outlineOffset('-2px')
46
+
47
+ styleBuilder
48
+ .select('.expandable-panel__chevron', theme)
49
+ .transition(
50
+ 'transform 180ms ease, color 180ms ease, border-color 180ms ease, background 180ms ease',
51
+ )
52
+
53
+ styleBuilder
54
+ .select('.expandable-panel[open] .expandable-panel__chevron', theme)
55
+ .transform('rotate(180deg)')
56
+ }
@@ -0,0 +1,269 @@
1
+ import {
2
+ type ComputedRef,
3
+ computed,
4
+ defineComponent,
5
+ html,
6
+ type RefOrValue,
7
+ unref,
8
+ } from 'regor'
9
+
10
+ export type FlexDirection = 'row' | 'row-reverse' | 'column' | 'column-reverse'
11
+ export type FlexAlign = 'stretch' | 'start' | 'center' | 'end' | 'baseline'
12
+ export type FlexJustify =
13
+ | 'start'
14
+ | 'center'
15
+ | 'end'
16
+ | 'stretch'
17
+ | 'between'
18
+ | 'around'
19
+ | 'evenly'
20
+ export type FlexWrap = boolean | 'wrap' | 'nowrap' | 'reverse' | 'true'
21
+
22
+ export interface Flex {
23
+ container?: RefOrValue<string>
24
+ direction?: RefOrValue<FlexDirection>
25
+ directionSm?: RefOrValue<FlexDirection>
26
+ directionMd?: RefOrValue<FlexDirection>
27
+ directionLg?: RefOrValue<FlexDirection>
28
+ directionXl?: RefOrValue<FlexDirection>
29
+ align?: RefOrValue<FlexAlign>
30
+ alignSm?: RefOrValue<FlexAlign>
31
+ alignMd?: RefOrValue<FlexAlign>
32
+ alignLg?: RefOrValue<FlexAlign>
33
+ alignXl?: RefOrValue<FlexAlign>
34
+ justify?: RefOrValue<FlexJustify>
35
+ justifySm?: RefOrValue<FlexJustify>
36
+ justifyMd?: RefOrValue<FlexJustify>
37
+ justifyLg?: RefOrValue<FlexJustify>
38
+ justifyXl?: RefOrValue<FlexJustify>
39
+ wrap?: RefOrValue<FlexWrap>
40
+ wrapSm?: RefOrValue<FlexWrap>
41
+ wrapMd?: RefOrValue<FlexWrap>
42
+ wrapLg?: RefOrValue<FlexWrap>
43
+ wrapXl?: RefOrValue<FlexWrap>
44
+ inline?: RefOrValue<boolean | string>
45
+ classes?: ComputedRef<string>
46
+ }
47
+
48
+ const flexTemplate = html`<div :is="container ?? 'div'" class="flex" :class="classes">
49
+ <slot></slot>
50
+ </div>`
51
+
52
+ function defineFlexComponent() {
53
+ return defineComponent<Flex>(flexTemplate, {
54
+ props: [
55
+ 'container',
56
+ 'direction',
57
+ 'directionSm',
58
+ 'directionMd',
59
+ 'directionLg',
60
+ 'directionXl',
61
+ 'align',
62
+ 'alignSm',
63
+ 'alignMd',
64
+ 'alignLg',
65
+ 'alignXl',
66
+ 'justify',
67
+ 'justifySm',
68
+ 'justifyMd',
69
+ 'justifyLg',
70
+ 'justifyXl',
71
+ 'wrap',
72
+ 'wrapSm',
73
+ 'wrapMd',
74
+ 'wrapLg',
75
+ 'wrapXl',
76
+ 'inline',
77
+ ],
78
+ context: (head) => resolveFlex(head.props),
79
+ })
80
+ }
81
+
82
+ export function defineFlexComponents() {
83
+ return {
84
+ flex: defineFlexComponent(),
85
+ }
86
+ }
87
+
88
+ function resolveFlex(props: Flex): Flex {
89
+ const classes = computed(() => {
90
+ return [
91
+ resolveDirectionClass(props.direction),
92
+ resolveResponsiveDirectionClass('sm', props.directionSm),
93
+ resolveResponsiveDirectionClass('md', props.directionMd),
94
+ resolveResponsiveDirectionClass('lg', props.directionLg),
95
+ resolveResponsiveDirectionClass('xl', props.directionXl),
96
+ resolveAlignClass(props.align),
97
+ resolveResponsiveAlignClass('sm', props.alignSm),
98
+ resolveResponsiveAlignClass('md', props.alignMd),
99
+ resolveResponsiveAlignClass('lg', props.alignLg),
100
+ resolveResponsiveAlignClass('xl', props.alignXl),
101
+ resolveJustifyClass(props.justify),
102
+ resolveResponsiveJustifyClass('sm', props.justifySm),
103
+ resolveResponsiveJustifyClass('md', props.justifyMd),
104
+ resolveResponsiveJustifyClass('lg', props.justifyLg),
105
+ resolveResponsiveJustifyClass('xl', props.justifyXl),
106
+ resolveWrapClass(props.wrap),
107
+ resolveResponsiveWrapClass('sm', props.wrapSm),
108
+ resolveResponsiveWrapClass('md', props.wrapMd),
109
+ resolveResponsiveWrapClass('lg', props.wrapLg),
110
+ resolveResponsiveWrapClass('xl', props.wrapXl),
111
+ resolveInlineClass(props.inline),
112
+ ]
113
+ .filter(Boolean)
114
+ .join(' ')
115
+ })
116
+
117
+ return {
118
+ ...props,
119
+ classes,
120
+ }
121
+ }
122
+
123
+ function resolveDirectionClass(value?: RefOrValue<FlexDirection>) {
124
+ if (!value) return ''
125
+
126
+ const normalized = unref(value)
127
+ if (normalized === 'column') return 'flex-column'
128
+ if (normalized === 'column-reverse') return 'flex-column-reverse'
129
+ if (normalized === 'row-reverse') return 'flex-row-reverse'
130
+ if (normalized === 'row') return ''
131
+
132
+ return ''
133
+ }
134
+
135
+ function resolveResponsiveDirectionClass(
136
+ breakpoint: 'sm' | 'md' | 'lg' | 'xl',
137
+ value?: RefOrValue<FlexDirection>,
138
+ ) {
139
+ if (!value) return ''
140
+
141
+ const normalized = unref(value)
142
+ if (normalized === 'column') return `flex-direction-${breakpoint}-column`
143
+ if (normalized === 'column-reverse') {
144
+ return `flex-direction-${breakpoint}-column-reverse`
145
+ }
146
+ if (normalized === 'row') return `flex-direction-${breakpoint}-row`
147
+ if (normalized === 'row-reverse') {
148
+ return `flex-direction-${breakpoint}-row-reverse`
149
+ }
150
+
151
+ return ''
152
+ }
153
+
154
+ function resolveAlignClass(value?: RefOrValue<FlexAlign>) {
155
+ if (!value) return ''
156
+
157
+ const normalized = unref(value)
158
+ if (normalized === 'start') return 'align-flex-start'
159
+ if (normalized === 'end') return 'align-flex-end'
160
+
161
+ if (
162
+ normalized === 'stretch' ||
163
+ normalized === 'center' ||
164
+ normalized === 'baseline'
165
+ ) {
166
+ return `align-${normalized}`
167
+ }
168
+
169
+ return ''
170
+ }
171
+
172
+ function resolveResponsiveAlignClass(
173
+ breakpoint: 'sm' | 'md' | 'lg' | 'xl',
174
+ value?: RefOrValue<FlexAlign>,
175
+ ) {
176
+ if (!value) return ''
177
+
178
+ const normalized = unref(value)
179
+ if (normalized === 'start') return `align-${breakpoint}-flex-start`
180
+ if (normalized === 'end') return `align-${breakpoint}-flex-end`
181
+
182
+ if (
183
+ normalized === 'stretch' ||
184
+ normalized === 'center' ||
185
+ normalized === 'baseline'
186
+ ) {
187
+ return `align-${breakpoint}-${normalized}`
188
+ }
189
+
190
+ return ''
191
+ }
192
+
193
+ function resolveJustifyClass(value?: RefOrValue<FlexJustify>) {
194
+ if (!value) return ''
195
+
196
+ const normalized = unref(value)
197
+ if (
198
+ normalized === 'start' ||
199
+ normalized === 'center' ||
200
+ normalized === 'end' ||
201
+ normalized === 'stretch' ||
202
+ normalized === 'between' ||
203
+ normalized === 'around' ||
204
+ normalized === 'evenly'
205
+ ) {
206
+ return `justify-${normalized}`
207
+ }
208
+
209
+ return ''
210
+ }
211
+
212
+ function resolveResponsiveJustifyClass(
213
+ breakpoint: 'sm' | 'md' | 'lg' | 'xl',
214
+ value?: RefOrValue<FlexJustify>,
215
+ ) {
216
+ if (!value) return ''
217
+
218
+ const normalized = unref(value)
219
+ if (
220
+ normalized === 'start' ||
221
+ normalized === 'center' ||
222
+ normalized === 'end' ||
223
+ normalized === 'stretch' ||
224
+ normalized === 'between' ||
225
+ normalized === 'around' ||
226
+ normalized === 'evenly'
227
+ ) {
228
+ return `justify-${breakpoint}-${normalized}`
229
+ }
230
+
231
+ return ''
232
+ }
233
+
234
+ function resolveWrapClass(value?: RefOrValue<FlexWrap>) {
235
+ if (!value) return ''
236
+
237
+ const normalized = unref(value)
238
+ if (normalized === true || normalized === 'true' || normalized === 'wrap') {
239
+ return 'flex-wrap'
240
+ }
241
+ if (normalized === 'reverse') return 'flex-wrap-reverse'
242
+
243
+ return ''
244
+ }
245
+
246
+ function resolveResponsiveWrapClass(
247
+ breakpoint: 'sm' | 'md' | 'lg' | 'xl',
248
+ value?: RefOrValue<FlexWrap>,
249
+ ) {
250
+ if (!value) return ''
251
+
252
+ const normalized = unref(value)
253
+ if (normalized === true || normalized === 'true' || normalized === 'wrap') {
254
+ return `flex-wrap-${breakpoint}`
255
+ }
256
+ if (normalized === 'nowrap') return `flex-nowrap-${breakpoint}`
257
+ if (normalized === 'reverse') return `flex-wrap-${breakpoint}-reverse`
258
+
259
+ return ''
260
+ }
261
+
262
+ function resolveInlineClass(value?: RefOrValue<boolean | string>) {
263
+ if (!value) return ''
264
+
265
+ const normalized = unref(value)
266
+ if (normalized === true || normalized === 'true') return 'flex-inline'
267
+
268
+ return ''
269
+ }