@datalayer/primer-addons 1.0.20 → 1.0.22

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 (85) hide show
  1. package/README.md +14 -0
  2. package/lib/components/appearance/AppearanceMenuWithStore.d.ts +26 -0
  3. package/lib/components/appearance/AppearanceMenuWithStore.js +21 -0
  4. package/lib/components/appearance/CollaboratorPalette.d.ts +65 -0
  5. package/lib/components/appearance/CollaboratorPalette.js +160 -0
  6. package/lib/components/appearance/index.d.ts +2 -0
  7. package/lib/components/appearance/index.js +2 -0
  8. package/lib/components/box/Box.d.ts +17 -5
  9. package/lib/components/box/Box.js +3 -5
  10. package/lib/components/calendar-picker/CalendarPicker.d.ts +35 -0
  11. package/lib/components/calendar-picker/CalendarPicker.js +146 -0
  12. package/lib/components/calendar-picker/index.d.ts +1 -0
  13. package/lib/components/calendar-picker/index.js +5 -0
  14. package/lib/components/card/Card.d.ts +6 -1
  15. package/lib/components/card/Card.js +1 -1
  16. package/lib/components/color/ColorSwatch.d.ts +1 -1
  17. package/lib/components/color-picker/ColorPicker.d.ts +97 -0
  18. package/lib/components/color-picker/ColorPicker.js +358 -0
  19. package/lib/components/color-picker/index.d.ts +1 -0
  20. package/lib/components/color-picker/index.js +5 -0
  21. package/lib/components/content-loader/ContentLoader.d.ts +1 -1
  22. package/lib/components/content-loader/ContentLoader.stories.d.ts +1 -1
  23. package/lib/components/date-picker/DatePicker.d.ts +46 -0
  24. package/lib/components/date-picker/DatePicker.js +98 -0
  25. package/lib/components/date-picker/index.d.ts +1 -0
  26. package/lib/components/date-picker/index.js +5 -0
  27. package/lib/components/icons/CircleIcon.d.ts +1 -1
  28. package/lib/components/icons/CircleIcon.stories.d.ts +1 -1
  29. package/lib/components/index.d.ts +5 -0
  30. package/lib/components/index.js +5 -0
  31. package/lib/components/logo/DatalayerText.d.ts +1 -1
  32. package/lib/components/logo/index.d.ts +0 -1
  33. package/lib/components/logo/index.js +0 -1
  34. package/lib/components/side-overlay/SideOverlay.d.ts +5 -5
  35. package/lib/components/side-overlay/SideOverlay.stories.d.ts +1 -1
  36. package/lib/components/slider/Slider.d.ts +1 -1
  37. package/lib/components/slider/Slider.stories.d.ts +1 -1
  38. package/lib/components/sliding-panel/SlidingPanel.d.ts +1 -1
  39. package/lib/components/sliding-panel/SlidingPanel.stories.d.ts +1 -1
  40. package/lib/components/toolbar/Toolbar.d.ts +2 -2
  41. package/lib/components/toolbar/Toolbar.js +0 -0
  42. package/lib/components/toolbar/ToolbarButton.d.ts +3 -1
  43. package/lib/components/toolbar/ToolbarButton.js +54 -22
  44. package/lib/components/toolbar/ToolbarDivider.d.ts +1 -1
  45. package/lib/components/toolbar/ToolbarDropdown.d.ts +3 -3
  46. package/lib/components/toolbar/ToolbarDropdown.js +66 -35
  47. package/lib/components/toolbar/ToolbarRenderer.d.ts +20 -3
  48. package/lib/components/toolbar/ToolbarRenderer.js +16 -16
  49. package/lib/components/toolbar/types.d.ts +15 -8
  50. package/lib/reactor/AppearancePlugin.d.ts +31 -0
  51. package/lib/reactor/AppearancePlugin.js +63 -0
  52. package/lib/reactor/ThemePlugin.d.ts +5 -0
  53. package/lib/reactor/ThemePlugin.js +98 -0
  54. package/lib/reactor/index.d.ts +30 -0
  55. package/lib/reactor/index.js +34 -0
  56. package/lib/reactor/page-layout/PageLayout.d.ts +148 -0
  57. package/lib/reactor/page-layout/PageLayout.js +310 -0
  58. package/lib/reactor/page-layout/PageLayoutPlugin.d.ts +59 -0
  59. package/lib/reactor/page-layout/PageLayoutPlugin.js +105 -0
  60. package/lib/reactor/page-layout/PagePanelToggle.d.ts +21 -0
  61. package/lib/reactor/page-layout/PagePanelToggle.js +29 -0
  62. package/lib/reactor/page-layout/SlotPageLayout.d.ts +36 -0
  63. package/lib/reactor/page-layout/SlotPageLayout.js +25 -0
  64. package/lib/reactor/page-layout/panelState.d.ts +28 -0
  65. package/lib/reactor/page-layout/panelState.js +49 -0
  66. package/lib/story-helpers.d.ts +2 -2
  67. package/lib/theme/DatalayerBrandThemeProvider.d.ts +1 -1
  68. package/lib/theme/DatalayerThemeProvider.d.ts +5 -5
  69. package/lib/theme/DatalayerThemeProvider.js +119 -58
  70. package/lib/theme/css/createThemeCSSVars.d.ts +1 -0
  71. package/lib/theme/css/createThemeCSSVars.js +9 -0
  72. package/lib/theme/fontStacks.d.ts +2 -0
  73. package/lib/theme/fontStacks.js +6 -0
  74. package/lib/theme/index.d.ts +2 -0
  75. package/lib/theme/index.js +2 -0
  76. package/lib/theme/palettes/ColorPalette.d.ts +3 -3
  77. package/lib/theme/portableTheme.d.ts +32 -0
  78. package/lib/theme/portableTheme.js +45 -0
  79. package/lib/utils/Helper.d.ts +2 -2
  80. package/lib/utils/Portals.d.ts +15 -0
  81. package/lib/utils/Portals.js +83 -28
  82. package/lib/utils/Styles.d.ts +1 -1
  83. package/package.json +15 -14
  84. package/lib/components/logo/DI.d.ts +0 -19
  85. package/lib/components/logo/DI.js +0 -20
