@astryxdesign/core 0.1.0 → 0.1.1-canary.129bf0e

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 (155) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/README.md +68 -0
  3. package/dist/AvatarGroup/AvatarGroupOverflow.d.ts +1 -1
  4. package/dist/AvatarGroup/AvatarGroupOverflow.d.ts.map +1 -1
  5. package/dist/AvatarGroup/AvatarGroupOverflow.js +4 -1
  6. package/dist/Banner/Banner.d.ts +7 -0
  7. package/dist/Banner/Banner.d.ts.map +1 -1
  8. package/dist/Banner/Banner.js +9 -2
  9. package/dist/Button/Button.d.ts.map +1 -1
  10. package/dist/Button/Button.js +2 -0
  11. package/dist/Chat/ChatLayoutScrollButton.d.ts.map +1 -1
  12. package/dist/Chat/ChatLayoutScrollButton.js +5 -1
  13. package/dist/ContextMenu/ContextMenu.js +2 -2
  14. package/dist/DropdownMenu/DropdownMenu.js +2 -2
  15. package/dist/DropdownMenu/{renderXDSDropdownItems.d.ts → renderDropdownItems.d.ts} +3 -3
  16. package/dist/DropdownMenu/renderDropdownItems.d.ts.map +1 -0
  17. package/dist/DropdownMenu/{renderXDSDropdownItems.js → renderDropdownItems.js} +2 -2
  18. package/dist/EmptyState/EmptyState.d.ts.map +1 -1
  19. package/dist/EmptyState/EmptyState.js +7 -1
  20. package/dist/HoverCard/HoverCard.d.ts +2 -2
  21. package/dist/HoverCard/HoverCard.d.ts.map +1 -1
  22. package/dist/HoverCard/HoverCard.js +18 -6
  23. package/dist/HoverCard/useHoverCard.d.ts.map +1 -1
  24. package/dist/HoverCard/useHoverCard.js +6 -3
  25. package/dist/Layer/useLayer.d.ts +13 -0
  26. package/dist/Layer/useLayer.d.ts.map +1 -1
  27. package/dist/Layer/useLayer.js +7 -2
  28. package/dist/Layout/Layout.d.ts +10 -1
  29. package/dist/Layout/Layout.d.ts.map +1 -1
  30. package/dist/Layout/Layout.js +5 -1
  31. package/dist/Markdown/Markdown.d.ts.map +1 -1
  32. package/dist/Markdown/Markdown.js +13 -3
  33. package/dist/MobileNav/MobileNav.d.ts.map +1 -1
  34. package/dist/MobileNav/MobileNav.js +13 -0
  35. package/dist/Outline/Outline.d.ts +3 -2
  36. package/dist/Outline/Outline.d.ts.map +1 -1
  37. package/dist/Outline/Outline.js +23 -4
  38. package/dist/Outline/useScrollSpy.d.ts +14 -1
  39. package/dist/Outline/useScrollSpy.d.ts.map +1 -1
  40. package/dist/Outline/useScrollSpy.js +161 -50
  41. package/dist/Pagination/Pagination.d.ts.map +1 -1
  42. package/dist/Pagination/Pagination.js +31 -27
  43. package/dist/Resizable/useResizable.d.ts.map +1 -1
  44. package/dist/Resizable/useResizable.js +1 -5
  45. package/dist/Selector/Selector.d.ts.map +1 -1
  46. package/dist/Selector/Selector.js +1 -1
  47. package/dist/Table/BaseTable.d.ts.map +1 -1
  48. package/dist/Table/BaseTable.js +26 -8
  49. package/dist/Table/Table.d.ts.map +1 -1
  50. package/dist/Table/Table.js +30 -7
  51. package/dist/Table/index.d.ts +3 -1
  52. package/dist/Table/index.d.ts.map +1 -1
  53. package/dist/Table/index.js +1 -0
  54. package/dist/Table/plugins/stickyColumns/index.d.ts +3 -0
  55. package/dist/Table/plugins/stickyColumns/index.d.ts.map +1 -0
  56. package/dist/Table/plugins/stickyColumns/index.js +3 -0
  57. package/dist/Table/plugins/stickyColumns/useTableStickyColumns.d.ts +25 -0
  58. package/dist/Table/plugins/stickyColumns/useTableStickyColumns.d.ts.map +1 -0
  59. package/dist/Table/plugins/stickyColumns/useTableStickyColumns.js +376 -0
  60. package/dist/Table/types.d.ts +90 -5
  61. package/dist/Table/types.d.ts.map +1 -1
  62. package/dist/Table/useBaseTablePlugins.d.ts.map +1 -1
  63. package/dist/Table/useBaseTablePlugins.js +1 -1
  64. package/dist/ToggleButton/ToggleButton.d.ts +10 -3
  65. package/dist/ToggleButton/ToggleButton.d.ts.map +1 -1
  66. package/dist/ToggleButton/ToggleButton.js +64 -18
  67. package/dist/astryx.css +11 -0
  68. package/dist/astryx.umd.js +147 -0
  69. package/dist/astryx.umd.js.map +7 -0
  70. package/dist/theme/Theme.js +1 -1
  71. package/dist/theme/defineTheme.d.ts +1 -1
  72. package/dist/theme/defineTheme.d.ts.map +1 -1
  73. package/dist/theme/defineTheme.js +1 -1
  74. package/dist/theme/index.d.ts +1 -1
  75. package/dist/theme/index.d.ts.map +1 -1
  76. package/dist/theme/index.js +1 -1
  77. package/dist/theme/syntax/defineSyntaxTheme.js +1 -1
  78. package/dist/theme/tokens.d.ts +1 -1
  79. package/dist/theme/tokens.js +4 -4
  80. package/dist/theme/useTheme.d.ts +2 -2
  81. package/dist/utils/dateParser.d.ts.map +1 -1
  82. package/dist/utils/dateParser.js +15 -2
  83. package/package.json +7 -3
  84. package/src/AvatarGroup/AvatarGroupOverflow.tsx +3 -0
  85. package/src/Banner/Banner.test.tsx +16 -7
  86. package/src/Banner/Banner.tsx +9 -2
  87. package/src/Button/Button.test.tsx +26 -11
  88. package/src/Button/Button.tsx +2 -0
  89. package/src/Chat/ChatLayoutScrollButton.tsx +7 -1
  90. package/src/Collapsible/useCollapsible.doc.mjs +2 -2
  91. package/src/ContextMenu/ContextMenu.tsx +2 -2
  92. package/src/DateInput/DateInput.test.tsx +68 -20
  93. package/src/Divider/Divider.doc.mjs +1 -1
  94. package/src/DropdownMenu/DropdownMenu.tsx +2 -2
  95. package/src/DropdownMenu/{renderXDSDropdownItems.tsx → renderDropdownItems.tsx} +2 -2
  96. package/src/EmptyState/EmptyState.test.tsx +4 -2
  97. package/src/EmptyState/EmptyState.tsx +6 -2
  98. package/src/FormLayout/FormLayout.doc.mjs +3 -3
  99. package/src/HoverCard/HoverCard.doc.mjs +3 -0
  100. package/src/HoverCard/HoverCard.test.tsx +178 -2
  101. package/src/HoverCard/HoverCard.tsx +20 -16
  102. package/src/HoverCard/useHoverCard.tsx +12 -10
  103. package/src/Icon/Icon.doc.mjs +4 -4
  104. package/src/Item/Item.doc.mjs +2 -2
  105. package/src/Layer/useLayer.doc.mjs +7 -2
  106. package/src/Layer/useLayer.tsx +19 -2
  107. package/src/Layout/Layout.doc.mjs +2 -1
  108. package/src/Layout/Layout.tsx +15 -1
  109. package/src/Layout/__tests__/childrenAsContent.test.tsx +59 -0
  110. package/src/Lightbox/Lightbox.doc.mjs +0 -2
  111. package/src/Link/Link.doc.mjs +3 -3
  112. package/src/Link/LinkProvider.doc.mjs +3 -3
  113. package/src/Markdown/Markdown.doc.mjs +6 -4
  114. package/src/Markdown/Markdown.test.tsx +17 -26
  115. package/src/Markdown/Markdown.tsx +16 -6
  116. package/src/MobileNav/MobileNav.doc.mjs +8 -8
  117. package/src/MobileNav/MobileNav.tsx +13 -0
  118. package/src/MobileNav/MobileNavReopen.test.tsx +118 -0
  119. package/src/Outline/Outline.doc.mjs +1 -1
  120. package/src/Outline/Outline.test.tsx +76 -38
  121. package/src/Outline/Outline.tsx +23 -4
  122. package/src/Outline/useScrollSpy.ts +196 -63
  123. package/src/Pagination/Pagination.test.tsx +137 -13
  124. package/src/Pagination/Pagination.tsx +33 -28
  125. package/src/Resizable/Resizable.doc.mjs +3 -3
  126. package/src/Resizable/useResizable.ts +1 -7
  127. package/src/Selector/Selector.doc.mjs +4 -0
  128. package/src/Selector/Selector.tsx +5 -6
  129. package/src/Skeleton/Skeleton.doc.mjs +11 -1
  130. package/src/Table/BaseTable.tsx +50 -24
  131. package/src/Table/Table.doc.mjs +3 -3
  132. package/src/Table/Table.tsx +22 -1
  133. package/src/Table/index.ts +3 -0
  134. package/src/Table/plugins/stickyColumns/index.ts +4 -0
  135. package/src/Table/plugins/stickyColumns/useTableStickyColumns.test.tsx +163 -0
  136. package/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx +414 -0
  137. package/src/Table/types.ts +96 -4
  138. package/src/Table/useBaseTablePlugins.ts +1 -0
  139. package/src/ToggleButton/ToggleButton.doc.mjs +2 -2
  140. package/src/ToggleButton/ToggleButton.test.tsx +148 -6
  141. package/src/ToggleButton/ToggleButton.tsx +83 -20
  142. package/src/Toolbar/Toolbar.doc.mjs +1 -1
  143. package/src/hooks/useEntryAnimation.doc.mjs +3 -3
  144. package/src/hooks/useMediaQuery.doc.mjs +2 -2
  145. package/src/hooks/useStreamingText.doc.mjs +3 -3
  146. package/src/theme/Theme.doc.mjs +2 -2
  147. package/src/theme/Theme.tsx +1 -1
  148. package/src/theme/defineTheme.ts +1 -1
  149. package/src/theme/index.ts +1 -1
  150. package/src/theme/syntax/defineSyntaxTheme.ts +1 -1
  151. package/src/theme/tokens.ts +4 -4
  152. package/src/theme/useTheme.ts +2 -2
  153. package/src/utils/dateParser.test.ts +26 -0
  154. package/src/utils/dateParser.ts +16 -2
  155. package/dist/DropdownMenu/renderXDSDropdownItems.d.ts.map +0 -1
@@ -16,7 +16,7 @@
16
16
  */
17
17
 
18
18
  import {
19
- xdsTokenDefaults,
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(xdsTokenDefaults).map(name => [name, tokenVar(name)]),
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 `xdsTokenDefaults`, applies `theme.tokens`, then
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(xdsTokenDefaults)) {
165
+ for (const [key, value] of Object.entries(tokenDefaults)) {
166
166
  resolved[key] = resolveXDSTokenValue(value, mode);
167
167
  }
168
168
 
@@ -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 xdsTokenDefaults if the token isn't overridden by the theme.
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 xdsTokenDefaults with the theme's overrides, resolving
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
  });
@@ -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
- return plainDateFromDate(parsed);
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"}