@astryxdesign/core 0.1.0 → 0.1.1-canary.080d887
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/CHANGELOG.md +66 -0
- package/README.md +119 -1
- package/dist/AvatarGroup/AvatarGroupOverflow.d.ts +1 -1
- package/dist/AvatarGroup/AvatarGroupOverflow.d.ts.map +1 -1
- package/dist/AvatarGroup/AvatarGroupOverflow.js +4 -1
- package/dist/Banner/Banner.d.ts +7 -0
- package/dist/Banner/Banner.d.ts.map +1 -1
- package/dist/Banner/Banner.js +9 -2
- package/dist/Button/Button.d.ts +12 -2
- package/dist/Button/Button.d.ts.map +1 -1
- package/dist/Button/Button.js +51 -13
- package/dist/Chat/ChatLayoutScrollButton.d.ts.map +1 -1
- package/dist/Chat/ChatLayoutScrollButton.js +5 -1
- package/dist/ContextMenu/ContextMenu.js +2 -2
- package/dist/DropdownMenu/DropdownMenu.js +2 -2
- package/dist/DropdownMenu/{renderXDSDropdownItems.d.ts → renderDropdownItems.d.ts} +3 -3
- package/dist/DropdownMenu/renderDropdownItems.d.ts.map +1 -0
- package/dist/DropdownMenu/{renderXDSDropdownItems.js → renderDropdownItems.js} +2 -2
- package/dist/EmptyState/EmptyState.d.ts.map +1 -1
- package/dist/EmptyState/EmptyState.js +7 -1
- package/dist/HoverCard/HoverCard.d.ts +2 -2
- package/dist/HoverCard/HoverCard.d.ts.map +1 -1
- package/dist/HoverCard/HoverCard.js +18 -6
- package/dist/HoverCard/useHoverCard.d.ts.map +1 -1
- package/dist/HoverCard/useHoverCard.js +6 -3
- package/dist/Kbd/Kbd.d.ts.map +1 -1
- package/dist/Kbd/Kbd.js +1 -1
- package/dist/Layer/useLayer.d.ts +13 -0
- package/dist/Layer/useLayer.d.ts.map +1 -1
- package/dist/Layer/useLayer.js +7 -2
- package/dist/Layout/Layout.d.ts +10 -1
- package/dist/Layout/Layout.d.ts.map +1 -1
- package/dist/Layout/Layout.js +5 -1
- package/dist/Markdown/Markdown.d.ts.map +1 -1
- package/dist/Markdown/Markdown.js +13 -3
- package/dist/MobileNav/MobileNav.d.ts.map +1 -1
- package/dist/MobileNav/MobileNav.js +13 -0
- package/dist/Outline/Outline.d.ts +3 -2
- package/dist/Outline/Outline.d.ts.map +1 -1
- package/dist/Outline/Outline.js +23 -4
- package/dist/Outline/useScrollSpy.d.ts +14 -1
- package/dist/Outline/useScrollSpy.d.ts.map +1 -1
- package/dist/Outline/useScrollSpy.js +161 -50
- package/dist/Pagination/Pagination.d.ts.map +1 -1
- package/dist/Pagination/Pagination.js +31 -27
- package/dist/Resizable/useResizable.d.ts.map +1 -1
- package/dist/Resizable/useResizable.js +1 -5
- package/dist/Selector/Selector.d.ts.map +1 -1
- package/dist/Selector/Selector.js +1 -1
- package/dist/Slider/Slider.js +2 -2
- package/dist/Table/BaseTable.d.ts.map +1 -1
- package/dist/Table/BaseTable.js +26 -8
- package/dist/Table/Table.d.ts.map +1 -1
- package/dist/Table/Table.js +30 -7
- package/dist/Table/index.d.ts +3 -1
- package/dist/Table/index.d.ts.map +1 -1
- package/dist/Table/index.js +1 -0
- package/dist/Table/plugins/stickyColumns/index.d.ts +3 -0
- package/dist/Table/plugins/stickyColumns/index.d.ts.map +1 -0
- package/dist/Table/plugins/stickyColumns/index.js +3 -0
- package/dist/Table/plugins/stickyColumns/useTableStickyColumns.d.ts +25 -0
- package/dist/Table/plugins/stickyColumns/useTableStickyColumns.d.ts.map +1 -0
- package/dist/Table/plugins/stickyColumns/useTableStickyColumns.js +376 -0
- package/dist/Table/types.d.ts +90 -5
- package/dist/Table/types.d.ts.map +1 -1
- package/dist/Table/useBaseTablePlugins.d.ts.map +1 -1
- package/dist/Table/useBaseTablePlugins.js +1 -1
- package/dist/Timestamp/Timestamp.d.ts +1 -1
- package/dist/Timestamp/Timestamp.d.ts.map +1 -1
- package/dist/Timestamp/Timestamp.js +28 -3
- package/dist/ToggleButton/ToggleButton.d.ts +10 -5
- package/dist/ToggleButton/ToggleButton.d.ts.map +1 -1
- package/dist/ToggleButton/ToggleButton.js +40 -17
- package/dist/astryx.css +20 -0
- package/dist/astryx.umd.js +147 -0
- package/dist/astryx.umd.js.map +7 -0
- package/dist/theme/Theme.js +1 -1
- package/dist/theme/defineTheme.d.ts +1 -1
- package/dist/theme/defineTheme.d.ts.map +1 -1
- package/dist/theme/defineTheme.js +1 -1
- package/dist/theme/index.d.ts +1 -1
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +1 -1
- package/dist/theme/syntax/defineSyntaxTheme.js +1 -1
- package/dist/theme/tokens.d.ts +1 -1
- package/dist/theme/tokens.js +4 -4
- package/dist/theme/useTheme.d.ts +2 -2
- package/dist/utils/dateParser.d.ts.map +1 -1
- package/dist/utils/dateParser.js +15 -2
- package/package.json +7 -3
- package/src/AvatarGroup/AvatarGroupOverflow.tsx +3 -0
- package/src/Banner/Banner.test.tsx +16 -7
- package/src/Banner/Banner.tsx +9 -2
- package/src/Button/Button.doc.mjs +6 -0
- package/src/Button/Button.test.tsx +105 -11
- package/src/Button/Button.tsx +73 -5
- package/src/Chat/ChatLayoutScrollButton.tsx +7 -1
- package/src/Collapsible/useCollapsible.doc.mjs +2 -2
- package/src/ContextMenu/ContextMenu.tsx +2 -2
- package/src/DateInput/DateInput.test.tsx +68 -20
- package/src/Divider/Divider.doc.mjs +1 -1
- package/src/DropdownMenu/DropdownMenu.tsx +2 -2
- package/src/DropdownMenu/{renderXDSDropdownItems.tsx → renderDropdownItems.tsx} +2 -2
- package/src/EmptyState/EmptyState.test.tsx +4 -2
- package/src/EmptyState/EmptyState.tsx +6 -2
- package/src/FormLayout/FormLayout.doc.mjs +3 -3
- package/src/HoverCard/HoverCard.doc.mjs +3 -0
- package/src/HoverCard/HoverCard.test.tsx +178 -2
- package/src/HoverCard/HoverCard.tsx +20 -16
- package/src/HoverCard/useHoverCard.tsx +12 -10
- package/src/Icon/Icon.doc.mjs +12 -4
- package/src/Item/Item.doc.mjs +2 -2
- package/src/Kbd/Kbd.tsx +2 -9
- package/src/Layer/useLayer.doc.mjs +7 -2
- package/src/Layer/useLayer.tsx +19 -2
- package/src/Layout/Layout.doc.mjs +2 -1
- package/src/Layout/Layout.tsx +15 -1
- package/src/Layout/__tests__/childrenAsContent.test.tsx +59 -0
- package/src/Lightbox/Lightbox.doc.mjs +0 -2
- package/src/Link/Link.doc.mjs +3 -3
- package/src/Link/LinkProvider.doc.mjs +3 -3
- package/src/Markdown/Markdown.doc.mjs +6 -4
- package/src/Markdown/Markdown.test.tsx +17 -26
- package/src/Markdown/Markdown.tsx +16 -6
- package/src/MobileNav/MobileNav.doc.mjs +8 -8
- package/src/MobileNav/MobileNav.tsx +13 -0
- package/src/MobileNav/MobileNavReopen.test.tsx +118 -0
- package/src/Outline/Outline.doc.mjs +1 -1
- package/src/Outline/Outline.test.tsx +76 -38
- package/src/Outline/Outline.tsx +23 -4
- package/src/Outline/useScrollSpy.ts +196 -63
- package/src/Pagination/Pagination.test.tsx +137 -13
- package/src/Pagination/Pagination.tsx +33 -28
- package/src/Resizable/Resizable.doc.mjs +3 -3
- package/src/Resizable/useResizable.ts +1 -7
- package/src/Selector/Selector.doc.mjs +4 -0
- package/src/Selector/Selector.tsx +5 -6
- package/src/Skeleton/Skeleton.doc.mjs +11 -1
- package/src/Slider/Slider.doc.mjs +4 -0
- package/src/Slider/Slider.test.tsx +3 -16
- package/src/Slider/Slider.tsx +1 -1
- package/src/Table/BaseTable.tsx +50 -24
- package/src/Table/Table.doc.mjs +15 -3
- package/src/Table/Table.tsx +22 -1
- package/src/Table/index.ts +3 -0
- package/src/Table/plugins/stickyColumns/index.ts +4 -0
- package/src/Table/plugins/stickyColumns/useTableStickyColumns.test.tsx +163 -0
- package/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx +414 -0
- package/src/Table/types.ts +96 -4
- package/src/Table/useBaseTablePlugins.ts +1 -0
- package/src/Text/Heading.doc.mjs +13 -0
- package/src/Timestamp/Timestamp.test.tsx +44 -18
- package/src/Timestamp/Timestamp.tsx +30 -10
- package/src/ToggleButton/ToggleButton.doc.mjs +4 -4
- package/src/ToggleButton/ToggleButton.test.tsx +172 -9
- package/src/ToggleButton/ToggleButton.tsx +57 -31
- package/src/Toolbar/Toolbar.doc.mjs +1 -1
- package/src/hooks/useEntryAnimation.doc.mjs +3 -3
- package/src/hooks/useMediaQuery.doc.mjs +2 -2
- package/src/hooks/useStreamingText.doc.mjs +3 -3
- package/src/theme/Theme.doc.mjs +2 -2
- package/src/theme/Theme.tsx +1 -1
- package/src/theme/defineTheme.ts +1 -1
- package/src/theme/index.ts +1 -1
- package/src/theme/syntax/defineSyntaxTheme.ts +1 -1
- package/src/theme/tokens.ts +4 -4
- package/src/theme/useTheme.ts +2 -2
- package/src/utils/dateParser.test.ts +26 -0
- package/src/utils/dateParser.ts +16 -2
- package/dist/DropdownMenu/renderXDSDropdownItems.d.ts.map +0 -1
package/src/theme/Theme.doc.mjs
CHANGED
|
@@ -39,7 +39,7 @@ export const docs = {
|
|
|
39
39
|
},
|
|
40
40
|
usage: {
|
|
41
41
|
description:
|
|
42
|
-
'Wraps a subtree with a specific
|
|
42
|
+
'Wraps a subtree with a specific Astryx theme. For static production themes, use `npx astryx theme build` and import the generated CSS plus built theme object for first-paint and SSR performance. Use runtime `defineTheme()` when themes are dynamic or for prototyping.\n\n`defineTheme` accepts a `tokens` object whose keys are CSS custom property names (always prefixed with `--`). Common token names include `--color-accent`, `--color-background-surface`, `--color-background-body`, `--color-text-primary`, `--color-text-secondary`, `--radius-container`, `--spacing-1` through `--spacing-6`. Values can be a string (same for light/dark) or a `[light, dark]` tuple.\n\nExample:\n```ts\nimport {defineTheme} from \'@astryxdesign/core/theme\';\nconst myTheme = defineTheme({\n name: \'ocean\',\n tokens: {\n \'--color-accent\': [\'#0077B6\', \'#48CAE4\'],\n \'--color-background-surface\': [\'#F0F8FF\', \'#0A1628\'],\n \'--color-text-primary\': [\'#0A1317\', \'#FFFFFF\'],\n \'--radius-container\': \'16px\',\n },\n});\n```',
|
|
43
43
|
bestPractices: [
|
|
44
44
|
{
|
|
45
45
|
guidance: true,
|
|
@@ -90,7 +90,7 @@ export const docs = {
|
|
|
90
90
|
export const docsDense = {
|
|
91
91
|
usage: {
|
|
92
92
|
description:
|
|
93
|
-
'Wraps subtree w/ specific
|
|
93
|
+
'Wraps subtree w/ specific Astryx theme. For static production themes, use `npx astryx theme build` + generated CSS + built theme object for first-paint/SSR performance. Use runtime `defineTheme()` for dynamic themes or prototyping. Token names always start with `--` (e.g. `--color-accent`, `--color-background-surface`).',
|
|
94
94
|
bestPractices: [
|
|
95
95
|
{
|
|
96
96
|
guidance: true,
|
package/src/theme/Theme.tsx
CHANGED
|
@@ -123,7 +123,7 @@ function useThemeStyleInjection(theme: DefinedTheme): void {
|
|
|
123
123
|
if (!warnedThemes.has(theme.name)) {
|
|
124
124
|
warnedThemes.add(theme.name);
|
|
125
125
|
console.warn(
|
|
126
|
-
`[
|
|
126
|
+
`[Astryx] Theme "${theme.name}" is using runtime style injection. ` +
|
|
127
127
|
`For better performance, use the pre-built theme:\n\n` +
|
|
128
128
|
` import {${theme.name}Theme} from '@astryxdesign/theme-${theme.name}/built';\n` +
|
|
129
129
|
` import '@astryxdesign/theme-${theme.name}/theme.css';\n\n` +
|
package/src/theme/defineTheme.ts
CHANGED
|
@@ -361,7 +361,7 @@ export interface DefinedTheme {
|
|
|
361
361
|
// =============================================================================
|
|
362
362
|
|
|
363
363
|
/** All Astryx token defaults as a flat map. Useful for resolving full token sets. */
|
|
364
|
-
export const
|
|
364
|
+
export const tokenDefaults: Record<string, string> = {
|
|
365
365
|
...colorDefaults,
|
|
366
366
|
...spacingDefaults,
|
|
367
367
|
...sizeDefaults,
|
package/src/theme/index.ts
CHANGED
|
@@ -134,7 +134,7 @@ export function defineSyntaxTheme(input: SyntaxThemeInput): SyntaxThemeDefinitio
|
|
|
134
134
|
const missing = ALL_SYNTAX_KEYS.filter(key => !(key in input.tokens));
|
|
135
135
|
if (missing.length > 0) {
|
|
136
136
|
console.warn(
|
|
137
|
-
'[
|
|
137
|
+
'[Astryx] defineSyntaxTheme("' + input.name + '"): missing tokens: ' +
|
|
138
138
|
missing.join(', ') + '. All 14 syntax tokens are required.',
|
|
139
139
|
);
|
|
140
140
|
}
|
package/src/theme/tokens.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import {
|
|
19
|
-
|
|
19
|
+
tokenDefaults,
|
|
20
20
|
type DefinedTheme,
|
|
21
21
|
type TokenName,
|
|
22
22
|
type TokenValue,
|
|
@@ -60,7 +60,7 @@ export function tokenVar(name: TokenName | (string & {})): string {
|
|
|
60
60
|
|
|
61
61
|
/** Flat map of every known Astryx token name to its `var(--token-name)` reference. */
|
|
62
62
|
export const tokenVars: Record<TokenName, string> = Object.fromEntries(
|
|
63
|
-
Object.keys(
|
|
63
|
+
Object.keys(tokenDefaults).map(name => [name, tokenVar(name)]),
|
|
64
64
|
) as Record<TokenName, string>;
|
|
65
65
|
|
|
66
66
|
/**
|
|
@@ -147,7 +147,7 @@ function resolveXDSTokenValue(
|
|
|
147
147
|
/**
|
|
148
148
|
* Resolve all Astryx token values for a theme and effective color mode.
|
|
149
149
|
*
|
|
150
|
-
* The result starts with `
|
|
150
|
+
* The result starts with `tokenDefaults`, applies `theme.tokens`, then
|
|
151
151
|
* reapplies `theme.__inputTokens` when available so explicit tuple overrides
|
|
152
152
|
* retain their original light/dark sides instead of relying on CSS parsing.
|
|
153
153
|
* This mirrors the token resolution used by `useTheme()` but does not need
|
|
@@ -162,7 +162,7 @@ export function resolveThemeTokens(
|
|
|
162
162
|
const {mode} = options;
|
|
163
163
|
const resolved: Record<string, string> = {};
|
|
164
164
|
|
|
165
|
-
for (const [key, value] of Object.entries(
|
|
165
|
+
for (const [key, value] of Object.entries(tokenDefaults)) {
|
|
166
166
|
resolved[key] = resolveXDSTokenValue(value, mode);
|
|
167
167
|
}
|
|
168
168
|
|
package/src/theme/useTheme.ts
CHANGED
|
@@ -63,7 +63,7 @@ export interface UseThemeReturn {
|
|
|
63
63
|
* For tokens with [light, dark] tuples, returns the value matching
|
|
64
64
|
* the current mode. For single-value tokens, returns the value as-is.
|
|
65
65
|
*
|
|
66
|
-
* Falls back to
|
|
66
|
+
* Falls back to tokenDefaults if the token isn't overridden by the theme.
|
|
67
67
|
*
|
|
68
68
|
* @example
|
|
69
69
|
* ```
|
|
@@ -75,7 +75,7 @@ export interface UseThemeReturn {
|
|
|
75
75
|
/**
|
|
76
76
|
* All tokens resolved for the current color mode.
|
|
77
77
|
*
|
|
78
|
-
* Merges
|
|
78
|
+
* Merges tokenDefaults with the theme's overrides, resolving
|
|
79
79
|
* light-dark() values based on the effective color mode.
|
|
80
80
|
*
|
|
81
81
|
* Memoized — stable reference unless theme or mode changes.
|
|
@@ -320,5 +320,31 @@ describe('parseDateInput', () => {
|
|
|
320
320
|
it('rejects mixed separators', () => {
|
|
321
321
|
expect(parseDateInput('1/25.2026')).toBeNull();
|
|
322
322
|
});
|
|
323
|
+
|
|
324
|
+
it('treats a single typed digit as incomplete, not a date', () => {
|
|
325
|
+
// A user starting to type a month (e.g. "0" or "1" for January) should
|
|
326
|
+
// not produce a date. Native Date parsing would otherwise coerce these
|
|
327
|
+
// into arbitrary dates (and a year of 0 in some engines).
|
|
328
|
+
expect(parseDateInput('0')).toBeNull();
|
|
329
|
+
expect(parseDateInput('1')).toBeNull();
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
it('treats bare numeric input as incomplete, not a date', () => {
|
|
333
|
+
expect(parseDateInput('00')).toBeNull();
|
|
334
|
+
expect(parseDateInput('01')).toBeNull();
|
|
335
|
+
expect(parseDateInput('12')).toBeNull();
|
|
336
|
+
expect(parseDateInput('2026')).toBeNull();
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
it('never returns an out-of-range date for partial input', () => {
|
|
340
|
+
// Regression: partial input must never yield a date with year < 1,
|
|
341
|
+
// which would throw when later re-parsed and crash the page.
|
|
342
|
+
for (const input of ['0', '1', '01', '00', '9', '99']) {
|
|
343
|
+
const result = parseDateInput(input);
|
|
344
|
+
if (result !== null) {
|
|
345
|
+
expect(result.year).toBeGreaterThanOrEqual(1);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
});
|
|
323
349
|
});
|
|
324
350
|
});
|
package/src/utils/dateParser.ts
CHANGED
|
@@ -124,10 +124,24 @@ export function parseDateInput(input: string): PlainDate | null {
|
|
|
124
124
|
return parseNumericDate(+first, +second, currentYear);
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
// 6. Fall back to native Date parsing for other formats
|
|
127
|
+
// 6. Fall back to native Date parsing for other formats.
|
|
128
|
+
//
|
|
129
|
+
// Skip bare numeric input (e.g. "0", "1", "01", "2026"). These are
|
|
130
|
+
// in-progress values a user is still typing, not complete dates. Native
|
|
131
|
+
// `Date` parsing coerces them into arbitrary dates ("0" -> year 2000 in V8,
|
|
132
|
+
// year 0 in some engines), which is both surprising and — when the year
|
|
133
|
+
// resolves to 0 — produces an out-of-range date that throws downstream.
|
|
134
|
+
// Treat them as not-yet-a-valid-date instead.
|
|
135
|
+
if (/^\d+$/.test(trimmed)) {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
|
|
128
139
|
const parsed = new Date(trimmed);
|
|
129
140
|
if (!isNaN(parsed.getTime())) {
|
|
130
|
-
|
|
141
|
+
const fromDate = plainDateFromDate(parsed);
|
|
142
|
+
// Validate the result so we never return an out-of-range date (e.g. a
|
|
143
|
+
// year of 0), which would throw when later re-parsed.
|
|
144
|
+
return tryCreatePlainDate(fromDate.year, fromDate.month, fromDate.day);
|
|
131
145
|
}
|
|
132
146
|
|
|
133
147
|
return null;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"renderXDSDropdownItems.d.ts","sourceRoot":"","sources":["../../src/DropdownMenu/renderXDSDropdownItems.tsx"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAUrC,OAAO,KAAK,EAEV,kBAAkB,EAEnB,MAAM,gBAAgB,CAAC;AAyBxB;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,kBAAkB,EAAE,GAC1B,SAAS,CA8CX"}
|