sprint-asia-custom-component 0.1.143 → 0.1.145

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
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('.components/dropdownbutton')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'react', '.components/dropdownbutton'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.MyComponent = {}, global.React, global.dropdownbutton));
5
- })(this, (function (exports, React, dropdownbutton) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.MyComponent = {}, global.React));
5
+ })(this, (function (exports, React) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -26,7 +26,6 @@
26
26
 
27
27
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
28
28
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
29
- var dropdownbutton__default = /*#__PURE__*/_interopDefaultLegacy(dropdownbutton);
30
29
 
31
30
  var DefaultContext = {
32
31
  color: undefined,
@@ -23902,7 +23901,7 @@
23902
23901
  };
23903
23902
 
23904
23903
  // THIS FILE IS AUTO GENERATED
23905
- function FaFileAlt(props){return GenIcon({"tag":"svg","attr":{"viewBox":"0 0 384 512"},"child":[{"tag":"path","attr":{"d":"M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm64 236c0 6.6-5.4 12-12 12H108c-6.6 0-12-5.4-12-12v-8c0-6.6 5.4-12 12-12h168c6.6 0 12 5.4 12 12v8zm0-64c0 6.6-5.4 12-12 12H108c-6.6 0-12-5.4-12-12v-8c0-6.6 5.4-12 12-12h168c6.6 0 12 5.4 12 12v8zm0-72v8c0 6.6-5.4 12-12 12H108c-6.6 0-12-5.4-12-12v-8c0-6.6 5.4-12 12-12h168c6.6 0 12 5.4 12 12zm96-114.1v6.1H256V0h6.1c6.4 0 12.5 2.5 17 7l97.9 98c4.5 4.5 7 10.6 7 16.9z"}}]})(props);}function FaFileImage(props){return GenIcon({"tag":"svg","attr":{"viewBox":"0 0 384 512"},"child":[{"tag":"path","attr":{"d":"M384 121.941V128H256V0h6.059a24 24 0 0 1 16.97 7.029l97.941 97.941a24.002 24.002 0 0 1 7.03 16.971zM248 160c-13.2 0-24-10.8-24-24V0H24C10.745 0 0 10.745 0 24v464c0 13.255 10.745 24 24 24h336c13.255 0 24-10.745 24-24V160H248zm-135.455 16c26.51 0 48 21.49 48 48s-21.49 48-48 48-48-21.49-48-48 21.491-48 48-48zm208 240h-256l.485-48.485L104.545 328c4.686-4.686 11.799-4.201 16.485.485L160.545 368 264.06 264.485c4.686-4.686 12.284-4.686 16.971 0L320.545 304v112z"}}]})(props);}
23904
+ function FaChevronDown(props){return GenIcon({"tag":"svg","attr":{"viewBox":"0 0 448 512"},"child":[{"tag":"path","attr":{"d":"M207.029 381.476L12.686 187.132c-9.373-9.373-9.373-24.569 0-33.941l22.667-22.667c9.357-9.357 24.522-9.375 33.901-.04L224 284.505l154.745-154.021c9.379-9.335 24.544-9.317 33.901.04l22.667 22.667c9.373 9.373 9.373 24.569 0 33.941L240.971 381.476c-9.373 9.372-24.569 9.372-33.942 0z"}}]})(props);}function FaFileAlt(props){return GenIcon({"tag":"svg","attr":{"viewBox":"0 0 384 512"},"child":[{"tag":"path","attr":{"d":"M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm64 236c0 6.6-5.4 12-12 12H108c-6.6 0-12-5.4-12-12v-8c0-6.6 5.4-12 12-12h168c6.6 0 12 5.4 12 12v8zm0-64c0 6.6-5.4 12-12 12H108c-6.6 0-12-5.4-12-12v-8c0-6.6 5.4-12 12-12h168c6.6 0 12 5.4 12 12v8zm0-72v8c0 6.6-5.4 12-12 12H108c-6.6 0-12-5.4-12-12v-8c0-6.6 5.4-12 12-12h168c6.6 0 12 5.4 12 12zm96-114.1v6.1H256V0h6.1c6.4 0 12.5 2.5 17 7l97.9 98c4.5 4.5 7 10.6 7 16.9z"}}]})(props);}function FaFileImage(props){return GenIcon({"tag":"svg","attr":{"viewBox":"0 0 384 512"},"child":[{"tag":"path","attr":{"d":"M384 121.941V128H256V0h6.059a24 24 0 0 1 16.97 7.029l97.941 97.941a24.002 24.002 0 0 1 7.03 16.971zM248 160c-13.2 0-24-10.8-24-24V0H24C10.745 0 0 10.745 0 24v464c0 13.255 10.745 24 24 24h336c13.255 0 24-10.745 24-24V160H248zm-135.455 16c26.51 0 48 21.49 48 48s-21.49 48-48 48-48-21.49-48-48 21.491-48 48-48zm208 240h-256l.485-48.485L104.545 328c4.686-4.686 11.799-4.201 16.485.485L160.545 368 264.06 264.485c4.686-4.686 12.284-4.686 16.971 0L320.545 304v112z"}}]})(props);}
23906
23905
 
23907
23906
  const DescriptionFile = ({
23908
23907
  title = "Title",
@@ -24157,6 +24156,7 @@
24157
24156
  const selectedValue = options.filter(val => {
24158
24157
  return val.value === currentOption;
24159
24158
  });
24159
+ const hasData = options.length > 0;
24160
24160
  return /*#__PURE__*/React__default["default"].createElement("div", {
24161
24161
  className: `relative inline-block text-left w-full ${className}`,
24162
24162
  ref: dropdownRef
@@ -24171,11 +24171,11 @@
24171
24171
  }, /*#__PURE__*/React__default["default"].createElement("button", {
24172
24172
  type: "button",
24173
24173
  className: `
24174
- ${!isEdited && "bg-neutral30 cursor-not-allowed"}
24175
- ${mode === "default" && currentOption === "" && "border-neutral50 bg-neutral20 cursor-pointer"}
24176
- ${mode === "default" && currentOption !== "" && "border-black bg-neutral20 cursor-pointer"}
24177
- ${mode === "danger" && "border-danger500 bg-danger50 cursor-pointer"}
24178
- flex items-center w-full py-2.5 text-left px-4 font-normal text-sm text-neutral300 rounded-md border focus:outline-none overflow-hidden`,
24174
+ ${!isEdited && "bg-neutral30 cursor-not-allowed"}
24175
+ ${mode === "default" && currentOption === "" && "border-neutral50 bg-neutral20 cursor-pointer"}
24176
+ ${mode === "default" && currentOption !== "" && "border-black bg-neutral20 cursor-pointer"}
24177
+ ${mode === "danger" && "border-danger500 bg-danger50 cursor-pointer"}
24178
+ flex items-center w-full py-2.5 text-left px-4 font-normal text-sm text-neutral300 rounded-md border focus:outline-none overflow-hidden`,
24179
24179
  onClick: () => isEdited && handleToggleDropdownText()
24180
24180
  }, /*#__PURE__*/React__default["default"].createElement("span", {
24181
24181
  className: "flex-grow overflow-hidden"
@@ -24194,7 +24194,7 @@
24194
24194
  "aria-labelledby": "options-menu"
24195
24195
  }, /*#__PURE__*/React__default["default"].createElement("div", {
24196
24196
  className: "px-1 py-2 max-h-40 overflow-y-auto"
24197
- }, options.map((option, index) => /*#__PURE__*/React__default["default"].createElement("div", {
24197
+ }, hasData ? options.map((option, index) => /*#__PURE__*/React__default["default"].createElement("div", {
24198
24198
  key: index,
24199
24199
  className: "hover:bg-neutral20 bg-white py-2.5 px-4 my-0.5 rounded-md",
24200
24200
  onClick: () => {
@@ -24204,7 +24204,11 @@
24204
24204
  }
24205
24205
  }, /*#__PURE__*/React__default["default"].createElement("p", {
24206
24206
  className: "text-sm text-black"
24207
- }, option.option))))), footer && /*#__PURE__*/React__default["default"].createElement("div", {
24207
+ }, option.option))) : /*#__PURE__*/React__default["default"].createElement("div", {
24208
+ className: "bg-white py-2.5 px-4 my-0.5 rounded-md"
24209
+ }, /*#__PURE__*/React__default["default"].createElement("p", {
24210
+ className: "text-sm text-neutral500"
24211
+ }, "No data")))), footer && /*#__PURE__*/React__default["default"].createElement("div", {
24208
24212
  className: "mt-1"
24209
24213
  }, mode === "danger" ? /*#__PURE__*/React__default["default"].createElement("div", {
24210
24214
  className: "flex"
@@ -48835,10 +48839,74 @@
48835
48839
  }, footer)));
48836
48840
  };
48837
48841
 
48838
- Object.defineProperty(exports, 'DropdownButton', {
48839
- enumerable: true,
48840
- get: function () { return dropdownbutton__default["default"]; }
48841
- });
48842
+ const DropdownButton = ({
48843
+ defaultType = 'Voucher Type'
48844
+ }) => {
48845
+ const [isOpen, setIsOpen] = React.useState(false);
48846
+ const [selectedValue, setSelectedValue] = React.useState(defaultType);
48847
+ const toggleDropdown = () => {
48848
+ setIsOpen(!isOpen);
48849
+ };
48850
+ const handleOptionClick = value => {
48851
+ setSelectedValue(value);
48852
+ setIsOpen(false);
48853
+ };
48854
+ return /*#__PURE__*/React__default["default"].createElement("div", {
48855
+ style: {
48856
+ position: 'relative',
48857
+ display: 'inline-block'
48858
+ }
48859
+ }, /*#__PURE__*/React__default["default"].createElement("button", {
48860
+ onClick: toggleDropdown,
48861
+ style: {
48862
+ display: 'flex',
48863
+ alignItems: 'center',
48864
+ justifyContent: 'space-between',
48865
+ border: '1px solid #007bff',
48866
+ background: '#fff',
48867
+ color: '#007bff',
48868
+ borderRadius: '5px',
48869
+ padding: '10px 15px',
48870
+ cursor: 'pointer',
48871
+ fontSize: '16px',
48872
+ fontWeight: 'bold'
48873
+ }
48874
+ }, selectedValue, /*#__PURE__*/React__default["default"].createElement(FaChevronDown, {
48875
+ style: {
48876
+ marginLeft: '8px'
48877
+ }
48878
+ })), isOpen && /*#__PURE__*/React__default["default"].createElement("div", {
48879
+ style: {
48880
+ position: 'absolute',
48881
+ top: '100%',
48882
+ left: '0',
48883
+ background: '#fff',
48884
+ boxShadow: '0 4px 6px rgba(0, 0, 0, 0.1)',
48885
+ borderRadius: '5px',
48886
+ marginTop: '8px',
48887
+ zIndex: 10
48888
+ }
48889
+ }, /*#__PURE__*/React__default["default"].createElement("ul", {
48890
+ style: {
48891
+ listStyle: 'none',
48892
+ margin: 0,
48893
+ padding: '10px 0'
48894
+ }
48895
+ }, /*#__PURE__*/React__default["default"].createElement("li", {
48896
+ style: {
48897
+ padding: '10px 20px',
48898
+ cursor: 'pointer'
48899
+ },
48900
+ onClick: () => handleOptionClick('Digital Voucher')
48901
+ }, "Digital Voucher"), /*#__PURE__*/React__default["default"].createElement("li", {
48902
+ style: {
48903
+ padding: '10px 20px',
48904
+ cursor: 'pointer'
48905
+ },
48906
+ onClick: () => handleOptionClick('PPOB Voucher')
48907
+ }, "PPOB Voucher"))));
48908
+ };
48909
+
48842
48910
  exports.Alert = Alert;
48843
48911
  exports.BillerList = BillerList;
48844
48912
  exports.BillerProductList = BillerProductList;
@@ -48860,6 +48928,7 @@
48860
48928
  exports.Description = Description;
48861
48929
  exports.DescriptionFile = DescriptionFile;
48862
48930
  exports.DetailDivision = DetailDivision;
48931
+ exports.DropdownButton = DropdownButton;
48863
48932
  exports.DropdownCard = DropdownCard;
48864
48933
  exports.DropdownChip = DropdownChip;
48865
48934
  exports.DropdownText = DropdownText;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sprint-asia-custom-component",
3
3
  "main": "dist/index.js",
4
- "version": "0.1.143",
4
+ "version": "0.1.145",
5
5
  "private": false,
6
6
  "dependencies": {
7
7
  "@headlessui/react": "^1.7.18",
@@ -47,6 +47,8 @@ const DropdownText = ({
47
47
  return val.value === currentOption;
48
48
  });
49
49
 
50
+ const hasData = options.length > 0;
51
+
50
52
  return (
51
53
  <div className={`relative inline-block text-left w-full ${className}`} ref={dropdownRef}>
52
54
  {title && (
@@ -60,11 +62,11 @@ const DropdownText = ({
60
62
  <button
61
63
  type="button"
62
64
  className={`
63
- ${!isEdited && "bg-neutral30 cursor-not-allowed"}
64
- ${mode === "default" && currentOption === "" && "border-neutral50 bg-neutral20 cursor-pointer"}
65
- ${mode === "default" && currentOption !== "" && "border-black bg-neutral20 cursor-pointer"}
66
- ${mode === "danger" && "border-danger500 bg-danger50 cursor-pointer"}
67
- flex items-center w-full py-2.5 text-left px-4 font-normal text-sm text-neutral300 rounded-md border focus:outline-none overflow-hidden`}
65
+ ${!isEdited && "bg-neutral30 cursor-not-allowed"}
66
+ ${mode === "default" && currentOption === "" && "border-neutral50 bg-neutral20 cursor-pointer"}
67
+ ${mode === "default" && currentOption !== "" && "border-black bg-neutral20 cursor-pointer"}
68
+ ${mode === "danger" && "border-danger500 bg-danger50 cursor-pointer"}
69
+ flex items-center w-full py-2.5 text-left px-4 font-normal text-sm text-neutral300 rounded-md border focus:outline-none overflow-hidden`}
68
70
  onClick={() => isEdited && handleToggleDropdownText()}
69
71
  >
70
72
  <span className="flex-grow overflow-hidden">
@@ -89,19 +91,25 @@ const DropdownText = ({
89
91
  aria-labelledby="options-menu"
90
92
  >
91
93
  <div className="px-1 py-2 max-h-40 overflow-y-auto">
92
- {options.map((option, index) => (
93
- <div
94
- key={index}
95
- className="hover:bg-neutral20 bg-white py-2.5 px-4 my-0.5 rounded-md"
96
- onClick={() => {
97
- if (option.option !== "Loading...") {
98
- handleOptionClick(option.option, option.value);
99
- }
100
- }}
101
- >
102
- <p className="text-sm text-black">{option.option}</p>
94
+ {hasData ? (
95
+ options.map((option, index) => (
96
+ <div
97
+ key={index}
98
+ className="hover:bg-neutral20 bg-white py-2.5 px-4 my-0.5 rounded-md"
99
+ onClick={() => {
100
+ if (option.option !== "Loading...") {
101
+ handleOptionClick(option.option, option.value);
102
+ }
103
+ }}
104
+ >
105
+ <p className="text-sm text-black">{option.option}</p>
106
+ </div>
107
+ ))
108
+ ) : (
109
+ <div className="bg-white py-2.5 px-4 my-0.5 rounded-md">
110
+ <p className="text-sm text-neutral500">No data</p>
103
111
  </div>
104
- ))}
112
+ )}
105
113
  </div>
106
114
  </div>
107
115
  )}
package/src/index.js CHANGED
@@ -90,7 +90,7 @@ import Header from "./components/header";
90
90
  import TextEditor from "./components/texteditor";
91
91
  import CustomPhone from "./components/customphone";
92
92
  import TextArea from "./components/textarea";
93
- import DropdownButton from ".components/dropdownbutton";
93
+ import DropdownButton from "./components/dropdownbutton";
94
94
 
95
95
  export {
96
96
  Header,