elseware-ui 2.20.4 → 2.20.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.
@@ -2,10 +2,17 @@ export interface I_ItemType {
2
2
  title: string;
3
3
  href: string;
4
4
  }
5
+ export interface RouteConfig {
6
+ path: string;
7
+ name: string;
8
+ }
5
9
  export interface BreadcrumbProps {
6
10
  gap?: number;
7
11
  seperator?: string;
8
12
  data?: I_ItemType[];
13
+ routes?: RouteConfig[];
14
+ currentPath?: string;
15
+ navigate?: (path: string) => void;
9
16
  styles?: string;
10
17
  }
11
- export declare const Breadcrumb: ({ gap, seperator, data, styles }: BreadcrumbProps) => import("react/jsx-runtime").JSX.Element;
18
+ export declare const Breadcrumb: ({ gap, seperator, data, routes, currentPath, navigate, styles, }: BreadcrumbProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,9 @@
1
+ import React from "react";
1
2
  export interface BreadcrumbItemProps {
2
3
  title: string;
3
4
  href: string;
4
5
  active: boolean;
6
+ onClick?: (e: React.MouseEvent<HTMLAnchorElement>) => void;
5
7
  }
6
- declare function BreadcrumbItem({ title, href, active }: BreadcrumbItemProps): import("react/jsx-runtime").JSX.Element;
8
+ declare function BreadcrumbItem({ title, href, active, onClick, }: BreadcrumbItemProps): import("react/jsx-runtime").JSX.Element;
7
9
  export default BreadcrumbItem;
package/build/index.es.js CHANGED
@@ -39422,7 +39422,17 @@ var UnsavedChangesGuard = function (_a) {
39422
39422
 
39423
39423
  var Form = function (_a) {
39424
39424
  var _b = _a.initialValues, initialValues = _b === void 0 ? {} : _b, validationSchema = _a.validationSchema, enableReinitialize = _a.enableReinitialize, children = _a.children, styles = _a.styles, onSubmit = _a.onSubmit, onChange = _a.onChange, _c = _a.warnOnUnsavedChanges, warnOnUnsavedChanges = _c === void 0 ? false : _c, onDirtyChange = _a.onDirtyChange;
39425
- return (jsx(Formik, __assign$1({ initialValues: initialValues, validationSchema: validationSchema, enableReinitialize: enableReinitialize, onSubmit: onSubmit }, { children: function (formik) { return (jsxs(Form$1, { children: [jsx(UnsavedChangesGuard, { formik: formik, enabled: warnOnUnsavedChanges }), jsx(DirtyObserver, { formik: formik, onDirtyChange: onDirtyChange }), jsx(FormObserver, { formik: formik, onChange: onChange }), jsx("div", __assign$1({ className: classnames(styles) }, { children: children }))] })); } })));
39425
+ return (jsx(Formik, __assign$1({ initialValues: initialValues, validationSchema: validationSchema, enableReinitialize: enableReinitialize, onSubmit: function (values, helpers) { return __awaiter(void 0, void 0, void 0, function () {
39426
+ return __generator(this, function (_a) {
39427
+ switch (_a.label) {
39428
+ case 0: return [4 /*yield*/, onSubmit(values)];
39429
+ case 1:
39430
+ _a.sent();
39431
+ helpers.resetForm({ values: values });
39432
+ return [2 /*return*/];
39433
+ }
39434
+ });
39435
+ }); } }, { children: function (formik) { return (jsxs(Form$1, { children: [jsx(UnsavedChangesGuard, { formik: formik, enabled: warnOnUnsavedChanges }), jsx(DirtyObserver, { formik: formik, onDirtyChange: onDirtyChange }), jsx(FormObserver, { formik: formik, onChange: onChange }), jsx("div", __assign$1({ className: classnames(styles) }, { children: children }))] })); } })));
39426
39436
  };
39427
39437
 
39428
39438
  var Backdrop = function (_a) {
@@ -141606,34 +141616,84 @@ function MarkdownViewer(_a) {
141606
141616
  }
141607
141617
 
141608
141618
  function BreadcrumbItem(_a) {
141609
- var title = _a.title, _b = _a.href, href = _b === void 0 ? "#" : _b, _c = _a.active, active = _c === void 0 ? true : _c;
141610
- return (jsx("a", __assign$1({ href: href, className: classnames({
141611
- "text-lg font-semibold ": true,
141612
- "text-gray-400 hover:text-gray-600": !active,
141619
+ var title = _a.title, _b = _a.href, href = _b === void 0 ? "#" : _b, _c = _a.active, active = _c === void 0 ? true : _c, onClick = _a.onClick;
141620
+ return (jsx("a", __assign$1({ href: href, onClick: onClick, className: classnames({
141621
+ "text-lg font-semibold": true,
141622
+ "text-gray-400 hover:text-gray-600 cursor-pointer": !active,
141613
141623
  "text-eui-light-800": active,
141614
141624
  "hover:underline": true,
141615
141625
  "transition-all ease-in-out": true,
141616
141626
  }) }, { children: title })));
141617
141627
  }
141618
141628
 
141629
+ // ----------------------
141630
+ // Utils
141631
+ // ----------------------
141632
+ var matchRoute = function (routePath, currentPath) {
141633
+ var routeParts = routePath.split("/").filter(Boolean);
141634
+ var pathParts = currentPath.split("/").filter(Boolean);
141635
+ if (routeParts.length !== pathParts.length)
141636
+ return false;
141637
+ return routeParts.every(function (part, index) {
141638
+ return part.startsWith(":") || part === pathParts[index];
141639
+ });
141640
+ };
141641
+ var buildFromRoutes = function (routes, currentPath) {
141642
+ var pathParts = currentPath.split("/").filter(Boolean);
141643
+ var items = [];
141644
+ var _loop_1 = function (i) {
141645
+ var subPath = "/" + pathParts.slice(0, i).join("/");
141646
+ var matched = routes.find(function (r) { return matchRoute(r.path, subPath); });
141647
+ if (matched) {
141648
+ items.push({
141649
+ title: matched.name,
141650
+ href: subPath || "/",
141651
+ });
141652
+ }
141653
+ };
141654
+ for (var i = 0; i <= pathParts.length; i++) {
141655
+ _loop_1(i);
141656
+ }
141657
+ return items;
141658
+ };
141659
+ // ----------------------
141660
+ // Component
141661
+ // ----------------------
141619
141662
  var Breadcrumb = function (_a) {
141620
141663
  var _b;
141621
- var _c = _a.gap, gap = _c === void 0 ? 1 : _c, _d = _a.seperator, seperator = _d === void 0 ? "/" : _d, _e = _a.data, data = _e === void 0 ? [] : _e, styles = _a.styles;
141622
- var splitData = __spreadArray([], data, true);
141664
+ var _c = _a.gap, gap = _c === void 0 ? 1 : _c, _d = _a.seperator, seperator = _d === void 0 ? "/" : _d, _e = _a.data, data = _e === void 0 ? [] : _e, routes = _a.routes, currentPath = _a.currentPath, navigate = _a.navigate, styles = _a.styles;
141665
+ var pathname = currentPath ||
141666
+ (typeof window !== "undefined" ? window.location.pathname : "/");
141667
+ // 🔥 Decide source of truth
141668
+ var resolvedData = useMemo$1(function () {
141669
+ if (routes && routes.length > 0) {
141670
+ return buildFromRoutes(routes, pathname);
141671
+ }
141672
+ return data;
141673
+ }, [routes, data, pathname]);
141623
141674
  var childrenContent;
141624
- if (splitData.length > 0) {
141625
- var items = splitData.map(function (item, index) {
141675
+ if (resolvedData.length > 0) {
141676
+ var items = resolvedData.map(function (item, index) {
141626
141677
  var _a;
141627
- return (jsxs(React__default.Fragment, { children: [jsx(BreadcrumbItem, { title: item.title, href: item.href, active: index == splitData.length - 1 }), index < splitData.length - 1 && (jsx("span", __assign$1({ className: classnames((_a = {
141678
+ var isLast = index === resolvedData.length - 1;
141679
+ var handleClick = function (e) {
141680
+ if (isLast)
141681
+ return;
141682
+ if (navigate) {
141683
+ e.preventDefault();
141684
+ navigate(item.href);
141685
+ }
141686
+ };
141687
+ return (jsxs(React__default.Fragment, { children: [jsx(BreadcrumbItem, { title: item.title, href: item.href, active: isLast, onClick: handleClick }), index < resolvedData.length - 1 && (jsx("span", __assign$1({ className: classnames((_a = {
141628
141688
  "text-lg font-semibold text-gray-500": true
141629
141689
  },
141630
141690
  _a["px-".concat(gap)] = gap,
141631
141691
  _a)) }, { children: seperator })))] }, index));
141632
141692
  });
141633
- childrenContent = jsx("div", { children: items });
141693
+ childrenContent = jsx("div", __assign$1({ className: "flex items-center" }, { children: items }));
141634
141694
  }
141635
141695
  return (jsx("div", __assign$1({ className: classnames((_b = {
141636
- "inline-flex gap-3": true
141696
+ "inline-flex": true
141637
141697
  },
141638
141698
  _b["".concat(styles)] = styles,
141639
141699
  _b)) }, { children: childrenContent })));
package/build/index.js CHANGED
@@ -39449,7 +39449,17 @@ var UnsavedChangesGuard = function (_a) {
39449
39449
 
39450
39450
  var Form = function (_a) {
39451
39451
  var _b = _a.initialValues, initialValues = _b === void 0 ? {} : _b, validationSchema = _a.validationSchema, enableReinitialize = _a.enableReinitialize, children = _a.children, styles = _a.styles, onSubmit = _a.onSubmit, onChange = _a.onChange, _c = _a.warnOnUnsavedChanges, warnOnUnsavedChanges = _c === void 0 ? false : _c, onDirtyChange = _a.onDirtyChange;
39452
- return (jsxRuntime.jsx(Formik, __assign$1({ initialValues: initialValues, validationSchema: validationSchema, enableReinitialize: enableReinitialize, onSubmit: onSubmit }, { children: function (formik) { return (jsxRuntime.jsxs(Form$1, { children: [jsxRuntime.jsx(UnsavedChangesGuard, { formik: formik, enabled: warnOnUnsavedChanges }), jsxRuntime.jsx(DirtyObserver, { formik: formik, onDirtyChange: onDirtyChange }), jsxRuntime.jsx(FormObserver, { formik: formik, onChange: onChange }), jsxRuntime.jsx("div", __assign$1({ className: classnames(styles) }, { children: children }))] })); } })));
39452
+ return (jsxRuntime.jsx(Formik, __assign$1({ initialValues: initialValues, validationSchema: validationSchema, enableReinitialize: enableReinitialize, onSubmit: function (values, helpers) { return __awaiter(void 0, void 0, void 0, function () {
39453
+ return __generator(this, function (_a) {
39454
+ switch (_a.label) {
39455
+ case 0: return [4 /*yield*/, onSubmit(values)];
39456
+ case 1:
39457
+ _a.sent();
39458
+ helpers.resetForm({ values: values });
39459
+ return [2 /*return*/];
39460
+ }
39461
+ });
39462
+ }); } }, { children: function (formik) { return (jsxRuntime.jsxs(Form$1, { children: [jsxRuntime.jsx(UnsavedChangesGuard, { formik: formik, enabled: warnOnUnsavedChanges }), jsxRuntime.jsx(DirtyObserver, { formik: formik, onDirtyChange: onDirtyChange }), jsxRuntime.jsx(FormObserver, { formik: formik, onChange: onChange }), jsxRuntime.jsx("div", __assign$1({ className: classnames(styles) }, { children: children }))] })); } })));
39453
39463
  };
39454
39464
 
39455
39465
  var Backdrop = function (_a) {
@@ -141633,34 +141643,84 @@ function MarkdownViewer(_a) {
141633
141643
  }
141634
141644
 
141635
141645
  function BreadcrumbItem(_a) {
141636
- var title = _a.title, _b = _a.href, href = _b === void 0 ? "#" : _b, _c = _a.active, active = _c === void 0 ? true : _c;
141637
- return (jsxRuntime.jsx("a", __assign$1({ href: href, className: classnames({
141638
- "text-lg font-semibold ": true,
141639
- "text-gray-400 hover:text-gray-600": !active,
141646
+ var title = _a.title, _b = _a.href, href = _b === void 0 ? "#" : _b, _c = _a.active, active = _c === void 0 ? true : _c, onClick = _a.onClick;
141647
+ return (jsxRuntime.jsx("a", __assign$1({ href: href, onClick: onClick, className: classnames({
141648
+ "text-lg font-semibold": true,
141649
+ "text-gray-400 hover:text-gray-600 cursor-pointer": !active,
141640
141650
  "text-eui-light-800": active,
141641
141651
  "hover:underline": true,
141642
141652
  "transition-all ease-in-out": true,
141643
141653
  }) }, { children: title })));
141644
141654
  }
141645
141655
 
141656
+ // ----------------------
141657
+ // Utils
141658
+ // ----------------------
141659
+ var matchRoute = function (routePath, currentPath) {
141660
+ var routeParts = routePath.split("/").filter(Boolean);
141661
+ var pathParts = currentPath.split("/").filter(Boolean);
141662
+ if (routeParts.length !== pathParts.length)
141663
+ return false;
141664
+ return routeParts.every(function (part, index) {
141665
+ return part.startsWith(":") || part === pathParts[index];
141666
+ });
141667
+ };
141668
+ var buildFromRoutes = function (routes, currentPath) {
141669
+ var pathParts = currentPath.split("/").filter(Boolean);
141670
+ var items = [];
141671
+ var _loop_1 = function (i) {
141672
+ var subPath = "/" + pathParts.slice(0, i).join("/");
141673
+ var matched = routes.find(function (r) { return matchRoute(r.path, subPath); });
141674
+ if (matched) {
141675
+ items.push({
141676
+ title: matched.name,
141677
+ href: subPath || "/",
141678
+ });
141679
+ }
141680
+ };
141681
+ for (var i = 0; i <= pathParts.length; i++) {
141682
+ _loop_1(i);
141683
+ }
141684
+ return items;
141685
+ };
141686
+ // ----------------------
141687
+ // Component
141688
+ // ----------------------
141646
141689
  var Breadcrumb = function (_a) {
141647
141690
  var _b;
141648
- var _c = _a.gap, gap = _c === void 0 ? 1 : _c, _d = _a.seperator, seperator = _d === void 0 ? "/" : _d, _e = _a.data, data = _e === void 0 ? [] : _e, styles = _a.styles;
141649
- var splitData = __spreadArray([], data, true);
141691
+ var _c = _a.gap, gap = _c === void 0 ? 1 : _c, _d = _a.seperator, seperator = _d === void 0 ? "/" : _d, _e = _a.data, data = _e === void 0 ? [] : _e, routes = _a.routes, currentPath = _a.currentPath, navigate = _a.navigate, styles = _a.styles;
141692
+ var pathname = currentPath ||
141693
+ (typeof window !== "undefined" ? window.location.pathname : "/");
141694
+ // 🔥 Decide source of truth
141695
+ var resolvedData = React.useMemo(function () {
141696
+ if (routes && routes.length > 0) {
141697
+ return buildFromRoutes(routes, pathname);
141698
+ }
141699
+ return data;
141700
+ }, [routes, data, pathname]);
141650
141701
  var childrenContent;
141651
- if (splitData.length > 0) {
141652
- var items = splitData.map(function (item, index) {
141702
+ if (resolvedData.length > 0) {
141703
+ var items = resolvedData.map(function (item, index) {
141653
141704
  var _a;
141654
- return (jsxRuntime.jsxs(React__default["default"].Fragment, { children: [jsxRuntime.jsx(BreadcrumbItem, { title: item.title, href: item.href, active: index == splitData.length - 1 }), index < splitData.length - 1 && (jsxRuntime.jsx("span", __assign$1({ className: classnames((_a = {
141705
+ var isLast = index === resolvedData.length - 1;
141706
+ var handleClick = function (e) {
141707
+ if (isLast)
141708
+ return;
141709
+ if (navigate) {
141710
+ e.preventDefault();
141711
+ navigate(item.href);
141712
+ }
141713
+ };
141714
+ return (jsxRuntime.jsxs(React__default["default"].Fragment, { children: [jsxRuntime.jsx(BreadcrumbItem, { title: item.title, href: item.href, active: isLast, onClick: handleClick }), index < resolvedData.length - 1 && (jsxRuntime.jsx("span", __assign$1({ className: classnames((_a = {
141655
141715
  "text-lg font-semibold text-gray-500": true
141656
141716
  },
141657
141717
  _a["px-".concat(gap)] = gap,
141658
141718
  _a)) }, { children: seperator })))] }, index));
141659
141719
  });
141660
- childrenContent = jsxRuntime.jsx("div", { children: items });
141720
+ childrenContent = jsxRuntime.jsx("div", __assign$1({ className: "flex items-center" }, { children: items }));
141661
141721
  }
141662
141722
  return (jsxRuntime.jsx("div", __assign$1({ className: classnames((_b = {
141663
- "inline-flex gap-3": true
141723
+ "inline-flex": true
141664
141724
  },
141665
141725
  _b["".concat(styles)] = styles,
141666
141726
  _b)) }, { children: childrenContent })));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elseware-ui",
3
- "version": "2.20.4",
3
+ "version": "2.20.6",
4
4
  "private": false,
5
5
  "description": "A modern and customizable React UI component library by elseware Technology.",
6
6
  "keywords": [