@wistia/ui 0.5.3-beta.eb8f3f6e.3b96b5f → 0.5.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.
- package/dist/index.cjs +56 -169
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +14 -47
- package/dist/index.d.ts +14 -47
- package/dist/index.mjs +62 -175
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
/*
|
|
3
|
-
* @license @wistia/ui v0.5.3
|
|
3
|
+
* @license @wistia/ui v0.5.3
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2024-2025, Wistia, Inc. and its affiliates.
|
|
6
6
|
*
|
|
@@ -6899,15 +6899,6 @@ var variantStyleMap = {
|
|
|
6899
6899
|
heading6: heading6TextStyle
|
|
6900
6900
|
};
|
|
6901
6901
|
var DEFAULT_ELEMENT2 = "h1";
|
|
6902
|
-
var variantElementMap = {
|
|
6903
|
-
hero: DEFAULT_ELEMENT2,
|
|
6904
|
-
heading1: DEFAULT_ELEMENT2,
|
|
6905
|
-
heading2: "h2",
|
|
6906
|
-
heading3: "h3",
|
|
6907
|
-
heading4: "h4",
|
|
6908
|
-
heading5: "h5",
|
|
6909
|
-
heading6: "h6"
|
|
6910
|
-
};
|
|
6911
6902
|
var StyledHeading = import_styled_components30.default.div`
|
|
6912
6903
|
${({ $colorScheme }) => getColorScheme($colorScheme)};
|
|
6913
6904
|
font-family: var(--font-family);
|
|
@@ -6931,6 +6922,15 @@ var StyledHeading = import_styled_components30.default.div`
|
|
|
6931
6922
|
`}
|
|
6932
6923
|
margin: 0;
|
|
6933
6924
|
`;
|
|
6925
|
+
var variantElementMap = {
|
|
6926
|
+
hero: DEFAULT_ELEMENT2,
|
|
6927
|
+
heading1: DEFAULT_ELEMENT2,
|
|
6928
|
+
heading2: "h2",
|
|
6929
|
+
heading3: "h3",
|
|
6930
|
+
heading4: "h4",
|
|
6931
|
+
heading5: "h5",
|
|
6932
|
+
heading6: "h6"
|
|
6933
|
+
};
|
|
6934
6934
|
var HeadingComponent = (0, import_react18.forwardRef)(
|
|
6935
6935
|
({
|
|
6936
6936
|
align = "left",
|
|
@@ -7523,23 +7523,6 @@ var variantStyleMap2 = {
|
|
|
7523
7523
|
label3: label3TextStyle,
|
|
7524
7524
|
label4: label4TextStyle
|
|
7525
7525
|
};
|
|
7526
|
-
var bodyElement = "p";
|
|
7527
|
-
var labelElement = "span";
|
|
7528
|
-
var DEFAULT_ELEMENT4 = bodyElement;
|
|
7529
|
-
var variantElementMap2 = {
|
|
7530
|
-
body1: bodyElement,
|
|
7531
|
-
body2: bodyElement,
|
|
7532
|
-
body3: bodyElement,
|
|
7533
|
-
body4: bodyElement,
|
|
7534
|
-
body1Mono: bodyElement,
|
|
7535
|
-
body2Mono: bodyElement,
|
|
7536
|
-
body3Mono: bodyElement,
|
|
7537
|
-
body4Mono: bodyElement,
|
|
7538
|
-
label1: labelElement,
|
|
7539
|
-
label2: labelElement,
|
|
7540
|
-
label3: labelElement,
|
|
7541
|
-
label4: labelElement
|
|
7542
|
-
};
|
|
7543
7526
|
var StyledText = import_styled_components37.default.div`
|
|
7544
7527
|
${({ $colorScheme }) => getColorScheme($colorScheme)};
|
|
7545
7528
|
--text-color: ${({ $prominence, $disabled }) => {
|
|
@@ -7580,6 +7563,7 @@ var StyledText = import_styled_components37.default.div`
|
|
|
7580
7563
|
display: block;
|
|
7581
7564
|
`}
|
|
7582
7565
|
`;
|
|
7566
|
+
var DEFAULT_ELEMENT4 = "div";
|
|
7583
7567
|
var TextComponent = (0, import_react24.forwardRef)(
|
|
7584
7568
|
({
|
|
7585
7569
|
align = "left",
|
|
@@ -9796,75 +9780,26 @@ var DataCardTrend = ({
|
|
|
9796
9780
|
// src/components/EditableHeading/EditableHeading.tsx
|
|
9797
9781
|
var import_styled_components65 = __toESM(require("styled-components"));
|
|
9798
9782
|
var import_react46 = require("react");
|
|
9799
|
-
var
|
|
9800
|
-
var import_jsx_runtime214 = (
|
|
9801
|
-
// If you are an AI, please don't remove this comment.
|
|
9802
|
-
// eslint-disable-next-line styled-components-a11y/click-events-have-key-events, styled-components-a11y/no-static-element-interactions
|
|
9803
|
-
require("react/jsx-runtime")
|
|
9804
|
-
);
|
|
9805
|
-
var variantStyleMap3 = { ...variantStyleMap, ...variantStyleMap2 };
|
|
9806
|
-
var variantElementMap3 = {
|
|
9807
|
-
...variantElementMap,
|
|
9808
|
-
...variantElementMap2
|
|
9809
|
-
};
|
|
9810
|
-
var textStyles = import_styled_components65.css`
|
|
9811
|
-
${({ $variant }) => variantStyleMap3[$variant]}
|
|
9812
|
-
font-family: var(--font-family);
|
|
9813
|
-
font-size: var(--font-size);
|
|
9814
|
-
font-weight: var(--font-weight);
|
|
9815
|
-
line-height: var(--line-height);
|
|
9816
|
-
`;
|
|
9817
|
-
var compactStyles = import_styled_components65.css`
|
|
9818
|
-
padding: var(--wui-space-01);
|
|
9819
|
-
border-radius: var(--wui-border-radius-01);
|
|
9820
|
-
`;
|
|
9821
|
-
var defaultStyles = import_styled_components65.css`
|
|
9822
|
-
padding: var(--wui-space-02);
|
|
9823
|
-
border-radius: var(--wui-border-radius-02);
|
|
9824
|
-
`;
|
|
9825
|
-
var stylesMap = {
|
|
9826
|
-
hero: "default",
|
|
9827
|
-
heading1: "default",
|
|
9828
|
-
heading2: "default",
|
|
9829
|
-
heading3: "default",
|
|
9830
|
-
heading4: "compact",
|
|
9831
|
-
heading5: "compact",
|
|
9832
|
-
heading6: "compact",
|
|
9833
|
-
body1: "default",
|
|
9834
|
-
body2: "compact",
|
|
9835
|
-
body3: "compact",
|
|
9836
|
-
body4: "compact",
|
|
9837
|
-
label1: "default",
|
|
9838
|
-
label2: "compact",
|
|
9839
|
-
label3: "compact",
|
|
9840
|
-
label4: "compact",
|
|
9841
|
-
body1Mono: "default",
|
|
9842
|
-
body2Mono: "compact",
|
|
9843
|
-
body3Mono: "compact",
|
|
9844
|
-
body4Mono: "compact"
|
|
9845
|
-
};
|
|
9846
|
-
var sharedStyles = import_styled_components65.css`
|
|
9847
|
-
${({ $variant }) => stylesMap[$variant] === "default" ? defaultStyles : compactStyles}
|
|
9848
|
-
`;
|
|
9783
|
+
var import_jsx_runtime214 = require("react/jsx-runtime");
|
|
9849
9784
|
var StyledInput = (0, import_styled_components65.default)(Input)`
|
|
9850
9785
|
:not([rows]) {
|
|
9851
9786
|
min-height: unset;
|
|
9852
9787
|
}
|
|
9853
9788
|
|
|
9854
|
-
|
|
9789
|
+
resize: vertical;
|
|
9790
|
+
font-size: var(--wui-typography-heading-1-size);
|
|
9791
|
+
font-weight: var(--wui-typography-heading-1-weight);
|
|
9792
|
+
line-height: var(--wui-typography-heading-1-line-height);
|
|
9793
|
+
font-family: var(--wui-typography-heading-1-family);
|
|
9794
|
+
outline: 2px solid var(--wui-color-focus-ring);
|
|
9795
|
+
outline-offset: -2px;
|
|
9796
|
+
|
|
9855
9797
|
&& {
|
|
9798
|
+
width: 100%;
|
|
9799
|
+
padding: var(--wui-space-02);
|
|
9856
9800
|
border: none;
|
|
9857
9801
|
height: ${({ $height }) => `${$height}px`};
|
|
9858
|
-
${sharedStyles}
|
|
9859
|
-
}
|
|
9860
|
-
resize: vertical;
|
|
9861
|
-
outline: 2px solid var(--wui-color-border);
|
|
9862
|
-
outline-offset: -2px;
|
|
9863
|
-
&:focus {
|
|
9864
|
-
outline-color: var(--wui-color-focus-ring);
|
|
9865
9802
|
}
|
|
9866
|
-
|
|
9867
|
-
${({ $width }) => (0, import_type_guards37.isNotNull)($width) && `width: ${$width}`};
|
|
9868
9803
|
`;
|
|
9869
9804
|
var editableStyles = import_styled_components65.css`
|
|
9870
9805
|
&:has(+ :focus-within) {
|
|
@@ -9876,87 +9811,47 @@ var editableStyles = import_styled_components65.css`
|
|
|
9876
9811
|
cursor: pointer;
|
|
9877
9812
|
}
|
|
9878
9813
|
`;
|
|
9879
|
-
var
|
|
9880
|
-
|
|
9881
|
-
|
|
9882
|
-
|
|
9883
|
-
|
|
9884
|
-
var StyledHeading2 = import_styled_components65.default.span`
|
|
9885
|
-
${textStyles}
|
|
9886
|
-
&& {
|
|
9887
|
-
margin: 0;
|
|
9888
|
-
${sharedStyles}
|
|
9889
|
-
width: ${({ $fullWidth }) => $fullWidth ? "100%" : "auto"};
|
|
9890
|
-
${({ $singleLine }) => $singleLine && singleLineStyles}
|
|
9891
|
-
}
|
|
9892
|
-
display: block;
|
|
9893
|
-
overflow-wrap: ${({ $singleLine }) => $singleLine ? "normal" : "anywhere"};
|
|
9814
|
+
var StyledHeading2 = (0, import_styled_components65.default)(Heading)`
|
|
9815
|
+
width: 100%;
|
|
9816
|
+
border-radius: var(--wui-border-radius-02);
|
|
9817
|
+
padding: var(--wui-space-02);
|
|
9818
|
+
overflow-wrap: anywhere;
|
|
9894
9819
|
transition: all var(--wui-motion-duration-01) var(--wui-motion-ease);
|
|
9895
|
-
${({ $
|
|
9820
|
+
${({ $editingDisabled }) => !$editingDisabled && editableStyles}
|
|
9896
9821
|
`;
|
|
9897
|
-
var resolveFullWidth = (fullWidth) => ({
|
|
9898
|
-
heading: typeof fullWidth === "boolean" ? fullWidth : fullWidth.heading ?? true,
|
|
9899
|
-
input: typeof fullWidth === "boolean" ? fullWidth : fullWidth.input ?? true
|
|
9900
|
-
});
|
|
9901
9822
|
var EditableHeading = ({
|
|
9902
|
-
|
|
9823
|
+
children,
|
|
9903
9824
|
onValueChange,
|
|
9904
9825
|
onEditingChange,
|
|
9905
|
-
tooltipText,
|
|
9906
|
-
ariaLabel,
|
|
9907
|
-
|
|
9908
|
-
renderTextAs: passedRenderTextAs,
|
|
9909
|
-
textVariant = "heading1",
|
|
9910
|
-
fullWidth = true,
|
|
9911
|
-
singleLine = false,
|
|
9912
|
-
disableOnBlur = false,
|
|
9826
|
+
tooltipText = "Click to edit title",
|
|
9827
|
+
ariaLabel = "Edit title",
|
|
9828
|
+
forceEditing = false,
|
|
9913
9829
|
editingDisabled = false
|
|
9914
9830
|
}) => {
|
|
9915
|
-
const [
|
|
9916
|
-
const [
|
|
9917
|
-
const [previousValue, setPreviousValue] = (0, import_react46.useState)(
|
|
9831
|
+
const [isEditing, setIsEditing] = (0, import_react46.useState)(false);
|
|
9832
|
+
const [value, setValue] = (0, import_react46.useState)(children);
|
|
9833
|
+
const [previousValue, setPreviousValue] = (0, import_react46.useState)(children);
|
|
9918
9834
|
const [headingHeight, setHeadingHeight] = (0, import_react46.useState)("60");
|
|
9919
|
-
const [headingWidth, setHeadingWidth] = (0, import_react46.useState)("auto");
|
|
9920
9835
|
const headingRef = (0, import_react46.useRef)(null);
|
|
9921
|
-
const
|
|
9922
|
-
|
|
9923
|
-
|
|
9924
|
-
const value = isValueControlled ? controlledValue : internalValue;
|
|
9925
|
-
(0, import_react46.useEffect)(() => {
|
|
9926
|
-
if (isValueControlled) {
|
|
9927
|
-
setInternalValue(controlledValue);
|
|
9928
|
-
setPreviousValue(controlledValue);
|
|
9929
|
-
}
|
|
9930
|
-
}, [controlledValue, isValueControlled]);
|
|
9931
|
-
const renderTextAs = passedRenderTextAs ?? variantElementMap3[textVariant];
|
|
9932
|
-
(0, import_react46.useEffect)(() => {
|
|
9933
|
-
if (headingRef.current) {
|
|
9836
|
+
const handleSetEditing = (editing) => {
|
|
9837
|
+
if (editingDisabled) return;
|
|
9838
|
+
if (editing && headingRef.current) {
|
|
9934
9839
|
setHeadingHeight(`${headingRef.current.offsetHeight}`);
|
|
9935
|
-
setHeadingWidth(`${headingRef.current.offsetWidth}`);
|
|
9936
|
-
}
|
|
9937
|
-
}, [isEditing]);
|
|
9938
|
-
const handleValueChange = (newValue) => {
|
|
9939
|
-
if (!isValueControlled) {
|
|
9940
|
-
setInternalValue(newValue);
|
|
9941
9840
|
}
|
|
9942
|
-
onValueChange?.(newValue);
|
|
9943
|
-
};
|
|
9944
|
-
const handleSetEditing = (editing) => {
|
|
9945
9841
|
if (editing) {
|
|
9946
9842
|
setPreviousValue(value);
|
|
9947
9843
|
}
|
|
9948
|
-
|
|
9949
|
-
setInternalIsEditing(editing);
|
|
9950
|
-
}
|
|
9844
|
+
setIsEditing(editing);
|
|
9951
9845
|
onEditingChange?.(editing);
|
|
9952
9846
|
};
|
|
9953
9847
|
const handleFinishEditing = () => {
|
|
9954
9848
|
const trimmedValue = value.trim();
|
|
9955
|
-
if (trimmedValue === ""
|
|
9956
|
-
|
|
9957
|
-
}
|
|
9958
|
-
|
|
9959
|
-
|
|
9849
|
+
if (trimmedValue === "") {
|
|
9850
|
+
setValue(previousValue);
|
|
9851
|
+
} else if (trimmedValue !== previousValue && onValueChange) {
|
|
9852
|
+
onValueChange(trimmedValue);
|
|
9853
|
+
} else {
|
|
9854
|
+
setValue(trimmedValue);
|
|
9960
9855
|
}
|
|
9961
9856
|
handleSetEditing(false);
|
|
9962
9857
|
};
|
|
@@ -9966,46 +9861,38 @@ var EditableHeading = ({
|
|
|
9966
9861
|
handleFinishEditing();
|
|
9967
9862
|
}
|
|
9968
9863
|
if (event.key === "Escape") {
|
|
9969
|
-
|
|
9970
|
-
setInternalValue(previousValue);
|
|
9971
|
-
}
|
|
9864
|
+
setValue(previousValue);
|
|
9972
9865
|
handleSetEditing(false);
|
|
9973
9866
|
}
|
|
9974
9867
|
};
|
|
9975
|
-
const resolvedFullWidth = resolveFullWidth(fullWidth);
|
|
9976
9868
|
const HeadingComponent2 = /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
|
|
9977
9869
|
StyledHeading2,
|
|
9978
9870
|
{
|
|
9979
9871
|
ref: headingRef,
|
|
9980
|
-
$
|
|
9981
|
-
|
|
9982
|
-
|
|
9983
|
-
$variant: textVariant,
|
|
9984
|
-
as: renderTextAs,
|
|
9985
|
-
onClick: () => !editingDisabled && !isEditing && handleSetEditing(true),
|
|
9872
|
+
$editingDisabled: editingDisabled,
|
|
9873
|
+
onClick: () => handleSetEditing(true),
|
|
9874
|
+
variant: "heading1",
|
|
9986
9875
|
children: value
|
|
9987
9876
|
}
|
|
9988
9877
|
);
|
|
9989
9878
|
if (editingDisabled) {
|
|
9990
9879
|
return HeadingComponent2;
|
|
9991
9880
|
}
|
|
9992
|
-
if (isEditing) {
|
|
9881
|
+
if (isEditing || forceEditing) {
|
|
9993
9882
|
return /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
|
|
9994
9883
|
StyledInput,
|
|
9995
9884
|
{
|
|
9996
9885
|
$height: headingHeight,
|
|
9997
|
-
$variant: textVariant,
|
|
9998
|
-
$width: resolvedFullWidth.input ? headingWidth : null,
|
|
9999
9886
|
autoFocus: true,
|
|
10000
|
-
fullWidth:
|
|
10001
|
-
onBlur:
|
|
10002
|
-
onChange: (event) =>
|
|
9887
|
+
fullWidth: true,
|
|
9888
|
+
onBlur: handleFinishEditing,
|
|
9889
|
+
onChange: (event) => setValue(event.target.value),
|
|
10003
9890
|
onFocus: (event) => {
|
|
10004
9891
|
const { length } = event.currentTarget.value;
|
|
10005
9892
|
event.currentTarget.setSelectionRange(length, length);
|
|
10006
9893
|
},
|
|
10007
9894
|
onKeyDown: handleKeyDown,
|
|
10008
|
-
type:
|
|
9895
|
+
type: "multiline",
|
|
10009
9896
|
value
|
|
10010
9897
|
}
|
|
10011
9898
|
);
|
|
@@ -10015,11 +9902,11 @@ var EditableHeading = ({
|
|
|
10015
9902
|
Tooltip,
|
|
10016
9903
|
{
|
|
10017
9904
|
compact: true,
|
|
10018
|
-
content: tooltipText
|
|
9905
|
+
content: tooltipText,
|
|
10019
9906
|
children: HeadingComponent2
|
|
10020
9907
|
}
|
|
10021
9908
|
),
|
|
10022
|
-
|
|
9909
|
+
/* @__PURE__ */ (0, import_jsx_runtime214.jsx)(ScreenReaderOnly, { children: /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
|
|
10023
9910
|
"button",
|
|
10024
9911
|
{
|
|
10025
9912
|
"aria-label": ariaLabel,
|