opus-toolkit-components 0.7.5 → 0.7.6

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.
@@ -3615,6 +3615,15 @@ function Card(_ref) {
3615
3615
  className: cardClasses
3616
3616
  }, children);
3617
3617
  }
3618
+ ;// ./src/utils/getDataCy.js
3619
+ const getDataCy = _ref => {
3620
+ let {
3621
+ name,
3622
+ value = '',
3623
+ dataCy
3624
+ } = _ref;
3625
+ return dataCy || (value ? "".concat(name, "-").concat(value) : name);
3626
+ };
3618
3627
  ;// ./src/components/Forms/Inputs/Input.jsx
3619
3628
  function Input_ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3620
3629
  function Input_objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? Input_ownKeys(Object(t), !0).forEach(function (r) { Input_defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : Input_ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -3622,6 +3631,7 @@ function Input_defineProperty(e, r, t) { return (r = Input_toPropertyKey(r)) in
3622
3631
  function Input_toPropertyKey(t) { var i = Input_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
3623
3632
  function Input_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
3624
3633
 
3634
+
3625
3635
  const Input = /*#__PURE__*/(0,external_react_.forwardRef)((_ref, ref) => {
3626
3636
  let {
3627
3637
  label,
@@ -3647,9 +3657,13 @@ const Input = /*#__PURE__*/(0,external_react_.forwardRef)((_ref, ref) => {
3647
3657
  // Condition to render custom component
3648
3658
  customComponent,
3649
3659
  // Custom component to render
3650
- customComponentProps = {} // Props for the custom component
3660
+ customComponentProps = {},
3661
+ // Props for the custom component
3662
+ disabled = false,
3663
+ // New disabled prop
3664
+ dataCy
3651
3665
  } = _ref;
3652
- const inputClasses = "".concat(className, " flex items-center rounded-md bg-[--color-input-bg] border ").concat(isValid ? 'border-[--color-stroke]' : 'border-utilRed1000', " text-md font-normal text-[--color-text-weak]");
3666
+ const inputClasses = "".concat(className, " flex items-center rounded-md bg-[--color-input-bg] border ").concat(isValid ? 'border-[--color-stroke]' : 'border-utilRed1000', " text-md font-normal text-[--color-text-weak] ").concat(disabled ? 'opacity-50 cursor-not-allowed' : '');
3653
3667
  const iconClasses = "h-5 w-5 ".concat(isAnimated ? 'transition-transform duration-200 group-focus-within:scale-125' : '', " text-[--color-text-weak]");
3654
3668
  return /*#__PURE__*/external_react_default().createElement("div", {
3655
3669
  className: "flex flex-col mb-4"
@@ -3672,9 +3686,11 @@ const Input = /*#__PURE__*/(0,external_react_.forwardRef)((_ref, ref) => {
3672
3686
  onChange: onChange,
3673
3687
  value: value,
3674
3688
  title: title,
3675
- tabindex: tabIndex,
3689
+ tabIndex: tabIndex,
3676
3690
  "aria-label": title,
3677
- required: required // Set HTML required attribute
3691
+ required: required,
3692
+ disabled: disabled,
3693
+ "data-cy": getDataCy(name, dataCy)
3678
3694
  }), Icon && iconPosition === 'right' && /*#__PURE__*/external_react_default().createElement("span", {
3679
3695
  className: "absolute right-3 flex items-center pointer-events-none"
3680
3696
  }, /*#__PURE__*/external_react_default().createElement(Icon, {
@@ -3744,6 +3760,7 @@ var datepicker_update = injectStylesIntoStyleTag_default()(datepicker/* default
3744
3760
 
3745
3761
 
3746
3762
 
3763
+
3747
3764
  function DatePicker(_ref) {
3748
3765
  let {
3749
3766
  initialDate = '',
@@ -3755,11 +3772,12 @@ function DatePicker(_ref) {
3755
3772
  value,
3756
3773
  className = '',
3757
3774
  title = '',
3758
- required = false
3775
+ required = false,
3776
+ dataCy,
3777
+ disabled = false
3759
3778
  } = _ref;
3760
3779
  const [selectedDate, setSelectedDate] = (0,external_react_.useState)(value || initialDate);
3761
- const inputRef = (0,external_react_.useRef)(null); // Create a reference for the input element
3762
-
3780
+ const inputRef = (0,external_react_.useRef)(null);
3763
3781
  (0,external_react_.useEffect)(() => {
3764
3782
  if (value !== undefined) {
3765
3783
  setSelectedDate(value);
@@ -3774,8 +3792,8 @@ function DatePicker(_ref) {
3774
3792
  }
3775
3793
  };
3776
3794
  const handleIconClick = () => {
3777
- if (inputRef.current) {
3778
- inputRef.current.showPicker(); // Opens the native date picker (supported in modern browsers)
3795
+ if (inputRef.current && !disabled) {
3796
+ inputRef.current.showPicker();
3779
3797
  }
3780
3798
  };
3781
3799
  return /*#__PURE__*/external_react_default().createElement("div", {
@@ -3789,27 +3807,30 @@ function DatePicker(_ref) {
3789
3807
  type: "date",
3790
3808
  id: name,
3791
3809
  name: name,
3792
- ref: inputRef // Assign the ref to the input
3793
- ,
3810
+ ref: inputRef,
3794
3811
  value: selectedDate,
3795
3812
  title: title,
3796
3813
  "aria-label": title,
3797
3814
  onChange: handleDateChange,
3798
3815
  required: required,
3799
- className: "w-full py-2 px-3 pr-10 rounded-md bg-[--color-input-bg] border ".concat(isValid ? 'border-[--color-stroke]' : 'border-utilRed1000', " text-md font-normal text-[--color-text-weak] ").concat(className)
3816
+ disabled: disabled,
3817
+ "data-cy": getDataCy(name, dataCy),
3818
+ className: "w-full py-2 px-3 pr-10 rounded-md bg-[--color-input-bg] border ".concat(isValid ? 'border-[--color-stroke]' : 'border-utilRed1000', " text-md font-normal text-[--color-text-weak] ").concat(disabled ? 'opacity-50 cursor-not-allowed' : '', " ").concat(className)
3800
3819
  }), /*#__PURE__*/external_react_default().createElement("button", {
3801
3820
  type: "button",
3802
3821
  onClick: handleIconClick,
3803
3822
  className: "absolute top-1/2 mt-1 right-3 transform",
3804
- "aria-label": "Open date picker"
3823
+ "aria-label": "Open date picker",
3824
+ disabled: disabled
3805
3825
  }, /*#__PURE__*/external_react_default().createElement(esm_CalendarIcon, {
3806
- className: "w-5 h-5 text-[--color-text-weak] hover:text-[--color-primary-btn-hover] transition"
3826
+ className: "w-5 h-5 ".concat(disabled ? 'text-[--color-text-disabled]' : 'text-[--color-text-weak] hover:text-[--color-primary-btn-hover]', " transition")
3807
3827
  })), !isValid && /*#__PURE__*/external_react_default().createElement("span", {
3808
3828
  className: "text-utilRed1000 text-sm"
3809
3829
  }, errorMessage));
3810
3830
  }
3811
3831
  ;// ./src/components/Forms/Radios/RadioButton.js
3812
3832
 
3833
+
3813
3834
  const RadioButton = _ref => {
3814
3835
  let {
3815
3836
  label,
@@ -3833,10 +3854,13 @@ const RadioButton = _ref => {
3833
3854
  title = '',
3834
3855
  isValid = true,
3835
3856
  errorMessage = "".concat(label, " is required"),
3836
- required = false
3857
+ required = false,
3858
+ dataCy,
3859
+ disabled = false
3837
3860
  } = _ref;
3838
3861
  const [selectedValue, setSelectedValue] = (0,external_react_.useState)('');
3839
3862
  const handleChange = item => {
3863
+ if (disabled) return;
3840
3864
  setSelectedValue(item.value);
3841
3865
  const event = {
3842
3866
  target: {
@@ -3849,7 +3873,7 @@ const RadioButton = _ref => {
3849
3873
  }
3850
3874
  };
3851
3875
  return /*#__PURE__*/external_react_default().createElement("div", {
3852
- className: "flex flex-col mb-4"
3876
+ className: "flex flex-col mb-4 ".concat(className)
3853
3877
  }, /*#__PURE__*/external_react_default().createElement("label", {
3854
3878
  className: "text-[--color-text-strong] mb-2 flex items-center"
3855
3879
  }, label, required && /*#__PURE__*/external_react_default().createElement("span", {
@@ -3858,17 +3882,23 @@ const RadioButton = _ref => {
3858
3882
  className: "flex space-x-4"
3859
3883
  }, options.map(option => /*#__PURE__*/external_react_default().createElement("label", {
3860
3884
  key: option.value,
3861
- className: "cursor-pointer py-2 px-4 border rounded-lg ".concat(selectedValue === option.value ? 'bg-[--color-primary-btn] text-[--color-text-strong] border-[--color-stroke]' : "bg-[--color-input-bg] text-[--color-text-strong] ".concat(!isValid && selectedValue === '' ? 'border-utilRed1000' : 'border-[--color-stroke]'), " transition duration-200")
3885
+ className: "py-2 px-4 border rounded-lg transition duration-200 ".concat(selectedValue === option.value ? 'bg-[--color-primary-btn] text-[--color-text-strong] border-[--color-stroke]' : "bg-[--color-input-bg] text-[--color-text-strong] ".concat(!isValid && selectedValue === '' ? 'border-utilRed1000' : 'border-[--color-stroke]'), " ").concat(disabled ? 'opacity-50 cursor-not-allowed' : 'cursor-pointer')
3862
3886
  }, /*#__PURE__*/external_react_default().createElement("input", {
3863
3887
  type: "radio",
3864
- tabindex: tabIndex,
3888
+ tabIndex: tabIndex,
3865
3889
  title: title,
3866
3890
  "aria-label": title,
3867
3891
  name: name,
3868
3892
  value: option.value,
3869
3893
  checked: selectedValue === option.value,
3870
3894
  onChange: () => handleChange(option),
3871
- className: "hidden"
3895
+ className: "hidden",
3896
+ disabled: disabled,
3897
+ "data-cy": getDataCy({
3898
+ name,
3899
+ value: option.value,
3900
+ dataCy
3901
+ })
3872
3902
  }), option.label))), !isValid && /*#__PURE__*/external_react_default().createElement("span", {
3873
3903
  className: "text-utilRed1000 text-sm mt-1"
3874
3904
  }, errorMessage));
@@ -3877,6 +3907,7 @@ RadioButton.displayName = 'RadioButton';
3877
3907
  /* harmony default export */ const Radios_RadioButton = (RadioButton);
3878
3908
  ;// ./src/components/Forms/Checkbox/Checkbox.jsx
3879
3909
 
3910
+
3880
3911
  function Checkbox(_ref) {
3881
3912
  let {
3882
3913
  label,
@@ -3885,7 +3916,8 @@ function Checkbox(_ref) {
3885
3916
  value = false,
3886
3917
  isValid = true,
3887
3918
  errorMessage = "",
3888
- disabled = false
3919
+ disabled = false,
3920
+ dataCy
3889
3921
  } = _ref;
3890
3922
  return /*#__PURE__*/external_react_default().createElement("div", {
3891
3923
  className: "flex flex-col mb-4"
@@ -3897,7 +3929,8 @@ function Checkbox(_ref) {
3897
3929
  checked: value,
3898
3930
  onChange: onChange,
3899
3931
  disabled: disabled,
3900
- className: "mr-2 cursor-pointer"
3932
+ "data-cy": getDataCy(name, dataCy),
3933
+ className: "mr-2 ".concat(disabled ? 'opacity-50 cursor-not-allowed' : 'cursor-pointer')
3901
3934
  }), label), !isValid && errorMessage && /*#__PURE__*/external_react_default().createElement("span", {
3902
3935
  className: "text-rose-500 text-sm mt-1"
3903
3936
  }, errorMessage));
@@ -12202,13 +12235,13 @@ const esm_ChevronDownIcon_ForwardRef = /*#__PURE__*/ external_react_.forwardRef(
12202
12235
 
12203
12236
 
12204
12237
 
12238
+
12205
12239
  function Dropdown(_ref) {
12206
12240
  let {
12207
12241
  items,
12208
12242
  label = 'Test Label',
12209
12243
  isValid = true,
12210
12244
  required = false,
12211
- // New prop for required field
12212
12245
  placeholder = 'Example Placeholder',
12213
12246
  name,
12214
12247
  className = '',
@@ -12217,8 +12250,9 @@ function Dropdown(_ref) {
12217
12250
  onChange,
12218
12251
  value,
12219
12252
  Icon,
12220
- // Left-aligned icon
12221
- errorMessage = 'This field is required' // Default error message for required validation
12253
+ errorMessage = 'This field is required',
12254
+ disabled = false,
12255
+ dataCy // optional override
12222
12256
  } = _ref;
12223
12257
  const initialSelectedItem = items.find(item => item.value === value) || null;
12224
12258
  const [selectedItem, setSelectedItem] = (0,external_react_.useState)(initialSelectedItem);
@@ -12227,12 +12261,13 @@ function Dropdown(_ref) {
12227
12261
  const newSelectedItem = items.find(item => item.value === value) || null;
12228
12262
  setSelectedItem(newSelectedItem);
12229
12263
  }, [value, items]);
12230
- const inputClasses = "inline-flex w-full justify-between items-center rounded-md bg-[--color-input-bg] text-md font-normal border p-2 text-[--color-text-weak] ".concat(isValid ? 'border-[--color-stroke]' : 'border-utilRed1000', " ").concat(className);
12264
+ const inputClasses = "inline-flex w-full justify-between items-center rounded-md bg-[--color-input-bg] text-md font-normal border p-2 text-[--color-text-weak] ".concat(isValid ? 'border-[--color-stroke]' : 'border-utilRed1000', " ").concat(disabled ? 'opacity-50 cursor-not-allowed' : '', " ").concat(className);
12231
12265
  const handleSelect = item => {
12266
+ if (disabled) return;
12232
12267
  setSelectedItem(item);
12233
12268
  const event = {
12234
12269
  target: {
12235
- name: name,
12270
+ name,
12236
12271
  value: item.value
12237
12272
  }
12238
12273
  };
@@ -12244,22 +12279,24 @@ function Dropdown(_ref) {
12244
12279
  name: name,
12245
12280
  title: title,
12246
12281
  "aria-label": title,
12247
- tabindex: tabIndex
12282
+ tabIndex: tabIndex,
12283
+ "data-cy": getDataCy(name, dataCy)
12248
12284
  }, /*#__PURE__*/external_react_default().createElement("label", {
12249
12285
  className: "flex items-center text-[--color-text-weak] mb-1"
12250
12286
  }, label, required && /*#__PURE__*/external_react_default().createElement("span", {
12251
12287
  className: "ml-1 text-utilRed1000"
12252
- }, "*"), " "), /*#__PURE__*/external_react_default().createElement("div", null, /*#__PURE__*/external_react_default().createElement(It, {
12288
+ }, "*")), /*#__PURE__*/external_react_default().createElement("div", null, /*#__PURE__*/external_react_default().createElement(It, {
12253
12289
  className: inputClasses,
12254
- onClick: () => setIsOpen(prev => !prev)
12290
+ onClick: () => !disabled && setIsOpen(prev => !prev),
12291
+ disabled: disabled
12255
12292
  }, /*#__PURE__*/external_react_default().createElement("div", {
12256
12293
  className: "flex items-center gap-2"
12257
12294
  }, Icon && /*#__PURE__*/external_react_default().createElement(Icon, {
12258
12295
  className: "h-5 w-5 text-[--color-text-weak]"
12259
- }), " ", /*#__PURE__*/external_react_default().createElement("span", null, selectedItem ? selectedItem.label : placeholder)), /*#__PURE__*/external_react_default().createElement(solid_esm_ChevronDownIcon, {
12296
+ }), /*#__PURE__*/external_react_default().createElement("span", null, selectedItem ? selectedItem.label : placeholder)), /*#__PURE__*/external_react_default().createElement(solid_esm_ChevronDownIcon, {
12260
12297
  "aria-hidden": "true",
12261
12298
  className: "-mr-1 h-5 w-5 text-[--color-text-weak] transition-transform duration-200 ".concat(isOpen ? 'rotate-180' : 'rotate-0')
12262
- }))), /*#__PURE__*/external_react_default().createElement(gt, {
12299
+ }))), !disabled && /*#__PURE__*/external_react_default().createElement(gt, {
12263
12300
  transition: true,
12264
12301
  className: "absolute right-0 z-10 mt-2 w-56 origin-top-right rounded-md bg-[--color-primary-bg] shadow-lg ring-1 ring-black ring-opacity-5 transition focus:outline-none max-h-48 overflow-y-auto",
12265
12302
  onClick: () => setIsOpen(false)
@@ -12456,4 +12493,4 @@ const Pill = _ref => {
12456
12493
  /******/ })()
12457
12494
  ;
12458
12495
  });
12459
- //# sourceMappingURL=main.83ac8a97df068a0b0db7.js.map
12496
+ //# sourceMappingURL=main.a8aa83e8cb55d25079a7.js.map