@cambly/syntax-core 7.2.0 → 7.4.0

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.d.ts CHANGED
@@ -568,7 +568,7 @@ declare namespace Divider {
568
568
  /**
569
569
  * [Heading](https://cambly-syntax.vercel.app/?path=/docs/components-heading--docs) enforces a consistent style & accessibility best practices for headings.
570
570
  */
571
- declare const Heading: ({ align, as, children, color, size, }: {
571
+ declare const Heading: ({ align, as, children, color, "data-testid": dataTestId, size, }: {
572
572
  /**
573
573
  * Aligns the text to the left, right, or center of the container.
574
574
  * * `start` and `end` will align the text to the left or right of the container depending on the locale.
@@ -593,6 +593,10 @@ declare const Heading: ({ align, as, children, color, size, }: {
593
593
  * @defaultValue "gray900"
594
594
  */
595
595
  color?: "gray200" | "gray900" | "primary" | "secondary" | "tertiary" | "destructive-primary" | "destructive-secondary" | "destructive-tertiary" | "branded" | "success" | "gray700" | "gray800" | "white" | "inherit" | undefined;
596
+ /**
597
+ * Test id for the text.
598
+ */
599
+ "data-testid"?: string | undefined;
596
600
  /**
597
601
  * Size of the text.
598
602
  *
@@ -657,10 +661,7 @@ type IconButtonProps = {
657
661
  */
658
662
  declare const IconButton: React__default.ForwardRefExoticComponent<IconButtonProps & React__default.RefAttributes<HTMLButtonElement>>;
659
663
 
660
- /**
661
- * [LinkButton](https://cambly-syntax.vercel.app/?path=/docs/components-linkbutton--docs) is a "variation" of Button that should look identical to Button, but should be used to render links instead.
662
- */
663
- declare function LinkButton({ text, href, target, rel, "data-testid": dataTestId, color, size, fullWidth, startIcon: StartIcon, endIcon: EndIcon, onClick, }: {
664
+ type LinkButtonProps = {
664
665
  /**
665
666
  * Test id for the button
666
667
  */
@@ -722,7 +723,11 @@ declare function LinkButton({ text, href, target, rel, "data-testid": dataTestId
722
723
  * An optional onClick event. This is used for certain wrapper's support (such as react-router-dom).
723
724
  */
724
725
  onClick?: React__default.MouseEventHandler<HTMLAnchorElement>;
725
- }): JSX.Element;
726
+ };
727
+ /**
728
+ * [LinkButton](https://cambly-syntax.vercel.app/?path=/docs/components-linkbutton--docs) is a "variation" of Button that should look identical to Button, but should be used to render links instead.
729
+ */
730
+ declare const LinkButton: React__default.ForwardRefExoticComponent<LinkButtonProps & React__default.RefAttributes<HTMLAnchorElement>>;
726
731
 
727
732
  /**
728
733
  * [MiniActionCard](https://cambly-syntax.vercel.app/?path=/docs/components-miniactioncard--docs) is component that alerts users to a call to action.
@@ -1034,7 +1039,7 @@ declare function TextField({ autoComplete, "data-testid": dataTestId, disabled,
1034
1039
  /**
1035
1040
  * [Typography](https://cambly-syntax.vercel.app/?path=/docs/components-typography--docs) is a component that renders text.
1036
1041
  */
1037
- declare const Typography: ({ align, as, children, color, inline, lineClamp, size, tooltip, transform, underline, weight, }: {
1042
+ declare const Typography: ({ align, as, children, color, "data-testid": dataTestId, inline, lineClamp, size, tooltip, transform, underline, weight, }: {
1038
1043
  /**
1039
1044
  * Aligns the text to the left, right, or center of the container.
1040
1045
  * * `start` and `end` will align the text to the left or right of the container depending on the locale.
@@ -1059,6 +1064,10 @@ declare const Typography: ({ align, as, children, color, inline, lineClamp, size
1059
1064
  * @defaultValue "gray900"
1060
1065
  */
1061
1066
  color?: "gray200" | "gray900" | "primary" | "secondary" | "tertiary" | "destructive-primary" | "destructive-secondary" | "destructive-tertiary" | "branded" | "success" | "gray700" | "gray800" | "white" | "inherit" | undefined;
1067
+ /**
1068
+ * Test id for the text
1069
+ */
1070
+ "data-testid"?: string | undefined;
1062
1071
  /**
1063
1072
  * Whether the text should flow inline with other elements.
1064
1073
  *
package/dist/index.js CHANGED
@@ -123,7 +123,7 @@ __export(src_exports, {
123
123
  Divider: () => Divider,
124
124
  Heading: () => Heading_default,
125
125
  IconButton: () => IconButton_default,
126
- LinkButton: () => LinkButton,
126
+ LinkButton: () => LinkButton_default,
127
127
  MiniActionCard: () => MiniActionCard_default,
128
128
  Modal: () => Modal,
129
129
  RadioButton: () => RadioButton_default,
@@ -189,6 +189,7 @@ var Typography = ({
189
189
  as = "div",
190
190
  children,
191
191
  color = "gray900",
192
+ "data-testid": dataTestId,
192
193
  inline = false,
193
194
  lineClamp = void 0,
194
195
  size = 200,
@@ -212,6 +213,7 @@ var Typography = ({
212
213
  underline && Typography_module_default.underline,
213
214
  lineClamp != null && Typography_module_default.lineClamp
214
215
  ),
216
+ "data-testid": dataTestId,
215
217
  style: {
216
218
  WebkitLineClamp: lineClamp
217
219
  },
@@ -889,10 +891,22 @@ var Heading = ({
889
891
  as = "h1",
890
892
  children,
891
893
  color = "gray900",
894
+ "data-testid": dataTestId,
892
895
  size = 500
893
896
  }) => {
894
897
  const weight = [700, 800].includes(size) ? "heavy" : "bold";
895
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Typography_default, { align, as, color, size, weight, children });
898
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
899
+ Typography_default,
900
+ {
901
+ align,
902
+ as,
903
+ color,
904
+ "data-testid": dataTestId,
905
+ size,
906
+ weight,
907
+ children
908
+ }
909
+ );
896
910
  };
897
911
  var Heading_default = Heading;
898
912
 
@@ -950,6 +964,7 @@ IconButton.displayName = "IconButton";
950
964
  var IconButton_default = IconButton;
951
965
 
952
966
  // src/LinkButton/LinkButton.tsx
967
+ var import_react6 = require("react");
953
968
  var import_classnames8 = __toESM(require_classnames());
954
969
 
955
970
  // css-module:../Button/Button.module.css#css-module
@@ -960,56 +975,66 @@ var LinkButton_module_default = { "linkButton": "_linkButton_1b3ot_1", "fitConte
960
975
 
961
976
  // src/LinkButton/LinkButton.tsx
962
977
  var import_jsx_runtime12 = require("react/jsx-runtime");
963
- function LinkButton({
964
- text,
965
- href,
966
- target,
967
- rel,
968
- "data-testid": dataTestId,
969
- color = "primary",
970
- size = "md",
971
- fullWidth = false,
972
- startIcon: StartIcon,
973
- endIcon: EndIcon,
974
- onClick
975
- }) {
976
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
977
- "a",
978
- {
979
- href,
980
- "data-testid": dataTestId,
981
- target,
982
- rel,
983
- className: (0, import_classnames8.default)(
984
- LinkButton_module_default.linkButton,
985
- Button_module_default3.button,
986
- foregroundColor(color),
987
- backgroundColor(color),
988
- Button_module_default3[size],
989
- {
990
- [Button_module_default3.fullWidth]: fullWidth,
991
- [LinkButton_module_default.fitContent]: !fullWidth,
992
- [Button_module_default3.buttonGap]: size === "lg" || size === "md",
993
- [Button_module_default3.secondaryBorder]: color === "secondary",
994
- [Button_module_default3.secondaryDestructiveBorder]: color === "destructive-secondary"
995
- }
996
- ),
997
- onClick,
998
- children: [
999
- StartIcon && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(StartIcon, { className: (0, import_classnames8.default)(Button_module_default3.icon, iconSize_default[size]) }),
1000
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1001
- Typography_default,
978
+ var LinkButton = (0, import_react6.forwardRef)(
979
+ ({
980
+ text,
981
+ href,
982
+ target,
983
+ rel,
984
+ "data-testid": dataTestId,
985
+ color = "primary",
986
+ size = "md",
987
+ fullWidth = false,
988
+ startIcon: StartIcon,
989
+ endIcon: EndIcon,
990
+ onClick
991
+ }, ref) => {
992
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
993
+ "a",
994
+ {
995
+ href,
996
+ "data-testid": dataTestId,
997
+ target,
998
+ ref,
999
+ rel,
1000
+ className: (0, import_classnames8.default)(
1001
+ LinkButton_module_default.linkButton,
1002
+ Button_module_default3.button,
1003
+ foregroundColor(color),
1004
+ backgroundColor(color),
1005
+ Button_module_default3[size],
1002
1006
  {
1003
- color: foregroundTypographyColor(color),
1004
- size: textVariant_default[size],
1005
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { style: { fontWeight: 500 }, children: text })
1007
+ [Button_module_default3.fullWidth]: fullWidth,
1008
+ [LinkButton_module_default.fitContent]: !fullWidth,
1009
+ [Button_module_default3.buttonGap]: size === "lg" || size === "md",
1010
+ [Button_module_default3.secondaryBorder]: color === "secondary",
1011
+ [Button_module_default3.secondaryDestructiveBorder]: color === "destructive-secondary"
1006
1012
  }
1007
1013
  ),
1008
- EndIcon && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(EndIcon, { className: (0, import_classnames8.default)(Button_module_default3.icon, iconSize_default[size]) })
1009
- ]
1010
- }
1011
- );
1012
- }
1014
+ onClick,
1015
+ children: [
1016
+ StartIcon && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1017
+ StartIcon,
1018
+ {
1019
+ className: (0, import_classnames8.default)(Button_module_default3.icon, iconSize_default[size])
1020
+ }
1021
+ ),
1022
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1023
+ Typography_default,
1024
+ {
1025
+ color: foregroundTypographyColor(color),
1026
+ size: textVariant_default[size],
1027
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { style: { fontWeight: 500 }, children: text })
1028
+ }
1029
+ ),
1030
+ EndIcon && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(EndIcon, { className: (0, import_classnames8.default)(Button_module_default3.icon, iconSize_default[size]) })
1031
+ ]
1032
+ }
1033
+ );
1034
+ }
1035
+ );
1036
+ LinkButton.displayName = "LinkButton";
1037
+ var LinkButton_default = LinkButton;
1013
1038
 
1014
1039
  // css-module:./MiniActionCard.module.css#css-module
1015
1040
  var MiniActionCard_module_default = { "miniActionCard": "_miniActionCard_qebkn_1", "card": "_card_qebkn_9" };
@@ -1025,7 +1050,7 @@ var MiniActionCard_default = MiniActionCard;
1025
1050
  var import_classnames9 = __toESM(require_classnames());
1026
1051
 
1027
1052
  // src/Modal/FocusTrap.tsx
1028
- var import_react6 = require("react");
1053
+ var import_react7 = require("react");
1029
1054
  var import_jsx_runtime14 = require("react/jsx-runtime");
1030
1055
  function queryFocusableAll(el) {
1031
1056
  const selector = [
@@ -1055,9 +1080,9 @@ var focusElement = (el) => {
1055
1080
  function FocusTrap({
1056
1081
  children
1057
1082
  }) {
1058
- const elRef = (0, import_react6.useRef)(null);
1059
- const previouslyFocusedElRef = (0, import_react6.useRef)(null);
1060
- (0, import_react6.useEffect)(() => {
1083
+ const elRef = (0, import_react7.useRef)(null);
1084
+ const previouslyFocusedElRef = (0, import_react7.useRef)(null);
1085
+ (0, import_react7.useEffect)(() => {
1061
1086
  const { current: element } = elRef;
1062
1087
  const focusFirstChild = () => {
1063
1088
  const withinIframe = window !== window.parent;
@@ -1091,9 +1116,9 @@ function FocusTrap({
1091
1116
  }
1092
1117
 
1093
1118
  // src/Modal/StopScroll.tsx
1094
- var import_react7 = require("react");
1119
+ var import_react8 = require("react");
1095
1120
  function StopScroll(props) {
1096
- (0, import_react7.useEffect)(() => {
1121
+ (0, import_react8.useEffect)(() => {
1097
1122
  const originalStyle = window.getComputedStyle(document.body).overflow;
1098
1123
  document.body.style.overflow = "hidden";
1099
1124
  return () => {
@@ -1214,7 +1239,7 @@ function Modal({
1214
1239
  Modal.displayName = "Modal";
1215
1240
 
1216
1241
  // src/RadioButton/RadioButton.tsx
1217
- var import_react8 = require("react");
1242
+ var import_react9 = require("react");
1218
1243
  var import_classnames10 = __toESM(require_classnames());
1219
1244
 
1220
1245
  // css-module:./RadioButton.module.css#css-module
@@ -1234,7 +1259,7 @@ var RadioButton = ({
1234
1259
  size = "md",
1235
1260
  value
1236
1261
  }) => {
1237
- const [isFocused, setIsFocused] = (0, import_react8.useState)(false);
1262
+ const [isFocused, setIsFocused] = (0, import_react9.useState)(false);
1238
1263
  const { isFocusVisible: isFocusVisible2 } = useFocusVisible();
1239
1264
  const sharedStyles = (0, import_classnames10.default)(RadioButton_module_default.background, RadioButton_module_default[size], {
1240
1265
  [RadioButton_module_default.errorBorderColor]: error,
@@ -1305,7 +1330,7 @@ var RadioButton = ({
1305
1330
  var RadioButton_default = RadioButton;
1306
1331
 
1307
1332
  // src/SelectList/SelectList.tsx
1308
- var import_react9 = require("react");
1333
+ var import_react10 = require("react");
1309
1334
  var import_classnames11 = __toESM(require_classnames());
1310
1335
 
1311
1336
  // ../syntax-design-tokens/dist/js/index.js
@@ -1345,9 +1370,9 @@ function SelectList({
1345
1370
  selectedValue = "",
1346
1371
  size = "md"
1347
1372
  }) {
1348
- const id = (0, import_react9.useId)();
1373
+ const id = (0, import_react10.useId)();
1349
1374
  const { isFocusVisible: isFocusVisible2 } = useFocusVisible();
1350
- const [isFocused, setIsFocused] = (0, import_react9.useState)(false);
1375
+ const [isFocused, setIsFocused] = (0, import_react10.useState)(false);
1351
1376
  return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
1352
1377
  "div",
1353
1378
  {
@@ -1415,7 +1440,7 @@ function SelectList({
1415
1440
  SelectList.Option = SelectOption_default;
1416
1441
 
1417
1442
  // src/TextField/TextField.tsx
1418
- var import_react10 = require("react");
1443
+ var import_react11 = require("react");
1419
1444
  var import_classnames12 = __toESM(require_classnames());
1420
1445
 
1421
1446
  // css-module:./TextField.module.css#css-module
@@ -1437,7 +1462,7 @@ function TextField({
1437
1462
  type = "text",
1438
1463
  value = ""
1439
1464
  }) {
1440
- const reactId = (0, import_react10.useId)();
1465
+ const reactId = (0, import_react11.useId)();
1441
1466
  const inputId = id != null ? id : reactId;
1442
1467
  return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
1443
1468
  Box_default,