@protonradio/proton-ui 0.6.4 → 0.6.6
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 +50 -50
- package/dist/icons.svg +10 -10
- package/dist/index-BQ3T2g7K.mjs.map +1 -1
- package/dist/index-BjFfiHOL.js.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +397 -398
- package/dist/index.es.js.map +1 -1
- package/dist/utils.cjs.js.map +1 -1
- package/dist/utils.es.js.map +1 -1
- package/package.json +89 -77
package/dist/utils.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs.js","sources":["../src/utils/index.ts"],"sourcesContent":["const isString = (x: unknown): boolean =>\
|
|
1
|
+
{"version":3,"file":"utils.cjs.js","sources":["../src/utils/index.ts"],"sourcesContent":["const isString = (x: unknown): boolean =>\n typeof x === \"string\" || x instanceof String;\n\nexport function csx(...classnames: unknown[]): string {\n return classnames.filter(isString).join(\" \");\n}\n\n/**\n * [getLinkHost] - get the host of a link.\n * Referenced from is-url-external npm package\n * https://github.com/mrded/is-url-external/blob/master/index.js\n */\nconst getLinkHost = (url) => {\n if (/^https?:\\/\\//.test(url)) {\n // Absolute URL.\n // The easy way to parse an URL, is to create <a> element.\n // @see: https://gist.github.com/jlong/2428561\n const parser = document.createElement(\"a\");\n parser.href = url;\n return parser.hostname;\n }\n return window.location.hostname;\n};\n\n/**\n * [isUrlExternal] - determine if passed absolute url is external to the current domain.\n */\nexport const isUrlExternal = (url) => {\n const host = window.location.hostname;\n const linkHost = getLinkHost(url);\n\n return host !== linkHost;\n};\n\n/**\n * Handles internal navigation clicks by preventing default browser behavior and\n * programmatically updating the URL and history state.\n *\n * @param e - The click event from the anchor element\n * @param to - The destination path to navigate to\n *\n * @remarks\n * - Converts relative paths to absolute by prepending \"/\" if needed\n * - Updates browser history using pushState and dispatches a popstate event\n */\nexport const handleInternalNavigation = (\n e: React.MouseEvent<HTMLAnchorElement>,\n to: string\n) => {\n // Don't handle navigation if modifier keys are pressed\n if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) {\n return;\n }\n\n // Don't handle middle clicks or right clicks\n if (e.button && e.button !== 0) {\n return;\n }\n\n e.preventDefault();\n\n // Handle relative paths\n const resolvedPath = to.startsWith(\"/\") ? to : `/${to}`;\n window.history.pushState({}, \"\", resolvedPath);\n window.dispatchEvent(new PopStateEvent(\"popstate\"));\n};\n\nexport type RGBArray = [number, number, number];\n\nconst ceilColor = 179;\nconst floorColor = 42;\n\n/**\n * Lightens an RGB color by a specified factor.\n * @param rgb - The RGB color array to lighten.\n * @param factor - The factor between 0 (darker) - 1 (lighter) by which to transform the color.\n * @returns The lightened RGB color array, RGB values are clamped to 42 (dark) - 179 (light).\n */\nexport const lightenRGBColor = (rgb: RGBArray, factor: number): RGBArray => {\n const lightenedRGB = [\n Math.min(rgb[0] + 255 * factor, ceilColor),\n Math.min(rgb[1] + 255 * factor, ceilColor),\n Math.min(rgb[2] + 255 * factor, ceilColor),\n ];\n\n return lightenedRGB.map((value) =>\n Math.round(Math.max(value, floorColor))\n ) as RGBArray;\n};\n\n/**\n * Darkens an RGB color by a specified factor.\n * @param color - The RGB color array to darken.\n * @param factor - The factor between 0 (lighter) - 1 (darker) by which to transform the color.\n * @returns The darkened RGB color array, RGB values are clamped to 0 (light) - 255 (dark).\n */\n\nexport const darkenRGBColor = (color: RGBArray, factor: number): RGBArray => {\n return color.map((c) => Math.max(0, c - c * factor)) as RGBArray;\n};\n\n/**\n * Converts an RGB array to a CSS string representation.\n * @param rgb - The RGB array to convert.\n * @param opacity - Optional opacity value.\n * @returns A CSS string representation of the RGB array, using `rgb()`, or `rgba()` if an opacity value is provided.\n */\nexport const arrayToRgbString = (rgb: RGBArray, opacity?: number): string => {\n return opacity === undefined\n ? `rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`\n : `rgba(${rgb[0]}, ${rgb[1]}, ${rgb[2]}, ${opacity})`;\n};\n"],"names":["isString","x","csx","classnames","getLinkHost","url","parser","isUrlExternal","host","linkHost","handleInternalNavigation","e","to","resolvedPath","ceilColor","floorColor","lightenRGBColor","rgb","factor","value","darkenRGBColor","color","c","arrayToRgbString","opacity"],"mappings":"gFAAA,MAAMA,EAAYC,GAChB,OAAOA,GAAM,UAAYA,aAAa,OAEjC,SAASC,KAAOC,EAA+B,CACpD,OAAOA,EAAW,OAAOH,CAAQ,EAAE,KAAK,GAAG,CAC7C,CAOA,MAAMI,EAAeC,GAAQ,CACvB,GAAA,eAAe,KAAKA,CAAG,EAAG,CAItB,MAAAC,EAAS,SAAS,cAAc,GAAG,EACzC,OAAAA,EAAO,KAAOD,EACPC,EAAO,QAChB,CACA,OAAO,OAAO,SAAS,QACzB,EAKaC,EAAiBF,GAAQ,CAC9B,MAAAG,EAAO,OAAO,SAAS,SACvBC,EAAWL,EAAYC,CAAG,EAEhC,OAAOG,IAASC,CAClB,EAaaC,EAA2B,CACtCC,EACAC,IACG,CAOH,GALID,EAAE,SAAWA,EAAE,QAAUA,EAAE,SAAWA,EAAE,UAKxCA,EAAE,QAAUA,EAAE,SAAW,EAC3B,OAGFA,EAAE,eAAe,EAGjB,MAAME,EAAeD,EAAG,WAAW,GAAG,EAAIA,EAAK,IAAIA,CAAE,GACrD,OAAO,QAAQ,UAAU,CAAC,EAAG,GAAIC,CAAY,EAC7C,OAAO,cAAc,IAAI,cAAc,UAAU,CAAC,CACpD,EAIMC,EAAY,IACZC,EAAa,GAQNC,EAAkB,CAACC,EAAeC,IACxB,CACnB,KAAK,IAAID,EAAI,CAAC,EAAI,IAAMC,EAAQJ,CAAS,EACzC,KAAK,IAAIG,EAAI,CAAC,EAAI,IAAMC,EAAQJ,CAAS,EACzC,KAAK,IAAIG,EAAI,CAAC,EAAI,IAAMC,EAAQJ,CAAS,CAAA,EAGvB,IAAKK,GACvB,KAAK,MAAM,KAAK,IAAIA,EAAOJ,CAAU,CAAC,CAAA,EAW7BK,EAAiB,CAACC,EAAiBH,IACvCG,EAAM,IAAKC,GAAM,KAAK,IAAI,EAAGA,EAAIA,EAAIJ,CAAM,CAAC,EASxCK,EAAmB,CAACN,EAAeO,IACvCA,IAAY,OACf,OAAOP,EAAI,CAAC,CAAC,KAAKA,EAAI,CAAC,CAAC,KAAKA,EAAI,CAAC,CAAC,IACnC,QAAQA,EAAI,CAAC,CAAC,KAAKA,EAAI,CAAC,CAAC,KAAKA,EAAI,CAAC,CAAC,KAAKO,CAAO"}
|
package/dist/utils.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.es.js","sources":["../src/utils/index.ts"],"sourcesContent":["const isString = (x: unknown): boolean =>\
|
|
1
|
+
{"version":3,"file":"utils.es.js","sources":["../src/utils/index.ts"],"sourcesContent":["const isString = (x: unknown): boolean =>\n typeof x === \"string\" || x instanceof String;\n\nexport function csx(...classnames: unknown[]): string {\n return classnames.filter(isString).join(\" \");\n}\n\n/**\n * [getLinkHost] - get the host of a link.\n * Referenced from is-url-external npm package\n * https://github.com/mrded/is-url-external/blob/master/index.js\n */\nconst getLinkHost = (url) => {\n if (/^https?:\\/\\//.test(url)) {\n // Absolute URL.\n // The easy way to parse an URL, is to create <a> element.\n // @see: https://gist.github.com/jlong/2428561\n const parser = document.createElement(\"a\");\n parser.href = url;\n return parser.hostname;\n }\n return window.location.hostname;\n};\n\n/**\n * [isUrlExternal] - determine if passed absolute url is external to the current domain.\n */\nexport const isUrlExternal = (url) => {\n const host = window.location.hostname;\n const linkHost = getLinkHost(url);\n\n return host !== linkHost;\n};\n\n/**\n * Handles internal navigation clicks by preventing default browser behavior and\n * programmatically updating the URL and history state.\n *\n * @param e - The click event from the anchor element\n * @param to - The destination path to navigate to\n *\n * @remarks\n * - Converts relative paths to absolute by prepending \"/\" if needed\n * - Updates browser history using pushState and dispatches a popstate event\n */\nexport const handleInternalNavigation = (\n e: React.MouseEvent<HTMLAnchorElement>,\n to: string\n) => {\n // Don't handle navigation if modifier keys are pressed\n if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) {\n return;\n }\n\n // Don't handle middle clicks or right clicks\n if (e.button && e.button !== 0) {\n return;\n }\n\n e.preventDefault();\n\n // Handle relative paths\n const resolvedPath = to.startsWith(\"/\") ? to : `/${to}`;\n window.history.pushState({}, \"\", resolvedPath);\n window.dispatchEvent(new PopStateEvent(\"popstate\"));\n};\n\nexport type RGBArray = [number, number, number];\n\nconst ceilColor = 179;\nconst floorColor = 42;\n\n/**\n * Lightens an RGB color by a specified factor.\n * @param rgb - The RGB color array to lighten.\n * @param factor - The factor between 0 (darker) - 1 (lighter) by which to transform the color.\n * @returns The lightened RGB color array, RGB values are clamped to 42 (dark) - 179 (light).\n */\nexport const lightenRGBColor = (rgb: RGBArray, factor: number): RGBArray => {\n const lightenedRGB = [\n Math.min(rgb[0] + 255 * factor, ceilColor),\n Math.min(rgb[1] + 255 * factor, ceilColor),\n Math.min(rgb[2] + 255 * factor, ceilColor),\n ];\n\n return lightenedRGB.map((value) =>\n Math.round(Math.max(value, floorColor))\n ) as RGBArray;\n};\n\n/**\n * Darkens an RGB color by a specified factor.\n * @param color - The RGB color array to darken.\n * @param factor - The factor between 0 (lighter) - 1 (darker) by which to transform the color.\n * @returns The darkened RGB color array, RGB values are clamped to 0 (light) - 255 (dark).\n */\n\nexport const darkenRGBColor = (color: RGBArray, factor: number): RGBArray => {\n return color.map((c) => Math.max(0, c - c * factor)) as RGBArray;\n};\n\n/**\n * Converts an RGB array to a CSS string representation.\n * @param rgb - The RGB array to convert.\n * @param opacity - Optional opacity value.\n * @returns A CSS string representation of the RGB array, using `rgb()`, or `rgba()` if an opacity value is provided.\n */\nexport const arrayToRgbString = (rgb: RGBArray, opacity?: number): string => {\n return opacity === undefined\n ? `rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`\n : `rgba(${rgb[0]}, ${rgb[1]}, ${rgb[2]}, ${opacity})`;\n};\n"],"names":["isString","x","csx","classnames","getLinkHost","url","parser","isUrlExternal","host","linkHost","handleInternalNavigation","e","to","resolvedPath","ceilColor","floorColor","lightenRGBColor","rgb","factor","value","darkenRGBColor","color","c","arrayToRgbString","opacity"],"mappings":"AAAA,MAAMA,IAAW,CAACC,MAChB,OAAOA,KAAM,YAAYA,aAAa;AAEjC,SAASC,KAAOC,GAA+B;AACpD,SAAOA,EAAW,OAAOH,CAAQ,EAAE,KAAK,GAAG;AAC7C;AAOA,MAAMI,IAAc,CAACC,MAAQ;AACvB,MAAA,eAAe,KAAKA,CAAG,GAAG;AAItB,UAAAC,IAAS,SAAS,cAAc,GAAG;AACzC,WAAAA,EAAO,OAAOD,GACPC,EAAO;AAAA,EAChB;AACA,SAAO,OAAO,SAAS;AACzB,GAKaC,IAAgB,CAACF,MAAQ;AAC9B,QAAAG,IAAO,OAAO,SAAS,UACvBC,IAAWL,EAAYC,CAAG;AAEhC,SAAOG,MAASC;AAClB,GAaaC,IAA2B,CACtCC,GACAC,MACG;AAOH,MALID,EAAE,WAAWA,EAAE,UAAUA,EAAE,WAAWA,EAAE,YAKxCA,EAAE,UAAUA,EAAE,WAAW;AAC3B;AAGF,EAAAA,EAAE,eAAe;AAGjB,QAAME,IAAeD,EAAG,WAAW,GAAG,IAAIA,IAAK,IAAIA,CAAE;AACrD,SAAO,QAAQ,UAAU,CAAC,GAAG,IAAIC,CAAY,GAC7C,OAAO,cAAc,IAAI,cAAc,UAAU,CAAC;AACpD,GAIMC,IAAY,KACZC,IAAa,IAQNC,IAAkB,CAACC,GAAeC,MACxB;AAAA,EACnB,KAAK,IAAID,EAAI,CAAC,IAAI,MAAMC,GAAQJ,CAAS;AAAA,EACzC,KAAK,IAAIG,EAAI,CAAC,IAAI,MAAMC,GAAQJ,CAAS;AAAA,EACzC,KAAK,IAAIG,EAAI,CAAC,IAAI,MAAMC,GAAQJ,CAAS;AAAA,EAGvB;AAAA,EAAI,CAACK,MACvB,KAAK,MAAM,KAAK,IAAIA,GAAOJ,CAAU,CAAC;AAAA,GAW7BK,IAAiB,CAACC,GAAiBH,MACvCG,EAAM,IAAI,CAACC,MAAM,KAAK,IAAI,GAAGA,IAAIA,IAAIJ,CAAM,CAAC,GASxCK,IAAmB,CAACN,GAAeO,MACvCA,MAAY,SACf,OAAOP,EAAI,CAAC,CAAC,KAAKA,EAAI,CAAC,CAAC,KAAKA,EAAI,CAAC,CAAC,MACnC,QAAQA,EAAI,CAAC,CAAC,KAAKA,EAAI,CAAC,CAAC,KAAKA,EAAI,CAAC,CAAC,KAAKO,CAAO;"}
|
package/package.json
CHANGED
|
@@ -1,77 +1,89 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@protonradio/proton-ui",
|
|
3
|
-
"version": "0.6.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "./dist/proton-ui.umd.js",
|
|
6
|
-
"module": "./dist/proton-ui.es.js",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": {
|
|
9
|
-
"import": "./dist/index.es.js",
|
|
10
|
-
"require": "./dist/index.cjs.js",
|
|
11
|
-
"types": "./dist/index.d.ts"
|
|
12
|
-
},
|
|
13
|
-
"./utils": {
|
|
14
|
-
"import": "./dist/utils.es.js",
|
|
15
|
-
"require": "./dist/utils.cjs.js",
|
|
16
|
-
"types": "./dist/utils.d.ts"
|
|
17
|
-
},
|
|
18
|
-
"./constants": {
|
|
19
|
-
"import": "./dist/constants.es.js",
|
|
20
|
-
"require": "./dist/constants.cjs.js",
|
|
21
|
-
"types": "./dist/constants.d.ts"
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
"@storybook/
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
"@
|
|
64
|
-
"@
|
|
65
|
-
"@
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"react
|
|
71
|
-
"storybook": "^8.4.2",
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
|
|
77
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@protonradio/proton-ui",
|
|
3
|
+
"version": "0.6.6",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "./dist/proton-ui.umd.js",
|
|
6
|
+
"module": "./dist/proton-ui.es.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./dist/index.es.js",
|
|
10
|
+
"require": "./dist/index.cjs.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"./utils": {
|
|
14
|
+
"import": "./dist/utils.es.js",
|
|
15
|
+
"require": "./dist/utils.cjs.js",
|
|
16
|
+
"types": "./dist/utils.d.ts"
|
|
17
|
+
},
|
|
18
|
+
"./constants": {
|
|
19
|
+
"import": "./dist/constants.es.js",
|
|
20
|
+
"require": "./dist/constants.cjs.js",
|
|
21
|
+
"types": "./dist/constants.d.ts"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"typesVersions": {
|
|
25
|
+
"*": {
|
|
26
|
+
"*": [
|
|
27
|
+
"./dist/index.d.ts"
|
|
28
|
+
],
|
|
29
|
+
"constants": [
|
|
30
|
+
"./dist/constants.d.ts"
|
|
31
|
+
],
|
|
32
|
+
"utils": [
|
|
33
|
+
"./dist/utils.d.ts"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"dev": "vite",
|
|
39
|
+
"build": "vite build",
|
|
40
|
+
"preview": "vite preview",
|
|
41
|
+
"storybook": "storybook dev -p 6006",
|
|
42
|
+
"storybook:build": "storybook build",
|
|
43
|
+
"test": "jest",
|
|
44
|
+
"dev-test": "jest --watch",
|
|
45
|
+
"prepare": "vite build",
|
|
46
|
+
"chromatic": "npx chromatic --exit-once-uploaded flag --force-rebuild --project-token=$CHROMATIC_PROJECT_TOKEN",
|
|
47
|
+
"omlet:analyze": "npx @omlet/cli analyze"
|
|
48
|
+
},
|
|
49
|
+
"files": [
|
|
50
|
+
"dist"
|
|
51
|
+
],
|
|
52
|
+
"author": "",
|
|
53
|
+
"license": "MIT",
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@storybook/cli": "^8.4.2",
|
|
56
|
+
"react": "^18.3.1",
|
|
57
|
+
"react-aria": "^3.35.1",
|
|
58
|
+
"react-aria-components": "^1.4.1",
|
|
59
|
+
"react-dom": "^18.3.1",
|
|
60
|
+
"react-stately": "^3.33.0"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@chromatic-com/storybook": "^3.2.2",
|
|
64
|
+
"@storybook/addon-a11y": "^8.4.2",
|
|
65
|
+
"@storybook/addon-essentials": "^8.4.2",
|
|
66
|
+
"@storybook/addon-interactions": "^8.4.2",
|
|
67
|
+
"@storybook/addon-links": "^8.4.2",
|
|
68
|
+
"@storybook/addon-onboarding": "^8.4.2",
|
|
69
|
+
"@storybook/blocks": "^8.4.2",
|
|
70
|
+
"@storybook/react": "^8.4.2",
|
|
71
|
+
"@storybook/react-vite": "^8.4.2",
|
|
72
|
+
"@storybook/test": "^8.4.2",
|
|
73
|
+
"@testing-library/jest-dom": "^6.6.3",
|
|
74
|
+
"@testing-library/react": "^16.0.1",
|
|
75
|
+
"@testing-library/user-event": "^14.5.2",
|
|
76
|
+
"@types/jest": "^29.5.14",
|
|
77
|
+
"@vitejs/plugin-react": "^4.3.3",
|
|
78
|
+
"colorthief": "^2.6.0",
|
|
79
|
+
"jest": "^29.7.0",
|
|
80
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
81
|
+
"lightningcss": "^1.28.1",
|
|
82
|
+
"react-docgen-typescript": "^2.2.2",
|
|
83
|
+
"storybook": "^8.4.2",
|
|
84
|
+
"ts-jest": "^29.2.5",
|
|
85
|
+
"ts-node": "^10.9.2",
|
|
86
|
+
"vite": "^5.4.10",
|
|
87
|
+
"vite-plugin-dts": "^4.3.0"
|
|
88
|
+
}
|
|
89
|
+
}
|