@clyrex-digital/clyrex-controls-dev 0.8.1-dev.20260724042342 → 0.8.1-dev.20260724060217

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.
@@ -39,7 +39,7 @@ import React5 from "react";
39
39
  import { useState, useEffect } from "react";
40
40
  import { jsx, jsxs } from "react/jsx-runtime";
41
41
  var Select = (props) => {
42
- const [list, setList] = useState([]);
42
+ const [list, setList] = useState();
43
43
  const getSafeValue = (val) => {
44
44
  if (val === null || val === void 0) return "";
45
45
  if (typeof val === "boolean") return val ? "1" : "0";
@@ -68,6 +68,14 @@ var Select = (props) => {
68
68
  groupKey: props.groupKey
69
69
  });
70
70
  };
71
+ const inputChangeHandler = (event) => {
72
+ props.callback?.({
73
+ name: props.name,
74
+ value: event.target.value,
75
+ index: props.index,
76
+ groupKey: props.groupKey
77
+ });
78
+ };
71
79
  useEffect(() => {
72
80
  async function fetchData() {
73
81
  if (props.dataset) {
@@ -77,7 +85,11 @@ var Select = (props) => {
77
85
  if (props.dataSource && props.serviceClient) {
78
86
  let dataSource = props.dataSource;
79
87
  let response;
80
- if (props.dataSourceDependsOn && props.dependentValue) {
88
+ if (props.dataSourceDependsOn) {
89
+ if (!props.dependentValue) {
90
+ setList([]);
91
+ return;
92
+ }
81
93
  dataSource = dataSource.replace(
82
94
  `{${props.dataSourceDependsOn}}`,
83
95
  props.dependentValue
@@ -85,7 +97,9 @@ var Select = (props) => {
85
97
  }
86
98
  response = await props.serviceClient.get(dataSource);
87
99
  setList(response.result ?? []);
100
+ return;
88
101
  }
102
+ setList([]);
89
103
  }
90
104
  fetchData();
91
105
  }, [
@@ -99,7 +113,24 @@ var Select = (props) => {
99
113
  props.attributes?.label && /* @__PURE__ */ jsx("span", { className: "text-sm font-medium inline-block pb-1", children: props.attributes?.label }),
100
114
  " ",
101
115
  props.attributes?.label && props.attributes?.required && /* @__PURE__ */ jsx("span", { className: "bg-error-weak", children: "*" }),
102
- /* @__PURE__ */ jsxs(
116
+ list && list.length === 0 && /* @__PURE__ */ jsx(
117
+ "input",
118
+ {
119
+ type: "text",
120
+ name: props.name,
121
+ id: props.name,
122
+ value,
123
+ onChange: inputChangeHandler,
124
+ required: props.attributes?.required,
125
+ placeholder: props.attributes?.placeholder,
126
+ maxLength: props.attributes?.maxLength,
127
+ pattern: props.attributes?.pattern,
128
+ disabled: props.attributes?.readOnly,
129
+ minLength: props.attributes?.minLength,
130
+ className: `peer input select mt-1 py-1.5 block w-full rounded shadow-sm ${props.inputClasses ?? ""}`
131
+ }
132
+ ),
133
+ list && list.length > 0 && /* @__PURE__ */ jsxs(
103
134
  "select",
104
135
  {
105
136
  name: props.name,
@@ -108,7 +139,9 @@ var Select = (props) => {
108
139
  onChange: textChangeHandler,
109
140
  required: props.attributes?.required,
110
141
  disabled: props.attributes?.readOnly,
111
- className: "peer select py-1.5 block w-full text-black rounded border-gray-300 shadow-sm\n focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50\n disabled:bg-slate-50 disabled:text-slate-500 disabled:border-slate-200 disabled:shadow-none",
142
+ className: `peer select py-1.5 block w-full text-black rounded border-gray-300 shadow-sm
143
+ focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50
144
+ disabled:bg-slate-50 disabled:text-slate-500 disabled:border-slate-200 disabled:shadow-none ${props.inputClasses ?? ""}`,
112
145
  children: [
113
146
  /* @__PURE__ */ jsx("option", { value: "", children: props.attributes?.placeholder || "Select" }),
114
147
  list.map((item, index) => {
package/dist/index.js CHANGED
@@ -1032,7 +1032,7 @@ var init_Select = __esm({
1032
1032
  import_react19 = require("react");
1033
1033
  import_jsx_runtime22 = require("react/jsx-runtime");
1034
1034
  Select = (props) => {
1035
- const [list, setList] = (0, import_react19.useState)([]);
1035
+ const [list, setList] = (0, import_react19.useState)();
1036
1036
  const getSafeValue = (val) => {
1037
1037
  if (val === null || val === void 0) return "";
1038
1038
  if (typeof val === "boolean") return val ? "1" : "0";
@@ -1061,6 +1061,14 @@ var init_Select = __esm({
1061
1061
  groupKey: props.groupKey
1062
1062
  });
1063
1063
  };
1064
+ const inputChangeHandler = (event) => {
1065
+ props.callback?.({
1066
+ name: props.name,
1067
+ value: event.target.value,
1068
+ index: props.index,
1069
+ groupKey: props.groupKey
1070
+ });
1071
+ };
1064
1072
  (0, import_react19.useEffect)(() => {
1065
1073
  async function fetchData() {
1066
1074
  if (props.dataset) {
@@ -1070,7 +1078,11 @@ var init_Select = __esm({
1070
1078
  if (props.dataSource && props.serviceClient) {
1071
1079
  let dataSource = props.dataSource;
1072
1080
  let response;
1073
- if (props.dataSourceDependsOn && props.dependentValue) {
1081
+ if (props.dataSourceDependsOn) {
1082
+ if (!props.dependentValue) {
1083
+ setList([]);
1084
+ return;
1085
+ }
1074
1086
  dataSource = dataSource.replace(
1075
1087
  `{${props.dataSourceDependsOn}}`,
1076
1088
  props.dependentValue
@@ -1078,7 +1090,9 @@ var init_Select = __esm({
1078
1090
  }
1079
1091
  response = await props.serviceClient.get(dataSource);
1080
1092
  setList(response.result ?? []);
1093
+ return;
1081
1094
  }
1095
+ setList([]);
1082
1096
  }
1083
1097
  fetchData();
1084
1098
  }, [
@@ -1092,7 +1106,24 @@ var init_Select = __esm({
1092
1106
  props.attributes?.label && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "text-sm font-medium inline-block pb-1", children: props.attributes?.label }),
1093
1107
  " ",
1094
1108
  props.attributes?.label && props.attributes?.required && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "bg-error-weak", children: "*" }),
1095
- /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
1109
+ list && list.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
1110
+ "input",
1111
+ {
1112
+ type: "text",
1113
+ name: props.name,
1114
+ id: props.name,
1115
+ value,
1116
+ onChange: inputChangeHandler,
1117
+ required: props.attributes?.required,
1118
+ placeholder: props.attributes?.placeholder,
1119
+ maxLength: props.attributes?.maxLength,
1120
+ pattern: props.attributes?.pattern,
1121
+ disabled: props.attributes?.readOnly,
1122
+ minLength: props.attributes?.minLength,
1123
+ className: `peer input select mt-1 py-1.5 block w-full rounded shadow-sm ${props.inputClasses ?? ""}`
1124
+ }
1125
+ ),
1126
+ list && list.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
1096
1127
  "select",
1097
1128
  {
1098
1129
  name: props.name,
@@ -1101,7 +1132,9 @@ var init_Select = __esm({
1101
1132
  onChange: textChangeHandler,
1102
1133
  required: props.attributes?.required,
1103
1134
  disabled: props.attributes?.readOnly,
1104
- className: "peer select py-1.5 block w-full text-black rounded border-gray-300 shadow-sm\n focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50\n disabled:bg-slate-50 disabled:text-slate-500 disabled:border-slate-200 disabled:shadow-none",
1135
+ className: `peer select py-1.5 block w-full text-black rounded border-gray-300 shadow-sm
1136
+ focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50
1137
+ disabled:bg-slate-50 disabled:text-slate-500 disabled:border-slate-200 disabled:shadow-none ${props.inputClasses ?? ""}`,
1105
1138
  children: [
1106
1139
  /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("option", { value: "", children: props.attributes?.placeholder || "Select" }),
1107
1140
  list.map((item, index) => {
package/dist/index.mjs CHANGED
@@ -412,7 +412,7 @@ var ViewControl_default = ViewControl;
412
412
 
413
413
  // src/components/controls/edit/InputControl.tsx
414
414
  import dynamic4 from "next/dynamic";
415
- var InputControl = dynamic4(() => import("./InputControlClient-TE33BZ6U.mjs"), {
415
+ var InputControl = dynamic4(() => import("./InputControlClient-J2NUB5BS.mjs"), {
416
416
  ssr: false
417
417
  });
418
418
  var InputControl_default = InputControl;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clyrex-digital/clyrex-controls-dev",
3
- "version": "0.8.1-dev.20260724042342",
3
+ "version": "0.8.1-dev.20260724060217",
4
4
  "description": "Reusable React components",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",