@clyrex-digital/clyrex-controls-dev 0.8.1-dev.20260903053106 → 0.8.1-dev.20260903094942

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.
@@ -0,0 +1,108 @@
1
+ "use client";
2
+
3
+ "use client";
4
+ import {
5
+ AssetUtility_default
6
+ } from "./chunk-UPCAOGEY.mjs";
7
+
8
+ // src/components/controls/view/AvatarViewClient.tsx
9
+ import React from "react";
10
+ import { jsx } from "react/jsx-runtime";
11
+ var AVATAR_COLORS = [
12
+ "bg-error-strong",
13
+ "bg-accent-base",
14
+ "bg-warning-base",
15
+ "bg-success-base",
16
+ "bg-info-base",
17
+ "bg-primary-base",
18
+ "bg-secondary-base"
19
+ ];
20
+ var getAvatarColor = (text) => {
21
+ let hash = 0;
22
+ for (let i = 0; i < text.length; i += 1) {
23
+ hash = hash * 31 + text.charCodeAt(i) >>> 0;
24
+ }
25
+ return AVATAR_COLORS[hash % AVATAR_COLORS.length];
26
+ };
27
+ var getInitials = (text) => {
28
+ const words = text.trim().split(/\s+/).filter(Boolean);
29
+ if (words.length === 0) {
30
+ return "?";
31
+ }
32
+ if (words.length === 1) {
33
+ return words[0].slice(0, 2).toUpperCase();
34
+ }
35
+ return `${words[0][0]}${words[words.length - 1][0]}`.toUpperCase();
36
+ };
37
+ var getContactImageInfo = (text) => {
38
+ if (!text.includes("-")) {
39
+ return null;
40
+ }
41
+ const parts = text.split("-");
42
+ if (parts.length <= 1) {
43
+ return null;
44
+ }
45
+ const first = parts[0].trim();
46
+ if (!/^\d+$/.test(first)) {
47
+ return null;
48
+ }
49
+ return {
50
+ contactId: first,
51
+ name: parts.slice(1).join("-").trim() || text
52
+ };
53
+ };
54
+ var AvatarViewClient = (props) => {
55
+ const text = props.value === null || props.value === void 0 ? "" : String(props.value).trim();
56
+ const [imageFailed, setImageFailed] = React.useState(false);
57
+ React.useEffect(() => {
58
+ setImageFailed(false);
59
+ }, [text, props.assetBaseUrl]);
60
+ if (!text) {
61
+ return null;
62
+ }
63
+ const size = props.width ?? "1.75rem";
64
+ const contactInfo = getContactImageInfo(text);
65
+ const imageUrl = contactInfo ? AssetUtility_default.resolveUrl(
66
+ props.assetBaseUrl,
67
+ `itemassets/contacts/contact-${contactInfo.contactId}`
68
+ ) : void 0;
69
+ const displayName = contactInfo?.name ?? text;
70
+ if (imageUrl && !imageFailed) {
71
+ return /* @__PURE__ */ jsx(
72
+ "img",
73
+ {
74
+ className: "avatar-view inline-block flex-shrink-0 rounded-full object-cover select-none",
75
+ src: imageUrl,
76
+ alt: displayName,
77
+ title: displayName,
78
+ "aria-label": displayName,
79
+ loading: "lazy",
80
+ onError: () => setImageFailed(true),
81
+ style: {
82
+ width: size,
83
+ height: size
84
+ }
85
+ }
86
+ );
87
+ }
88
+ return /* @__PURE__ */ jsx(
89
+ "span",
90
+ {
91
+ className: `avatar-view inline-flex flex-shrink-0 items-center justify-center rounded-full font-semibold uppercase select-none overflow-hidden ${getAvatarColor(displayName)}`,
92
+ title: displayName,
93
+ "aria-label": displayName,
94
+ style: {
95
+ width: size,
96
+ height: size,
97
+ fontSize: "0.6875rem",
98
+ letterSpacing: "0.02em",
99
+ lineHeight: 1
100
+ },
101
+ children: getInitials(displayName)
102
+ }
103
+ );
104
+ };
105
+ var AvatarViewClient_default = AvatarViewClient;
106
+ export {
107
+ AvatarViewClient_default as default
108
+ };
@@ -0,0 +1,106 @@
1
+ "use client";
2
+ import {
3
+ AssetUtility_default
4
+ } from "./chunk-TQ6BXQ3A.mjs";
5
+
6
+ // src/components/controls/view/AvatarViewClient.tsx
7
+ import React from "react";
8
+ import { jsx } from "react/jsx-runtime";
9
+ var AVATAR_COLORS = [
10
+ "bg-error-strong",
11
+ "bg-accent-base",
12
+ "bg-warning-base",
13
+ "bg-success-base",
14
+ "bg-info-base",
15
+ "bg-primary-base",
16
+ "bg-secondary-base"
17
+ ];
18
+ var getAvatarColor = (text) => {
19
+ let hash = 0;
20
+ for (let i = 0; i < text.length; i += 1) {
21
+ hash = hash * 31 + text.charCodeAt(i) >>> 0;
22
+ }
23
+ return AVATAR_COLORS[hash % AVATAR_COLORS.length];
24
+ };
25
+ var getInitials = (text) => {
26
+ const words = text.trim().split(/\s+/).filter(Boolean);
27
+ if (words.length === 0) {
28
+ return "?";
29
+ }
30
+ if (words.length === 1) {
31
+ return words[0].slice(0, 2).toUpperCase();
32
+ }
33
+ return `${words[0][0]}${words[words.length - 1][0]}`.toUpperCase();
34
+ };
35
+ var getContactImageInfo = (text) => {
36
+ if (!text.includes("-")) {
37
+ return null;
38
+ }
39
+ const parts = text.split("-");
40
+ if (parts.length <= 1) {
41
+ return null;
42
+ }
43
+ const first = parts[0].trim();
44
+ if (!/^\d+$/.test(first)) {
45
+ return null;
46
+ }
47
+ return {
48
+ contactId: first,
49
+ name: parts.slice(1).join("-").trim() || text
50
+ };
51
+ };
52
+ var AvatarViewClient = (props) => {
53
+ const text = props.value === null || props.value === void 0 ? "" : String(props.value).trim();
54
+ const [imageFailed, setImageFailed] = React.useState(false);
55
+ React.useEffect(() => {
56
+ setImageFailed(false);
57
+ }, [text, props.assetBaseUrl]);
58
+ if (!text) {
59
+ return null;
60
+ }
61
+ const size = props.width ?? "1.75rem";
62
+ const contactInfo = getContactImageInfo(text);
63
+ const imageUrl = contactInfo ? AssetUtility_default.resolveUrl(
64
+ props.assetBaseUrl,
65
+ `itemassets/contacts/contact-${contactInfo.contactId}`
66
+ ) : void 0;
67
+ const displayName = contactInfo?.name ?? text;
68
+ if (imageUrl && !imageFailed) {
69
+ return /* @__PURE__ */ jsx(
70
+ "img",
71
+ {
72
+ className: "avatar-view inline-block flex-shrink-0 rounded-full object-cover select-none",
73
+ src: imageUrl,
74
+ alt: displayName,
75
+ title: displayName,
76
+ "aria-label": displayName,
77
+ loading: "lazy",
78
+ onError: () => setImageFailed(true),
79
+ style: {
80
+ width: size,
81
+ height: size
82
+ }
83
+ }
84
+ );
85
+ }
86
+ return /* @__PURE__ */ jsx(
87
+ "span",
88
+ {
89
+ className: `avatar-view inline-flex flex-shrink-0 items-center justify-center rounded-full font-semibold uppercase select-none overflow-hidden ${getAvatarColor(displayName)}`,
90
+ title: displayName,
91
+ "aria-label": displayName,
92
+ style: {
93
+ width: size,
94
+ height: size,
95
+ fontSize: "0.6875rem",
96
+ letterSpacing: "0.02em",
97
+ lineHeight: 1
98
+ },
99
+ children: getInitials(displayName)
100
+ }
101
+ );
102
+ };
103
+ var AvatarViewClient_default = AvatarViewClient;
104
+ export {
105
+ AvatarViewClient_default as default
106
+ };
@@ -3,7 +3,7 @@
3
3
  "use client";
4
4
  import {
5
5
  InputControl_default
6
- } from "./chunk-Q3LFGHLM.mjs";
6
+ } from "./chunk-7JWVEYJY.mjs";
7
7
  import {
8
8
  InputControlType_default
9
9
  } from "./chunk-DTWPZPSX.mjs";
@@ -3,7 +3,7 @@
3
3
 
4
4
  // src/components/controls/edit/InputControl.tsx
5
5
  import dynamic from "next/dynamic";
6
- var InputControl = dynamic(() => import("./InputControlClient-GRH7VSJR.mjs"), {
6
+ var InputControl = dynamic(() => import("./InputControlClient-5NX4CEZB.mjs"), {
7
7
  ssr: false
8
8
  });
9
9
  var InputControl_default = InputControl;