visits-style 1.4.17 → 1.4.19

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.
@@ -1,2 +1,2 @@
1
1
  import type { ToastContainerProps } from './types';
2
- export default function Toast({ toasts, clear, fixed, margin, position, space }: ToastContainerProps): import("react/jsx-runtime").JSX.Element;
2
+ export default function Toast({ toasts, clear, fixed, offset, position, space }: ToastContainerProps): import("react/jsx-runtime").JSX.Element;
@@ -30,10 +30,15 @@ export interface ToastContainerProps {
30
30
  */
31
31
  position?: ToastContainerPositionType;
32
32
  /**
33
- * margin 単位はpx
34
- * @default '16px'
33
+ * offset 単位はpx
34
+ * @default positionによって16px自動反映
35
35
  */
36
- margin?: string;
36
+ offset?: Partial<{
37
+ top: string;
38
+ left: string;
39
+ right: string;
40
+ bottom: string;
41
+ }>;
37
42
  /**
38
43
  * toast間の間隔
39
44
  * @default '16px'
package/dist/index.cjs.js CHANGED
@@ -1017,7 +1017,7 @@ function ToastItem({
1017
1017
  clearRef.current = clear;
1018
1018
  if (!isMounted)
1019
1019
  return null;
1020
- return /* @__PURE__ */ jsxRuntime.jsx(Item, { ref: refs.setFloating, role: "status", "data-testid": "vs-toast-item", className, style: styles, onClick: handleClickToast, children: message });
1020
+ return /* @__PURE__ */ jsxRuntime.jsx(Item, { ref: refs.setFloating, role: "log", "data-testid": "vs-toast-item", className, style: styles, onClick: handleClickToast, children: message });
1021
1021
  }