@@ -3,7 +3,14 @@
3
3
  * Distributed under the terms of the Modified BSD License.
4
4
  */
5
5
  import { registerPortalRoot } from '@primer/react';
6
- const PRIMER_PORTAL_ROOT_ID = '__primerPortalRoot__';
6
+ /**
7
+ * Id of the element Primer portals render under.
8
+ *
9
+ * Exported because a host may need to mark that element as its own — the
10
+ * JupyterLab theming of jupyter-react adds `jp-ThemedContainer` to it, so
11
+ * the rules JupyterLab scopes to that class reach portaled content too.
12
+ */
13
+ export const PRIMER_PORTAL_ROOT_ID = '__primerPortalRoot__';
7
14
  /**
8
15
  * Key used on `document.body` to track the CSS-property names we
9
16
  * previously applied so we can remove stale entries on theme switch.
@@ -81,11 +88,38 @@ export const setupPrimerPortals = (colormode) => {
81
88
  portalRoot.dataset['colorMode'] = resolved;
82
89
  portalRoot.dataset['lightTheme'] = lightTheme;
83
90
  portalRoot.dataset['darkTheme'] = darkTheme;
84
- // High z-index so overlays render above positioned UI (e.g. chat z-index 1001).
85
- portalRoot.style.position = 'relative';
91
+ /*
92
+ * Pinned to the origin of the document, never left in the flow of the body.
93
+ *
94
+ * Primer positions an anchored overlay — a menu, a dropdown — with
95
+ * `position: absolute` and coordinates taken from the VIEWPORT rectangle
96
+ * of its anchor. Those coordinates are only right when the containing
97
+ * block of the overlay starts at the origin of the document, which is why
98
+ * Primer's own default portal root is `absolute` at `0, 0`.
99
+ *
100
+ * Left `relative`, this root instead sits wherever the flow of the body
101
+ * ends and becomes the containing block of everything portaled into it:
102
+ * in an application whose markup is a full-height element — a React page
103
+ * hosting JupyterLab — that is the bottom of the screen, and every menu
104
+ * opened at the top of the page was drawn a screen further down, off the
105
+ * bottom edge. Which reads, to whoever clicked, as a menu that refuses to
106
+ * open. The high z-index is kept: it needs a positioned element, and
107
+ * `absolute` is one.
108
+ */
109
+ portalRoot.style.position = 'absolute';
110
+ portalRoot.style.top = '0';
111
+ portalRoot.style.left = '0';
112
+ portalRoot.style.width = '100%';
86
113
  portalRoot.style.zIndex = '9999';
87
114
  registerPortalRoot(portalRoot);
88
115
  };
