opus-toolkit-components 0.2.9 → 0.3.1

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.
@@ -12,7 +12,7 @@ return /******/ (() => { // webpackBootstrap
12
12
  /******/ "use strict";
13
13
  /******/ var __webpack_modules__ = ({
14
14
 
15
- /***/ 250:
15
+ /***/ 289:
16
16
  /***/ ((module, __webpack_exports__, __webpack_require__) => {
17
17
 
18
18
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
@@ -27,7 +27,7 @@ return /******/ (() => { // webpackBootstrap
27
27
 
28
28
  var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
29
29
  // Module
30
- ___CSS_LOADER_EXPORT___.push([module.id, `.primary-btn{background:#e23193;color:#fff}.primary-btn:hover{background:#005de5}.secondary-btn{background:#005de5;color:#fff}.secondary-btn:hover{background:#e23193}.outline-btn{background:none;border:2px solid #fff;color:#fff}.outline-btn:hover{background:#e23193;border-color:#e23193}`, "",{"version":3,"sources":["webpack://./src/components/Buttons/_button.scss","webpack://./node_modules/opus-toolkit-styles/fragments/_colours.scss"],"names":[],"mappings":"AAoBA,aACI,kBCEO,CDDP,UAhBS,CAKX,mBACE,kBCSO,CDMX,eACI,kBCPO,CDQP,UAvBS,CAKX,qBACE,kBCWO,CDWX,aACI,eAAA,CACA,qBAAA,CACA,UA/BS,CAKX,mBACE,kBCWO,CDTL,oBCSK","sourcesContent":["@import 'opus-toolkit-styles/fragments/colours';\r\n// Define color variables\r\n$primary-color: $c247Pink;\r\n$primary-hover-color: $c247Blue;\r\n$secondary-color: $c247Blue;\r\n$hover-color: $c247Pink;\r\n$text-color: white;\r\n$outline-border-color: white;\r\n\r\n// Create a mixin for hover effects to avoid repetition\r\n@mixin hover-effect($hover-bg, $hover-border: null) {\r\n &:hover {\r\n background: $hover-bg;\r\n @if $hover-border {\r\n border-color: $hover-border;\r\n }\r\n }\r\n}\r\n\r\n// Primary button styles\r\n.primary-btn {\r\n background: $primary-color;\r\n color: $text-color;\r\n @include hover-effect($primary-hover-color);\r\n}\r\n\r\n// Secondary button styles\r\n.secondary-btn {\r\n background: $secondary-color;\r\n color: $text-color;\r\n @include hover-effect($hover-color);\r\n}\r\n\r\n// Outline button styles\r\n.outline-btn {\r\n background: none;\r\n border: 2px solid $outline-border-color;\r\n color: $text-color;\r\n @include hover-effect($hover-color, $hover-color);\r\n}","// Foundation Brand colors\r\n$opusDeepBlue: #0c022f;\r\n$opusNavy: #24135f;\r\n$opusRichBlue: #003494;\r\n\r\n// Grey/Blue Scale\r\n$opusDarkest: #07011c;\r\n$opusGrey800: #1b1f51;\r\n$opusGrey700: #444877;\r\n$opusGrey600: #8b8fac;\r\n$opusGrey400: #e3e4eb;\r\n$opusGrey200: #f8f8fb;\r\n$opusWhite: #ffffff;\r\n\r\n// Brand Colours\r\n$opusLightBlue: #005de5;\r\n$opusBrandBlue: #0176d9;\r\n$opusPurple: #451f88;\r\n$opusPink: #e05db4;\r\n\r\n// C247 Colours\r\n$c247Blue: #005de5;\r\n$c247Purple: #ad43c4;\r\n$c247Pink: #e23193;\r\n\r\n// Utility Colours\r\n$danger: #bb0808;\r\n$success: #27be36;"],"sourceRoot":""}]);
30
+ ___CSS_LOADER_EXPORT___.push([module.id, `.primary-btn{color:#fff;box-shadow:0px 2px 4px -2px rgba(0,0,0,.08),0px 4px 8px -2px rgba(0,0,0,.04)}.primary-btn:hover{background-color:#b52776}`, "",{"version":3,"sources":["webpack://./src/components/Buttons/button.scss"],"names":[],"mappings":"AAoBA,aAII,UAlBS,CAmBT,4EAAA,CAJF,mBACE,wBAAA","sourcesContent":["@import 'opus-toolkit-styles/fragments/colours';\r\n// Define color variables\r\n// $primary-color: $c247Pink;\r\n// $primary-hover-color: $c247Blue;\r\n// $secondary-color: $c247Blue;\r\n// $hover-color: $c247Pink;\r\n$text-color: white;\r\n// $outline-border-color: white;\r\n\r\n// Create a mixin for hover effects to avoid repetition\r\n// @mixin hover-effect($hover-bg, $hover-border: null) {\r\n// &:hover {\r\n// background: $hover-bg;\r\n// @if $hover-border {\r\n// border-color: $hover-border;\r\n// }\r\n// }\r\n// }\r\n\r\n// // Primary button styles\r\n.primary-btn {\r\n &:hover {\r\n background-color: #B52776;\r\n }\r\n color: $text-color;\r\n box-shadow: 0px 2px 4px -2px rgba(0, 0, 0, 0.08), 0px 4px 8px -2px rgba(0, 0, 0, 0.04);\r\n}\r\n\r\n// // Secondary button styles\r\n// .secondary-btn {\r\n// background: $secondary-color;\r\n// color: $text-color;\r\n// }"],"sourceRoot":""}]);
31
31
  // Exports
32
32
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
33
33
 
@@ -546,7 +546,7 @@ __webpack_require__.d(__webpack_exports__, {
546
546
  Card: () => (/* reexport */ Card),
547
547
  DatePicker: () => (/* reexport */ DatePicker),
548
548
  Dropdown: () => (/* reexport */ Dropdown),
549
- Input: () => (/* reexport */ Input),
549
+ Input: () => (/* reexport */ Inputs_Input),
550
550
  RadioButton: () => (/* reexport */ RadioButton),
551
551
  Table: () => (/* reexport */ Table)
552
552
  });
@@ -622,9 +622,9 @@ var insertStyleElement_default = /*#__PURE__*/__webpack_require__.n(insertStyleE
622
622
  // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/styleTagTransform.js
623
623
  var styleTagTransform = __webpack_require__(113);
624
624
  var styleTagTransform_default = /*#__PURE__*/__webpack_require__.n(styleTagTransform);
625
- // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/components/Buttons/_button.scss
626
- var _button = __webpack_require__(250);
627
- ;// ./src/components/Buttons/_button.scss
625
+ // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/components/Buttons/button.scss
626
+ var Buttons_button = __webpack_require__(289);
627
+ ;// ./src/components/Buttons/button.scss
628
628
 
629
629
 
630
630
 
@@ -644,12 +644,12 @@ options.insert = insertBySelector_default().bind(null, "head");
644
644
  options.domAPI = (styleDomAPI_default());
645
645
  options.insertStyleElement = (insertStyleElement_default());
646
646
 
647
- var update = injectStylesIntoStyleTag_default()(_button/* default */.A, options);
647
+ var update = injectStylesIntoStyleTag_default()(Buttons_button/* default */.A, options);
648
648
 
649
649
 
650
650
 
651
651
 
652
- /* harmony default export */ const Buttons_button = (_button/* default */.A && _button/* default */.A.locals ? _button/* default */.A.locals : undefined);
652
+ /* harmony default export */ const components_Buttons_button = (Buttons_button/* default */.A && Buttons_button/* default */.A.locals ? Buttons_button/* default */.A.locals : undefined);
653
653
 
654
654
  ;// ./src/components/Buttons/Button.js
655
655
 
@@ -657,15 +657,35 @@ var update = injectStylesIntoStyleTag_default()(_button/* default */.A, options)
657
657
  function Button(_ref) {
658
658
  let {
659
659
  type = 'button',
660
+ cat = 'c247',
661
+ // c247, neutral, destructive, inverse
660
662
  rank = 'primary',
663
+ // Primary, secondary, tertiary
664
+ state = 'default',
665
+ // default, hover, disabled
661
666
  text = 'Example Button',
662
667
  size = 'md',
663
668
  isFullWidth = false,
664
- // The boolean to toggle 'w-full'
665
669
  onClick
666
670
  } = _ref;
667
- // Conditional class based on isFullWidth
668
- const classNames = `transition ease-in-out duration-700 rounded px-6 py-2 text-${size} ${rank}-btn ${isFullWidth ? 'w-full' : ''}`;
671
+ // Define style classes based on button rank
672
+ const rankStyles = {
673
+ primary: 'bg-c247-pinkDefault hover:bg-c247-pinkHover',
674
+ neutral: 'bg-c247-neutralDefault hover:bg-c247-neutralHover',
675
+ destructive: 'bg-c247-destructiveDefault hover:bg-c247-destructiveHover'
676
+ };
677
+ const classNames = `
678
+ ${rankStyles[rank] || rankStyles.primary}
679
+ text-white
680
+ transition
681
+ ease-in-out
682
+ duration-700
683
+ rounded-lg
684
+ px-6
685
+ py-2
686
+ text-${size}
687
+ ${isFullWidth ? 'w-full' : ''}
688
+ `;
669
689
  return /*#__PURE__*/external_react_default().createElement("button", {
670
690
  type: type,
671
691
  className: classNames,
@@ -716,7 +736,7 @@ function Card(_ref) {
716
736
  }
717
737
  ;// ./src/components/Forms/Inputs/Input.js
718
738
 
719
- function Input(_ref) {
739
+ const Input = /*#__PURE__*/(0,external_react_.forwardRef)((_ref, ref) => {
720
740
  let {
721
741
  label,
722
742
  placeholder,
@@ -731,6 +751,7 @@ function Input(_ref) {
731
751
  return /*#__PURE__*/external_react_default().createElement("div", {
732
752
  className: "flex flex-col mb-4"
733
753
  }, /*#__PURE__*/external_react_default().createElement("label", null, label), /*#__PURE__*/external_react_default().createElement("input", {
754
+ ref: ref,
734
755
  className: inputClasses,
735
756
  type: type,
736
757
  name: name,
@@ -740,7 +761,8 @@ function Input(_ref) {
740
761
  }), !isValid && /*#__PURE__*/external_react_default().createElement("span", {
741
762
  className: "text-rose-500 text-sm"
742
763
  }, errorMessage));
743
- }
764
+ });
765
+ /* harmony default export */ const Inputs_Input = (Input);
744
766
  ;// ./src/components/Forms/Datepickers/DatePicker.js
745
767
 
746
768
  function DatePicker(_ref) {
@@ -9020,33 +9042,41 @@ function Dropdown(_ref) {
9020
9042
  onChange,
9021
9043
  value
9022
9044
  } = _ref;
9023
- const [selectedItem, setSelectedItem] = (0,external_react_.useState)(value); // Initialize to null
9024
-
9045
+ const initialSelectedItem = items.find(item => item.value === value) || null;
9046
+ const [selectedItem, setSelectedItem] = (0,external_react_.useState)(initialSelectedItem);
9047
+ (0,external_react_.useEffect)(() => {
9048
+ const newSelectedItem = items.find(item => item.value === value) || null;
9049
+ setSelectedItem(newSelectedItem);
9050
+ }, [value, items]);
9025
9051
  const inputClasses = `inline-flex w-full justify-center gap-x-1.5 rounded-md bg-white border px-4 py-3 text-md font-normal text-gray-900 ${isValid ? 'border-slate-500' : 'border-rose-500'}`;
9026
9052
  const handleSelect = item => {
9027
- setSelectedItem(item); // Store the whole item
9028
-
9029
- // Create a synthetic event
9053
+ setSelectedItem(item);
9030
9054
  const event = {
9031
9055
  target: {
9032
9056
  name: name,
9033
- value: item.value // Use the value of the selected item
9057
+ value: item.value
9034
9058
  }
9035
9059
  };
9036
- onChange(event); // Pass the synthetic event object
9060
+ onChange(event);
9037
9061
  };
9038
9062
  return /*#__PURE__*/external_react_default().createElement(rn, {
9039
9063
  as: "div",
9040
9064
  className: "relative inline-block text-left",
9041
9065
  name: name
9042
9066
  }, /*#__PURE__*/external_react_default().createElement("label", null, label), /*#__PURE__*/external_react_default().createElement("div", null, /*#__PURE__*/external_react_default().createElement(It, {
9043
- className: inputClasses
9044
- }, selectedItem ? selectedItem.label : placeholder, " ", /*#__PURE__*/external_react_default().createElement(esm_ChevronDownIcon, {
9067
+ className: inputClasses,
9068
+ style: {
9069
+ backgroundColor: 'white'
9070
+ }
9071
+ }, selectedItem ? selectedItem.label : placeholder, /*#__PURE__*/external_react_default().createElement(esm_ChevronDownIcon, {
9045
9072
  "aria-hidden": "true",
9046
9073
  className: "-mr-1 h-5 w-5 text-gray-400"
9047
9074
  }))), /*#__PURE__*/external_react_default().createElement(gt, {
9048
9075
  transition: true,
9049
- className: "absolute right-0 z-10 mt-2 w-56 origin-top-right rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 transition focus:outline-none"
9076
+ className: "absolute right-0 z-10 mt-2 w-56 origin-top-right rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 transition focus:outline-none",
9077
+ style: {
9078
+ backgroundColor: 'white'
9079
+ }
9050
9080
  }, /*#__PURE__*/external_react_default().createElement("div", {
9051
9081
  className: "py-1"
9052
9082
  }, items.map((item, index) => /*#__PURE__*/external_react_default().createElement(Et, {
@@ -9056,15 +9086,13 @@ function Dropdown(_ref) {
9056
9086
  active
9057
9087
  } = _ref2;
9058
9088
  return /*#__PURE__*/external_react_default().createElement("button", {
9059
- type: "button" // Prevent form submission
9060
- ,
9061
- onClick: () => handleSelect(item) // Pass the whole item to handleSelect
9062
- ,
9089
+ type: "button",
9090
+ onClick: () => handleSelect(item),
9063
9091
  className: `block w-full px-4 py-2 text-left text-sm text-gray-700 ${active ? 'bg-gray-100 text-gray-900' : ''}`
9064
9092
  }, item.label);
9065
9093
  })))), !isValid && /*#__PURE__*/external_react_default().createElement("span", {
9066
9094
  className: "text-rose-500 text-sm"
9067
- }));
9095
+ }, "Please select a valid option"));
9068
9096
  }
9069
9097
  ;// ./src/index.js
9070
9098
 
@@ -9079,4 +9107,4 @@ function Dropdown(_ref) {
9079
9107
  /******/ })()
9080
9108
  ;
9081
9109
  });
9082
- //# sourceMappingURL=main.cbe51cd922acdf7e3218.js.map
9110
+ //# sourceMappingURL=main.cf31769a0398dce70335.js.map