opus-toolkit-components 0.7.5 → 0.7.7

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.
@@ -3540,6 +3540,17 @@ function AiTwotoneWarning (props) {
3540
3540
  return GenIcon({"tag":"svg","attr":{"viewBox":"0 0 1024 1024"},"child":[{"tag":"path","attr":{"fill":"#333","d":"M955.7 856l-416-720c-6.2-10.7-16.9-16-27.7-16s-21.6 5.3-27.7 16l-416 720C56 877.4 71.4 904 96 904h832c24.6 0 40-26.6 27.7-48zm-783.5-27.9L512 239.9l339.8 588.2H172.2z"},"child":[]},{"tag":"path","attr":{"fill":"#E6E6E6","d":"M172.2 828.1h679.6L512 239.9 172.2 828.1zM560 720a48.01 48.01 0 0 1-96 0 48.01 48.01 0 0 1 96 0zm-16-304v184c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V416c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8z"},"child":[]},{"tag":"path","attr":{"fill":"#333","d":"M464 720a48 48 0 1 0 96 0 48 48 0 1 0-96 0zm16-304v184c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V416c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8z"},"child":[]}]})(props);
3541
3541
  };
3542
3542
 
3543
+ ;// ./src/utils/getDataCy.js
3544
+ const getDataCy = function () {
3545
+ let {
3546
+ name,
3547
+ value,
3548
+ dataCy
3549
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3550
+ if (dataCy) return dataCy;
3551
+ if (name && value) return "".concat(name, "-").concat(value);
3552
+ return name || '';
3553
+ };
3543
3554
  ;// ./src/components/Buttons/Button.js
3544
3555
 
3545
3556
 
@@ -3552,6 +3563,9 @@ function Button(_ref) {
3552
3563
  state = 'default',
3553
3564
  text = 'Example Button',
3554
3565
  size = 'md',
3566
+ name,
3567
+ dataCy,
3568
+ tabIndex,
3555
3569
  isFullWidth = false,
3556
3570
  icon: Icon,
3557
3571
  // Icon as a React component
@@ -3588,8 +3602,14 @@ function Button(_ref) {
3588
3602
  return /*#__PURE__*/external_react_default().createElement("button", {
3589
3603
  type: type,
3590
3604
  title: title,
3605
+ name: name,
3591
3606
  "aria-label": title,
3592
3607
  className: classNames,
3608
+ tabIndex: tabIndex,
3609
+ "data-cy": getDataCy({
3610
+ name,
3611
+ dataCy
3612
+ }),
3593
3613
  onClick: !isSaving && state !== 'disabled' ? onClick : null,
3594
3614
  disabled: isSaving || state === 'disabled'
3595
3615
  }, isSaving ? /*#__PURE__*/external_react_default().createElement(AiOutlineLoading3Quarters, {
@@ -3622,6 +3642,7 @@ function Input_defineProperty(e, r, t) { return (r = Input_toPropertyKey(r)) in
3622
3642
  function Input_toPropertyKey(t) { var i = Input_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
3623
3643
  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
3644
 
3645
+
3625
3646
  const Input = /*#__PURE__*/(0,external_react_.forwardRef)((_ref, ref) => {
3626
3647
  let {
3627
3648
  label,
@@ -3647,9 +3668,13 @@ const Input = /*#__PURE__*/(0,external_react_.forwardRef)((_ref, ref) => {
3647
3668
  // Condition to render custom component
3648
3669
  customComponent,
3649
3670
  // Custom component to render
3650
- customComponentProps = {} // Props for the custom component
3671
+ customComponentProps = {},
3672
+ // Props for the custom component
3673
+ disabled = false,
3674
+ // New disabled prop
3675
+ dataCy
3651
3676
  } = _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]");
3677
+ 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
3678
  const iconClasses = "h-5 w-5 ".concat(isAnimated ? 'transition-transform duration-200 group-focus-within:scale-125' : '', " text-[--color-text-weak]");
3654
3679
  return /*#__PURE__*/external_react_default().createElement("div", {
3655
3680
  className: "flex flex-col mb-4"
@@ -3672,9 +3697,14 @@ const Input = /*#__PURE__*/(0,external_react_.forwardRef)((_ref, ref) => {
3672
3697
  onChange: onChange,
3673
3698
  value: value,
3674
3699
  title: title,
3675
- tabindex: tabIndex,
3700
+ tabIndex: tabIndex,
3676
3701
  "aria-label": title,
3677
- required: required // Set HTML required attribute
3702
+ required: required,
3703
+ disabled: disabled,
3704
+ "data-cy": getDataCy({
3705
+ name,
3706
+ dataCy
3707
+ })
3678
3708
  }), Icon && iconPosition === 'right' && /*#__PURE__*/external_react_default().createElement("span", {
3679
3709
  className: "absolute right-3 flex items-center pointer-events-none"
3680
3710
  }, /*#__PURE__*/external_react_default().createElement(Icon, {
@@ -3744,6 +3774,7 @@ var datepicker_update = injectStylesIntoStyleTag_default()(datepicker/* default
3744
3774
 
3745
3775
 
3746
3776
 
3777
+
3747
3778
  function DatePicker(_ref) {
3748
3779
  let {
3749
3780
  initialDate = '',
@@ -3755,11 +3786,12 @@ function DatePicker(_ref) {
3755
3786
  value,
3756
3787
  className = '',
3757
3788
  title = '',
3758
- required = false
3789
+ required = false,
3790
+ dataCy,
3791
+ disabled = false
3759
3792
  } = _ref;
3760
3793
  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
-
3794
+ const inputRef = (0,external_react_.useRef)(null);
3763
3795
  (0,external_react_.useEffect)(() => {
3764
3796
  if (value !== undefined) {
3765
3797
  setSelectedDate(value);
@@ -3774,8 +3806,8 @@ function DatePicker(_ref) {
3774
3806
  }
3775
3807
  };
3776
3808
  const handleIconClick = () => {
3777
- if (inputRef.current) {
3778
- inputRef.current.showPicker(); // Opens the native date picker (supported in modern browsers)
3809
+ if (inputRef.current && !disabled) {
3810
+ inputRef.current.showPicker();
3779
3811
  }
3780
3812
  };
3781
3813
  return /*#__PURE__*/external_react_default().createElement("div", {
@@ -3789,27 +3821,33 @@ function DatePicker(_ref) {
3789
3821
  type: "date",
3790
3822
  id: name,
3791
3823
  name: name,
3792
- ref: inputRef // Assign the ref to the input
3793
- ,
3824
+ ref: inputRef,
3794
3825
  value: selectedDate,
3795
3826
  title: title,
3796
3827
  "aria-label": title,
3797
3828
  onChange: handleDateChange,
3798
3829
  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)
3830
+ disabled: disabled,
3831
+ "data-cy": getDataCy({
3832
+ name,
3833
+ dataCy
3834
+ }),
3835
+ 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
3836
  }), /*#__PURE__*/external_react_default().createElement("button", {
3801
3837
  type: "button",
3802
3838
  onClick: handleIconClick,
3803
3839
  className: "absolute top-1/2 mt-1 right-3 transform",
3804
- "aria-label": "Open date picker"
3840
+ "aria-label": "Open date picker",
3841
+ disabled: disabled
3805
3842
  }, /*#__PURE__*/external_react_default().createElement(esm_CalendarIcon, {
3806
- className: "w-5 h-5 text-[--color-text-weak] hover:text-[--color-primary-btn-hover] transition"
3843
+ className: "w-5 h-5 ".concat(disabled ? 'text-[--color-text-disabled]' : 'text-[--color-text-weak] hover:text-[--color-primary-btn-hover]', " transition")
3807
3844
  })), !isValid && /*#__PURE__*/external_react_default().createElement("span", {
3808
3845
  className: "text-utilRed1000 text-sm"
3809
3846
  }, errorMessage));
3810
3847
  }
3811
3848
  ;// ./src/components/Forms/Radios/RadioButton.js
3812
3849
 
3850
+
3813
3851
  const RadioButton = _ref => {
3814
3852
  let {
3815
3853
  label,
@@ -3833,10 +3871,13 @@ const RadioButton = _ref => {
3833
3871
  title = '',
3834
3872
  isValid = true,
3835
3873
  errorMessage = "".concat(label, " is required"),
3836
- required = false
3874
+ required = false,
3875
+ dataCy,
3876
+ disabled = false
3837
3877
  } = _ref;
3838
3878
  const [selectedValue, setSelectedValue] = (0,external_react_.useState)('');
3839
3879
  const handleChange = item => {
3880
+ if (disabled) return;
3840
3881
  setSelectedValue(item.value);
3841
3882
  const event = {
3842
3883
  target: {
@@ -3849,7 +3890,7 @@ const RadioButton = _ref => {
3849
3890
  }
3850
3891
  };
3851
3892
  return /*#__PURE__*/external_react_default().createElement("div", {
3852
- className: "flex flex-col mb-4"
3893
+ className: "flex flex-col mb-4 ".concat(className)
3853
3894
  }, /*#__PURE__*/external_react_default().createElement("label", {
3854
3895
  className: "text-[--color-text-strong] mb-2 flex items-center"
3855
3896
  }, label, required && /*#__PURE__*/external_react_default().createElement("span", {
@@ -3858,17 +3899,23 @@ const RadioButton = _ref => {
3858
3899
  className: "flex space-x-4"
3859
3900
  }, options.map(option => /*#__PURE__*/external_react_default().createElement("label", {
3860
3901
  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")
3902
+ 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
3903
  }, /*#__PURE__*/external_react_default().createElement("input", {
3863
3904
  type: "radio",
3864
- tabindex: tabIndex,
3905
+ tabIndex: tabIndex,
3865
3906
  title: title,
3866
3907
  "aria-label": title,
3867
3908
  name: name,
3868
3909
  value: option.value,
3869
3910
  checked: selectedValue === option.value,
3870
3911
  onChange: () => handleChange(option),
3871
- className: "hidden"
3912
+ className: "hidden",
3913
+ disabled: disabled,
3914
+ "data-cy": getDataCy({
3915
+ name,
3916
+ value: option.value,
3917
+ dataCy
3918
+ })
3872
3919
  }), option.label))), !isValid && /*#__PURE__*/external_react_default().createElement("span", {
3873
3920
  className: "text-utilRed1000 text-sm mt-1"
3874
3921
  }, errorMessage));
@@ -3877,6 +3924,7 @@ RadioButton.displayName = 'RadioButton';
3877
3924
  /* harmony default export */ const Radios_RadioButton = (RadioButton);
3878
3925
  ;// ./src/components/Forms/Checkbox/Checkbox.jsx
3879
3926
 
3927
+
3880
3928
  function Checkbox(_ref) {
3881
3929
  let {
3882
3930
  label,
@@ -3885,7 +3933,8 @@ function Checkbox(_ref) {
3885
3933
  value = false,
3886
3934
  isValid = true,
3887
3935
  errorMessage = "",
3888
- disabled = false
3936
+ disabled = false,
3937
+ dataCy
3889
3938
  } = _ref;
3890
3939
  return /*#__PURE__*/external_react_default().createElement("div", {
3891
3940
  className: "flex flex-col mb-4"
@@ -3897,7 +3946,11 @@ function Checkbox(_ref) {
3897
3946
  checked: value,
3898
3947
  onChange: onChange,
3899
3948
  disabled: disabled,
3900
- className: "mr-2 cursor-pointer"
3949
+ "data-cy": getDataCy({
3950
+ name,
3951
+ dataCy
3952
+ }),
3953
+ className: "mr-2 ".concat(disabled ? 'opacity-50 cursor-not-allowed' : 'cursor-pointer')
3901
3954
  }), label), !isValid && errorMessage && /*#__PURE__*/external_react_default().createElement("span", {
3902
3955
  className: "text-rose-500 text-sm mt-1"
3903
3956
  }, errorMessage));
@@ -12202,13 +12255,13 @@ const esm_ChevronDownIcon_ForwardRef = /*#__PURE__*/ external_react_.forwardRef(
12202
12255
 
12203
12256
 
12204
12257
 
12258
+
12205
12259
  function Dropdown(_ref) {
12206
12260
  let {
12207
12261
  items,
12208
12262
  label = 'Test Label',
12209
12263
  isValid = true,
12210
12264
  required = false,
12211
- // New prop for required field
12212
12265
  placeholder = 'Example Placeholder',
12213
12266
  name,
12214
12267
  className = '',
@@ -12217,8 +12270,9 @@ function Dropdown(_ref) {
12217
12270
  onChange,
12218
12271
  value,
12219
12272
  Icon,
12220
- // Left-aligned icon
12221
- errorMessage = 'This field is required' // Default error message for required validation
12273
+ errorMessage = 'This field is required',
12274
+ disabled = false,
12275
+ dataCy // optional override
12222
12276
  } = _ref;
12223
12277
  const initialSelectedItem = items.find(item => item.value === value) || null;
12224
12278
  const [selectedItem, setSelectedItem] = (0,external_react_.useState)(initialSelectedItem);
@@ -12227,12 +12281,13 @@ function Dropdown(_ref) {
12227
12281
  const newSelectedItem = items.find(item => item.value === value) || null;
12228
12282
  setSelectedItem(newSelectedItem);
12229
12283
  }, [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);
12284
+ 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
12285
  const handleSelect = item => {
12286
+ if (disabled) return;
12232
12287
  setSelectedItem(item);
12233
12288
  const event = {
12234
12289
  target: {
12235
- name: name,
12290
+ name,
12236
12291
  value: item.value
12237
12292
  }
12238
12293
  };
@@ -12244,22 +12299,27 @@ function Dropdown(_ref) {
12244
12299
  name: name,
12245
12300
  title: title,
12246
12301
  "aria-label": title,
12247
- tabindex: tabIndex
12302
+ tabIndex: tabIndex,
12303
+ "data-cy": getDataCy({
12304
+ name,
12305
+ dataCy
12306
+ })
12248
12307
  }, /*#__PURE__*/external_react_default().createElement("label", {
12249
12308
  className: "flex items-center text-[--color-text-weak] mb-1"
12250
12309
  }, label, required && /*#__PURE__*/external_react_default().createElement("span", {
12251
12310
  className: "ml-1 text-utilRed1000"
12252
- }, "*"), " "), /*#__PURE__*/external_react_default().createElement("div", null, /*#__PURE__*/external_react_default().createElement(It, {
12311
+ }, "*")), /*#__PURE__*/external_react_default().createElement("div", null, /*#__PURE__*/external_react_default().createElement(It, {
12253
12312
  className: inputClasses,
12254
- onClick: () => setIsOpen(prev => !prev)
12313
+ onClick: () => !disabled && setIsOpen(prev => !prev),
12314
+ disabled: disabled
12255
12315
  }, /*#__PURE__*/external_react_default().createElement("div", {
12256
12316
  className: "flex items-center gap-2"
12257
12317
  }, Icon && /*#__PURE__*/external_react_default().createElement(Icon, {
12258
12318
  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, {
12319
+ }), /*#__PURE__*/external_react_default().createElement("span", null, selectedItem ? selectedItem.label : placeholder)), /*#__PURE__*/external_react_default().createElement(solid_esm_ChevronDownIcon, {
12260
12320
  "aria-hidden": "true",
12261
12321
  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, {
12322
+ }))), !disabled && /*#__PURE__*/external_react_default().createElement(gt, {
12263
12323
  transition: true,
12264
12324
  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
12325
  onClick: () => setIsOpen(false)
@@ -12456,4 +12516,4 @@ const Pill = _ref => {
12456
12516
  /******/ })()
12457
12517
  ;
12458
12518
  });
12459
- //# sourceMappingURL=main.83ac8a97df068a0b0db7.js.map
12519
+ //# sourceMappingURL=main.56fc8a295b30cd3236eb.js.map