@prokodo/ui 0.0.35 → 0.0.37

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,7 +2,7 @@
2
2
  var __defProp = Object.defineProperty;
3
3
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
4
  import { jsxs, Fragment, jsx } from "react/jsx-runtime";
5
- import { Link } from "../link/Link.js";
5
+ import LinkClient from "../link/Link.client.js";
6
6
  import { ButtonView } from "./Button.view.js";
7
7
  import { Loading } from "../loading/Loading.js";
8
8
  function ButtonClient(props) {
@@ -17,7 +17,7 @@ function ButtonClient(props) {
17
17
  ...rest,
18
18
  iconProps: finalIconProps,
19
19
  isIconOnly: Boolean(isIconOnly),
20
- LinkComponent: Link
20
+ LinkComponent: LinkClient
21
21
  }
22
22
  )
23
23
  ] });
@@ -1,21 +1,12 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import { jsx } from "react/jsx-runtime";
4
- import { Suspense, lazy } from "react";
3
+ import { createIsland } from "../../helpers/createIsland.js";
5
4
  import ButtonServer from "./Button.server.js";
6
- const preload = /* @__PURE__ */ __name(() => import("./Button.lazy.js"), "preload");
7
- if (typeof window !== "undefined") void preload();
8
- const LazyWrapper = typeof window !== "undefined" ? lazy(
9
- () => preload().then((m) => ({ default: m.default }))
10
- // <- adapter
11
- ) : null;
12
- function Button({ priority = false, ...props }) {
13
- const interactive = !!props.onClick || !!props.onKeyDown || !!props.redirect;
14
- if (!interactive) return /* @__PURE__ */ jsx(ButtonServer, { ...props });
15
- const Fallback = /* @__PURE__ */ jsx("div", { "data-island": "button", children: /* @__PURE__ */ jsx(ButtonServer, { ...props }) });
16
- return /* @__PURE__ */ jsx(Suspense, { fallback: Fallback, children: LazyWrapper ? /* @__PURE__ */ jsx(LazyWrapper, { ...props, priority }) : Fallback });
17
- }
18
- __name(Button, "Button");
5
+ const Button = createIsland({
6
+ name: "Button",
7
+ Server: ButtonServer,
8
+ loadLazy: /* @__PURE__ */ __name(() => import("./Button.lazy.js"), "loadLazy")
9
+ });
19
10
  export {
20
11
  Button
21
12
  };
@@ -1,24 +1,12 @@
1
1
  "use client";
2
- var __defProp = Object.defineProperty;
3
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
- import { jsx } from "react/jsx-runtime";
5
- import { useHydrationReady } from "../../hooks/useHydrationReady.js";
2
+ import { createLazyWrapper } from "../../helpers/createLazyWrapper.js";
6
3
  import ButtonClient from "./Button.client.js";
7
4
  import ButtonServer from "./Button.server.js";
8
- function ButtonWrapper({
9
- priority = false,
10
- ...props
11
- }) {
12
- const hasInteraction = !!props.onClick || !!props.onKeyDown || !!props.redirect;
13
- const [visible, ref] = useHydrationReady({
14
- enabled: hasInteraction && !priority
15
- });
16
- if (hasInteraction && (priority || visible)) {
17
- return /* @__PURE__ */ jsx(ButtonClient, { ...props });
18
- }
19
- return /* @__PURE__ */ jsx("div", { ref, "data-island": "button", children: /* @__PURE__ */ jsx(ButtonServer, { ...props }) });
20
- }
21
- __name(ButtonWrapper, "ButtonWrapper");
5
+ const Button_lazy = createLazyWrapper({
6
+ name: "Button",
7
+ Client: ButtonClient,
8
+ Server: ButtonServer
9
+ });
22
10
  export {
23
- ButtonWrapper as default
11
+ Button_lazy as default
24
12
  };
@@ -1,7 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
  import { jsx } from "react/jsx-runtime";
4
- import { Link } from "../link/Link.js";
4
+ import LinkServer from "../link/Link.server.js";
5
5
  import { ButtonView } from "./Button.view.js";
6
6
  function ButtonServer(p) {
7
7
  var _a;
@@ -11,7 +11,7 @@ function ButtonServer(p) {
11
11
  {
12
12
  ...p,
13
13
  isIconOnly: Boolean(isIconOnly),
14
- LinkComponent: Link
14
+ LinkComponent: LinkServer
15
15
  }
16
16
  );
17
17
  }
