@datalayer/primer-addons 0.0.8 → 0.0.10

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,8 @@
1
+ import React from "react";
2
+ import { BoxProps } from "@primer/react";
3
+ export type CardProps = Omit<BoxProps, 'border'> & {
4
+ rounded?: 'small' | 'medium' | 'large' | 'full' | number;
5
+ border?: boolean;
6
+ shadow?: 'small' | 'medium' | 'large' | 'extraLarge';
7
+ };
8
+ export declare const Card: React.FC<CardProps>;
@@ -0,0 +1,37 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Box } from "@primer/react";
3
+ const roundedVals = {
4
+ "small": "3px",
5
+ "medium": "6px",
6
+ "large": "12px",
7
+ "full": "100vh",
8
+ };
9
+ const shadowVals = {
10
+ "small": '0 1px 0 rgba(31,35,40,0.04)',
11
+ "medium": '0 3px 6px rgba(140,149,159,0.15)',
12
+ "large": '0 8px 24px rgba(140,149,159,0.2)',
13
+ "extraLarge": '0 12px 28px rgba(140,149,159,0.3)',
14
+ };
15
+ export const Card = (props) => {
16
+ const { sx, rounded, border, shadow, children, ...otherProps } = props;
17
+ return (_jsx(Box, { sx: {
18
+ ...(sx ? sx : undefined),
19
+ display: 'flex',
20
+ alignItems: 'center',
21
+ ...(rounded ? typeof rounded === "string" ? {
22
+ borderRadius: roundedVals[rounded]
23
+ } : {
24
+ borderRadius: props.rounded
25
+ } : undefined),
26
+ ...(border ? {
27
+ borderWidth: 1,
28
+ borderStyle: 'solid',
29
+ borderColor: 'border.default'
30
+ } : undefined),
31
+ ...(shadow ? {
32
+ boxShadow: shadowVals[shadow]
33
+ } : {
34
+ boxShadow: shadowVals['small']
35
+ })
36
+ }, className: "color-shadow-medium", ...otherProps, children: children }));
37
+ };
@@ -1,5 +1,7 @@
1
1
  import React from "react";
2
2
  import { FlashProps } from "@primer/react";
3
- type CloseableFlashProps = FlashProps;
3
+ type CloseableFlashProps = FlashProps & {
4
+ onClose: () => void;
5
+ };
4
6
  export declare const CloseableFlash: React.FC<CloseableFlashProps>;
5
7
  export {};
@@ -5,6 +5,7 @@ import { XIcon } from "@primer/octicons-react";
5
5
  export const CloseableFlash = (props) => {
6
6
  const [isVisible, setIsVisible] = useState(true);
7
7
  const handleClose = () => {
8
+ props.onClose();
8
9
  setIsVisible(false);
9
10
  };
10
11
  if (!isVisible) {
@@ -1,8 +1,8 @@
1
1
  interface CommonProps {
2
- name: string;
3
- id: string;
4
- min: number;
5
- max: number;
2
+ name?: string;
3
+ id?: string;
4
+ min?: number;
5
+ max?: number;
6
6
  label?: string;
7
7
  value?: number;
8
8
  displayValue?: boolean;
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useState } from "react";
3
3
  import { useTheme, Box, CounterLabel, FormControl } from "@primer/react";
4
- export const Slider = ({ name = "slider", id = "slider", min, max, value, label, step = 1, markers = false, displayValue = true, disabled = false, orientation = "horizontal", width = "200px", onChange, }) => {
4
+ export const Slider = ({ name = "slider", id = "slider", min = 0, max = 10, value = 5, label = "label", step = 1, markers = false, displayValue = true, disabled = false, orientation = "horizontal", width = "200px", onChange, }) => {
5
5
  const { colorMode } = useTheme();
6
6
  const defaultValue = max < min ? min : min + (max - min) / 2;
7
7
  const [sliderVal, setSliderVal] = useState(defaultValue);
package/lib/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from "./components/card/Card";
1
2
  export * from "./components/closeableflash/CloseableFlash";
2
3
  export * from "./components/slider/Slider";
3
4
  export * from "./components/toolbar/Toolbar";
package/lib/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export * from "./components/card/Card";
1
2
  export * from "./components/closeableflash/CloseableFlash";
2
3
  export * from "./components/slider/Slider";
3
4
  export * from "./components/toolbar/Toolbar";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datalayer/primer-addons",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "license": "BSD-3-Clause",
5
5
  "scripts": {
6
6
  "dev": "vite",