@bbl-digital/snorre 4.1.36 → 4.1.38

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. package/dist/bundle.js +17 -4
  2. package/esm/core/Input/index.js +17 -4
  3. package/esm/v2/core/Button/Button.stories.js +66 -1
  4. package/esm/v2/core/Button/index.js +3 -1
  5. package/esm/v2/core/Button/styles.js +32 -39
  6. package/esm/v2/core/ButtonsFilter/ButtonsFilter.stories.js +38 -0
  7. package/esm/v2/core/ButtonsFilter/index.js +73 -0
  8. package/esm/v2/core/ButtonsFilter/styles.js +16 -0
  9. package/lib/app-shell/theme.d.ts +50 -0
  10. package/lib/app-shell/theme.d.ts.map +1 -1
  11. package/lib/core/Input/index.d.ts.map +1 -1
  12. package/lib/core/Input/index.js +17 -4
  13. package/lib/v2/core/Button/Button.stories.d.ts +8 -0
  14. package/lib/v2/core/Button/Button.stories.d.ts.map +1 -1
  15. package/lib/v2/core/Button/Button.stories.js +66 -1
  16. package/lib/v2/core/Button/index.d.ts +8 -0
  17. package/lib/v2/core/Button/index.d.ts.map +1 -1
  18. package/lib/v2/core/Button/index.js +3 -1
  19. package/lib/v2/core/Button/styles.d.ts +2 -2
  20. package/lib/v2/core/Button/styles.d.ts.map +1 -1
  21. package/lib/v2/core/Button/styles.js +32 -39
  22. package/lib/v2/core/ButtonsFilter/ButtonsFilter.stories.d.ts +9 -0
  23. package/lib/v2/core/ButtonsFilter/ButtonsFilter.stories.d.ts.map +1 -0
  24. package/lib/v2/core/ButtonsFilter/ButtonsFilter.stories.js +38 -0
  25. package/lib/v2/core/ButtonsFilter/index.d.ts +14 -0
  26. package/lib/v2/core/ButtonsFilter/index.d.ts.map +1 -0
  27. package/lib/v2/core/ButtonsFilter/index.js +73 -0
  28. package/lib/v2/core/ButtonsFilter/styles.d.ts +5 -0
  29. package/lib/v2/core/ButtonsFilter/styles.d.ts.map +1 -0
  30. package/lib/v2/core/ButtonsFilter/styles.js +16 -0
  31. package/package.json +1 -1
