@datalayer/primer-addons 1.0.2 → 1.0.4

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.
@@ -0,0 +1,7 @@
1
+ import { ComponentProps } from 'react';
2
+ import type { BackgroundProps, BorderProps, ColorProps, FlexboxProps, GridProps, LayoutProps, PositionProps, ShadowProps, SpaceProps, TypographyProps } from 'styled-system';
3
+ import { type SxProp } from './sx';
4
+ type StyledBoxProps = SxProp & SpaceProps & ColorProps & TypographyProps & LayoutProps & FlexboxProps & GridProps & BackgroundProps & BorderProps & PositionProps & ShadowProps;
5
+ export declare const Box: import("styled-components").StyledComponent<"div", any, StyledBoxProps, never>;
6
+ export type BoxProps = ComponentProps<typeof Box>;
7
+ export default Box;
@@ -0,0 +1,10 @@
1
+ /*
2
+ * Copyright (c) 2021-2024 Datalayer, Inc.
3
+ *
4
+ * Datalayer License
5
+ */
6
+ import styled from 'styled-components';
7
+ import { background, border, color, flexbox, grid, layout, position, shadow, space, typography } from 'styled-system';
8
+ import sx from './sx';
9
+ export const Box = styled.div(space, color, typography, layout, flexbox, grid, background, border, position, shadow, sx);
10
+ export default Box;
@@ -0,0 +1,21 @@
1
+ import type { SystemCssProperties, SystemStyleObject } from '@styled-system/css';
2
+ import type { ColorProps, BorderColorProps, ShadowProps } from 'styled-system';
3
+ import merge from 'deepmerge';
4
+ type ThemeColorPaths = string;
5
+ type ThemeShadowPaths = string;
6
+ export type BetterCssProperties = {
7
+ [K in keyof SystemCssProperties]: K extends keyof ColorProps ? ThemeColorPaths | SystemCssProperties[K] : K extends keyof BorderColorProps ? ThemeColorPaths | SystemCssProperties[K] : K extends keyof ShadowProps ? ThemeShadowPaths | SystemCssProperties[K] : SystemCssProperties[K];
8
+ };
9
+ export type CSSCustomProperties = {
10
+ [key: `--${string}`]: string | number;
11
+ };
12
+ type CSSSelectorObject = {
13
+ [cssSelector: string]: SystemStyleObject | CSSCustomProperties;
14
+ };
15
+ export type BetterSystemStyleObject = BetterCssProperties | SystemStyleObject | CSSCustomProperties | CSSSelectorObject;
16
+ export interface SxProp {
17
+ sx?: BetterSystemStyleObject;
18
+ }
19
+ declare const sx: (props: SxProp) => import("@styled-system/css").CssFunctionReturnType;
20
+ export default sx;
21
+ export { merge };
@@ -0,0 +1,10 @@
1
+ /*
2
+ * Copyright (c) 2021-2024 Datalayer, Inc.
3
+ *
4
+ * Datalayer License
5
+ */
6
+ import css from '@styled-system/css';
7
+ import merge from 'deepmerge';
8
+ const sx = (props) => css(props.sx);
9
+ export default sx;
10
+ export { merge };
@@ -0,0 +1,7 @@
1
+ export * from "./box/Box";
2
+ export * from "./card/Card";
3
+ export * from "./content-loader/ContentLoader";
4
+ export * from "./closeable-flash/CloseableFlash";
5
+ export * from "./icons/CircleIcon";
6
+ export * from "./overlay/Overlay";
7
+ export * from "./slider/Slider";
@@ -0,0 +1,7 @@
1
+ export * from "./box/Box";
2
+ export * from "./card/Card";
3
+ export * from "./content-loader/ContentLoader";
4
+ export * from "./closeable-flash/CloseableFlash";
5
+ export * from "./icons/CircleIcon";
6
+ export * from "./overlay/Overlay";
7
+ export * from "./slider/Slider";
package/lib/index.d.ts CHANGED
@@ -1,6 +1,2 @@
1
- export * from "./components/card/Card";
2
- export * from "./components/content-loader/ContentLoader";
3
- export * from "./components/closeable-flash/CloseableFlash";
4
- export * from "./components/icons/CircleIcon";
5
- export * from "./components/overlay/Overlay";
6
- export * from "./components/slider/Slider";
1
+ export * from "./components";
2
+ export * from "./utils";
package/lib/index.js CHANGED
@@ -1,6 +1,2 @@
1
- export * from "./components/card/Card";
2
- export * from "./components/content-loader/ContentLoader";
3
- export * from "./components/closeable-flash/CloseableFlash";
4
- export * from "./components/icons/CircleIcon";
5
- export * from "./components/overlay/Overlay";
6
- export * from "./components/slider/Slider";
1
+ export * from "./components";
2
+ export * from "./utils";
@@ -0,0 +1,32 @@
1
+ import React, { Ref, PropsWithChildren } from 'react';
2
+ import { AnimateProps } from '@primer/react-brand';
3
+ /**
4
+ * Layout
5
+ */
6
+ export declare const Container: ({ children, style, }: {
7
+ children: React.ReactElement[] | React.ReactElement;
8
+ style?: React.CSSProperties;
9
+ }) => import("react/jsx-runtime").JSX.Element;
10
+ type RedlineBackgroundProps = {
11
+ height?: number;
12
+ hasBorder?: boolean;
13
+ };
14
+ export declare function RedlineBackground({ height, hasBorder, ...rest }: PropsWithChildren<RedlineBackgroundProps>): import("react/jsx-runtime").JSX.Element;
15
+ /**
16
+ * Base Types
17
+ *
18
+ * Component helper type to be extended by component types, e.g.:
19
+ * type CustomComponentProps = BaseProps<HTMLDivElement> & { ... }
20
+ *
21
+ * Example use:
22
+ * const CustomComponent = forwardRef<HTMLDivElement, CustomComponentProps>(({className, ...props}, ref) => { ... })
23
+ * // OR:
24
+ * const CustomComponent = forwardRef(({className: CustomComponentProps, ...props}, ref: Ref<HTMLDivElement>) => { ... })
25
+ */
26
+ export type BaseProps<T> = {
27
+ className?: string;
28
+ id?: string;
29
+ ref?: Ref<T>;
30
+ animate?: AnimateProps;
31
+ };
32
+ export {};
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * Layout
4
+ */
5
+ export const Container = ({ children, style, }) => (_jsx("div", { style: { maxWidth: 1024, margin: '0 auto', ...style }, children: children }));
6
+ export function RedlineBackground({ height, hasBorder = true, ...rest }) {
7
+ return (_jsx("div", { style: {
8
+ display: 'flex',
9
+ overflow: 'hidden',
10
+ border: hasBorder
11
+ ? '1px solid var(--base-color-scale-red-2)'
12
+ : undefined,
13
+ backgroundImage: 'linear-gradient(45deg, var(--base-color-scale-red-0) 12.5%, hsla(var(--base-color-scale-red-2-hsl) / 50%) 12.5%, hsla(var(--base-color-scale-red-2-hsl) / 50%) 50%, var(--base-color-scale-red-0) 50%, var(--base-color-scale-red-0) 62.5%, hsla(var(--base-color-scale-red-2-hsl) / 50%) 62.5%, hsla(var(--base-color-scale-red-2-hsl) / 50%) 100%)',
14
+ backgroundSize: '5.66px 5.66px',
15
+ WebkitBoxPack: 'center',
16
+ justifyContent: 'center',
17
+ alignItems: 'center',
18
+ width: '100%',
19
+ height,
20
+ }, ...rest }));
21
+ }
@@ -0,0 +1,10 @@
1
+ import '@primer/react-brand/lib/css/main.css';
2
+ type Colormode = 'light' | 'dark' | 'auto';
3
+ /**
4
+ * Ensure we define a root for Primer portal root.
5
+ *
6
+ * @see https://github.com/primer/react/blob/main/packages/react/src/Portal/Portal.tsx#L23
7
+ * @see https://github.com/primer/react/blob/030fe020b48b7f12c2994c6614e5d4191fe764ee/src/Portal/Portal.tsx#L33
8
+ */
9
+ export declare const setupPrimerPortals: (colormode?: Colormode) => void;
10
+ export default setupPrimerPortals;
@@ -0,0 +1,23 @@
1
+ /*
2
+ * Copyright (c) 2023-2025 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ import { registerPortalRoot } from '@primer/react';
6
+ import '@primer/react-brand/lib/css/main.css';
7
+ const PRIMER_PORTAL_ROOT_ID = '__primerPortalRoot__';
8
+ /**
9
+ * Ensure we define a root for Primer portal root.
10
+ *
11
+ * @see https://github.com/primer/react/blob/main/packages/react/src/Portal/Portal.tsx#L23
12
+ * @see https://github.com/primer/react/blob/030fe020b48b7f12c2994c6614e5d4191fe764ee/src/Portal/Portal.tsx#L33
13
+ */
14
+ export const setupPrimerPortals = (colormode = 'light') => {
15
+ const body = document.body;
16
+ body.dataset['portalRoot'] = 'true';
17
+ body.dataset['colorMode'] = colormode;
18
+ body.dataset['lightTheme'] = 'light';
19
+ body.dataset['darkTheme'] = 'dark';
20
+ body.id = PRIMER_PORTAL_ROOT_ID;
21
+ registerPortalRoot(body);
22
+ };
23
+ export default setupPrimerPortals;
@@ -0,0 +1,2 @@
1
+ export declare const Styles: () => import("react/jsx-runtime").JSX.Element;
2
+ export default Styles;
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright (c) 2023-2025 Datalayer, Inc.
4
+ * Distributed under the terms of the Modified BSD License.
5
+ */
6
+ import { ThemeProvider, BaseStyles } from '@primer/react';
7
+ export const Styles = () => {
8
+ return (_jsx(_Fragment, { children: _jsx(ThemeProvider, { children: _jsx(BaseStyles, {}) }) }));
9
+ };
10
+ export default Styles;
@@ -0,0 +1,2 @@
1
+ export * from './Helper';
2
+ export * from './Portals';
@@ -0,0 +1,6 @@
1
+ /*
2
+ * Copyright (c) 2023-2025 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ export * from './Helper';
6
+ export * from './Portals';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datalayer/primer-addons",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "license": "BSD-3-Clause",
5
5
  "scripts": {
6
6
  "dev": "vite",