@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.
- package/README.md +14 -0
- package/lib/components/appearance/AppearanceMenuWithStore.d.ts +26 -0
- package/lib/components/appearance/AppearanceMenuWithStore.js +21 -0
- package/lib/components/appearance/CollaboratorPalette.d.ts +65 -0
- package/lib/components/appearance/CollaboratorPalette.js +160 -0
- package/lib/components/appearance/index.d.ts +2 -0
- package/lib/components/appearance/index.js +2 -0
- package/lib/components/box/Box.d.ts +17 -5
- package/lib/components/box/Box.js +3 -5
- package/lib/components/calendar-picker/CalendarPicker.d.ts +35 -0
- package/lib/components/calendar-picker/CalendarPicker.js +146 -0
- package/lib/components/calendar-picker/index.d.ts +1 -0
- package/lib/components/calendar-picker/index.js +5 -0
- package/lib/components/card/Card.d.ts +6 -1
- package/lib/components/card/Card.js +1 -1
- package/lib/components/color/ColorSwatch.d.ts +1 -1
- package/lib/components/color-picker/ColorPicker.d.ts +97 -0
- package/lib/components/color-picker/ColorPicker.js +358 -0
- package/lib/components/color-picker/index.d.ts +1 -0
- package/lib/components/color-picker/index.js +5 -0
- package/lib/components/content-loader/ContentLoader.d.ts +1 -1
- package/lib/components/content-loader/ContentLoader.stories.d.ts +1 -1
- package/lib/components/date-picker/DatePicker.d.ts +46 -0
- package/lib/components/date-picker/DatePicker.js +98 -0
- package/lib/components/date-picker/index.d.ts +1 -0
- package/lib/components/date-picker/index.js +5 -0
- package/lib/components/icons/CircleIcon.d.ts +1 -1
- package/lib/components/icons/CircleIcon.stories.d.ts +1 -1
- package/lib/components/index.d.ts +5 -0
- package/lib/components/index.js +5 -0
- package/lib/components/logo/DatalayerText.d.ts +1 -1
- package/lib/components/logo/index.d.ts +0 -1
- package/lib/components/logo/index.js +0 -1
- package/lib/components/side-overlay/SideOverlay.d.ts +5 -5
- package/lib/components/side-overlay/SideOverlay.stories.d.ts +1 -1
- package/lib/components/slider/Slider.d.ts +1 -1
- package/lib/components/slider/Slider.stories.d.ts +1 -1
- package/lib/components/sliding-panel/SlidingPanel.d.ts +1 -1
- package/lib/components/sliding-panel/SlidingPanel.stories.d.ts +1 -1
- package/lib/components/toolbar/Toolbar.d.ts +2 -2
- package/lib/components/toolbar/Toolbar.js +0 -0
- package/lib/components/toolbar/ToolbarButton.d.ts +3 -1
- package/lib/components/toolbar/ToolbarButton.js +54 -22
- package/lib/components/toolbar/ToolbarDivider.d.ts +1 -1
- package/lib/components/toolbar/ToolbarDropdown.d.ts +3 -3
- package/lib/components/toolbar/ToolbarDropdown.js +66 -35
- package/lib/components/toolbar/ToolbarRenderer.d.ts +20 -3
- package/lib/components/toolbar/ToolbarRenderer.js +16 -16
- package/lib/components/toolbar/types.d.ts +15 -8
- package/lib/reactor/AppearancePlugin.d.ts +31 -0
- package/lib/reactor/AppearancePlugin.js +63 -0
- package/lib/reactor/ThemePlugin.d.ts +5 -0
- package/lib/reactor/ThemePlugin.js +98 -0
- package/lib/reactor/index.d.ts +30 -0
- package/lib/reactor/index.js +34 -0
- package/lib/reactor/page-layout/PageLayout.d.ts +148 -0
- package/lib/reactor/page-layout/PageLayout.js +310 -0
- package/lib/reactor/page-layout/PageLayoutPlugin.d.ts +59 -0
- package/lib/reactor/page-layout/PageLayoutPlugin.js +105 -0
- package/lib/reactor/page-layout/PagePanelToggle.d.ts +21 -0
- package/lib/reactor/page-layout/PagePanelToggle.js +29 -0
- package/lib/reactor/page-layout/SlotPageLayout.d.ts +36 -0
- package/lib/reactor/page-layout/SlotPageLayout.js +25 -0
- package/lib/reactor/page-layout/panelState.d.ts +28 -0
- package/lib/reactor/page-layout/panelState.js +49 -0
- package/lib/story-helpers.d.ts +2 -2
- package/lib/theme/DatalayerBrandThemeProvider.d.ts +1 -1
- package/lib/theme/DatalayerThemeProvider.d.ts +5 -5
- package/lib/theme/DatalayerThemeProvider.js +119 -58
- package/lib/theme/css/createThemeCSSVars.d.ts +1 -0
- package/lib/theme/css/createThemeCSSVars.js +9 -0
- package/lib/theme/fontStacks.d.ts +2 -0
- package/lib/theme/fontStacks.js +6 -0
- package/lib/theme/index.d.ts +2 -0
- package/lib/theme/index.js +2 -0
- package/lib/theme/palettes/ColorPalette.d.ts +3 -3
- package/lib/theme/portableTheme.d.ts +32 -0
- package/lib/theme/portableTheme.js +45 -0
- package/lib/utils/Helper.d.ts +2 -2
- package/lib/utils/Portals.d.ts +15 -0
- package/lib/utils/Portals.js +83 -28
- package/lib/utils/Styles.d.ts +1 -1
- package/package.json +15 -14
- package/lib/components/logo/DI.d.ts +0 -19
- package/lib/components/logo/DI.js +0 -20
package/lib/utils/Portals.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
85
|
-
|
|
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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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;
|
package/lib/utils/Styles.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const Styles: () => import("react
|
|
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.
|
|
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
|
-
"@
|
|
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": "
|
|
40
|
-
"react-dom": "
|
|
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": "
|
|
56
|
-
"@types/react-dom": "
|
|
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.
|
|
59
|
-
"@typescript-eslint/parser": "^8.
|
|
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.
|
|
63
|
-
"eslint-plugin-react-hooks": "^
|
|
64
|
-
"eslint-plugin-react-refresh": "^0.
|
|
65
|
-
"eslint-plugin-storybook": "^
|
|
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": "
|
|
70
|
-
"vite": "
|
|
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;
|