@clyrex-digital/clyrex-controls-dev 0.8.1-dev.20261103045814 → 0.8.1-dev.20261119092426

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.
@@ -14,16 +14,17 @@ import {
14
14
  OtpInput_default,
15
15
  PercentageInput_default,
16
16
  PhoneInput_default,
17
+ PicklistInput_default,
17
18
  RadioInput_default,
18
19
  SelectWithSearchInput_default,
19
20
  Select_default,
20
21
  TimeInput_default
21
- } from "./chunk-GNIFUHGR.mjs";
22
+ } from "./chunk-RTUD2GCR.mjs";
22
23
  import {
23
24
  Hyperlink,
24
25
  Icon_default,
25
26
  InputControlType_default
26
- } from "./chunk-N3EYMPAJ.mjs";
27
+ } from "./chunk-W4RXVJJ7.mjs";
27
28
  import {
28
29
  Button_default,
29
30
  ClientButton_default
@@ -592,7 +593,8 @@ var InputControl = React4.forwardRef(
592
593
  [InputControlType_default.switchInput]: SwitchInput_default,
593
594
  [InputControlType_default.dateInput]: DateInput_default,
594
595
  [InputControlType_default.radioInput]: RadioInput_default,
595
- [InputControlType_default.referenceInput]: ReferenceInput_default
596
+ [InputControlType_default.referenceInput]: ReferenceInput_default,
597
+ [InputControlType_default.picklist]: PicklistInput_default
596
598
  };
597
599
  const SelectedControlComponent = ControlComponents[props.controlType];
598
600
  return /* @__PURE__ */ jsx5(React4.Fragment, { children: SelectedControlComponent ? /* @__PURE__ */ jsx5(SelectedControlComponent, { ...props }) : "Control not found:" + props.controlType });
@@ -3,12 +3,12 @@
3
3
  "use client";
4
4
  import {
5
5
  OdataBuilder
6
- } from "./chunk-RSUG2VPX.mjs";
6
+ } from "./chunk-4Y2KBXMJ.mjs";
7
7
  import {
8
8
  Constants,
9
9
  Hyperlink,
10
10
  Icon_default
11
- } from "./chunk-N3EYMPAJ.mjs";
11
+ } from "./chunk-W4RXVJJ7.mjs";
12
12
  import "./chunk-IMNQO57B.mjs";
13
13
 
14
14
  // src/components/Pagination.tsx
@@ -2,7 +2,7 @@
2
2
 
3
3
  import {
4
4
  Constants
5
- } from "./chunk-N3EYMPAJ.mjs";
5
+ } from "./chunk-W4RXVJJ7.mjs";
6
6
 
7
7
  // src/clients/OdataBuilder.tsx
8
8
  var encodeFilter = (filter) => encodeURIComponent(filter);
@@ -2,7 +2,7 @@
2
2
 
3
3
  import {
4
4
  Icon_default
5
- } from "./chunk-N3EYMPAJ.mjs";
5
+ } from "./chunk-W4RXVJJ7.mjs";
6
6
 
7
7
  // src/components/controls/edit/MultilineTextInput.tsx
8
8
  import React from "react";
@@ -1607,6 +1607,280 @@ var RadioInput = (props) => {
1607
1607
  };
1608
1608
  var RadioInput_default = RadioInput;
1609
1609
 
