@wistia/ui 0.8.0 → 0.8.1-beta.457b4199.8f2a9db

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.
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  /*
3
- * @license @wistia/ui v0.8.0
3
+ * @license @wistia/ui v0.8.1-beta.457b4199.8f2a9db
4
4
  *
5
5
  * Copyright (c) 2024-2025, Wistia, Inc. and its affiliates.
6
6
  *
@@ -76,6 +76,7 @@ __export(index_exports, {
76
76
  Image: () => Image,
77
77
  ImageDimensionsValidator: () => import_validators.ImageDimensionsValidator,
78
78
  Input: () => Input,
79
+ InputClickToCopy: () => InputClickToCopy,
79
80
  Label: () => Label,
80
81
  Link: () => Link,
81
82
  Menu: () => Menu,
@@ -7032,11 +7033,14 @@ var Link = (0, import_react15.forwardRef)(
7032
7033
  }, ref) => {
7033
7034
  const inRouterContext = (0, import_react_router_dom.useInRouterContext)();
7034
7035
  const to = generateHref(props.href, type, disabled);
7036
+ const shouldUseReactRouterLink = inRouterContext && type !== "external" && !to?.startsWith("http");
7035
7037
  const handleClick = async (event) => {
7036
7038
  if (disabled) {
7037
7039
  event.preventDefault();
7038
7040
  } else if (beforeAction) {
7039
- event.preventDefault();
7041
+ if (!shouldUseReactRouterLink) {
7042
+ event.preventDefault();
7043
+ }
7040
7044
  try {
7041
7045
  await beforeAction();
7042
7046
  } catch (error) {
@@ -7080,7 +7084,6 @@ var Link = (0, import_react15.forwardRef)(
7080
7084
  ...commonProps,
7081
7085
  ...externalLinkProps
7082
7086
  };
7083
- const shouldUseReactRouterLink = inRouterContext && type !== "external" && !to?.startsWith("http");
7084
7087
  return shouldUseReactRouterLink ? /* @__PURE__ */ (0, import_jsx_runtime192.jsx)(
7085
7088
  StyledLink,
7086
7089
  {
@@ -12693,6 +12696,70 @@ var Thumbnail = (0, import_react66.forwardRef)(
12693
12696
  }
12694
12697
  );
12695
12698
  Thumbnail.displayName = "Thumbnail";
12699
+
12700
+ // src/components/InputClickToCopy/InputClickToCopy.tsx
12701
+ var import_styled_components90 = __toESM(require("styled-components"));
12702
+ var import_react67 = require("react");
12703
+ var import_type_guards54 = require("@wistia/type-guards");
12704
+ var import_jsx_runtime271 = require("react/jsx-runtime");
12705
+ var StyledInput2 = (0, import_styled_components90.default)(Input)`
12706
+ &:not([aria-disabled='true']) {
12707
+ cursor: pointer;
12708
+ }
12709
+
12710
+ &::selection {
12711
+ background-color: transparent;
12712
+ }
12713
+ `;
12714
+ var COPY_SUCCESS_DURATION = 2e3;
12715
+ var InputClickToCopy = (0, import_react67.forwardRef)(
12716
+ ({ value, onCopy, ...props }, ref) => {
12717
+ const [isCopied, setIsCopied] = (0, import_react67.useState)(false);
12718
+ (0, import_react67.useEffect)(() => {
12719
+ if (isCopied) {
12720
+ const timeout = setTimeout(() => {
12721
+ setIsCopied(false);
12722
+ }, COPY_SUCCESS_DURATION);
12723
+ return () => {
12724
+ clearTimeout(timeout);
12725
+ };
12726
+ }
12727
+ return () => null;
12728
+ }, [isCopied]);
12729
+ const handleClick = (event) => {
12730
+ event.preventDefault();
12731
+ if ((0, import_type_guards54.isFunction)(props.onClick)) {
12732
+ props.onClick(event);
12733
+ }
12734
+ void copyToClipboard(value).then(() => {
12735
+ setIsCopied(true);
12736
+ if ((0, import_type_guards54.isFunction)(onCopy)) {
12737
+ onCopy(value);
12738
+ }
12739
+ return value;
12740
+ });
12741
+ };
12742
+ return /* @__PURE__ */ (0, import_jsx_runtime271.jsx)(
12743
+ StyledInput2,
12744
+ {
12745
+ "aria-label": "Click to Copy",
12746
+ ...props,
12747
+ ref,
12748
+ onClick: handleClick,
12749
+ readOnly: true,
12750
+ rightIcon: isCopied ? /* @__PURE__ */ (0, import_jsx_runtime271.jsx)(
12751
+ Icon,
12752
+ {
12753
+ colorScheme: "success",
12754
+ type: "checkmark-circle"
12755
+ }
12756
+ ) : /* @__PURE__ */ (0, import_jsx_runtime271.jsx)(Icon, { type: "save-as-copy" }),
12757
+ value
12758
+ }
12759
+ );
12760
+ }
12761
+ );
12762
+ InputClickToCopy.displayName = "InputClickToCopy";
12696
12763
  // Annotate the CommonJS export names for ESM import in node:
12697
12764
  0 && (module.exports = {
12698
12765
  ActionButton,
@@ -12732,6 +12799,7 @@ Thumbnail.displayName = "Thumbnail";
12732
12799
  Image,
12733
12800
  ImageDimensionsValidator,
12734
12801
  Input,
12802
+ InputClickToCopy,
12735
12803
  Label,
12736
12804
  Link,
12737
12805
  Menu,