bianic-ui 2.5.1-beta.0 → 2.6.0-beta.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/README.md CHANGED
@@ -1,49 +1,49 @@
1
- # Bianic 2.0
2
-
3
- DLS designed by BIAENERGI
4
-
5
- ## Installation
6
-
7
- ### First Installation
8
-
9
- `npm i bianic-ui`
10
-
11
- ## Usage
12
-
13
- After Bianic-Ui succesfully installed, you can call the component using JSX tag declaration style ex: `<Alert />`. Futher documentation about component can be access [here](https://ristek.link/bianic-dev-docs)
14
-
15
- ## Support
16
-
17
- If you found any bug, please contact at [devbiaenergi@gmail.com](mailto:devbiaenergi@gmail.com)
18
-
19
- ## Contributing
20
-
21
- If you're interested in contributing to Bianic-Ui, please contact our team at [devbiaenergi@gmail.com](mailto:devbiaenergi@gmail.com)
22
-
23
- ## Change Log
24
-
25
- Coming soon
26
-
27
- ## Development Notes
28
-
29
- ### Code Convention
30
-
31
- - Always separate style with tsx
32
- - For style config always try to be object with one level
33
- - Separate config file and component file for more readable code
34
- - The variable name of style config must be describe what you styling not describe the parameters (or key)
35
- - Use .tsx only when defining component, just us .ts if no component defined on the file
36
- - Don't import simulation or any demo to index.ts
37
- - Update storybook for every change or new component
38
-
39
- ### Component attribute naming
40
-
41
- - Check on html documentation. Always try to use the exisiting html atribute name.
42
- - If there the attibute not listed on html documentation. You can make it on your own with rules :
43
- - Use "is" prefix for boolean
44
- - Use "on" prefix for event listener
45
-
46
- ### Another Notes
47
-
48
- - Please assign class `...-primary-black` when need black color. If not assigned system will use #000000 black.
49
- - Just discuss any concept you had. **Discuss first, Implement later**.
1
+ # Bianic 2.0
2
+
3
+ DLS designed by BIAENERGI
4
+
5
+ ## Installation
6
+
7
+ ### First Installation
8
+
9
+ `npm i bianic-ui`
10
+
11
+ ## Usage
12
+
13
+ After Bianic-Ui succesfully installed, you can call the component using JSX tag declaration style ex: `<Alert />`. Futher documentation about component can be access [here](https://ristek.link/bianic-dev-docs)
14
+
15
+ ## Support
16
+
17
+ If you found any bug, please contact at [devbiaenergi@gmail.com](mailto:devbiaenergi@gmail.com)
18
+
19
+ ## Contributing
20
+
21
+ If you're interested in contributing to Bianic-Ui, please contact our team at [devbiaenergi@gmail.com](mailto:devbiaenergi@gmail.com)
22
+
23
+ ## Change Log
24
+
25
+ Coming soon
26
+
27
+ ## Development Notes
28
+
29
+ ### Code Convention
30
+
31
+ - Always separate style with tsx
32
+ - For style config always try to be object with one level
33
+ - Separate config file and component file for more readable code
34
+ - The variable name of style config must be describe what you styling not describe the parameters (or key)
35
+ - Use .tsx only when defining component, just us .ts if no component defined on the file
36
+ - Don't import simulation or any demo to index.ts
37
+ - Update storybook for every change or new component
38
+
39
+ ### Component attribute naming
40
+
41
+ - Check on html documentation. Always try to use the exisiting html atribute name.
42
+ - If there the attibute not listed on html documentation. You can make it on your own with rules :
43
+ - Use "is" prefix for boolean
44
+ - Use "on" prefix for event listener
45
+
46
+ ### Another Notes
47
+
48
+ - Please assign class `...-primary-black` when need black color. If not assigned system will use #000000 black.
49
+ - Just discuss any concept you had. **Discuss first, Implement later**.
package/dist/cjs/index.js CHANGED
@@ -583,7 +583,8 @@ var AvatarConfig = {
583
583
  };
584
584
 
585
585
  function Avatar(_a) {
586
- var _b = _a.size, size = _b === void 0 ? 'md' : _b, variant = _a.variant, _c = _a.name, name = _c === void 0 ? 'Test' : _c;
586
+ var _b, _c, _d, _e;
587
+ var _f = _a.size, size = _f === void 0 ? 'md' : _f, _g = _a.variant, variant = _g === void 0 ? 'initial' : _g, _h = _a.name, name = _h === void 0 ? 'Test' : _h;
587
588
  var getInitials = function (initial) {
588
589
  if (!initial)
589
590
  return '';
@@ -593,17 +594,19 @@ function Avatar(_a) {
593
594
  .join('');
594
595
  return initials.slice(0, 2).toUpperCase();
595
596
  };
597
+ var usedSize = size in AvatarConfig ? size : 'md';
598
+ var usedVariant = variant in ['image', 'picture', 'initial'] ? variant : 'initial';
596
599
  var avatarResult = null;
597
- switch (variant) {
600
+ switch (usedVariant) {
598
601
  case 'picture':
599
- avatarResult = (React.createElement("img", { src: "https://img.freepik.com/free-psd/girl-avatar-emoji-3d-icon_23-2150579870.jpg", alt: "avatar", className: "".concat(AvatarConfig[size].picture) }));
602
+ avatarResult = (React.createElement("img", { src: "https://img.freepik.com/free-psd/girl-avatar-emoji-3d-icon_23-2150579870.jpg", alt: "avatar", className: "".concat((_b = AvatarConfig[usedSize]) === null || _b === void 0 ? void 0 : _b.picture) }));
600
603
  break;
601
604
  case 'initial':
602
- avatarResult = (React.createElement("div", { className: "".concat(AvatarConfig[size].picture, " flex items-center justify-center bg-bia-sky") },
603
- React.createElement("div", { className: "".concat(AvatarConfig[size]['no picture']) }, getInitials(name))));
605
+ avatarResult = (React.createElement("div", { className: "".concat((_c = AvatarConfig[usedSize]) === null || _c === void 0 ? void 0 : _c.picture, " flex items-center justify-center bg-bia-sky") },
606
+ React.createElement("div", { className: "".concat((_d = AvatarConfig[usedSize]) === null || _d === void 0 ? void 0 : _d['no picture']) }, getInitials(name))));
604
607
  break;
605
608
  case 'image':
606
- avatarResult = (React.createElement("svg", { width: "160", height: "160", viewBox: "0 0 160 160", fill: "none", xmlns: "http://www.w3.org/2000/svg", xmlnsXlink: "http://www.w3.org/1999/xlink", className: "".concat(AvatarConfig[size].picture, " flex items-center justify-center") },
609
+ avatarResult = (React.createElement("svg", { width: "160", height: "160", viewBox: "0 0 160 160", fill: "none", xmlns: "http://www.w3.org/2000/svg", xmlnsXlink: "http://www.w3.org/1999/xlink", className: "".concat((_e = AvatarConfig[usedSize]) === null || _e === void 0 ? void 0 : _e.picture, " flex items-center justify-center") },
607
610
  React.createElement("rect", { width: "160", height: "160", fill: "url(#pattern0_9212_4625)" }),
608
611
  React.createElement("defs", null,
609
612
  React.createElement("pattern", { id: "pattern0_9212_4625", patternContentUnits: "objectBoundingBox", width: "1", height: "1" },
@@ -615,6 +618,7 @@ function Avatar(_a) {
615
618
  }
616
619
  Avatar.defaultProps = {
617
620
  name: '',
621
+ variant: 'initial',
618
622
  size: 'md',
619
623
  };
620
624
 
@@ -1953,9 +1957,6 @@ var getDropdownStyle = function (anchorRef, popupRef) {
1953
1957
  return style;
1954
1958
  };
1955
1959
  var usePopupPosition = function (anchorRef, popupRef, position) {
1956
- // In projects where bianic-ui is installed,
1957
- // there is a delay in rendering styles,
1958
- // which causes popups to lose their position and need to be re-rendered.
1959
1960
  if (!anchorRef || !popupRef) {
1960
1961
  return [{}, function () { }];
1961
1962
  }
@@ -1968,18 +1969,23 @@ var usePopupPosition = function (anchorRef, popupRef, position) {
1968
1969
  setPositionStyle(newStyle);
1969
1970
  };
1970
1971
  React.useLayoutEffect(function () {
1971
- if (!(anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current))
1972
+ if (!(anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) || !(popupRef === null || popupRef === void 0 ? void 0 : popupRef.current))
1972
1973
  return;
1973
1974
  calcPosition();
1974
- window.addEventListener('scroll', calcPosition);
1975
+ var resizeObserver = new ResizeObserver(calcPosition);
1976
+ resizeObserver.observe(popupRef.current);
1977
+ window.addEventListener('scroll', calcPosition, true);
1975
1978
  window.addEventListener('resize', calcPosition);
1976
- setRepeateRender(0);
1977
1979
  return function () {
1978
- window.removeEventListener('scroll', calcPosition);
1980
+ resizeObserver.disconnect();
1981
+ window.removeEventListener('scroll', calcPosition, true);
1979
1982
  window.removeEventListener('resize', calcPosition);
1980
1983
  };
1981
- }, [anchorRef]);
1984
+ }, [anchorRef, popupRef]);
1982
1985
  React.useEffect(function () {
1986
+ // In projects where bianic-ui is installed,
1987
+ // there is a delay in rendering styles,
1988
+ // which causes popups to lose their position and need to be re-rendered.
1983
1989
  if (repeateRender < 5 && (anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current)) {
1984
1990
  calcPosition();
1985
1991
  setRepeateRender(repeateRender + 1);
@@ -2384,17 +2390,31 @@ var sizeConfig$a = {
2384
2390
  };
2385
2391
 
2386
2392
  function TextArea(_a) {
2387
- var descText = _a.descText, _b = _a.disabled, disabled = _b === void 0 ? false : _b, id = _a.id, _c = _a.size, size = _c === void 0 ? 'md' : _c, label = _a.label, _d = _a.placeholder, placeholder = _d === void 0 ? '' : _d, required = _a.required, rows = _a.rows, _e = _a.maxLength, maxLength = _e === void 0 ? undefined : _e, value = _a.value, _f = _a.readOnly, readOnly = _f === void 0 ? false : _f, _g = _a.autoComplete, autoComplete = _g === void 0 ? 'off' : _g, props = __rest(_a, ["descText", "disabled", "id", "size", "label", "placeholder", "required", "rows", "maxLength", "value", "readOnly", "autoComplete"]);
2393
+ var descText = _a.descText, _b = _a.disabled, disabled = _b === void 0 ? false : _b, id = _a.id, _c = _a.size, size = _c === void 0 ? 'md' : _c, label = _a.label, _d = _a.placeholder, placeholder = _d === void 0 ? '' : _d, required = _a.required, rows = _a.rows, _e = _a.maxLength, maxLength = _e === void 0 ? undefined : _e, value = _a.value, _f = _a.readOnly, readOnly = _f === void 0 ? false : _f, _g = _a.autoComplete, autoComplete = _g === void 0 ? 'off' : _g, _h = _a.isValid, isValid = _h === void 0 ? null : _h, props = __rest(_a, ["descText", "disabled", "id", "size", "label", "placeholder", "required", "rows", "maxLength", "value", "readOnly", "autoComplete", "isValid"]);
2388
2394
  var inputRow = rows !== null && rows !== void 0 ? rows : 4;
2389
2395
  var inputClass = sizeConfig$a[size].inputClass;
2390
2396
  var remainWords = maxLength ? maxLength - (value ? value.length : 0) : 0;
2397
+ var isExistValidation = isValid !== null;
2398
+ var descColor = 'text-primary-cool';
2399
+ if (!disabled && isExistValidation && isValid)
2400
+ descColor = 'text-bia-green';
2401
+ if (!disabled && isExistValidation && !isValid)
2402
+ descColor = 'text-bia-red';
2403
+ var bottomBorderColor = 'enabled:hover:border-b-bia-blue enabled:focus:border-b-bia-blue';
2404
+ if (!disabled && isExistValidation && isValid)
2405
+ bottomBorderColor =
2406
+ 'enabled:hover:border-b-bia-green enabled:focus:border-b-bia-green';
2407
+ if (!disabled && isExistValidation && !isValid)
2408
+ bottomBorderColor =
2409
+ 'enabled:hover:border-b-bia-red enabled:focus:border-b-bia-red';
2391
2410
  var disabledClass = disabled ? 'cursor-not-allowed' : '';
2411
+ var extendedInputClassName = "".concat(inputClass, " ").concat(bottomBorderColor);
2392
2412
  return (React.createElement("div", { className: "field-group group/form flex w-full flex-col gap-y-2" },
2393
2413
  label && (React.createElement(FormLabel, { htmlFor: id, required: required, readOnly: readOnly }, label)),
2394
2414
  React.createElement("div", { className: "relative h-fit w-full min-w-[250px] ".concat(disabledClass) },
2395
2415
  React.createElement(ResizeIcon, { className: "absolute bottom-[11px] right-[5px]" }),
2396
- React.createElement("textarea", __assign({ className: "field bianic-text-area w-full rounded border border-bia-grey-dark-10 bg-primary-white p-2.5 read-only:pointer-events-none focus-visible:outline-none enabled:hover:rounded-b-none enabled:hover:border-b-bia-blue enabled:focus:rounded-b-none enabled:focus:border-b-bia-blue disabled:cursor-not-allowed disabled:bg-bia-grey-light-80 disabled:text-bia-grey-active ".concat(inputClass), rows: inputRow, id: id, placeholder: placeholder, disabled: disabled, maxLength: maxLength, value: value, autoComplete: autoComplete, readOnly: readOnly }, props))),
2397
- React.createElement("div", { className: "desc flex justify-between gap-1 text-xs text-primary-cool" },
2416
+ React.createElement("textarea", __assign({ className: "field bianic-text-area w-full rounded border border-bia-grey-dark-10 bg-primary-white p-2.5 read-only:pointer-events-none focus-visible:outline-none enabled:hover:rounded-b-none enabled:focus:rounded-b-none disabled:cursor-not-allowed disabled:bg-bia-grey-light-80 disabled:text-bia-grey-active ".concat(extendedInputClassName), rows: inputRow, id: id, placeholder: placeholder, disabled: disabled, maxLength: maxLength, value: value, autoComplete: autoComplete, readOnly: readOnly }, props))),
2417
+ React.createElement("div", { className: "desc flex justify-between gap-1 text-xs ".concat(descColor) },
2398
2418
  descText && React.createElement("span", null, descText),
2399
2419
  maxLength && (React.createElement("span", null,
2400
2420
  remainWords,
@@ -3655,8 +3675,8 @@ var colorConfig$1 = {
3655
3675
  };
3656
3676
  var sizeConfig$3 = {
3657
3677
  container: 'min-h-fit p-5 text-wrap',
3658
- 'form-sm': 'h-[30px] whitespace-nowrap px-2.5',
3659
- 'form-md': 'h-10 whitespace-nowrap px-2.5',
3678
+ 'form-sm': 'min-h-[30px] h-fit whitespace-nowrap p-[7px]',
3679
+ 'form-md': 'min-h-[40px] h-fit whitespace-nowrap px-2.5 py-[9.5px]',
3660
3680
  };
3661
3681
 
3662
3682
  var InfoPanel = function (_a) {
@@ -3715,8 +3735,8 @@ var Notification = function (props) {
3715
3735
  };
3716
3736
 
3717
3737
  var sizeConfig$2 = {
3718
- md: 'min-w-[38px] h-[40px] text-[14px] font-semibold',
3719
- sm: 'min-w-[29px] h-[30px] text-[12px] font-normal',
3738
+ md: 'min-w-[40px] h-[40px] text-[14px] font-semibold',
3739
+ sm: 'min-w-[30px] h-[30px] text-[12px] font-normal',
3720
3740
  };
3721
3741
  var positionConfig = {
3722
3742
  start: 'justify-start',
@@ -3763,15 +3783,11 @@ function PaginationBar(_a) {
3763
3783
  else
3764
3784
  setStartIndex(0);
3765
3785
  };
3766
- var getStartIndex = function (index) {
3767
- if (index + PAGE_SIZE > totalPages)
3768
- return Math.max(0, totalPages - PAGE_SIZE);
3769
- return index;
3770
- };
3771
3786
  React.useEffect(function () {
3772
- var correctedIndex = getStartIndex(startIndex);
3773
- setShowedPages(totalRange.slice(correctedIndex, correctedIndex + PAGE_SIZE));
3774
- }, [startIndex, totalRange, totalPages]);
3787
+ var start = Math.max(0, Math.min(startIndex, totalPages - PAGE_SIZE));
3788
+ var newPages = Array.from({ length: totalPages }, function (_, i) { return i + 1; }).slice(start, start + PAGE_SIZE);
3789
+ setShowedPages(newPages);
3790
+ }, [startIndex, totalPages]);
3775
3791
  return (React.createElement("div", { className: "flex ".concat(positionConfig[position], " gap-[5px]") },
3776
3792
  totalPages > 5 && (React.createElement(Button, { variant: "subtle", size: size, type: "button", onClick: handlePrevRange, className: showedPages[0] === 1 ? '' : 'cursor-pointer', iconLeft: React.createElement(TbChevronsLeft, { size: iconSize }), disabled: showedPages[0] === 1 })),
3777
3793
  React.createElement(Button, { variant: "subtle", size: size, type: "button", onClick: function () {