1022
1022
  const Item = /* @__PURE__ */ styledComponents.styled.li.withConfig({
1023
1023
  displayName: "ToastItem__Item",
@@ -1028,24 +1028,30 @@ function Toast({
1028
1028
  toasts,
1029
1029
  clear,
1030
1030
  fixed,
1031
- margin = "16px",
1031
+ offset = {},
1032
1032
  position = "top-left",
1033
1033
  space = "16px"
1034
1034
  }) {
1035
1035
  const style = React.useMemo(() => {
1036
1036
  const base = {
1037
- position: fixed ? "fixed" : "absolute"
1037
+ position: fixed ? "fixed" : "absolute",
1038
+ ...offset
1038
1039
  };
1039
- if (position.indexOf("top") > -1) {
1040
- base.top = margin;
1041
- } else if (position.indexOf("bottom") > -1) {
1042
- base.bottom = margin;
1040
+ if (!Object.keys(offset).length) {
1041
+ if (position.indexOf("top") > -1) {
1042
+ base.top = "16px";
1043
+ } else if (position.indexOf("bottom") > -1) {
1044
+ base.bottom = "16px";
1045
+ }
1046
+ if (position.indexOf("left") > -1) {
1047
+ base.left = "16px";
1048
+ } else if (position.indexOf("right") > -1) {
1049
+ base.right = "16px";
1050
+ }
1043
1051
  }
1044
1052
  if (position.indexOf("left") > -1) {
1045
- base.left = margin;
1046
1053
  base.alignItems = "flex-start";
1047
1054
  } else if (position.indexOf("right") > -1) {
1048
- base.right = margin;
1049
1055
  base.alignItems = "flex-end";
1050
1056
  } else {
1051
1057
  base.left = "50%";
@@ -1053,7 +1059,7 @@ function Toast({
1053
1059
  base.transform = "translateX(-50%)";
1054
1060
  }
1055
1061
  return base;
1056
- }, [fixed, margin, position]);
1062
+ }, [fixed, offset, position]);
1057
1063
  return /* @__PURE__ */ jsxRuntime.jsx(Portal$1, { children: /* @__PURE__ */ jsxRuntime.jsx(ToastList, { style, $space: space, children: toasts.map((props) => /* @__PURE__ */ React.createElement(ToastItem, { ...props, key: props.id, clear })) }) });
1058
1064
  }
1059
1065
  const ToastList = /* @__PURE__ */ styledComponents.styled.ul.withConfig({
package/dist/index.es.js CHANGED
@@ -1009,7 +1009,7 @@ function ToastItem({
1009
1009
  clearRef.current = clear;
1010
1010
  if (!isMounted)
1011
1011
  return null;
1012
- return /* @__PURE__ */ jsx(Item, { ref: refs.setFloating, role: "status", "data-testid": "vs-toast-item", className, style: styles, onClick: handleClickToast, children: message });
1012
+ return /* @__PURE__ */ jsx(Item, { ref: refs.setFloating, role: "log", "data-testid": "vs-toast-item", className, style: styles, onClick: handleClickToast, children: message });
1013
1013
  }
1014
1014
  const Item = /* @__PURE__ */ styled.li.withConfig({
1015
1015
  displayName: "ToastItem__Item",
@@ -1020,24 +1020,30 @@ function Toast({
1020
1020
  toasts,
1021
1021
  clear,
1022
1022
  fixed,
1023
- margin = "16px",
1023
+ offset = {},
1024
1024
  position = "top-left",
1025
1025
  space = "16px"
1026
1026
  }) {
1027
1027
  const style = useMemo(() => {
1028
1028
  const base = {
1029
- position: fixed ? "fixed" : "absolute"
1029
+ position: fixed ? "fixed" : "absolute",
1030
+ ...offset
1030
1031
  };
1031
- if (position.indexOf("top") > -1) {
1032
- base.top = margin;
1033
- } else if (position.indexOf("bottom") > -1) {
1034
- base.bottom = margin;
1032
+ if (!Object.keys(offset).length) {
1033
+ if (position.indexOf("top") > -1) {
1034
+ base.top = "16px";
1035
+ } else if (position.indexOf("bottom") > -1) {
1036
+ base.bottom = "16px";
1037
+ }
1038
+ if (position.indexOf("left") > -1) {
1039
+ base.left = "16px";
1040
+ } else if (position.indexOf("right") > -1) {
1041
+ base.right = "16px";
1042
+ }
1035
1043
  }
1036
1044
  if (position.indexOf("left") > -1) {
1037
- base.left = margin;
1038
1045
  base.alignItems = "flex-start";
1039
1046
  } else if (position.indexOf("right") > -1) {
1040
- base.right = margin;
1041
1047
  base.alignItems = "flex-end";
1042
1048
  } else {
1043
1049
  base.left = "50%";
@@ -1045,7 +1051,7 @@ function Toast({
1045
1051
  base.transform = "translateX(-50%)";
1046
1052
  }
1047
1053
  return base;
1048
- }, [fixed, margin, position]);
1054
+ }, [fixed, offset, position]);
1049
1055
  return /* @__PURE__ */ jsx(Portal$1, { children: /* @__PURE__ */ jsx(ToastList, { style, $space: space, children: toasts.map((props) => /* @__PURE__ */ createElement(ToastItem, { ...props, key: props.id, clear })) }) });
1050
1056
  }
1051
1057
  const ToastList = /* @__PURE__ */ styled.ul.withConfig({
package/package.json CHANGED
@@ -1,16 +1,25 @@
1
1
  {
2
2
  "name": "visits-style",
3
- "repository": "https://github.com/visits-works/visits-style",
3
+ "repository": {
4
+ "type": "git",
5
+ "url": "git+https://github.com/visits-works/visits-style.git"
6
+ },
4
7
  "homepage": "https://github.com/visits-works/visits-style",
5
- "version": "1.4.17",
8
+ "version": "1.4.19",
6
9
  "type": "module",
7
10
  "main": "./dist/index.cjs.js",
8
11
  "module": "./dist/index.es.js",
9
12
  "types": "./dist/index.d.ts",
10
13
  "exports": {
11
14
  ".": {
12
- "import": "./dist/index.es.js",
13
- "require": "./dist/index.cjs.js"
15
+ "import": {
16
+ "types": "./dist/index.d.ts",
17
+ "default": "./dist/index.es.js"
18
+ },
19
+ "default": {
20
+ "types": "./dist/index.d.ts",
21
+ "default": "./dist/index.cjs.js"
22
+ }
14
23
  }
15
24
  },
16
25
  "license": "Apache-2.0",
@@ -24,7 +33,7 @@
24
33
  "styled-components": ">=6.0.5"
25
34
  },
26
35
  "dependencies": {
27
- "@floating-ui/react": "^0.27.8",
36
+ "@floating-ui/react": "^0.27.19",
28
37
  "polished": "^4.3.1"
29
38
  }
30
39
  }