@pindoba/core-alert 0.0.0-alpha-20260320034942

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/LICENSE ADDED
@@ -0,0 +1,12 @@
1
+ Copyright 2025 Eduardo Lopes
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
8
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
9
+ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
10
+ FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
11
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
12
+ DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,3 @@
1
+ import { AlertApi, AlertBaseProps, AlertBorder, AlertClasses, AlertEmphasis, AlertFeedback, AlertHeaderOrientation, AlertPadding, AlertPassThrough, AlertRadius, AlertRootProps, AlertSize, AlertSlotPassThrough, ConnectAlertOptions, ElementAttributes } from "./src/types.js";
2
+ import { alertDefaults, connectAlert } from "./src/connect-alert.js";
3
+ export { type AlertApi, type AlertBaseProps, type AlertBorder, type AlertClasses, type AlertEmphasis, type AlertFeedback, type AlertHeaderOrientation, type AlertPadding, type AlertPassThrough, type AlertRadius, type AlertRootProps, type AlertSize, type AlertSlotPassThrough, type ConnectAlertOptions, type ElementAttributes, alertDefaults, connectAlert };
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import { alertDefaults, connectAlert } from "./src/connect-alert.js";
2
+ export { alertDefaults, connectAlert };
@@ -0,0 +1,15 @@
1
+ import { AlertApi, ConnectAlertOptions } from "./types.js";
2
+
3
+ //#region src/connect-alert.d.ts
4
+ declare const alertDefaults: {
5
+ readonly feedback: "default";
6
+ readonly emphasis: "primary";
7
+ readonly size: "md";
8
+ readonly radius: "md";
9
+ readonly padding: "2xs";
10
+ readonly translucent: false;
11
+ };
12
+ declare function connectAlert(options: ConnectAlertOptions): AlertApi;
13
+ //#endregion
14
+ export { alertDefaults, connectAlert };
15
+ //# sourceMappingURL=connect-alert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connect-alert.d.ts","names":[],"sources":["../../src/connect-alert.ts"],"mappings":";;;cAWa,aAAA;EAAA;;;;;;;iBA4BG,YAAA,CAAa,OAAA,EAAS,mBAAA,GAAsB,QAAA"}
@@ -0,0 +1,68 @@
1
+ import { css } from "@pindoba/styled-system/css";
2
+ import { panelStyles } from "@pindoba/styles-panel";
3
+ import { alertStyles } from "@pindoba/styles-alert";
4
+ //#region src/connect-alert.ts
5
+ const alertDefaults = {
6
+ feedback: "default",
7
+ emphasis: "primary",
8
+ size: "md",
9
+ radius: "md",
10
+ padding: "2xs",
11
+ translucent: false
12
+ };
13
+ /**
14
+ * Maps alert feedback values to panel feedback values.
15
+ * Alert's "default" maps to panel's "primary" (both set colorPalette: "primary").
16
+ * Other values are shared 1:1.
17
+ */
18
+ function mapFeedbackToPanel(feedback) {
19
+ return {
20
+ default: "primary",
21
+ success: "success",
22
+ danger: "danger",
23
+ warning: "warning"
24
+ }[feedback];
25
+ }
26
+ function connectAlert(options) {
27
+ const { feedback = alertDefaults.feedback, emphasis = alertDefaults.emphasis, size = alertDefaults.size, noIcon: _noIcon, border, radius = alertDefaults.radius, padding = alertDefaults.padding, translucent = alertDefaults.translucent, headerOrientation = "row", passThrough, class: className, ...restProps } = options;
28
+ const panelFeedback = mapFeedbackToPanel(feedback);
29
+ const panelAccent = emphasis === "primary";
30
+ const panelBackground = emphasis === "primary" ? "surface" : "sunken";
31
+ const resolvedBorder = border ?? (emphasis === "primary" ? "none" : "muted");
32
+ const panelClasses = panelStyles.raw({
33
+ feedback: panelFeedback,
34
+ accent: panelAccent,
35
+ background: panelBackground,
36
+ border: resolvedBorder,
37
+ radius,
38
+ padding,
39
+ translucent,
40
+ interactive: false
41
+ });
42
+ const slotClasses = alertStyles.raw({
43
+ emphasis,
44
+ size,
45
+ headerOrientation
46
+ });
47
+ const generatedClass = css(panelClasses.root, slotClasses.root, passThrough?.root?.style);
48
+ const userClass = className != null ? String(className) : void 0;
49
+ return {
50
+ rootProps: {
51
+ ...restProps,
52
+ ...passThrough?.root?.props,
53
+ "data-component": "alert",
54
+ class: userClass ? `${generatedClass} ${userClass}` : generatedClass
55
+ },
56
+ classes: {
57
+ header: css(slotClasses.header, passThrough?.header?.style),
58
+ icon: css(slotClasses.icon, passThrough?.icon?.style),
59
+ title: css(slotClasses.title, passThrough?.title?.style),
60
+ actions: css(slotClasses.actions, passThrough?.actions?.style),
61
+ content: css(slotClasses.content, passThrough?.content?.style)
62
+ }
63
+ };
64
+ }
65
+ //#endregion
66
+ export { alertDefaults, connectAlert };
67
+
68
+ //# sourceMappingURL=connect-alert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connect-alert.js","names":[],"sources":["../../src/connect-alert.ts"],"sourcesContent":["import { css } from \"@pindoba/styled-system/css\";\nimport { panelStyles, type PanelStyleProps } from \"@pindoba/styles-panel\";\nimport { alertStyles } from \"@pindoba/styles-alert\";\nimport type {\n ConnectAlertOptions,\n AlertFeedback,\n AlertApi,\n AlertRootProps,\n AlertBaseProps,\n} from \"./types.js\";\n\nexport const alertDefaults = {\n feedback: \"default\",\n emphasis: \"primary\",\n size: \"md\",\n radius: \"md\",\n padding: \"2xs\",\n translucent: false,\n} as const satisfies Partial<AlertBaseProps>;\n\ntype PanelFeedback = NonNullable<PanelStyleProps[\"feedback\"]>;\ntype PanelBackground = NonNullable<PanelStyleProps[\"background\"]>;\ntype PanelBorder = NonNullable<PanelStyleProps[\"border\"]>;\n\n/**\n * Maps alert feedback values to panel feedback values.\n * Alert's \"default\" maps to panel's \"primary\" (both set colorPalette: \"primary\").\n * Other values are shared 1:1.\n */\nfunction mapFeedbackToPanel(feedback: AlertFeedback): PanelFeedback {\n const feedbackMap: Record<AlertFeedback, PanelFeedback> = {\n default: \"primary\",\n success: \"success\",\n danger: \"danger\",\n warning: \"warning\",\n };\n return feedbackMap[feedback];\n}\n\nexport function connectAlert(options: ConnectAlertOptions): AlertApi {\n const {\n feedback = alertDefaults.feedback,\n emphasis = alertDefaults.emphasis,\n size = alertDefaults.size,\n noIcon: _noIcon,\n border,\n radius = alertDefaults.radius,\n padding = alertDefaults.padding,\n translucent = alertDefaults.translucent,\n headerOrientation = \"row\",\n passThrough,\n class: className,\n ...restProps\n } = options;\n\n const panelFeedback = mapFeedbackToPanel(feedback);\n\n // Map alert emphasis to panel surface config:\n // - primary: full-color outer container (accent=true + background=\"surface\")\n // - secondary/tertiary: neutral sunken outer (background=\"sunken\")\n const panelAccent = emphasis === \"primary\";\n const panelBackground: PanelBackground =\n emphasis === \"primary\" ? \"surface\" : \"sunken\";\n\n // Default border: primary has no visible border (full-color bg provides contrast),\n // secondary/tertiary get a muted border for separation.\n const resolvedBorder: PanelBorder =\n border ?? (emphasis === \"primary\" ? \"none\" : \"muted\");\n\n // Panel handles root surface: background, color, boxShadow (border/elevation),\n // borderRadius, padding, colorPalette.\n const panelClasses = panelStyles.raw({\n feedback: panelFeedback,\n accent: panelAccent,\n background: panelBackground,\n border: resolvedBorder,\n radius,\n padding,\n translucent,\n interactive: false,\n });\n\n // Alert styles handle layout (display, flex, gap) and inner slot styling.\n const slotClasses = alertStyles.raw({\n emphasis,\n size,\n headerOrientation,\n });\n\n // Merge: panel surface → alert layout + inner slots.\n // Alert's root layout (display, flex, gap, fontSize) takes precedence over\n // any conflicting Panel layout properties.\n const generatedClass = css(\n panelClasses.root,\n slotClasses.root,\n passThrough?.root?.style,\n );\n\n const userClass = className != null ? String(className) : undefined;\n\n const rootProps: AlertRootProps = {\n ...restProps,\n ...passThrough?.root?.props,\n \"data-component\": \"alert\",\n class: userClass ? `${generatedClass} ${userClass}` : generatedClass,\n };\n\n return {\n rootProps,\n classes: {\n header: css(slotClasses.header, passThrough?.header?.style),\n icon: css(slotClasses.icon, passThrough?.icon?.style),\n title: css(slotClasses.title, passThrough?.title?.style),\n actions: css(slotClasses.actions, passThrough?.actions?.style),\n content: css(slotClasses.content, passThrough?.content?.style),\n },\n };\n}\n"],"mappings":";;;;AAWA,MAAa,gBAAgB;CAC3B,UAAU;CACV,UAAU;CACV,MAAM;CACN,QAAQ;CACR,SAAS;CACT,aAAa;CACd;;;;;;AAWD,SAAS,mBAAmB,UAAwC;AAOlE,QAN0D;EACxD,SAAS;EACT,SAAS;EACT,QAAQ;EACR,SAAS;EACV,CACkB;;AAGrB,SAAgB,aAAa,SAAwC;CACnE,MAAM,EACJ,WAAW,cAAc,UACzB,WAAW,cAAc,UACzB,OAAO,cAAc,MACrB,QAAQ,SACR,QACA,SAAS,cAAc,QACvB,UAAU,cAAc,SACxB,cAAc,cAAc,aAC5B,oBAAoB,OACpB,aACA,OAAO,WACP,GAAG,cACD;CAEJ,MAAM,gBAAgB,mBAAmB,SAAS;CAKlD,MAAM,cAAc,aAAa;CACjC,MAAM,kBACJ,aAAa,YAAY,YAAY;CAIvC,MAAM,iBACJ,WAAW,aAAa,YAAY,SAAS;CAI/C,MAAM,eAAe,YAAY,IAAI;EACnC,UAAU;EACV,QAAQ;EACR,YAAY;EACZ,QAAQ;EACR;EACA;EACA;EACA,aAAa;EACd,CAAC;CAGF,MAAM,cAAc,YAAY,IAAI;EAClC;EACA;EACA;EACD,CAAC;CAKF,MAAM,iBAAiB,IACrB,aAAa,MACb,YAAY,MACZ,aAAa,MAAM,MACpB;CAED,MAAM,YAAY,aAAa,OAAO,OAAO,UAAU,GAAG,KAAA;AAS1D,QAAO;EACL,WARgC;GAChC,GAAG;GACH,GAAG,aAAa,MAAM;GACtB,kBAAkB;GAClB,OAAO,YAAY,GAAG,eAAe,GAAG,cAAc;GACvD;EAIC,SAAS;GACP,QAAQ,IAAI,YAAY,QAAQ,aAAa,QAAQ,MAAM;GAC3D,MAAM,IAAI,YAAY,MAAM,aAAa,MAAM,MAAM;GACrD,OAAO,IAAI,YAAY,OAAO,aAAa,OAAO,MAAM;GACxD,SAAS,IAAI,YAAY,SAAS,aAAa,SAAS,MAAM;GAC9D,SAAS,IAAI,YAAY,SAAS,aAAa,SAAS,MAAM;GAC/D;EACF"}
@@ -0,0 +1,67 @@
1
+ import { PanelStyleProps } from "@pindoba/styles-panel";
2
+ import { AlertStyleProps } from "@pindoba/styles-alert";
3
+ import { SystemStyleObject } from "@pindoba/styled-system/types";
4
+
5
+ //#region src/types.d.ts
6
+ type ElementAttributes = Partial<Record<string, unknown>>;
7
+ type AlertFeedback = "success" | "danger" | "warning" | "default";
8
+ type AlertEmphasis = NonNullable<AlertStyleProps["emphasis"]>;
9
+ type AlertSize = NonNullable<AlertStyleProps["size"]>;
10
+ type AlertHeaderOrientation = NonNullable<AlertStyleProps["headerOrientation"]>;
11
+ type AlertBorder = NonNullable<PanelStyleProps["border"]>;
12
+ type AlertRadius = NonNullable<PanelStyleProps["radius"]>;
13
+ type AlertPadding = NonNullable<PanelStyleProps["padding"]>;
14
+ interface AlertSlotPassThrough<T = ElementAttributes> {
15
+ style?: SystemStyleObject;
16
+ props?: T;
17
+ }
18
+ interface AlertPassThrough<RootElementAttributes = ElementAttributes> {
19
+ root?: AlertSlotPassThrough<RootElementAttributes>;
20
+ header?: AlertSlotPassThrough;
21
+ icon?: AlertSlotPassThrough;
22
+ title?: AlertSlotPassThrough;
23
+ actions?: AlertSlotPassThrough;
24
+ content?: AlertSlotPassThrough;
25
+ }
26
+ /**
27
+ * Base alert props shared across all frameworks (Svelte, Astro).
28
+ * Each framework extends this with its own additions.
29
+ */
30
+ interface AlertBaseProps<RootElementAttributes = ElementAttributes> {
31
+ feedback?: AlertFeedback;
32
+ emphasis?: AlertEmphasis;
33
+ size?: AlertSize;
34
+ noIcon?: boolean;
35
+ border?: AlertBorder;
36
+ radius?: AlertRadius;
37
+ padding?: AlertPadding;
38
+ translucent?: boolean;
39
+ passThrough?: AlertPassThrough<RootElementAttributes>;
40
+ }
41
+ /**
42
+ * Options for connectAlert. Framework components can spread their props
43
+ * directly into this function.
44
+ */
45
+ interface ConnectAlertOptions extends AlertBaseProps<object> {
46
+ headerOrientation?: AlertHeaderOrientation;
47
+ class?: unknown;
48
+ }
49
+ interface AlertClasses {
50
+ header: string;
51
+ icon: string;
52
+ title: string;
53
+ actions: string;
54
+ content: string;
55
+ }
56
+ interface AlertRootProps {
57
+ class: string;
58
+ "data-component": "alert";
59
+ [key: string]: unknown;
60
+ }
61
+ interface AlertApi {
62
+ rootProps: AlertRootProps;
63
+ classes: AlertClasses;
64
+ }
65
+ //#endregion
66
+ export { AlertApi, AlertBaseProps, AlertBorder, AlertClasses, AlertEmphasis, AlertFeedback, AlertHeaderOrientation, AlertPadding, AlertPassThrough, AlertRadius, AlertRootProps, AlertSize, AlertSlotPassThrough, ConnectAlertOptions, ElementAttributes };
67
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../../src/types.ts"],"mappings":";;;;;KAMY,iBAAA,GAAoB,OAAA,CAAQ,MAAA;AAAA,KAI5B,aAAA;AAAA,KACA,aAAA,GAAgB,WAAA,CAAY,eAAA;AAAA,KAC5B,SAAA,GAAY,WAAA,CAAY,eAAA;AAAA,KACxB,sBAAA,GAAyB,WAAA,CACnC,eAAA;AAAA,KAGU,WAAA,GAAc,WAAA,CAAY,eAAA;AAAA,KAC1B,WAAA,GAAc,WAAA,CAAY,eAAA;AAAA,KAC1B,YAAA,GAAe,WAAA,CAAY,eAAA;AAAA,UAItB,oBAAA,KAAyB,iBAAA;EACxC,KAAA,GAAQ,iBAAA;EACR,KAAA,GAAQ,CAAA;AAAA;AAAA,UAGO,gBAAA,yBAAyC,iBAAA;EACxD,IAAA,GAAO,oBAAA,CAAqB,qBAAA;EAC5B,MAAA,GAAS,oBAAA;EACT,IAAA,GAAO,oBAAA;EACP,KAAA,GAAQ,oBAAA;EACR,OAAA,GAAU,oBAAA;EACV,OAAA,GAAU,oBAAA;AAAA;;;AArBZ;;UA8BiB,cAAA,yBAAuC,iBAAA;EACtD,QAAA,GAAW,aAAA;EACX,QAAA,GAAW,aAAA;EACX,IAAA,GAAO,SAAA;EACP,MAAA;EACA,MAAA,GAAS,WAAA;EACT,MAAA,GAAS,WAAA;EACT,OAAA,GAAU,YAAA;EACV,WAAA;EACA,WAAA,GAAc,gBAAA,CAAiB,qBAAA;AAAA;;;AAjCjC;;UA0CiB,mBAAA,SAA4B,cAAA;EAC3C,iBAAA,GAAoB,sBAAA;EACpB,KAAA;AAAA;AAAA,UAGe,YAAA;EACf,MAAA;EACA,IAAA;EACA,KAAA;EACA,OAAA;EACA,OAAA;AAAA;AAAA,UAGe,cAAA;EACf,KAAA;EACA,gBAAA;EAAA,CACC,GAAA;AAAA;AAAA,UAGc,QAAA;EACf,SAAA,EAAW,cAAA;EACX,OAAA,EAAS,YAAA;AAAA"}
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@pindoba/core-alert",
3
+ "version": "0.0.0-alpha-20260320034942",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "sideEffects": false,
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ },
14
+ "./*": {
15
+ "types": "./dist/src/*.d.ts",
16
+ "import": "./dist/src/*.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "dependencies": {
23
+ "@pindoba/styles-panel": "0.0.0-alpha-20260320034942",
24
+ "@pindoba/styled-system": "0.0.0-alpha-20260320034942",
25
+ "@pindoba/styles-alert": "0.0.0-alpha-20260320034942"
26
+ },
27
+ "devDependencies": {
28
+ "typescript": "^5.9.3",
29
+ "tsdown": "^0.21.2"
30
+ },
31
+ "scripts": {
32
+ "build": "tsdown",
33
+ "dev": "tsdown --watch",
34
+ "clean": "rm -rf dist && rm -rf node_modules && rm -rf .turbo"
35
+ }
36
+ }