@cmdniels/uikit 1.0.2 → 1.0.4

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.
@@ -1,11 +1,11 @@
1
1
  import { cva } from "class-variance-authority";
2
- export const badgeVariants = cva("group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!", {
2
+ export const badgeVariants = cva("group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all duration-300 ease-in-out focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!", {
3
3
  variants: {
4
4
  variant: {
5
5
  default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
6
6
  secondary: "bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",
7
7
  destructive: "bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",
8
- outline: "border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",
8
+ outline: "border-border bg-background text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",
9
9
  ghost: "hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",
10
10
  link: "text-primary underline-offset-4 hover:underline",
11
11
  },
@@ -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.4",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "type": "module",