@@ -0,0 +1,21 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { memo } from "react";
4
+ import { LinkView } from "./Link.view.js";
5
+ const LinkClient = memo((props) => {
6
+ const { href, onClick } = props;
7
+ const linkTag = onClick && !href ? "span" : "a";
8
+ const hasHandlers = Boolean(onClick) || Boolean(props.onKeyDown);
9
+ return /* @__PURE__ */ jsx(
10
+ LinkView,
11
+ {
12
+ ...props,
13
+ hasHandlers,
14
+ LinkTag: linkTag
15
+ }
16
+ );
17
+ });
18
+ LinkClient.displayName = "LinkClient";
19
+ export {
20
+ LinkClient as default
21
+ };
@@ -1,63 +1,14 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { memo } from "react";
3
- import { create } from "../../helpers/bem.js";
4
- import { isString } from "../../helpers/validations.js";
5
- import styles from "./Link.module.scss.js";
6
- import { BaseLink } from "../base-link/BaseLink.js";
7
- const bem = create(styles, "Link");
8
- const Link = memo(
9
- ({
10
- variant = "inherit",
11
- href,
12
- children,
13
- className,
14
- style,
15
- target,
16
- itemProp,
17
- hasBackground,
18
- onMouseEnter,
19
- onClick,
20
- onKeyDown,
21
- ariaLabel
22
- }) => {
23
- const linkModifier = {
24
- "has-no-background": hasBackground === false,
25
- [`has-no-background--${variant}`]: hasBackground === false
26
- };
27
- const defaultProps = {
28
- className: bem(void 0, linkModifier, className),
29
- style,
30
- onMouseEnter
31
- };
32
- if (onClick && !isString(href)) {
33
- return /* @__PURE__ */ jsx(
34
- "span",
35
- {
36
- "aria-label": ariaLabel,
37
- role: "button",
38
- tabIndex: 0,
39
- onClick,
40
- onKeyDown,
41
- ...defaultProps,
42
- children
43
- }
44
- );
45
- }
46
- return /* @__PURE__ */ jsx(
47
- BaseLink,
48
- {
49
- ...defaultProps,
50
- "aria-label": ariaLabel,
51
- href,
52
- itemProp,
53
- target: target ?? void 0,
54
- onClick,
55
- children
56
- }
57
- );
58
- }
59
- );
60
- Link.displayName = "Link";
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { createIsland } from "../../helpers/createIsland.js";
4
+ import LinkServer from "./Link.server.js";
5
+ const Link = createIsland({
6
+ name: "Link",
7
+ Server: LinkServer,
8
+ loadLazy: /* @__PURE__ */ __name(() => import("./Link.lazy.js"), "loadLazy"),
9
+ // optional: custom predicate (e.g. always interactive if target="_blank")
10
+ isInteractive: /* @__PURE__ */ __name((p) => typeof p.onClick === "function" || typeof p.onKeyDown === "function" || p.target === "_blank", "isInteractive")
11
+ });
61
12
  export {
62
13
  Link
63
14
  };
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { createLazyWrapper } from "../../helpers/createLazyWrapper.js";
3
+ import LinkClient from "./Link.client.js";
4
+ import LinkServer from "./Link.server.js";
5
+ const Link_lazy = createLazyWrapper({
6
+ name: "Link",
7
+ Client: LinkClient,
8
+ Server: LinkServer
9
+ });
10
+ export {
11
+ Link_lazy as default
12
+ };
@@ -0,0 +1,20 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { jsx } from "react/jsx-runtime";
4
+ import { LinkView } from "./Link.view.js";
5
+ function LinkServer(props) {
6
+ const hasHandlers = false;
7
+ const linkTag = props.onClick && !props.href ? "span" : "a";
8
+ return /* @__PURE__ */ jsx(
9
+ LinkView,
10
+ {
11
+ ...props,
12
+ hasHandlers,
13
+ LinkTag: linkTag
14
+ }
15
+ );
16
+ }
17
+ __name(LinkServer, "LinkServer");
18
+ export {
19
+ LinkServer as default
20
+ };
@@ -0,0 +1,55 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { jsx } from "react/jsx-runtime";
4
+ import { create } from "../../helpers/bem.js";
5
+ import styles from "./Link.module.scss.js";
6
+ import { BaseLink } from "../base-link/BaseLink.js";
7
+ const bem = create(styles, "Link");
8
+ function LinkView({
9
+ variant = "inherit",
10
+ href,
11
+ children,
12
+ className,
13
+ style,
14
+ target,
15
+ itemProp,
16
+ hasBackground,
17
+ ariaLabel,
18
+ LinkTag,
19
+ hasHandlers,
20
+ ...rest
21
+ }) {
22
+ const linkMod = {
23
+ "has-no-background": hasBackground === false,
24
+ [`has-no-background--${variant}`]: hasBackground === false
25
+ };
26
+ const common = {
27
+ className: bem(void 0, linkMod, className),
28
+ style,
29
+ "aria-label": ariaLabel,
30
+ itemProp
31
+ };
32
+ return LinkTag === "span" ? /* @__PURE__ */ jsx(
33
+ "span",
34
+ {
35
+ ...common,
36
+ role: "button",
37
+ tabIndex: 0,
38
+ ...rest,
39
+ children
40
+ }
41
+ ) : /* @__PURE__ */ jsx(
42
+ BaseLink,
43
+ {
44
+ ...common,
45
+ href,
46
+ target: target ?? void 0,
47
+ ...hasHandlers ? { onClick: rest == null ? void 0 : rest.onClick } : null,
48
+ children
49
+ }
50
+ );
51
+ }
52
+ __name(LinkView, "LinkView");
53
+ export {
54
+ LinkView
55
+ };
@@ -1,4 +1,4 @@
1
- const PROKODO_UI_VERSION = "0.0.35";
1
+ const PROKODO_UI_VERSION = "0.0.37";
2
2
  export {
3
3
  PROKODO_UI_VERSION
4
4
  };