116
+ /**
117
+ * The element Primer portals render under, when it has been set up.
118
+ *
119
+ * `setupPrimerPortals` creates it; before that call there is none, and this
120
+ * answers `null` rather than inventing one.
121
+ */
122
+ export const getPrimerPortalRoot = () => document.getElementById(PRIMER_PORTAL_ROOT_ID);
89
123
  /* ─── camelCase → kebab-case ─────────────────────────────────────────── */
90
124
  const camelToKebab = (s) => s.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
91
125
  /**
@@ -102,33 +136,54 @@ const camelToKebab = (s) => s.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
102
136
  * portals stay in sync whenever theme or color-mode changes.
103
137
  */
104
138
  export function syncPortalThemeStyles(styles) {
105
- const body = document.body;
106
- // 1. Remove properties set by the previous invocation.
107
- const prev = body[PORTAL_THEME_KEYS];
108
- if (prev) {
109
- for (const key of prev) {
110
- body.style.removeProperty(key);
111
- }
112
- }
113
- // 2. Apply the new properties.
114
- const tracked = [];
115
- for (const [key, value] of Object.entries(styles)) {
116
- if (value == null)
117
- continue;
118
- const strVal = String(value);
119
- if (key.startsWith('--')) {
120
- // CSS custom property — must use setProperty
121
- body.style.setProperty(key, strVal);
122
- tracked.push(key);
139
+ /*
140
+ * On the portal root as well as on the body, and that is the point.
141
+ *
142
+ * The body was enough for what portals INHERIT — a font, a line height —
143
+ * and never enough for the colours. The portal root carries Primer's own
144
+ * theme markers (`data-color-mode`, `data-light-theme`), and Primer's
145
+ * stylesheet declares `--bgColor-*`, `--fgColor-*` and the rest ON any
146
+ * element carrying them. A declaration on the element always beats a value
147
+ * inherited from an ancestor, so Primer's default palette won on the portal
148
+ * root and everything drawn inside it — the buttons of a dialog, the
149
+ * background of a menu — came out in the default theme while the same
150
+ * components in the page wore the chosen one.
151
+ *
152
+ * Written inline on that element, the theme wins in turn: an inline style
153
+ * outranks any selector in a stylesheet.
154
+ */
155
+ const targets = [
156
+ document.body,
157
+ document.getElementById(PRIMER_PORTAL_ROOT_ID)
158
+ ].filter(Boolean);
159
+ for (const target of targets) {
160
+ // 1. Remove properties set by the previous invocation.
161
+ const prev = target[PORTAL_THEME_KEYS];
162
+ if (prev) {
163
+ for (const key of prev) {
164
+ target.style.removeProperty(key);
165
+ }
123
166
  }
124
- else {
125
- // Standard CSS property (camelCase → kebab-case)
126
- const kebab = camelToKebab(key);
127
- body.style.setProperty(kebab, strVal);
128
- tracked.push(kebab);
167
+ // 2. Apply the new properties.
168
+ const tracked = [];
169
+ for (const [key, value] of Object.entries(styles)) {
170
+ if (value == null)
171
+ continue;
172
+ const strVal = String(value);
173
+ if (key.startsWith('--')) {
174
+ // CSS custom property — must use setProperty
175
+ target.style.setProperty(key, strVal);
176
+ tracked.push(key);
177
+ }
178
+ else {
179
+ // Standard CSS property (camelCase → kebab-case)
180
+ const kebab = camelToKebab(key);
181
+ target.style.setProperty(kebab, strVal);
182
+ tracked.push(kebab);
183
+ }
129
184
  }
185
+ // 3. Stash the list for the next cleanup.
186
+ target[PORTAL_THEME_KEYS] = tracked;
130
187
  }
131
- // 3. Stash the list for the next cleanup.
132
- body[PORTAL_THEME_KEYS] = tracked;
133
188
  }
134
189
  export default setupPrimerPortals;
@@ -1,2 +1,2 @@
1
- export declare const Styles: () => import("react/jsx-runtime").JSX.Element;
1
+ export declare const Styles: () => import("react").JSX.Element;
2
2
  export default Styles;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datalayer/primer-addons",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
4
4
  "license": "BSD-3-Clause",
5
5
  "scripts": {
6
6
  "build": "npm run build:lib",
@@ -33,11 +33,12 @@
33
33
  "homepage": "https://primer-addons.datalayer.tech",
34
34
  "dependencies": {
35
35
  "@datalayer/icons-react": "^1.0.0",
36
- "@primer/octicons-react": "^19.29.1",
36
+ "@datalayer/reactor": "^1.0.0",
37
+ "@primer/octicons-react": "^19.35.0",
37
38
  "@primer/primitives": "^10.7.0",
38
39
  "@primer/react": "^37.31.0",
39
- "react": "^18.3.1 || ^19.0.0",
40
- "react-dom": "^18.3.1 || ^19.0.0",
40
+ "react": "19.2.8",
41
+ "react-dom": "19.2.8",
41
42
  "react-loading-skeleton": "^3.5.0",
42
43
  "styled-components": "^5.3.10",
43
44
  "zustand": "^5.0.0"
@@ -52,21 +53,21 @@
52
53
  "@storybook/react-vite": "^9.0.15",
53
54
  "@storybook/testing-library": "^0.2.2",
54
55
  "@types/prettier": "^3.0.0",
55
- "@types/react": "18.3.20",
56
- "@types/react-dom": "18.3.6",
56
+ "@types/react": "19.2.18",
57
+ "@types/react-dom": "19.2.5",
57
58
  "@types/styled-components": "^5.1.34",
58
- "@typescript-eslint/eslint-plugin": "^8.29.1",
59
- "@typescript-eslint/parser": "^8.29.1",
59
+ "@typescript-eslint/eslint-plugin": "^8.69.0",
60
+ "@typescript-eslint/parser": "^8.69.0",
60
61
  "@vitejs/plugin-react": "^4.5.2",
61
62
  "crypto-browserify": "^3.12.0",
62
- "eslint": "^9.0.0",
63
- "eslint-plugin-react-hooks": "^5.2.0",
64
- "eslint-plugin-react-refresh": "^0.3.4",
65
- "eslint-plugin-storybook": "^0.6.12",
63
+ "eslint": "^10.9.1",
64
+ "eslint-plugin-react-hooks": "^7.1.1",
65
+ "eslint-plugin-react-refresh": "^0.5.5",
66
+ "eslint-plugin-storybook": "^10.5.10",
66
67
  "prettier": "^3.3.2",
67
68
  "prop-types": "^15.8.1",
68
69
  "storybook": "^9.0.15",
69
- "typescript": "^5.8.3",
70
- "vite": "^7.0.0"
70
+ "typescript": "5.9.3",
71
+ "vite": "7.3.6"
71
72
  }
72
73
  }
@@ -1,19 +0,0 @@
1
- import { type SVGProps } from 'react';
2
- import { type ThemeVariant } from '../../theme';
3
- export interface DIProps extends Omit<SVGProps<SVGSVGElement>, 'ref'> {
4
- size?: number;
5
- variant?: ThemeVariant;
6
- colorMode?: 'light' | 'dark' | 'auto';
7
- /** Colour of the "I" glyph. */
8
- primaryColor?: string;
9
- /** Colour of the "D" glyph. */
10
- secondaryColor?: string;
11
- }
12
- /**
13
- * DI glyph mark.
14
- *
15
- * Uses the same public API and semantic color mapping as AI:
16
- * primaryColor styles the "I", secondaryColor styles the "D".
17
- */
18
- export declare const DI: import("react").ForwardRefExoticComponent<DIProps & import("react").RefAttributes<SVGSVGElement>>;
19
- export default DI;
@@ -1,20 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- /*
3
- * Copyright (c) 2023-2026 Datalayer, Inc.
4
- * Distributed under the terms of the Modified BSD License.
5
- */
6
- import { forwardRef } from 'react';
7
- import { getLogoColors } from './DatalayerLogo';
8
- /**
9
- * DI glyph mark.
10
- *
11
- * Uses the same public API and semantic color mapping as AI:
12
- * primaryColor styles the "I", secondaryColor styles the "D".
13
- */
14
- export const DI = forwardRef(function DI({ size = 24, variant = 'datalayer', colorMode = 'light', primaryColor, secondaryColor, ...svgProps }, ref) {
15
- const themed = getLogoColors(variant, colorMode);
16
- const resolvedPrimary = primaryColor ?? themed.primary;
17
- const resolvedSecondary = secondaryColor ?? themed.textColor;
18
- return (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", width: size, height: size, role: "img", "aria-label": "DI", ref: ref, ...svgProps, children: [_jsx("path", { d: "M2 3.932H5V20.068075H2ZM3.5 3.932H6.5L12.933 20.068075H9.933ZM2 17.068075H11.4V20.068075H2Z", fill: resolvedSecondary, strokeWidth: 0.25 }), _jsx("path", { d: "m10.788825 3.932 6.43325 16.136075h3.5279L14.316725 3.932H10.788825Z", fill: resolvedPrimary, strokeWidth: 0.25 })] }));
19
- });
20
- export default DI;