@@ -0,0 +1,9 @@
1
+ import { Meta, StoryObj } from '@storybook/react/*';
2
+ import ButtonsFilter from '.';
3
+ declare const meta: Meta<typeof ButtonsFilter>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof ButtonsFilter>;
6
+ export declare const Default: Story;
7
+ export declare const Loading: Story;
8
+ export declare const ObjectValues: Story;
9
+ //# sourceMappingURL=ButtonsFilter.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ButtonsFilter.stories.d.ts","sourceRoot":"","sources":["../../../../src/packages/v2/core/ButtonsFilter/ButtonsFilter.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,aAAa,MAAM,GAAG,CAAA;AAE7B,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,aAAa,CAGpC,CAAA;AAED,eAAe,IAAI,CAAA;AAEnB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,aAAa,CAAC,CAAA;AAE3C,eAAO,MAAM,OAAO,EAAE,KAOrB,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,KAKrB,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,KAY1B,CAAA"}
@@ -0,0 +1,38 @@
1
+ import ButtonsFilter from '.';
2
+ const meta = {
3
+ title: 'v2/Core/ButtonsFilter',
4
+ component: ButtonsFilter
5
+ };
6
+ export default meta;
7
+ export const Default = {
8
+ name: 'Default',
9
+ args: {
10
+ values: ['One', 'Two', 'Three'],
11
+ disabled: false,
12
+ onChange: e => console.log(e)
13
+ }
14
+ };
15
+ export const Loading = {
16
+ name: 'Loading',
17
+ args: {
18
+ loading: true
19
+ }
20
+ };
21
+ export const ObjectValues = {
22
+ name: 'Object Values',
23
+ args: {
24
+ values: [{
25
+ label: 'One',
26
+ value: 15
27
+ }, {
28
+ label: 'Two',
29
+ value: 2
30
+ }, {
31
+ label: 'Three',
32
+ value: 5
33
+ }],
34
+ labelField: 'label',
35
+ valueField: 'value',
36
+ onChange: e => console.log(e)
37
+ }
38
+ };
@@ -0,0 +1,14 @@
1
+ /** @jsxImportSource @emotion/react */
2
+ import { AriaAttributes } from 'react';
3
+ interface IProps extends AriaAttributes {
4
+ values: Array<string | Record<string, any>>;
5
+ labelField: string;
6
+ valueField: string;
7
+ disabled?: boolean;
8
+ loading?: boolean;
9
+ skeletons?: number;
10
+ onChange?: (value: string) => void;
11
+ }
12
+ declare const ButtonsFilter: React.FC<IProps>;
13
+ export default ButtonsFilter;
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/packages/v2/core/ButtonsFilter/index.tsx"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC,OAAO,EAAE,cAAc,EAAgC,MAAM,OAAO,CAAA;AAKpE,UAAU,MAAO,SAAQ,cAAc;IACrC,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAA;IAC3C,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;CACnC;AAMD,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CA2EnC,CAAA;AAED,eAAe,aAAa,CAAA"}
@@ -0,0 +1,73 @@
1
+ /** @jsxImportSource @emotion/react */
2
+
3
+ import { useEffect, useMemo, useState } from 'react';
4
+ import Button from '../Button';
5
+ import { Wrapper } from './styles';
6
+ import Skeleton from '../../../core/Skeleton';
7
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
8
+ const resolve = (value, field) => {
9
+ const valueIsObject = typeof value === 'object';
10
+ return valueIsObject ? value[field] : value;
11
+ };
12
+ const ButtonsFilter = ({
13
+ values,
14
+ disabled,
15
+ skeletons = 3,
16
+ labelField,
17
+ valueField,
18
+ loading,
19
+ onChange,
20
+ ...rest
21
+ }) => {
22
+ const [selected, setSelected] = useState(undefined);
23
+ const isEmpty = !values?.length;
24
+ const handleClick = value => {
25
+ setSelected(value);
26
+ onChange?.(value);
27
+ };
28
+ const resolvedValues = useMemo(() => {
29
+ if (!values) return [];
30
+ return values.map(value => ({
31
+ label: resolve(value, labelField),
32
+ value: resolve(value, valueField)
33
+ }));
34
+ }, [values, labelField, valueField]);
35
+ useEffect(() => {
36
+ if (loading || isEmpty || selected !== undefined) return;
37
+ const firstValue = resolve(values[0], valueField);
38
+ const selectedExists = resolvedValues.some(({
39
+ value
40
+ }) => value === selected);
41
+ if (!selectedExists) {
42
+ setSelected(firstValue);
43
+ onChange?.(firstValue);
44
+ }
45
+ }, [values, loading, selected, isEmpty, valueField, onChange]);
46
+ if (loading) return _jsx(Wrapper, {
47
+ children: Array.from({
48
+ length: skeletons
49
+ }).map((_, index) => _jsx(Skeleton, {
50
+ width: "100px",
51
+ height: "32px",
52
+ borderRadius: "100px",
53
+ rectangle: true
54
+ }, index))
55
+ });
56
+ if (isEmpty) return null;
57
+ return _jsx(Wrapper, {
58
+ children: resolvedValues.map(({
59
+ label,
60
+ value
61
+ }) => _jsx(Button, {
62
+ small: true,
63
+ title: label,
64
+ onClick: () => handleClick(value),
65
+ secondary: selected !== value,
66
+ "aria-pressed": selected === value,
67
+ disabled: disabled,
68
+ ...rest,
69
+ children: label
70
+ }, value))
71
+ });
72
+ };
73
+ export default ButtonsFilter;
@@ -0,0 +1,5 @@
1
+ export declare const Wrapper: import("@emotion/styled").StyledComponent<{
2
+ theme?: import("@emotion/react").Theme;
3
+ as?: React.ElementType;
4
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
5
+ //# sourceMappingURL=styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/packages/v2/core/ButtonsFilter/styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO;;eAO0b,WAAW;yGADxd,CAAA"}
@@ -0,0 +1,16 @@
1
+ import _styled from "@emotion/styled/base";
2
+ function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
3
+ export const Wrapper = /*#__PURE__*/_styled("div", process.env.NODE_ENV === "production" ? {
4
+ target: "e1djumss0"
5
+ } : {
6
+ target: "e1djumss0",
7
+ label: "Wrapper"
8
+ })(process.env.NODE_ENV === "production" ? {
9
+ name: "11impfd",
10
+ styles: "display:flex;gap:8px;margin-bottom:16px;flex-flow:wrap;width:100%"
11
+ } : {
12
+ name: "11impfd",
13
+ styles: "display:flex;gap:8px;margin-bottom:16px;flex-flow:wrap;width:100%",
14
+ map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9wYWNrYWdlcy92Mi9jb3JlL0J1dHRvbnNGaWx0ZXIvc3R5bGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVpQyIsImZpbGUiOiIuLi8uLi8uLi8uLi9zcmMvcGFja2FnZXMvdjIvY29yZS9CdXR0b25zRmlsdGVyL3N0eWxlcy50cyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBzdHlsZWQgZnJvbSAnQGVtb3Rpb24vc3R5bGVkJ1xuXG5leHBvcnQgY29uc3QgV3JhcHBlciA9IHN0eWxlZC5kaXZgXG4gIGRpc3BsYXk6IGZsZXg7XG4gIGdhcDogOHB4O1xuICBtYXJnaW4tYm90dG9tOiAxNnB4O1xuICBmbGV4LWZsb3c6IHdyYXA7XG4gIHdpZHRoOiAxMDAlO1xuYFxuIl19 */",
15
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
16
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbl-digital/snorre",
3
- "version": "4.1.36",
3
+ "version": "4.1.38",
4
4
  "description": "Design library for BBL Digital",
5
5
  "license": "MIT",
6
6
  "main": "./lib/index.js",