1610
+ // src/components/controls/edit/PicklistInput.tsx
1611
+ import React17, { useState as useState5, useMemo as useMemo3, useCallback } from "react";
1612
+ import { jsx as jsx17, jsxs as jsxs17 } from "react/jsx-runtime";
1613
+ function Svg({
1614
+ s = 16,
1615
+ c = "",
1616
+ fill = "none",
1617
+ sw = 2,
1618
+ children
1619
+ }) {
1620
+ return /* @__PURE__ */ jsx17(
1621
+ "svg",
1622
+ {
1623
+ width: s,
1624
+ height: s,
1625
+ viewBox: "0 0 24 24",
1626
+ fill,
1627
+ stroke: "currentColor",
1628
+ strokeWidth: sw,
1629
+ strokeLinecap: "round",
1630
+ strokeLinejoin: "round",
1631
+ className: c,
1632
+ children
1633
+ }
1634
+ );
1635
+ }
1636
+ var IcoPlus = (p) => /* @__PURE__ */ jsxs17(Svg, { ...p, children: [
1637
+ /* @__PURE__ */ jsx17("line", { x1: "12", y1: "5", x2: "12", y2: "19" }),
1638
+ /* @__PURE__ */ jsx17("line", { x1: "5", y1: "12", x2: "19", y2: "12" })
1639
+ ] });
1640
+ var IcoEdit = (p) => /* @__PURE__ */ jsxs17(Svg, { ...p, children: [
1641
+ /* @__PURE__ */ jsx17("path", { d: "M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" }),
1642
+ /* @__PURE__ */ jsx17("path", { d: "M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z" })
1643
+ ] });
1644
+ var IcoX = (p) => /* @__PURE__ */ jsxs17(Svg, { ...p, children: [
1645
+ /* @__PURE__ */ jsx17("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
1646
+ /* @__PURE__ */ jsx17("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
1647
+ ] });
1648
+ var parseValueToOptions = (val, textField) => {
1649
+ if (val === void 0 || val === null || val === "") return [];
1650
+ let parsed = val;
1651
+ if (typeof parsed === "string") {
1652
+ try {
1653
+ parsed = JSON.parse(parsed);
1654
+ } catch {
1655
+ return parsed.split(",").map((s) => s.trim()).filter(Boolean).map((text) => ({ text, rawItem: text }));
1656
+ }
1657
+ }
1658
+ if (Array.isArray(parsed)) {
1659
+ return parsed.map((item) => {
1660
+ if (typeof item === "string") {
1661
+ return { text: item.trim(), rawItem: item };
1662
+ }
1663
+ if (item && typeof item === "object") {
1664
+ const key = textField || (item.attributeValue !== void 0 ? "attributeValue" : item.value !== void 0 ? "value" : item.name !== void 0 ? "name" : item.title !== void 0 ? "title" : Object.keys(item).find((k) => typeof item[k] === "string"));
1665
+ const text = key && item[key] !== void 0 ? String(item[key]).trim() : "";
1666
+ return { text, rawItem: item };
1667
+ }
1668
+ return { text: String(item).trim(), rawItem: item };
1669
+ }).filter((opt) => opt.text.length > 0);
1670
+ }
1671
+ return [];
1672
+ };
1673
+ var PicklistInput = (props) => {
1674
+ const [isOpen, setIsOpen] = useState5(false);
1675
+ const [draftOptions, setDraftOptions] = useState5([]);
1676
+ const [inputValue, setInputValue] = useState5("");
1677
+ const savedOptions = useMemo3(() => {
1678
+ return parseValueToOptions(props.value, props.dataTextFieldName);
1679
+ }, [props.value, props.dataTextFieldName]);
1680
+ const handleOpen = useCallback(() => {
1681
+ setDraftOptions([...savedOptions]);
1682
+ setInputValue("");
1683
+ setIsOpen(true);
1684
+ }, [savedOptions]);
1685
+ const handleAdd = useCallback(() => {
1686
+ const trimmed = inputValue.trim();
1687
+ if (!trimmed) return;
1688
+ let newTexts = [];
1689
+ if (trimmed.includes(",")) {
1690
+ newTexts = trimmed.split(",").map((s) => s.trim()).filter(Boolean);
1691
+ } else {
1692
+ newTexts = [trimmed];
1693
+ }
1694
+ const updated = [...draftOptions];
1695
+ for (const text of newTexts) {
1696
+ if (!updated.some((opt) => opt.text.toLowerCase() === text.toLowerCase())) {
1697
+ updated.push({ text });
1698
+ }
1699
+ }
1700
+ setDraftOptions(updated);
1701
+ setInputValue("");
1702
+ }, [draftOptions, inputValue]);
1703
+ const handleRemove = useCallback((index) => {
1704
+ setDraftOptions((prev) => prev.filter((_, i) => i !== index));
1705
+ }, []);
1706
+ const handleSave = useCallback(() => {
1707
+ const textField = props.dataTextFieldName || (draftOptions.some(
1708
+ (o) => o.rawItem && typeof o.rawItem === "object" && "attributeValue" in o.rawItem
1709
+ ) ? "attributeValue" : void 0);
1710
+ let outputValue;
1711
+ if (textField) {
1712
+ outputValue = draftOptions.map((opt) => {
1713
+ if (opt.rawItem && typeof opt.rawItem === "object") {
1714
+ return {
1715
+ ...opt.rawItem,
1716
+ [textField]: opt.text
1717
+ };
1718
+ }
1719
+ return {
1720
+ [textField]: opt.text
1721
+ };
1722
+ });
1723
+ } else if (draftOptions.some((o) => o.rawItem && typeof o.rawItem === "object")) {
1724
+ outputValue = draftOptions.map((opt) => {
1725
+ if (opt.rawItem && typeof opt.rawItem === "object") {
1726
+ return {
1727
+ ...opt.rawItem,
1728
+ value: opt.text
1729
+ };
1730
+ }
1731
+ return { value: opt.text };
1732
+ });
1733
+ } else {
1734
+ outputValue = draftOptions.map((opt) => opt.text);
1735
+ }
1736
+ if (props.callback) {
1737
+ props.callback({
1738
+ name: props.name,
1739
+ value: outputValue,
1740
+ index: props.index
1741
+ });
1742
+ }
1743
+ setIsOpen(false);
1744
+ }, [draftOptions, props]);
1745
+ const title = props.attributes?.label || (typeof props.name === "string" ? props.name : "Field");
1746
+ return /* @__PURE__ */ jsxs17(React17.Fragment, { children: [
1747
+ /* @__PURE__ */ jsxs17(
1748
+ "button",
1749
+ {
1750
+ type: "button",
1751
+ onClick: handleOpen,
1752
+ disabled: props.attributes?.disable || props.disable || props.attributes?.readOnly,
1753
+ className: "w-full text-left px-2.5 py-1.5 text-xs bg-neutral-weak hover:bg-neutral-soft border border-neutral-soft rounded transition-colors flex items-center justify-between gap-2 shadow-2xs group cursor-pointer disabled:opacity-50",
1754
+ children: [
1755
+ /* @__PURE__ */ jsx17("div", { className: "truncate flex items-center gap-1.5 min-w-0", children: savedOptions.length > 0 ? /* @__PURE__ */ jsxs17(React17.Fragment, { children: [
1756
+ /* @__PURE__ */ jsxs17("span", { className: "shrink-0 text-[10px] font-bold px-1.5 py-0.5 rounded-full bg-info-weak border border-info-soft", children: [
1757
+ savedOptions.length,
1758
+ " option",
1759
+ savedOptions.length !== 1 ? "s" : ""
1760
+ ] }),
1761
+ /* @__PURE__ */ jsxs17("span", { className: "truncate opacity-75 text-[11px]", children: [
1762
+ savedOptions.slice(0, 2).map((o) => o.text).join(", "),
1763
+ savedOptions.length > 2 ? ` (+${savedOptions.length - 2})` : ""
1764
+ ] })
1765
+ ] }) : /* @__PURE__ */ jsxs17("span", { className: "italic text-[11px] flex items-center gap-1", children: [
1766
+ /* @__PURE__ */ jsx17(IcoPlus, { s: 11 }),
1767
+ " ",
1768
+ props.attributes?.placeholder || "Add Options"
1769
+ ] }) }),
1770
+ /* @__PURE__ */ jsx17("span", { className: "shrink-0 p-1 rounded-md bg-neutral-weak group-hover:bg-neutral-soft transition-colors", children: /* @__PURE__ */ jsx17(IcoEdit, { s: 11 }) })
1771
+ ]
1772
+ }
1773
+ ),
1774
+ isOpen && /* @__PURE__ */ jsxs17("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-neutral-stronger/60 backdrop-blur-xs", children: [
1775
+ /* @__PURE__ */ jsx17(
1776
+ "div",
1777
+ {
1778
+ className: "absolute inset-0",
1779
+ onClick: () => setIsOpen(false)
1780
+ }
1781
+ ),
1782
+ /* @__PURE__ */ jsxs17("div", { className: "relative bg-neutral-weak border border-neutral-soft rounded-2xl shadow-2xl w-full max-w-xl mx-4 overflow-hidden z-10", children: [
1783
+ /* @__PURE__ */ jsxs17("div", { className: "flex items-center justify-between px-6 py-4 border-b border-neutral-soft", children: [
1784
+ /* @__PURE__ */ jsxs17("h2", { className: "text-sm font-bold", children: [
1785
+ "Configure Picklist \u2014 ",
1786
+ title
1787
+ ] }),
1788
+ /* @__PURE__ */ jsx17(
1789
+ "button",
1790
+ {
1791
+ type: "button",
1792
+ onClick: () => setIsOpen(false),
1793
+ className: "p-1 rounded-lg bg-neutral-weak hover:bg-neutral-soft border border-neutral-soft cursor-pointer transition-colors",
1794
+ children: /* @__PURE__ */ jsx17(IcoX, { s: 14 })
1795
+ }
1796
+ )
1797
+ ] }),
1798
+ /* @__PURE__ */ jsxs17("div", { className: "px-6 py-5 space-y-4", children: [
1799
+ /* @__PURE__ */ jsxs17("div", { children: [
1800
+ /* @__PURE__ */ jsx17("p", { className: "text-xs font-semibold mb-1", children: "Add Options" }),
1801
+ /* @__PURE__ */ jsxs17("div", { className: "flex items-stretch gap-2", children: [
1802
+ /* @__PURE__ */ jsx17(
1803
+ "input",
1804
+ {
1805
+ type: "text",
1806
+ value: inputValue,
1807
+ onChange: (e) => setInputValue(e.target.value),
1808
+ onKeyDown: (e) => {
1809
+ if (e.key === "Enter") {
1810
+ e.preventDefault();
1811
+ handleAdd();
1812
+ }
1813
+ },
1814
+ placeholder: "Type option name or paste comma-separated values",
1815
+ className: "flex-1 px-3 py-2 text-xs bg-neutral-weak border border-neutral-soft rounded-lg focus:outline-hidden focus:border-primary-base"
1816
+ }
1817
+ ),
1818
+ /* @__PURE__ */ jsx17(
1819
+ "button",
1820
+ {
1821
+ type: "button",
1822
+ onClick: handleAdd,
1823
+ disabled: !inputValue.trim(),
1824
+ className: "px-3 py-2 text-xs font-semibold bg-primary-base hover:bg-primary-strong disabled:opacity-50 border border-primary-strong rounded-lg cursor-pointer flex items-center justify-center gap-1 transition-colors",
1825
+ children: /* @__PURE__ */ jsx17(IcoPlus, { s: 12 })
1826
+ }
1827
+ )
1828
+ ] }),
1829
+ /* @__PURE__ */ jsx17("small", { className: "bg-info-weak border border-info-soft rounded-md px-3 py-1.5 block mt-2 text-[11px]", children: "Tip: Paste comma-separated values (e.g. \u201Cremote, office, hybrid\u201D) to add multiple options at once." })
1830
+ ] }),
1831
+ /* @__PURE__ */ jsxs17("div", { children: [
1832
+ /* @__PURE__ */ jsxs17("div", { className: "flex items-center justify-between mb-2", children: [
1833
+ /* @__PURE__ */ jsx17("p", { className: "text-xs font-semibold", children: "Configured Options" }),
1834
+ /* @__PURE__ */ jsx17("span", { className: "text-[10px] font-bold bg-neutral-soft px-2 py-0.5 rounded-full", children: draftOptions.length })
1835
+ ] }),
1836
+ draftOptions.length === 0 ? /* @__PURE__ */ jsx17("div", { className: "p-6 bg-neutral-soft rounded-md border border-dashed border-neutral-base text-center", children: /* @__PURE__ */ jsx17("small", { className: "italic block", children: "No options defined yet. Type above to add options." }) }) : /* @__PURE__ */ jsx17("div", { className: "flex flex-wrap gap-1.5 max-h-48 overflow-y-auto", children: draftOptions.map((opt, idx) => /* @__PURE__ */ jsxs17(
1837
+ "div",
1838
+ {
1839
+ className: "flex items-center gap-1.5 px-2.5 py-1 bg-info-soft hover:bg-neutral-soft border border-info-soft rounded-md text-xs font-semibold transition-colors",
1840
+ children: [
1841
+ /* @__PURE__ */ jsx17("span", { children: opt.text }),
1842
+ /* @__PURE__ */ jsx17(
1843
+ "button",
1844
+ {
1845
+ type: "button",
1846
+ onClick: () => handleRemove(idx),
1847
+ title: "Remove option",
1848
+ className: "p-0.5 rounded hover:bg-error-soft cursor-pointer transition-colors",
1849
+ children: /* @__PURE__ */ jsx17(IcoX, { s: 11 })
1850
+ }
1851
+ )
1852
+ ]
1853
+ },
1854
+ idx
1855
+ )) })
1856
+ ] })
1857
+ ] }),
1858
+ /* @__PURE__ */ jsxs17("div", { className: "flex justify-end gap-2 px-6 py-4 border-t border-neutral-soft bg-neutral-weak", children: [
1859
+ /* @__PURE__ */ jsx17(
1860
+ "button",
1861
+ {
1862
+ type: "button",
1863
+ onClick: () => setIsOpen(false),
1864
+ className: "px-4 py-2 text-xs font-medium bg-neutral-soft hover:bg-neutral-base border border-neutral-soft rounded-lg cursor-pointer transition-colors",
1865
+ children: "Cancel"
1866
+ }
1867
+ ),
1868
+ /* @__PURE__ */ jsx17(
1869
+ "button",
1870
+ {
1871
+ type: "button",
1872
+ onClick: handleSave,
1873
+ className: "px-4 py-2 text-xs font-medium bg-primary-base hover:bg-primary-strong border border-primary-strong rounded-lg cursor-pointer transition-colors",
1874
+ children: "Save Options"
1875
+ }
1876
+ )
1877
+ ] })
1878
+ ] })
1879
+ ] })
1880
+ ] });
1881
+ };
1882
+ var PicklistInput_default = PicklistInput;
1883
+
1610
1884
  export {
1611
1885
  MultilineTextInput_default,
1612
1886
  LineTextInput_default,
@@ -1630,5 +1904,6 @@ export {
1630
1904
  EmailInput_default,
1631
1905
  TimeInput_default,
1632
1906
  DateInput_default,
1633
- RadioInput_default
1907
+ RadioInput_default,
1908
+ PicklistInput_default
1634
1909
  };
@@ -29,7 +29,8 @@ var InputControlType = {
29
29
  dateInput: "dateInput",
30
30
  radioInput: "radioInput",
31
31
  videoInput: "videoInput",
32
- referenceInput: "referenceInput"
32
+ referenceInput: "referenceInput",
33
+ picklist: "picklist"
33
34
  };
34
35
  var InputControlType_default = InputControlType;
35
36
 
package/dist/index.d.mts CHANGED
@@ -69,6 +69,7 @@ declare const InputControlType: {
69
69
  radioInput: string;
70
70
  videoInput: string;
71
71
  referenceInput: string;
72
+ picklist: string;
72
73
  };
73
74
 
74
75
  interface InputCallbackValues<T> {
@@ -311,6 +312,8 @@ declare const DateInput: React__default.FC<InputControlProps>;
311
312
 
312
313
  declare const RadioInput: React__default.FC<InputControlProps>;
313
314
 
315
+ declare const PicklistInput: React__default.FC<InputControlProps>;
316
+
314
317
  interface TabItem {
315
318
  tabTitle: string;
316
319
  displayOrder: number;
@@ -510,4 +513,4 @@ interface DataFormRendererProps {
510
513
  }
511
514
  declare const DataFormRenderer: ({ formDefinition, dataItem, params, tabs, apiBaseUrl, session, widgetProps, onSave, onDelete, onCancelAdd, isAddPage, entityId, }: DataFormRendererProps) => React.JSX.Element | null;
512
515
 
513
- export { type ActionResponse$1 as ActionResponse, Button, COUNTRY_CODES, CheckboxInput, ColorInput, type CountryCode, DataFormRenderer, DataList, DataListRenderer, DateInput, DateTimeInput, EmailInput, EnterAnimationHydrator, InputControl, type InputControlProps, InputControlType, LineTextInput, MoneyInput, MultilineTextInput, NavigationTabsV2, NumberInput, OtpInput, PageBodyRenderer, PercentageInput, PhoneInput, RadioInput, Select, StyleTypes, TimeInput, Toast, ToastService, ViewControl, type ViewControlProps, ViewControlTypes, findCountryByDialCode, findCountryByIso2, getCountryFlag, getDialCodeByCountryCode, resolveCountry, splitPhoneNumber };
516
+ export { type ActionResponse$1 as ActionResponse, Button, COUNTRY_CODES, CheckboxInput, ColorInput, type CountryCode, DataFormRenderer, DataList, DataListRenderer, DateInput, DateTimeInput, EmailInput, EnterAnimationHydrator, InputControl, type InputControlProps, InputControlType, LineTextInput, MoneyInput, MultilineTextInput, NavigationTabsV2, NumberInput, OtpInput, PageBodyRenderer, PercentageInput, PhoneInput, PicklistInput, RadioInput, Select, StyleTypes, TimeInput, Toast, ToastService, ViewControl, type ViewControlProps, ViewControlTypes, findCountryByDialCode, findCountryByIso2, getCountryFlag, getDialCodeByCountryCode, resolveCountry, splitPhoneNumber };
package/dist/index.d.ts CHANGED
@@ -69,6 +69,7 @@ declare const InputControlType: {
69
69
  radioInput: string;
70
70
  videoInput: string;
71
71
  referenceInput: string;
72
+ picklist: string;
72
73
  };
73
74
 
74
75
  interface InputCallbackValues<T> {
@@ -311,6 +312,8 @@ declare const DateInput: React__default.FC<InputControlProps>;
311
312
 
312
313
  declare const RadioInput: React__default.FC<InputControlProps>;
313
314
 
315
+ declare const PicklistInput: React__default.FC<InputControlProps>;
316
+
314
317
  interface TabItem {
315
318
  tabTitle: string;
316
319
  displayOrder: number;
@@ -510,4 +513,4 @@ interface DataFormRendererProps {
510
513
  }
511
514
  declare const DataFormRenderer: ({ formDefinition, dataItem, params, tabs, apiBaseUrl, session, widgetProps, onSave, onDelete, onCancelAdd, isAddPage, entityId, }: DataFormRendererProps) => React.JSX.Element | null;
512
515
 
513
- export { type ActionResponse$1 as ActionResponse, Button, COUNTRY_CODES, CheckboxInput, ColorInput, type CountryCode, DataFormRenderer, DataList, DataListRenderer, DateInput, DateTimeInput, EmailInput, EnterAnimationHydrator, InputControl, type InputControlProps, InputControlType, LineTextInput, MoneyInput, MultilineTextInput, NavigationTabsV2, NumberInput, OtpInput, PageBodyRenderer, PercentageInput, PhoneInput, RadioInput, Select, StyleTypes, TimeInput, Toast, ToastService, ViewControl, type ViewControlProps, ViewControlTypes, findCountryByDialCode, findCountryByIso2, getCountryFlag, getDialCodeByCountryCode, resolveCountry, splitPhoneNumber };
516
+ export { type ActionResponse$1 as ActionResponse, Button, COUNTRY_CODES, CheckboxInput, ColorInput, type CountryCode, DataFormRenderer, DataList, DataListRenderer, DateInput, DateTimeInput, EmailInput, EnterAnimationHydrator, InputControl, type InputControlProps, InputControlType, LineTextInput, MoneyInput, MultilineTextInput, NavigationTabsV2, NumberInput, OtpInput, PageBodyRenderer, PercentageInput, PhoneInput, PicklistInput, RadioInput, Select, StyleTypes, TimeInput, Toast, ToastService, ViewControl, type ViewControlProps, ViewControlTypes, findCountryByDialCode, findCountryByIso2, getCountryFlag, getDialCodeByCountryCode, resolveCountry, splitPhoneNumber };