@sydsoft/base 1.12.0 → 1.13.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.
@@ -1,9 +1,9 @@
1
1
  import { __assign } from "tslib";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { Box, BoxFooter } from "../box";
4
- import { Button } from "./Button";
5
- import { Modal } from "../modal";
6
4
  import { createRoot } from "react-dom/client";
5
+ import { Modal } from "../modal";
6
+ import { Button } from "./Button";
7
7
  export var Dialog = function (config) {
8
8
  return new Promise(function (resolve) {
9
9
  if (typeof window === "undefined")
@@ -17,7 +17,7 @@ export var Dialog = function (config) {
17
17
  }
18
18
  var root = createRoot(mainDiv);
19
19
  var settings = __assign({ acceptButtonShow: true, cancelButtonShow: true, acceptButtonText: "EVET", cancelButtonText: "HAYIR", acceptButtonClass: "danger", cancelButtonClass: "secondary", vertialAlign: "center", horizontalAlign: "center", hideBackdrop: true, hideEsc: true, styleMessage: {
20
- fontSize: "1.2rem",
20
+ fontSize: "1.1rem",
21
21
  padding: "10px 20px"
22
22
  }, styleBox: { padding: 0, margin: 0, minWidth: 250 }, styleBoxFooter: { padding: "8px 5px" }, autoFocus: "accept" }, config);
23
23
  var close = function () {
@@ -5,6 +5,7 @@ export * from "./datetime";
5
5
  export * from "./form";
6
6
  export * from "./grid";
7
7
  export * from "./icon";
8
+ export * from "./menu";
8
9
  export * from "./modal";
9
10
  export * from "./popover";
10
11
  export * from "./tooltip";
package/dist/esm/index.js CHANGED
@@ -5,6 +5,7 @@ export * from "./datetime";
5
5
  export * from "./form";
6
6
  export * from "./grid";
7
7
  export * from "./icon";
8
+ export * from "./menu";
8
9
  export * from "./modal";
9
10
  export * from "./popover";
10
11
  export * from "./tooltip";
@@ -0,0 +1,43 @@
1
+ import { propsDialog } from "../form";
2
+ import React from "react";
3
+ interface BaseProps {
4
+ style?: React.CSSProperties;
5
+ itemProps?: any;
6
+ [key: string]: any;
7
+ }
8
+ interface SeperatorProps extends BaseProps {
9
+ seperator: boolean;
10
+ title?: never;
11
+ icon?: never;
12
+ fullComponent?: never;
13
+ href?: never;
14
+ onClick?: never;
15
+ dialog?: never;
16
+ }
17
+ interface FullComponentProps extends BaseProps {
18
+ fullComponent: React.ReactElement;
19
+ seperator?: never;
20
+ title?: never;
21
+ icon?: never;
22
+ href?: never;
23
+ onClick?: never;
24
+ dialog?: never;
25
+ }
26
+ interface ItemComponentProps extends BaseProps {
27
+ seperator?: false;
28
+ fullComponent?: never;
29
+ title: string;
30
+ icon?: React.ReactNode;
31
+ href?: string;
32
+ onClick?: (e: React.MouseEvent<HTMLLIElement>) => void;
33
+ dialog?: propsDialog;
34
+ }
35
+ export type typeMenu = SeperatorProps | FullComponentProps | ItemComponentProps;
36
+ interface Props {
37
+ menu: typeMenu[];
38
+ className?: string;
39
+ style?: React.CSSProperties;
40
+ withIcon?: boolean;
41
+ }
42
+ export declare const Menu: React.NamedExoticComponent<Props>;
43
+ export {};
@@ -0,0 +1,32 @@
1
+ import { __assign, __rest } from "tslib";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Dialog } from "../form";
4
+ import React, { memo } from "react";
5
+ import Link from "next/link";
6
+ import styles from "./index.module.css";
7
+ export var Menu = memo(function MemoFunction(_a) {
8
+ var menu = _a.menu, className = _a.className, style = _a.style, _b = _a.withIcon, withIcon = _b === void 0 ? true : _b;
9
+ var handleClick = function (item, e) {
10
+ if (!item.onClick)
11
+ return;
12
+ if (item.dialog) {
13
+ Dialog(__assign({}, item.dialog)).then(function (result) {
14
+ if (result && item.onClick) {
15
+ item.onClick(e);
16
+ }
17
+ });
18
+ }
19
+ else {
20
+ item.onClick(e);
21
+ }
22
+ };
23
+ return (_jsx("ul", { className: "smenu ".concat(styles.ul, " ").concat(className || ""), style: style, children: Object.values(menu).map(function (item, key) {
24
+ var fullComponent = item.fullComponent, icon = item.icon, title = item.title, onClick = item.onClick, seperator = item.seperator, href = item.href, style = item.style, itemProps = item.itemProps, other = __rest(item, ["fullComponent", "icon", "title", "onClick", "seperator", "href", "style", "itemProps"]);
25
+ if (fullComponent)
26
+ return React.cloneElement(fullComponent, { key: key });
27
+ if (seperator)
28
+ return _jsx("li", __assign({ className: "".concat(styles.li, " ").concat(styles.seperator), style: style }, itemProps, other), key);
29
+ var Component = (_jsxs(_Fragment, { children: [withIcon && _jsx("div", { className: styles.menuicon, children: icon }), _jsx("div", { className: styles.menutitle, children: title })] }));
30
+ return (_jsx("li", __assign({ className: "".concat(styles.li), style: style, onClick: function (e) { return handleClick(item, e); } }, itemProps, other, { children: (href) ? _jsx(Link, { href: href, children: Component }) : Component }), key));
31
+ }) }));
32
+ });
@@ -0,0 +1,67 @@
1
+ .ul {
2
+ position: relative;
3
+ width: 100%;
4
+ background-color: #fff;
5
+ box-shadow: 0 2px 4px rgb(0 0 0 / 40%), 0 8px 16px rgb(0 0 0 / 10%);
6
+ border-radius: 8px;
7
+ margin: 0;
8
+ padding: 4px 0;
9
+ list-style: none;
10
+ }
11
+ .li {
12
+ cursor: pointer;
13
+ padding: 7px 15px;
14
+ min-height: 25px;
15
+ }
16
+ .li,
17
+ .li a {
18
+ display: flex;
19
+ flex-direction: row;
20
+ flex-wrap: nowrap;
21
+ width: 100%;
22
+ }
23
+ .li a,
24
+ .li a:visited {
25
+ color: inherit;
26
+ text-decoration: none;
27
+ }
28
+
29
+ .li.seperator {
30
+ display: block;
31
+ border-bottom: 1px #ced0d4 solid;
32
+ margin: 4px;
33
+ padding: 0;
34
+ cursor: default;
35
+ min-height: unset;
36
+ }
37
+
38
+ .li:first-child {
39
+ margin-top: 5px;
40
+ }
41
+
42
+ .li:last-child {
43
+ margin-bottom: 5px;
44
+ }
45
+
46
+ .li:hover {
47
+ background: #f0f2f5;
48
+ }
49
+
50
+ .menuicon {
51
+ display: inline-flex;
52
+ overflow: hidden;
53
+ width: 35px;
54
+ flex: 0 0 auto;
55
+ align-items: center;
56
+ justify-content: center;
57
+ margin-right: 15px;
58
+ color: #606060;
59
+ }
60
+
61
+ .menutitle {
62
+ display: inline-flex;
63
+ flex: 1;
64
+ align-items: center;
65
+ justify-content: flex-start;
66
+ margin-right: 10px;
67
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sydsoft/base",
3
3
  "private": false,
4
- "version": "1.12.0",
4
+ "version": "1.13.0",
5
5
  "description": "",
6
6
  "main": "./dist/cjs/index.js",
7
7
  "module": "./dist/esm/index.js",