@@ -0,0 +1,32 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { jsx } from "react/jsx-runtime";
4
+ import { lazy, Suspense } from "react";
5
+ function createIsland({
6
+ name,
7
+ Server,
8
+ loadLazy,
9
+ isInteractive: customInteractive
10
+ }) {
11
+ if (typeof window !== "undefined") void loadLazy();
12
+ const LazyWrapper = typeof window !== "undefined" ? lazy(() => loadLazy().then((m) => ({ default: m.default }))) : null;
13
+ const Island = /* @__PURE__ */ __name(({
14
+ priority = false,
15
+ ...raw
16
+ }) => {
17
+ const props = raw;
18
+ const autoInteractive = Object.entries(props).some(
19
+ ([key, val]) => key.startsWith("on") && typeof val === "function"
20
+ ) || props.redirect !== void 0;
21
+ const interactive = customInteractive ? customInteractive(props) || autoInteractive : autoInteractive;
22
+ if (!interactive) return /* @__PURE__ */ jsx(Server, { ...props });
23
+ const fallback = /* @__PURE__ */ jsx("div", { "data-island": name.toLowerCase(), children: /* @__PURE__ */ jsx(Server, { ...props }) });
24
+ return /* @__PURE__ */ jsx(Suspense, { fallback, children: LazyWrapper ? /* @__PURE__ */ jsx(LazyWrapper, { ...props, priority }) : fallback });
25
+ }, "Island");
26
+ Island.displayName = `${name}Island`;
27
+ return Island;
28
+ }
29
+ __name(createIsland, "createIsland");
30
+ export {
31
+ createIsland
32
+ };
@@ -0,0 +1,30 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { jsx } from "react/jsx-runtime";
4
+ import { useHydrationReady } from "../hooks/useHydrationReady.js";
5
+ function createLazyWrapper({
6
+ name,
7
+ Client,
8
+ Server
9
+ }) {
10
+ const LazyWrapper = /* @__PURE__ */ __name(({
11
+ priority = false,
12
+ ...raw
13
+ }) => {
14
+ const props = raw;
15
+ const hasInteraction = typeof props.onClick === "function" || typeof props.onKeyDown === "function" || props.redirect !== void 0;
16
+ const [visible, ref] = useHydrationReady({
17
+ enabled: hasInteraction && !priority
18
+ });
19
+ if (hasInteraction && (priority || visible)) {
20
+ return /* @__PURE__ */ jsx(Client, { ...raw });
21
+ }
22
+ return /* @__PURE__ */ jsx("div", { ref, "data-island": name.toLowerCase(), children: /* @__PURE__ */ jsx(Server, { ...raw }) });
23
+ }, "LazyWrapper");
24
+ LazyWrapper.displayName = `${name}Lazy`;
25
+ return LazyWrapper;
26
+ }
27
+ __name(createLazyWrapper, "createLazyWrapper");
28
+ export {
29
+ createLazyWrapper
30
+ };