@cmdniels/uikit 1.0.2 → 1.0.3

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.
@@ -31,7 +31,8 @@ export default function CopyInput(_a) {
31
31
  const text = (_d = (_c = Children.map(children, (child) => {
32
32
  if (isValidElement(child) && child.props.children) {
33
33
  const inputGroupText = child.props.children;
34
- if (isValidElement(inputGroupText) && inputGroupText.props.children) {
34
+ if (isValidElement(inputGroupText) &&
35
+ inputGroupText.props.children) {
35
36
  const innerText = inputGroupText.props.children;
36
37
  if (typeof innerText === "string" || typeof innerText === "number") {
37
38
  return innerText;
@@ -18,10 +18,22 @@ import InputGroup from "../../components/input-group/InputGroup";
18
18
  import InputGroupAddon from "../../components/input-group/InputGroupAddon";
19
19
  import InputGroupInput from "../../components/input-group/InputGroupInput";
20
20
  export default function LinkInput(_a) {
21
+ var _b, _c;
21
22
  var { disabled, defaultValue, value, onChange, children } = _a, props = __rest(_a, ["disabled", "defaultValue", "value", "onChange", "children"]);
22
23
  const inputRef = useRef(null);
23
24
  const debounceRef = useRef(undefined);
24
25
  const [hasValidValue, setHasValidValue] = useState(/^https?:\/\/.+/.test(String(value !== null && value !== void 0 ? value : defaultValue)));
26
+ const innerText = (_c = (_b = Children.map(children, (child) => {
27
+ if (isValidElement(child) && child.props.children) {
28
+ const inputGroupText = child.props.children;
29
+ if (isValidElement(inputGroupText) && inputGroupText.props.children) {
30
+ const inputGroupTextInnerText = inputGroupText.props.children;
31
+ if (typeof inputGroupTextInnerText === "string" || typeof inputGroupTextInnerText === "number") {
32
+ return inputGroupTextInnerText;
33
+ }
34
+ }
35
+ }
36
+ })) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : "";
25
37
  const handleChange = (e) => {
26
38
  onChange === null || onChange === void 0 ? void 0 : onChange(e);
27
39
  if (!e.target.value) {
@@ -29,24 +41,13 @@ export default function LinkInput(_a) {
29
41
  }
30
42
  clearTimeout(debounceRef.current);
31
43
  debounceRef.current = setTimeout(() => {
32
- setHasValidValue(/^https?:\/\/.+/.test(e.target.value));
44
+ setHasValidValue(/^https?:\/\/.+/.test(innerText + e.target.value));
33
45
  }, 300);
34
46
  };
35
- const handleCopy = () => {
36
- var _a, _b, _c, _d;
47
+ const handleOpen = () => {
48
+ var _a, _b;
37
49
  const inputValue = (_b = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : "";
38
- const text = (_d = (_c = Children.map(children, (child) => {
39
- if (isValidElement(child) && child.props.children) {
40
- const inputGroupText = child.props.children;
41
- if (isValidElement(inputGroupText) && inputGroupText.props.children) {
42
- const innerText = inputGroupText.props.children;
43
- if (typeof innerText === "string" || typeof innerText === "number") {
44
- return innerText;
45
- }
46
- }
47
- }
48
- })) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : "";
49
- window.open(text + inputValue, "_blank", "noopener,noreferrer");
50
+ window.open(innerText + inputValue, "_blank", "noopener,noreferrer");
50
51
  };
51
- return (_jsxs(InputGroup, { children: [_jsx(InputGroupInput, Object.assign({ ref: inputRef, disabled: disabled, defaultValue: defaultValue, value: value, onChange: handleChange }, props)), _jsx(InputGroupAddon, { align: "inline-end", children: _jsx(Button, { variant: "link", className: "h-8 px-2", disabled: disabled !== null && disabled !== void 0 ? disabled : !hasValidValue, onClick: handleCopy, children: _jsx(IconExternalLink, { className: "size-4" }) }) }), children] }));
52
+ return (_jsxs(InputGroup, { children: [_jsx(InputGroupInput, Object.assign({ ref: inputRef, disabled: disabled, defaultValue: defaultValue, value: value, onChange: handleChange }, props)), _jsx(InputGroupAddon, { align: "inline-end", children: _jsx(Button, { variant: "link", className: "h-8 px-2", disabled: disabled !== null && disabled !== void 0 ? disabled : !hasValidValue, onClick: handleOpen, children: _jsx(IconExternalLink, { className: "size-4" }) }) }), children] }));
52
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmdniels/uikit",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "type": "module",