@purpurds/container 7.6.1 → 7.8.0
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/dist/container.cjs.js +2 -2
- package/dist/container.cjs.js.map +1 -1
- package/dist/container.d.ts +19 -10
- package/dist/container.d.ts.map +1 -1
- package/dist/container.es.js +24 -12
- package/dist/container.es.js.map +1 -1
- package/dist/metadata.js +4 -0
- package/package.json +6 -6
- package/src/container.stories.tsx +18 -8
- package/src/container.tsx +26 -10
package/dist/container.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react/jsx-runtime"),x=require("react");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react/jsx-runtime"),x=require("react");function d(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var p={exports:{}};/*!
|
|
2
2
|
Copyright (c) 2018 Jed Watson.
|
|
3
3
|
Licensed under the MIT License (MIT), see
|
|
4
4
|
http://jedwatson.github.io/classnames
|
|
5
|
-
*/var c;function
|
|
5
|
+
*/var c;function _(){return c||(c=1,function(n){(function(){var s={}.hasOwnProperty;function e(){for(var r="",t=0;t<arguments.length;t++){var o=arguments[t];o&&(r=i(r,u.call(this,o)))}return r}function u(r){if(typeof r=="string"||typeof r=="number")return this&&this[r]||r;if(typeof r!="object")return"";if(Array.isArray(r))return e.apply(this,r);if(r.toString!==Object.prototype.toString&&!r.toString.toString().includes("[native code]"))return r.toString();var t="";for(var o in r)s.call(r,o)&&r[o]&&(t=i(t,this&&this[o]||o));return t}function i(r,t){return t?r?r+" "+t:r+t:r}n.exports?(e.default=e,n.exports=e):window.classNames=e})()}(p)),p.exports}var m=_();const h=d(m),y={"purpur-container":"_purpur-container_1t9gx_1","purpur-container--xs":"_purpur-container--xs_1t9gx_13","purpur-container--sm":"_purpur-container--sm_1t9gx_24","purpur-container--md":"_purpur-container--md_1t9gx_39","purpur-container--lg":"_purpur-container--lg_1t9gx_42","purpur-container--xl":"_purpur-container--xl_1t9gx_45","purpur-container--xxl":"_purpur-container--xxl_1t9gx_48"},v=h.bind(y),S={XS:"xs",SM:"sm",MD:"md",LG:"lg",XL:"xl",XXL:"xxl"},b={DIV:"div",SPAN:"span"},a="purpur-container",l=x.forwardRef(({children:n,className:s,width:e="xxl",element:u="div",...i},r)=>{const t=v([s,a,`${a}--${e}`]);return f.jsx(u,{className:t,ref:r,...i,children:n})});l.displayName="Container";exports.Container=l;exports.Element=b;exports.Width=S;
|
|
6
6
|
//# sourceMappingURL=container.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.cjs.js","sources":["../../../common/temp/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/bind.js","../src/container.tsx"],"sourcesContent":["/*!\n\tCopyright (c) 2018 Jed Watson.\n\tLicensed under the MIT License (MIT), see\n\thttp://jedwatson.github.io/classnames\n*/\n/* global define */\n\n(function () {\n\t'use strict';\n\n\tvar hasOwn = {}.hasOwnProperty;\n\n\tfunction classNames () {\n\t\tvar classes = '';\n\n\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\tvar arg = arguments[i];\n\t\t\tif (arg) {\n\t\t\t\tclasses = appendClass(classes, parseValue.call(this, arg));\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction parseValue (arg) {\n\t\tif (typeof arg === 'string' || typeof arg === 'number') {\n\t\t\treturn this && this[arg] || arg;\n\t\t}\n\n\t\tif (typeof arg !== 'object') {\n\t\t\treturn '';\n\t\t}\n\n\t\tif (Array.isArray(arg)) {\n\t\t\treturn classNames.apply(this, arg);\n\t\t}\n\n\t\tif (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {\n\t\t\treturn arg.toString();\n\t\t}\n\n\t\tvar classes = '';\n\n\t\tfor (var key in arg) {\n\t\t\tif (hasOwn.call(arg, key) && arg[key]) {\n\t\t\t\tclasses = appendClass(classes, this && this[key] || key);\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction appendClass (value, newClass) {\n\t\tif (!newClass) {\n\t\t\treturn value;\n\t\t}\n\t\n\t\tif (value) {\n\t\t\treturn value + ' ' + newClass;\n\t\t}\n\t\n\t\treturn value + newClass;\n\t}\n\n\tif (typeof module !== 'undefined' && module.exports) {\n\t\tclassNames.default = classNames;\n\t\tmodule.exports = classNames;\n\t} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {\n\t\t// register as 'classnames', consistent with npm package name\n\t\tdefine('classnames', [], function () {\n\t\t\treturn classNames;\n\t\t});\n\t} else {\n\t\twindow.classNames = classNames;\n\t}\n}());\n","import React, {
|
|
1
|
+
{"version":3,"file":"container.cjs.js","sources":["../../../common/temp/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/bind.js","../src/container.tsx"],"sourcesContent":["/*!\n\tCopyright (c) 2018 Jed Watson.\n\tLicensed under the MIT License (MIT), see\n\thttp://jedwatson.github.io/classnames\n*/\n/* global define */\n\n(function () {\n\t'use strict';\n\n\tvar hasOwn = {}.hasOwnProperty;\n\n\tfunction classNames () {\n\t\tvar classes = '';\n\n\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\tvar arg = arguments[i];\n\t\t\tif (arg) {\n\t\t\t\tclasses = appendClass(classes, parseValue.call(this, arg));\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction parseValue (arg) {\n\t\tif (typeof arg === 'string' || typeof arg === 'number') {\n\t\t\treturn this && this[arg] || arg;\n\t\t}\n\n\t\tif (typeof arg !== 'object') {\n\t\t\treturn '';\n\t\t}\n\n\t\tif (Array.isArray(arg)) {\n\t\t\treturn classNames.apply(this, arg);\n\t\t}\n\n\t\tif (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {\n\t\t\treturn arg.toString();\n\t\t}\n\n\t\tvar classes = '';\n\n\t\tfor (var key in arg) {\n\t\t\tif (hasOwn.call(arg, key) && arg[key]) {\n\t\t\t\tclasses = appendClass(classes, this && this[key] || key);\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction appendClass (value, newClass) {\n\t\tif (!newClass) {\n\t\t\treturn value;\n\t\t}\n\t\n\t\tif (value) {\n\t\t\treturn value + ' ' + newClass;\n\t\t}\n\t\n\t\treturn value + newClass;\n\t}\n\n\tif (typeof module !== 'undefined' && module.exports) {\n\t\tclassNames.default = classNames;\n\t\tmodule.exports = classNames;\n\t} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {\n\t\t// register as 'classnames', consistent with npm package name\n\t\tdefine('classnames', [], function () {\n\t\t\treturn classNames;\n\t\t});\n\t} else {\n\t\twindow.classNames = classNames;\n\t}\n}());\n","import React, { forwardRef, type ReactNode } from \"react\";\nimport type { BaseProps } from \"@purpurds/common-types\";\nimport c from \"classnames/bind\";\n\nimport styles from \"./container.module.scss\";\n\nconst cx = c.bind(styles);\n\nexport const Width = {\n XS: \"xs\",\n SM: \"sm\",\n MD: \"md\",\n LG: \"lg\",\n XL: \"xl\",\n XXL: \"xxl\",\n} as const;\n\nexport type WidthType = (typeof Width)[keyof typeof Width];\n\nexport const Element = {\n DIV: \"div\",\n SPAN: \"span\",\n} as const;\n\nexport type ElementType = (typeof Element)[keyof typeof Element];\n\nexport type ContainerProps = Omit<BaseProps, \"children\"> & {\n children: ReactNode;\n width?: WidthType;\n element?: ElementType;\n};\n\nconst rootClassName = \"purpur-container\";\n\nexport const Container = forwardRef<HTMLDivElement, ContainerProps>(\n ({ children, className, width = \"xxl\", element: Element = \"div\", ...props }, ref) => {\n const classes = cx([className, rootClassName, `${rootClassName}--${width}`]);\n return (\n <Element className={classes} ref={ref} {...props}>\n {children}\n </Element>\n );\n }\n);\n\nContainer.displayName = \"Container\";\n"],"names":["hasOwn","classNames","classes","i","arg","appendClass","parseValue","key","value","newClass","module","cx","c","styles","Width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UAAAC,EAAW,MAAAC,EAAQ,MAAO,QAASN,EAAU,MAAO,GAAGO,CAAM,EAAGC,IAAQ,CAC7E,MAAArB,EAAUS,EAAG,CAACS,EAAWJ,EAAe,GAAGA,CAAa,KAAKK,CAAK,EAAE,CAAC,EAEzE,OAAAG,EAAA,IAACT,EAAA,CAAQ,UAAWb,EAAS,IAAAqB,EAAW,GAAGD,EACxC,SAAAH,EACH,CAAA,CAGN,EAEAF,EAAU,YAAc","x_google_ignoreList":[0]}
|
package/dist/container.d.ts
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
import { default as React, ReactNode } from 'react';
|
|
2
|
+
import { BaseProps } from '@purpurds/common-types';
|
|
2
3
|
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export declare const Width: {
|
|
5
|
+
readonly XS: "xs";
|
|
6
|
+
readonly SM: "sm";
|
|
7
|
+
readonly MD: "md";
|
|
8
|
+
readonly LG: "lg";
|
|
9
|
+
readonly XL: "xl";
|
|
10
|
+
readonly XXL: "xxl";
|
|
11
|
+
};
|
|
12
|
+
export type WidthType = (typeof Width)[keyof typeof Width];
|
|
13
|
+
export declare const Element: {
|
|
14
|
+
readonly DIV: "div";
|
|
15
|
+
readonly SPAN: "span";
|
|
8
16
|
};
|
|
9
|
-
export
|
|
10
|
-
|
|
17
|
+
export type ElementType = (typeof Element)[keyof typeof Element];
|
|
18
|
+
export type ContainerProps = Omit<BaseProps, "children"> & {
|
|
11
19
|
children: ReactNode;
|
|
12
|
-
width?:
|
|
13
|
-
element?:
|
|
14
|
-
}
|
|
20
|
+
width?: WidthType;
|
|
21
|
+
element?: ElementType;
|
|
22
|
+
};
|
|
23
|
+
export declare const Container: React.ForwardRefExoticComponent<Omit<ContainerProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
15
24
|
//# sourceMappingURL=container.d.ts.map
|
package/dist/container.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../src/container.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../src/container.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAc,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAOxD,eAAO,MAAM,KAAK;;;;;;;CAOR,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,OAAO,KAAK,CAAC,CAAC;AAE3D,eAAO,MAAM,OAAO;;;CAGV,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;AAEjE,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,GAAG;IACzD,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB,CAAC;AAIF,eAAO,MAAM,SAAS,oGASrB,CAAC"}
|
package/dist/container.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { forwardRef as
|
|
1
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as f } from "react";
|
|
3
3
|
function x(n) {
|
|
4
4
|
return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
|
|
5
5
|
}
|
|
@@ -13,15 +13,15 @@ var c;
|
|
|
13
13
|
function _() {
|
|
14
14
|
return c || (c = 1, function(n) {
|
|
15
15
|
(function() {
|
|
16
|
-
var
|
|
16
|
+
var s = {}.hasOwnProperty;
|
|
17
17
|
function e() {
|
|
18
18
|
for (var r = "", t = 0; t < arguments.length; t++) {
|
|
19
19
|
var o = arguments[t];
|
|
20
|
-
o && (r = i(r,
|
|
20
|
+
o && (r = i(r, u.call(this, o)));
|
|
21
21
|
}
|
|
22
22
|
return r;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function u(r) {
|
|
25
25
|
if (typeof r == "string" || typeof r == "number")
|
|
26
26
|
return this && this[r] || r;
|
|
27
27
|
if (typeof r != "object")
|
|
@@ -32,7 +32,7 @@ function _() {
|
|
|
32
32
|
return r.toString();
|
|
33
33
|
var t = "";
|
|
34
34
|
for (var o in r)
|
|
35
|
-
|
|
35
|
+
s.call(r, o) && r[o] && (t = i(t, this && this[o] || o));
|
|
36
36
|
return t;
|
|
37
37
|
}
|
|
38
38
|
function i(r, t) {
|
|
@@ -51,14 +51,26 @@ const m = /* @__PURE__ */ x(d), h = {
|
|
|
51
51
|
"purpur-container--lg": "_purpur-container--lg_1t9gx_42",
|
|
52
52
|
"purpur-container--xl": "_purpur-container--xl_1t9gx_45",
|
|
53
53
|
"purpur-container--xxl": "_purpur-container--xxl_1t9gx_48"
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
}, v = m.bind(h), g = {
|
|
55
|
+
XS: "xs",
|
|
56
|
+
SM: "sm",
|
|
57
|
+
MD: "md",
|
|
58
|
+
LG: "lg",
|
|
59
|
+
XL: "xl",
|
|
60
|
+
XXL: "xxl"
|
|
61
|
+
}, N = {
|
|
62
|
+
DIV: "div",
|
|
63
|
+
SPAN: "span"
|
|
64
|
+
}, a = "purpur-container", y = f(
|
|
65
|
+
({ children: n, className: s, width: e = "xxl", element: u = "div", ...i }, r) => {
|
|
66
|
+
const t = v([s, a, `${a}--${e}`]);
|
|
67
|
+
return /* @__PURE__ */ l(u, { className: t, ref: r, ...i, children: n });
|
|
58
68
|
}
|
|
59
69
|
);
|
|
60
|
-
|
|
70
|
+
y.displayName = "Container";
|
|
61
71
|
export {
|
|
62
|
-
|
|
72
|
+
y as Container,
|
|
73
|
+
N as Element,
|
|
74
|
+
g as Width
|
|
63
75
|
};
|
|
64
76
|
//# sourceMappingURL=container.es.js.map
|
package/dist/container.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.es.js","sources":["../../../common/temp/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/bind.js","../src/container.tsx"],"sourcesContent":["/*!\n\tCopyright (c) 2018 Jed Watson.\n\tLicensed under the MIT License (MIT), see\n\thttp://jedwatson.github.io/classnames\n*/\n/* global define */\n\n(function () {\n\t'use strict';\n\n\tvar hasOwn = {}.hasOwnProperty;\n\n\tfunction classNames () {\n\t\tvar classes = '';\n\n\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\tvar arg = arguments[i];\n\t\t\tif (arg) {\n\t\t\t\tclasses = appendClass(classes, parseValue.call(this, arg));\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction parseValue (arg) {\n\t\tif (typeof arg === 'string' || typeof arg === 'number') {\n\t\t\treturn this && this[arg] || arg;\n\t\t}\n\n\t\tif (typeof arg !== 'object') {\n\t\t\treturn '';\n\t\t}\n\n\t\tif (Array.isArray(arg)) {\n\t\t\treturn classNames.apply(this, arg);\n\t\t}\n\n\t\tif (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {\n\t\t\treturn arg.toString();\n\t\t}\n\n\t\tvar classes = '';\n\n\t\tfor (var key in arg) {\n\t\t\tif (hasOwn.call(arg, key) && arg[key]) {\n\t\t\t\tclasses = appendClass(classes, this && this[key] || key);\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction appendClass (value, newClass) {\n\t\tif (!newClass) {\n\t\t\treturn value;\n\t\t}\n\t\n\t\tif (value) {\n\t\t\treturn value + ' ' + newClass;\n\t\t}\n\t\n\t\treturn value + newClass;\n\t}\n\n\tif (typeof module !== 'undefined' && module.exports) {\n\t\tclassNames.default = classNames;\n\t\tmodule.exports = classNames;\n\t} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {\n\t\t// register as 'classnames', consistent with npm package name\n\t\tdefine('classnames', [], function () {\n\t\t\treturn classNames;\n\t\t});\n\t} else {\n\t\twindow.classNames = classNames;\n\t}\n}());\n","import React, {
|
|
1
|
+
{"version":3,"file":"container.es.js","sources":["../../../common/temp/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/bind.js","../src/container.tsx"],"sourcesContent":["/*!\n\tCopyright (c) 2018 Jed Watson.\n\tLicensed under the MIT License (MIT), see\n\thttp://jedwatson.github.io/classnames\n*/\n/* global define */\n\n(function () {\n\t'use strict';\n\n\tvar hasOwn = {}.hasOwnProperty;\n\n\tfunction classNames () {\n\t\tvar classes = '';\n\n\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\tvar arg = arguments[i];\n\t\t\tif (arg) {\n\t\t\t\tclasses = appendClass(classes, parseValue.call(this, arg));\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction parseValue (arg) {\n\t\tif (typeof arg === 'string' || typeof arg === 'number') {\n\t\t\treturn this && this[arg] || arg;\n\t\t}\n\n\t\tif (typeof arg !== 'object') {\n\t\t\treturn '';\n\t\t}\n\n\t\tif (Array.isArray(arg)) {\n\t\t\treturn classNames.apply(this, arg);\n\t\t}\n\n\t\tif (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {\n\t\t\treturn arg.toString();\n\t\t}\n\n\t\tvar classes = '';\n\n\t\tfor (var key in arg) {\n\t\t\tif (hasOwn.call(arg, key) && arg[key]) {\n\t\t\t\tclasses = appendClass(classes, this && this[key] || key);\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction appendClass (value, newClass) {\n\t\tif (!newClass) {\n\t\t\treturn value;\n\t\t}\n\t\n\t\tif (value) {\n\t\t\treturn value + ' ' + newClass;\n\t\t}\n\t\n\t\treturn value + newClass;\n\t}\n\n\tif (typeof module !== 'undefined' && module.exports) {\n\t\tclassNames.default = classNames;\n\t\tmodule.exports = classNames;\n\t} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {\n\t\t// register as 'classnames', consistent with npm package name\n\t\tdefine('classnames', [], function () {\n\t\t\treturn classNames;\n\t\t});\n\t} else {\n\t\twindow.classNames = classNames;\n\t}\n}());\n","import React, { forwardRef, type ReactNode } from \"react\";\nimport type { BaseProps } from \"@purpurds/common-types\";\nimport c from \"classnames/bind\";\n\nimport styles from \"./container.module.scss\";\n\nconst cx = c.bind(styles);\n\nexport const Width = {\n XS: \"xs\",\n SM: \"sm\",\n MD: \"md\",\n LG: \"lg\",\n XL: \"xl\",\n XXL: \"xxl\",\n} as const;\n\nexport type WidthType = (typeof Width)[keyof typeof Width];\n\nexport const Element = {\n DIV: \"div\",\n SPAN: \"span\",\n} as const;\n\nexport type ElementType = (typeof Element)[keyof typeof Element];\n\nexport type ContainerProps = Omit<BaseProps, \"children\"> & {\n children: ReactNode;\n width?: WidthType;\n element?: ElementType;\n};\n\nconst rootClassName = \"purpur-container\";\n\nexport const Container = forwardRef<HTMLDivElement, ContainerProps>(\n ({ children, className, width = \"xxl\", element: Element = \"div\", ...props }, ref) => {\n const classes = cx([className, rootClassName, `${rootClassName}--${width}`]);\n return (\n <Element className={classes} ref={ref} {...props}>\n {children}\n </Element>\n );\n }\n);\n\nContainer.displayName = \"Container\";\n"],"names":["hasOwn","classNames","classes","i","arg","appendClass","parseValue","key","value","newClass","module","cx","c","styles","Width","Element","rootClassName","Container","forwardRef","children","className","width","props","ref","jsx"],"mappings":";;;;;;;;;;;;;;AAOA,KAAC,WAAY;AAGZ,UAAIA,IAAS,CAAA,EAAG;AAEhB,eAASC,IAAc;AAGtB,iBAFIC,IAAU,IAELC,IAAI,GAAGA,IAAI,UAAU,QAAQA,KAAK;AAC1C,cAAIC,IAAM,UAAUD,CAAC;AACrB,UAAIC,MACHF,IAAUG,EAAYH,GAASI,EAAW,KAAK,MAAMF,CAAG,CAAC;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WAAA,gBAAAG,EAACT,GAAA,EAAQ,WAAWb,GAAS,KAAAqB,GAAW,GAAGD,GACxC,UAAAH,GACH;AAAA,EAAA;AAGN;AAEAF,EAAU,cAAc;","x_google_ignoreList":[0]}
|
package/dist/metadata.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@purpurds/container",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.8.0",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"main": "./dist/container.cjs.js",
|
|
6
6
|
"types": "./dist/container.d.ts",
|
|
@@ -16,24 +16,24 @@
|
|
|
16
16
|
"source": "src/container.tsx",
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"classnames": "~2.5.0",
|
|
19
|
-
"@purpurds/
|
|
19
|
+
"@purpurds/common-types": "7.8.0",
|
|
20
|
+
"@purpurds/tokens": "7.8.0"
|
|
20
21
|
},
|
|
21
22
|
"devDependencies": {
|
|
22
|
-
"
|
|
23
|
-
"@storybook/blocks": "^8.6.4",
|
|
24
|
-
"@storybook/react": "^8.6.4",
|
|
23
|
+
"@storybook/react-vite": "^9.0.18",
|
|
25
24
|
"@testing-library/dom": "~10.4.0",
|
|
26
25
|
"@testing-library/jest-dom": "~6.4.0",
|
|
27
26
|
"@testing-library/react": "~16.2.0",
|
|
28
27
|
"@types/node": "20.12.12",
|
|
29
28
|
"@types/react-dom": "^19.0.4",
|
|
30
29
|
"@types/react": "^19.0.10",
|
|
30
|
+
"eslint": "9.24.0",
|
|
31
31
|
"jsdom": "~22.1.0",
|
|
32
32
|
"lint-staged": "15.5.0",
|
|
33
33
|
"prettier": "~2.8.8",
|
|
34
34
|
"react-dom": "^19.0.0",
|
|
35
35
|
"react": "^19.0.0",
|
|
36
|
-
"storybook": "^
|
|
36
|
+
"storybook": "^9.0.18",
|
|
37
37
|
"typescript": "^5.6.3",
|
|
38
38
|
"vite": "^6.2.1",
|
|
39
39
|
"vitest": "^3.1.2",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
3
3
|
|
|
4
|
-
import { Container } from "./container";
|
|
4
|
+
import { Container, Element, Width } from "./container";
|
|
5
5
|
|
|
6
6
|
const meta = {
|
|
7
7
|
title: "Layout and Structure/Container",
|
|
@@ -21,16 +21,26 @@ const meta = {
|
|
|
21
21
|
},
|
|
22
22
|
argTypes: {
|
|
23
23
|
width: {
|
|
24
|
-
control: {
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
control: { type: "select" },
|
|
25
|
+
options: Object.values(Width),
|
|
26
|
+
table: {
|
|
27
|
+
type: {
|
|
28
|
+
summary: Object.values(Width)
|
|
29
|
+
.map((x) => `"${x}"`)
|
|
30
|
+
.join(" | "),
|
|
31
|
+
},
|
|
27
32
|
},
|
|
28
33
|
description: "Sets the width of the container.",
|
|
29
34
|
},
|
|
30
35
|
element: {
|
|
31
|
-
control: {
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
control: { type: "select" },
|
|
37
|
+
options: Object.values(Element),
|
|
38
|
+
table: {
|
|
39
|
+
type: {
|
|
40
|
+
summary: Object.values(Element)
|
|
41
|
+
.map((x) => `"${x}"`)
|
|
42
|
+
.join(" | "),
|
|
43
|
+
},
|
|
34
44
|
},
|
|
35
45
|
description: "Sets the HTML element used for the container.",
|
|
36
46
|
},
|
package/src/container.tsx
CHANGED
|
@@ -1,23 +1,39 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { forwardRef, type ReactNode } from "react";
|
|
2
|
+
import type { BaseProps } from "@purpurds/common-types";
|
|
2
3
|
import c from "classnames/bind";
|
|
3
4
|
|
|
4
5
|
import styles from "./container.module.scss";
|
|
6
|
+
|
|
5
7
|
const cx = c.bind(styles);
|
|
6
8
|
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
+
export const Width = {
|
|
10
|
+
XS: "xs",
|
|
11
|
+
SM: "sm",
|
|
12
|
+
MD: "md",
|
|
13
|
+
LG: "lg",
|
|
14
|
+
XL: "xl",
|
|
15
|
+
XXL: "xxl",
|
|
16
|
+
} as const;
|
|
17
|
+
|
|
18
|
+
export type WidthType = (typeof Width)[keyof typeof Width];
|
|
19
|
+
|
|
20
|
+
export const Element = {
|
|
21
|
+
DIV: "div",
|
|
22
|
+
SPAN: "span",
|
|
23
|
+
} as const;
|
|
24
|
+
|
|
25
|
+
export type ElementType = (typeof Element)[keyof typeof Element];
|
|
26
|
+
|
|
27
|
+
export type ContainerProps = Omit<BaseProps, "children"> & {
|
|
9
28
|
children: ReactNode;
|
|
10
|
-
width?:
|
|
11
|
-
element?:
|
|
29
|
+
width?: WidthType;
|
|
30
|
+
element?: ElementType;
|
|
12
31
|
};
|
|
13
32
|
|
|
14
33
|
const rootClassName = "purpur-container";
|
|
15
34
|
|
|
16
|
-
export const Container = forwardRef(
|
|
17
|
-
(
|
|
18
|
-
{ children, className, width = "xxl", element: Element = "div", ...props }: ContainerProps,
|
|
19
|
-
ref: ForwardedRef<HTMLDivElement>
|
|
20
|
-
) => {
|
|
35
|
+
export const Container = forwardRef<HTMLDivElement, ContainerProps>(
|
|
36
|
+
({ children, className, width = "xxl", element: Element = "div", ...props }, ref) => {
|
|
21
37
|
const classes = cx([className, rootClassName, `${rootClassName}--${width}`]);
|
|
22
38
|
return (
|
|
23
39
|
<Element className={classes} ref={ref} {...props}>
|