karsten-design-system 1.0.67 → 1.0.69

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/index.js CHANGED
@@ -32,4 +32,5 @@ export { EmptyContent } from './stories/components/emptyContent.js';
32
32
  export { Select } from './stories/components/select.js';
33
33
  export { CalendarInput } from './stories/components/calendarInput.js';
34
34
  export { Table } from './stories/components/table.js';
35
+ import './stories/components/customToast.js';
35
36
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,43 @@
1
+ import { j as jsxRuntimeExports } from '../../_virtual/jsx-runtime.js';
2
+ import clsx from 'clsx';
3
+ import { Toast } from 'primereact/toast';
4
+ import { forwardRef, useRef, useImperativeHandle } from 'react';
5
+ import SuccessIcon from '../../assets/icons/success.js';
6
+ import ErrorIcon from '../../assets/icons/error.js';
7
+ import InfoIcon from '../../assets/icons/info.js';
8
+
9
+ function CustomToast(props, ref) {
10
+ const { severity = 'info', summary = '', detail = '', life = 3000, onShow } = props;
11
+ const customToastRef = useRef(null);
12
+ function getIcon(severity) {
13
+ switch (severity) {
14
+ case 'success':
15
+ return SuccessIcon;
16
+ case 'error':
17
+ return ErrorIcon;
18
+ default:
19
+ return InfoIcon;
20
+ }
21
+ }
22
+ useImperativeHandle(ref, () => ({
23
+ show: (showProps) => {
24
+ const mergedProps = { severity, summary, detail, life, onShow, ...showProps };
25
+ customToastRef.current?.show({
26
+ severity: mergedProps.severity,
27
+ summary: mergedProps.summary,
28
+ detail: mergedProps.detail,
29
+ life: mergedProps.life,
30
+ className: clsx(mergedProps.severity === 'error' ? 'border-redError' : 'border-primary'),
31
+ icon: getIcon(mergedProps.severity),
32
+ contentClassName: clsx('text-primary bg-secondary border border-l-4 rounded-r-lg', mergedProps.severity === 'error'
33
+ ? 'border-redError text-redError'
34
+ : 'border-primary text-primary'),
35
+ closeIcon: clsx('pi pi-times text-primary', mergedProps.severity === 'error' ? 'text-redError' : 'text-primary'),
36
+ });
37
+ mergedProps.onShow?.();
38
+ },
39
+ }));
40
+ return jsxRuntimeExports.jsx(Toast, { ref: customToastRef });
41
+ }
42
+ forwardRef(CustomToast);
43
+ //# sourceMappingURL=customToast.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customToast.js","sources":["../../../../src/stories/components/customToast.tsx"],"sourcesContent":[null],"names":["_jsx","ToastPrime"],"mappings":";;;;;;;;AAqBA,SAAS,WAAW,CAAC,KAAuB,EAAE,GAA8B,EAAA;IAC1E,MAAM,EAAE,QAAQ,GAAG,MAAM,EAAE,OAAO,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,EAAE,IAAI,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,KAAK;AACnF,IAAA,MAAM,cAAc,GAAG,MAAM,CAAa,IAAI,CAAC;IAE/C,SAAS,OAAO,CAAC,QAA6B,EAAA;QAC5C,QAAQ,QAAQ;AACd,YAAA,KAAK,SAAS;AACZ,gBAAA,OAAO,WAAW;AACpB,YAAA,KAAK,OAAO;AACV,gBAAA,OAAO,SAAS;AAClB,YAAA;AACE,gBAAA,OAAO,QAAQ;;;AAIrB,IAAA,mBAAmB,CAAC,GAAG,EAAE,OAAO;AAC9B,QAAA,IAAI,EAAE,CAAC,SAA4B,KAAI;AACrC,YAAA,MAAM,WAAW,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE;AAE7E,YAAA,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC;gBAC3B,QAAQ,EAAE,WAAW,CAAC,QAAQ;gBAC9B,OAAO,EAAE,WAAW,CAAC,OAAO;gBAC5B,MAAM,EAAE,WAAW,CAAC,MAAM;gBAC1B,IAAI,EAAE,WAAW,CAAC,IAAI;AACtB,gBAAA,SAAS,EAAE,IAAI,CACb,WAAW,CAAC,QAAQ,KAAK,OAAO,GAAG,iBAAiB,GAAG,gBAAgB,CACxE;AACD,gBAAA,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC;gBACnC,gBAAgB,EAAE,IAAI,CACpB,0DAA0D,EAC1D,WAAW,CAAC,QAAQ,KAAK;AACvB,sBAAE;sBACA,6BAA6B,CAClC;AACD,gBAAA,SAAS,EAAE,IAAI,CACb,0BAA0B,EAC1B,WAAW,CAAC,QAAQ,KAAK,OAAO,GAAG,eAAe,GAAG,cAAc,CACpE;AACF,aAAA,CAAC;AAEF,YAAA,WAAW,CAAC,MAAM,IAAI;SACvB;AACF,KAAA,CAAC,CAAC;AAEH,IAAA,OAAOA,sBAACC,KAAU,EAAA,EAAC,GAAG,EAAE,cAAc,GAAI;AAC5C;AAEe,UAAU,CAAC,WAAW,CAAC"}
@@ -32,3 +32,4 @@ export * from './stories/components/emptyContent';
32
32
  export * from './stories/components/select';
33
33
  export * from './stories/components/calendarInput';
34
34
  export * from './stories/components/table';
35
+ export * from './stories/components/customToast';
@@ -0,0 +1,13 @@
1
+ export type CustomToastSeverity = 'success' | 'info' | 'error';
2
+ export type CustomToastProps = {
3
+ severity?: CustomToastSeverity;
4
+ summary?: string;
5
+ detail?: string;
6
+ life?: number;
7
+ onShow?: () => void;
8
+ };
9
+ export type CustomToastRef = {
10
+ show: (props?: CustomToastProps) => void;
11
+ };
12
+ declare const _default: import("react").ForwardRefExoticComponent<CustomToastProps & import("react").RefAttributes<CustomToastRef>>;
13
+ export default _default;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "karsten-design-system",
3
3
  "description": "Karsten Design System Components",
4
- "version": "1.0.67",
4
+ "version": "1.0.69",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",