@cambly/syntax-core 2.2.0 → 2.3.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.js CHANGED
@@ -66,7 +66,7 @@ var require_classnames = __commonJS({
66
66
  "use strict";
67
67
  var hasOwn = {}.hasOwnProperty;
68
68
  var nativeCodeString = "[native code]";
69
- function classNames8() {
69
+ function classNames9() {
70
70
  var classes = [];
71
71
  for (var i = 0; i < arguments.length; i++) {
72
72
  var arg = arguments[i];
@@ -77,7 +77,7 @@ var require_classnames = __commonJS({
77
77
  classes.push(arg);
78
78
  } else if (Array.isArray(arg)) {
79
79
  if (arg.length) {
80
- var inner = classNames8.apply(null, arg);
80
+ var inner = classNames9.apply(null, arg);
81
81
  if (inner) {
82
82
  classes.push(inner);
83
83
  }
@@ -97,14 +97,14 @@ var require_classnames = __commonJS({
97
97
  return classes.join(" ");
98
98
  }
99
99
  if (typeof module2 !== "undefined" && module2.exports) {
100
- classNames8.default = classNames8;
101
- module2.exports = classNames8;
100
+ classNames9.default = classNames9;
101
+ module2.exports = classNames9;
102
102
  } else if (typeof define === "function" && typeof define.amd === "object" && define.amd) {
103
103
  define("classnames", [], function() {
104
- return classNames8;
104
+ return classNames9;
105
105
  });
106
106
  } else {
107
- window.classNames = classNames8;
107
+ window.classNames = classNames9;
108
108
  }
109
109
  })();
110
110
  }
@@ -124,6 +124,7 @@ __export(src_exports, {
124
124
  IconButton: () => IconButton_default,
125
125
  MiniActionCard: () => MiniActionCard_default,
126
126
  RadioButton: () => RadioButton_default,
127
+ SelectList: () => SelectList_default,
127
128
  Typography: () => Typography_default
128
129
  });
129
130
  module.exports = __toCommonJS(src_exports);
@@ -837,6 +838,116 @@ var RadioButton = ({
837
838
  );
838
839
  };
839
840
  var RadioButton_default = RadioButton;
841
+
842
+ // src/SelectList/SelectList.tsx
843
+ var import_react7 = require("react");
844
+ var import_classnames9 = __toESM(require_classnames());
845
+ var import_js = require("@cambly/syntax-design-tokens/dist/js/index.js");
846
+
847
+ // css-module:./SelectList.module.css#css-module
848
+ var SelectList_module_default = { "selectContainer": "_selectContainer_1y5p4_1", "opacityOverlay": "_opacityOverlay_1y5p4_7", "outerTextContainer": "_outerTextContainer_1y5p4_11", "selectWrapper": "_selectWrapper_1y5p4_16", "selectBox": "_selectBox_1y5p4_21", "unselected": "_unselected_1y5p4_40", "selected": "_selected_1y5p4_44", "arrowIcon": "_arrowIcon_1y5p4_48", "sm": "_sm_1y5p4_62", "md": "_md_1y5p4_67", "lg": "_lg_1y5p4_72", "selectError": "_selectError_1y5p4_77" };
849
+
850
+ // src/SelectList/SelectOption.tsx
851
+ var import_jsx_runtime13 = require("react/jsx-runtime");
852
+ var SelectOption = ({
853
+ value,
854
+ label,
855
+ disabled = false
856
+ }) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
857
+ "option",
858
+ {
859
+ "data-testid": `syntax-select-${value}`,
860
+ value,
861
+ disabled,
862
+ children: label
863
+ }
864
+ );
865
+ var SelectOption_default = SelectOption;
866
+
867
+ // src/SelectList/SelectList.tsx
868
+ var import_jsx_runtime14 = require("react/jsx-runtime");
869
+ var iconSize3 = {
870
+ sm: 20,
871
+ md: 24,
872
+ lg: 24
873
+ };
874
+ var SelectList = ({
875
+ children,
876
+ disabled = false,
877
+ errorText,
878
+ helperText,
879
+ label,
880
+ onChange,
881
+ placeholderText,
882
+ selectedValue = "",
883
+ size = "md"
884
+ }) => {
885
+ const id = (0, import_react7.useId)();
886
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
887
+ "div",
888
+ {
889
+ className: (0, import_classnames9.default)(SelectList_module_default.selectContainer, {
890
+ [SelectList_module_default.opacityOverlay]: disabled
891
+ }),
892
+ children: [
893
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("label", { htmlFor: id, className: SelectList_module_default.outerTextContainer, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
894
+ Typography_default,
895
+ {
896
+ size: 100,
897
+ color: errorText ? "destructive-primary" : "gray700",
898
+ children: label
899
+ }
900
+ ) }),
901
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: SelectList_module_default.selectWrapper, children: [
902
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
903
+ "select",
904
+ {
905
+ id,
906
+ "data-testid": "syntax-select",
907
+ disabled,
908
+ className: (0, import_classnames9.default)(SelectList_module_default.selectBox, SelectList_module_default[size], {
909
+ [SelectList_module_default.unselected]: !selectedValue && !errorText,
910
+ [SelectList_module_default.selected]: selectedValue && !errorText,
911
+ [SelectList_module_default.selectError]: errorText
912
+ }),
913
+ onChange,
914
+ children: [
915
+ placeholderText && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { disabled: true, value: "", children: placeholderText }),
916
+ children
917
+ ]
918
+ }
919
+ ),
920
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: SelectList_module_default.arrowIcon, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
921
+ "svg",
922
+ {
923
+ focusable: "false",
924
+ "aria-hidden": "true",
925
+ viewBox: "0 0 24 24",
926
+ width: iconSize3[size],
927
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
928
+ "path",
929
+ {
930
+ fill: errorText ? import_js.ColorBaseDestructive700 : import_js.ColorBaseGray800,
931
+ d: "M15.88 9.29 12 13.17 8.12 9.29a.9959.9959 0 0 0-1.41 0c-.39.39-.39 1.02 0 1.41l4.59 4.59c.39.39 1.02.39 1.41 0l4.59-4.59c.39-.39.39-1.02 0-1.41-.39-.38-1.03-.39-1.42 0z"
932
+ }
933
+ )
934
+ }
935
+ ) })
936
+ ] }),
937
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: SelectList_module_default.outerTextContainer, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
938
+ Typography_default,
939
+ {
940
+ size: 100,
941
+ color: errorText ? "destructive-primary" : "gray700",
942
+ children: errorText != null ? errorText : helperText
943
+ }
944
+ ) })
945
+ ]
946
+ }
947
+ );
948
+ };
949
+ var SelectList_default = SelectList;
950
+ SelectList.Option = SelectOption_default;
840
951
  // Annotate the CommonJS export names for ESM import in node:
841
952
  0 && (module.exports = {
842
953
  Avatar,
@@ -850,6 +961,7 @@ var RadioButton_default = RadioButton;
850
961
  IconButton,
851
962
  MiniActionCard,
852
963
  RadioButton,
964
+ SelectList,
853
965
  Typography
854
966
  });
855
967
  /*! Bundled license information: