@dilicorp/ui 0.0.78 → 0.0.80

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.
@@ -1,9 +1,11 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import { DropdownProps } from '../../molecules/dropdown/dropdown';
3
3
  import { ImageProps } from '../../atoms/image';
4
4
  export declare type NavbarProps = {
5
5
  image?: ImageProps;
6
6
  dropdown: DropdownProps;
7
+ showUserIcon?: boolean;
8
+ items?: React.ReactNode[];
7
9
  };
8
10
  export declare const Navbar: (props: NavbarProps) => JSX.Element;
9
11
  //# sourceMappingURL=navbar.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"navbar.d.ts","sourceRoot":"","sources":["../../../src/components/navbar/navbar.tsx"],"names":[],"mappings":";AACA,OAAO,EAAY,aAAa,EAAE,MAAM,mCAAmC,CAAA;AAE3E,OAAO,EAAS,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAErD,oBAAY,WAAW,GAAG;IACxB,KAAK,CAAC,EAAE,UAAU,CAAA;IAClB,QAAQ,EAAE,aAAa,CAAA;CACxB,CAAA;AAED,eAAO,MAAM,MAAM,UAAW,WAAW,gBAoBxC,CAAA"}
1
+ {"version":3,"file":"navbar.d.ts","sourceRoot":"","sources":["../../../src/components/navbar/navbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAY,aAAa,EAAE,MAAM,mCAAmC,CAAA;AAE3E,OAAO,EAAS,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAErD,oBAAY,WAAW,GAAG;IACxB,KAAK,CAAC,EAAE,UAAU,CAAA;IAClB,QAAQ,EAAE,aAAa,CAAA;IACvB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,EAAE,CAAA;CAC1B,CAAA;AAED,eAAO,MAAM,MAAM,UAAW,WAAW,gBAuBxC,CAAA"}
@@ -3,12 +3,14 @@ import { Dropdown } from '../../molecules/dropdown/dropdown';
3
3
  import { Icon } from '../../atoms/icon';
4
4
  import { Image } from '../../atoms/image';
5
5
  export const Navbar = (props) => {
6
- const { image, dropdown } = props;
6
+ const { image, dropdown, showUserIcon = true, items } = props;
7
7
  return (React.createElement("div", { className: "navbar mb-3" },
8
- React.createElement("div", { className: "navbar-profile" },
8
+ React.createElement("div", { className: "navbar-profile" }, items === null || items === void 0 ? void 0 :
9
+ items.map(item => React.createElement("div", { className: 'mx-2 d-flex align-items-center justify-content-center' }, item)),
9
10
  image
10
11
  ? React.createElement(Image, Object.assign({}, image, { circle: true, width: "38px", height: "38px", objectFit: "cover", className: "me-2" }))
11
- : (React.createElement("div", { className: "image-profile circle me-2" },
12
- React.createElement(Icon, { icon: "faUserAlt" }))),
12
+ : (showUserIcon &&
13
+ React.createElement("div", { className: "image-profile circle me-2" },
14
+ React.createElement(Icon, { icon: "faUserAlt" }))),
13
15
  React.createElement(Dropdown, Object.assign({}, dropdown)))));
14
16
  };
@@ -13,7 +13,7 @@ declare type FilterSelectProps = {
13
13
  placeholder: string;
14
14
  groupedOptions?: GroupedOptions[];
15
15
  id?: string;
16
- value?: string | GroupedOptions | GroupedOptions[];
16
+ value?: string | Options | Options[];
17
17
  isDisabled?: boolean;
18
18
  isLoading?: boolean;
19
19
  isClearable?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"filter-select-group.d.ts","sourceRoot":"","sources":["../../../../src/components/page-list/filters/filter-select-group.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAoB,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAErE,UAAU,OAAO;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,EAAE,CAAA;CACnB;AAED,aAAK,iBAAiB,GAAG;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,cAAc,EAAE,CAAA;IACjC,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,GAAC,cAAc,GAAC,cAAc,EAAE,CAAA;IAC9C,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,UAAU,EAAE,UAAU,CAAC,GAAG,CAAC,KAAK,IAAI,CAAA;CACpF,CAAA;AAED,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA8CzD,CAAA"}
1
+ {"version":3,"file":"filter-select-group.d.ts","sourceRoot":"","sources":["../../../../src/components/page-list/filters/filter-select-group.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAoB,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAErE,UAAU,OAAO;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,EAAE,CAAA;CACnB;AAID,aAAK,iBAAiB,GAAG;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,cAAc,EAAE,CAAA;IACjC,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,EAAE,CAAA;IACpC,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,UAAU,EAAE,UAAU,CAAC,GAAG,CAAC,KAAK,IAAI,CAAA;CACpF,CAAA;AA+BD,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAkDzD,CAAA"}
@@ -1,7 +1,34 @@
1
1
  import React from 'react';
2
2
  import ReactSelect from 'react-select';
3
+ const getValueInOption = (groups, value) => {
4
+ const initial = [];
5
+ const options = groups.reduce((total, curr) => (total.concat(curr.options)), initial);
6
+ return options.find(({ value: currValue }) => typeof currValue === 'number'
7
+ ? currValue === Number(value)
8
+ : currValue === value);
9
+ };
10
+ const getValue = (value, options) => {
11
+ if (!value)
12
+ return undefined;
13
+ const isArray = typeof value === 'object' && Array.isArray(value);
14
+ const isObject = !isArray && typeof value === 'object';
15
+ if (!isObject && !isObject) {
16
+ return getValueInOption(options, (value).toString());
17
+ }
18
+ if (isArray) {
19
+ const selected = [];
20
+ value.forEach(val => {
21
+ const data = getValueInOption(options, (val.value).toString());
22
+ if (data)
23
+ selected.push(data);
24
+ });
25
+ return selected;
26
+ }
27
+ return getValueInOption(options, (value.value).toString());
28
+ };
3
29
  export const FilterSelectGroup = (props) => {
4
- const { groupedOptions = [], name, id = name, placeholder, isDisabled = false, isLoading = false, isClearable = false, isSearchable = true, onChange } = props;
30
+ const { groupedOptions = [], name, id = name, placeholder, isDisabled = false, isLoading = false, isClearable = false, isSearchable = true, value = undefined, onChange } = props;
31
+ const newValue = getValue(value, groupedOptions);
5
32
  const handleChange = React.useCallback((event, action) => {
6
33
  if (onChange) {
7
34
  onChange({
@@ -20,5 +47,5 @@ export const FilterSelectGroup = (props) => {
20
47
  Boolean(placeholder) && React.createElement("label", { className: "form-label", htmlFor: name },
21
48
  placeholder,
22
49
  ":"),
23
- React.createElement(ReactSelect, { placeholder: placeholder, className: "form-builder-select", classNamePrefix: "form-builder", options: groupedOptions, name: name, id: id, isDisabled: isDisabled, isLoading: isLoading, isClearable: isClearable, isSearchable: isSearchable, onChange: handleChange })));
50
+ React.createElement(ReactSelect, { placeholder: placeholder, className: "form-builder-select", classNamePrefix: "form-builder", options: groupedOptions, name: name, id: id, defaultValue: newValue, isDisabled: isDisabled, isLoading: isLoading, isClearable: isClearable, isSearchable: isSearchable, onChange: handleChange })));
24
51
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dilicorp/ui",
3
- "version": "0.0.78",
3
+ "version": "0.0.80",
4
4
  "description": "A simple UI design for Dilicorp",
5
5
  "repository": {
6
6
  "type": "git",