@grucloud/bau-ui 0.42.0 → 0.43.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.
Files changed (66) hide show
  1. package/README.md +2 -2
  2. package/accordion/accordion.js +32 -62
  3. package/accordion/index.d.ts +5 -7
  4. package/alert/alert.js +33 -30
  5. package/animate/animate.js +1 -1
  6. package/autocomplete/autocomplete.js +14 -11
  7. package/avatar/avatar.js +5 -2
  8. package/bau-ui.d.ts +3 -1
  9. package/breadcrumbs/breadcrumbs.js +2 -5
  10. package/button/button.js +59 -61
  11. package/buttonGroup/buttonGroup.js +4 -3
  12. package/carousel/carousel.js +105 -0
  13. package/carousel/index.d.ts +22 -0
  14. package/carousel/index.js +1 -0
  15. package/chip/chip.js +8 -8
  16. package/collapsible/collapsible.js +121 -0
  17. package/collapsible/index.d.ts +10 -0
  18. package/collapsible/index.js +1 -0
  19. package/constants.d.ts +8 -2
  20. package/constants.js +8 -1
  21. package/context.d.ts +2 -0
  22. package/drillDownMenu/drillDownMenu.js +59 -26
  23. package/drillDownMenu/index.d.ts +1 -0
  24. package/fileInput/fileInput.js +3 -5
  25. package/form/form.js +32 -1
  26. package/globalStyle/globalStyle.js +1 -1
  27. package/input/input.js +13 -13
  28. package/linearProgress/index.d.ts +12 -0
  29. package/linearProgress/index.js +1 -0
  30. package/linearProgress/linearProgress.js +84 -0
  31. package/list/list.js +3 -11
  32. package/loadingButton/index.d.ts +12 -0
  33. package/loadingButton/index.js +1 -0
  34. package/loadingButton/loadingButton.js +70 -0
  35. package/modal/modal.js +25 -27
  36. package/package.json +10 -5
  37. package/paginationNavigation/index.d.ts +10 -0
  38. package/paginationNavigation/index.js +1 -0
  39. package/paginationNavigation/paginationNavigation.js +78 -0
  40. package/paper/index.d.ts +10 -0
  41. package/paper/index.js +1 -0
  42. package/paper/paper.js +51 -0
  43. package/popover/popover.js +14 -3
  44. package/radioButton/index.d.ts +15 -0
  45. package/radioButton/index.js +1 -0
  46. package/radioButton/radioButton.js +49 -0
  47. package/select/select.js +21 -8
  48. package/spinner/index.d.ts +1 -3
  49. package/spinner/spinner.js +98 -55
  50. package/stepper/index.d.ts +28 -0
  51. package/stepper/index.js +1 -0
  52. package/stepper/stepper.js +159 -0
  53. package/tableContainer/tableContainer.js +2 -3
  54. package/tableOfContent/index.d.ts +10 -0
  55. package/tableOfContent/index.js +1 -0
  56. package/tableOfContent/tableOfContent.js +159 -0
  57. package/tabs/tabs.js +56 -56
  58. package/toggle/index.d.ts +10 -0
  59. package/toggle/index.js +1 -0
  60. package/toggle/toggle.js +106 -0
  61. package/toggleGroup/index.d.ts +13 -0
  62. package/toggleGroup/index.js +1 -0
  63. package/toggleGroup/toggleGroup.js +94 -0
  64. package/tooltip/tooltip.js +1 -6
  65. package/treeView/treeView.js +30 -88
  66. package/tsconfig.json +23 -0
@@ -3,9 +3,7 @@ declare module "@grucloud/bau-ui/spinner" {
3
3
  type ComponentOption = import("../bau-ui").ComponentOption;
4
4
 
5
5
  export type SpinnerProps = {
6
- //size?: Number;
7
- //color?: "primary" | "secondary" | "warning" | "danger" | "info" | "success";
8
- visibility?: boolean;
6
+ visibility?: boolean | import("@grucloud/bau").State<boolean>;
9
7
  } & DefaultDesignProps;
10
8
 
11
9
  type Component = import("../bau-ui").Component<SpinnerProps>;
@@ -1,78 +1,121 @@
1
1
  import classNames from "@grucloud/bau-css/classNames.js";
2
+ import { Colors } from "../constants.js";
2
3
 
3
4
  const sizeToPixel = {
4
- sm: 16,
5
- md: 32,
6
- lg: 64,
5
+ sm: 12,
6
+ md: 16,
7
+ lg: 24,
7
8
  };
8
9
 
10
+ const colorsToCss = () =>
11
+ Colors.map(
12
+ (color) =>
13
+ `
14
+ &.${color} {
15
+ background-color:transparent;
16
+ }
17
+ &.plain.${color} {
18
+ & .path {
19
+ stroke: var(--color-${color});
20
+ }
21
+ }
22
+ &.outline.${color} {
23
+ border: none;
24
+ & .path {
25
+ stroke: var(--color-${color});
26
+ }
27
+ }
28
+ &.solid.${color} {
29
+ background-color:transparent;
30
+ & .path {
31
+ stroke: var(--font-color-inverse);
32
+ ;
33
+ }
34
+ }
35
+ `
36
+ ).join("\n");
37
+
9
38
  export default function (context, options = {}) {
10
- const { bau, css } = context;
39
+ const { bau, css, keyframes } = context;
40
+ const { svg, circle } = bau.tagsNS("http://www.w3.org/2000/svg");
11
41
 
12
- const { svg, animate, animateTransform, rect } = bau.tagsNS(
13
- "http://www.w3.org/2000/svg"
14
- );
42
+ const rotate = keyframes`
43
+ 100% {
44
+ transform: rotate(360deg);
45
+ }
46
+ `;
47
+ const dash = keyframes`
48
+ 0% {
49
+ stroke-dasharray: 1, 150;
50
+ stroke-dashoffset: 0;
51
+ }
52
+ 50% {
53
+ stroke-dasharray: 90, 150;
54
+ stroke-dashoffset: -35;
55
+ }
56
+ 100% {
57
+ stroke-dasharray: 90, 150;
58
+ stroke-dashoffset: -124;
59
+ }
60
+ `;
15
61
 
16
62
  return function Spinner({
17
- size = "md",
18
- color = "color-base",
19
- variant = "outline",
63
+ size = options.size ?? "md",
64
+ color = options.color ?? "primary",
65
+ variant = options.variant ?? "outline",
20
66
  visibility = true,
21
67
  ...otherProps
22
68
  } = {}) {
69
+ const className = css`
70
+ visibility: hidden;
71
+ opacity: 0;
72
+ transition: all var(--transition-slow) ease-in-out;
73
+ &.visibility {
74
+ visibility: visible;
75
+ opacity: 1;
76
+ }
77
+ animation: ${rotate} 2s linear infinite;
78
+ width: ${sizeToPixel[size]};
79
+ height: ${sizeToPixel[size]};
80
+ & .path {
81
+ stroke-linecap: round;
82
+ animation: ${dash} 1.5s ease-in-out infinite;
83
+ }
84
+ ${colorsToCss()}
85
+ `;
86
+
23
87
  return svg(
24
88
  {
25
- class: classNames(
26
- css`
27
- visibility: ${visibility ? "visible" : "hidden"};
28
- color: var(--color-${color});
29
- `,
30
- options.class,
31
- otherProps.class
32
- ),
89
+ class: {
90
+ deps: [visibility],
91
+ renderProp: () => (visibility) =>
92
+ classNames(
93
+ "spinner",
94
+ className,
95
+ color,
96
+ variant,
97
+ visibility == false ? "" : "visibility",
98
+ options?.class,
99
+ otherProps.class
100
+ ),
101
+ },
33
102
  version: "1.1",
34
- id: "L6",
35
103
  x: "0px",
36
104
  y: "0px",
37
105
  width: sizeToPixel[size],
38
106
  height: sizeToPixel[size],
39
- viewBox: `0 0 100 100`,
40
- enableBackground: `new 0 0 100 100`,
107
+ viewBox: `0 0 50 50`,
108
+ enableBackground: `new 0 0 50 50`,
109
+ ...otherProps,
41
110
  },
42
- rect(
43
- {
44
- fill: "none",
45
- stroke: "currentColor",
46
- strokeWidth: "4",
47
- x: "25",
48
- y: "25",
49
- width: "50",
50
- height: "50",
51
- },
52
- animateTransform({
53
- attributeName: "transform",
54
- dur: "0.4s",
55
- from: "0 50 50",
56
- to: "180 50 50",
57
- type: "rotate",
58
- id: "strokeBox",
59
- attributeType: "XML",
60
- begin: "rectBox.end",
61
- })
62
- ),
63
- rect(
64
- { x: "27", y: "27", fill: "currentColor", width: "46", height: "50" },
65
- animate({
66
- attributeName: "height",
67
- dur: "1.3s",
68
- attributeType: "XML",
69
- from: "50",
70
- to: "0",
71
- id: "rectBox",
72
- fill: "freeze",
73
- begin: "0s;strokeBox.end",
74
- })
75
- )
111
+ circle({
112
+ class: "path",
113
+ cx: "25",
114
+ cy: "25",
115
+ r: "20",
116
+ fill: "none",
117
+ "stroke-width": "5",
118
+ })
76
119
  );
77
120
  };
78
121
  }
@@ -0,0 +1,28 @@
1
+ declare module "@grucloud/bau-ui/stepper" {
2
+ type ComponentOption = import("../bau-ui").ComponentOption;
3
+
4
+ type StepperPagePropBase = {
5
+ name: string;
6
+ disabled?: boolean;
7
+ enter?: Function;
8
+ exit?: Function;
9
+ };
10
+
11
+ type ComponentStepper =
12
+ import("../bau-ui").ComponentWithProp<StepperPagePropBase>;
13
+
14
+ export type StepperPage = {
15
+ Header: ComponentStepper;
16
+ Content: ComponentStepper;
17
+ } & StepperPagePropBase;
18
+
19
+ export type StepperProps = {
20
+ stepperDefs: StepperPage[];
21
+ };
22
+
23
+ type Component = import("../bau-ui").Component<StepperProps>;
24
+
25
+ type Option = {} & ComponentOption;
26
+
27
+ export default function (context: any, option?: Option): Component;
28
+ }
@@ -0,0 +1 @@
1
+ export { default } from "./stepper";
@@ -0,0 +1,159 @@
1
+ import { toPropsAndChildren } from "@grucloud/bau/bau.js";
2
+ import classNames from "@grucloud/bau-css/classNames.js";
3
+
4
+ import { Colors } from "../constants.js";
5
+
6
+ const colorsToCss = () =>
7
+ Colors.map(
8
+ (color) =>
9
+ `
10
+ `
11
+ ).join("\n");
12
+
13
+ export default function (context, options) {
14
+ const { bau, css } = context;
15
+ const { div, ul, li, span } = bau.tags;
16
+
17
+ const className = css`
18
+ display: flex;
19
+ flex-direction: column;
20
+ padding: 1rem;
21
+ & > ul {
22
+ display: flex;
23
+ align-items: flex-end;
24
+ justify-content: space-around;
25
+ align-items: flex-start;
26
+ padding: 0;
27
+ list-style: none;
28
+ & > li {
29
+ display: flex;
30
+ flex-direction: column;
31
+ align-items: center;
32
+ box-sizing: border-box;
33
+ flex-grow: 1;
34
+ padding: 0.5rem;
35
+ padding-bottom: 0rem;
36
+ color: inherit;
37
+ font-weight: var(--font-weight-semibold);
38
+ transition: all var(--transition-slow) ease-in-out;
39
+ background-color: var(--background-color);
40
+ overflow: hidden;
41
+ & .step-number {
42
+ background-color: var(--color-primary);
43
+ color: var(--font-color-inverse);
44
+ height: 1.5rem;
45
+ width: 1.5rem;
46
+ display: flex;
47
+ justify-content: center;
48
+ align-items: center;
49
+ border-radius: 100%;
50
+ }
51
+ & .step-label {
52
+ text-align: center;
53
+ }
54
+ }
55
+ & .not-completed {
56
+ & .step-number {
57
+ background-color: var(--color-neutral);
58
+ }
59
+ & .step-label {
60
+ color: var(--font-color-secondary);
61
+ }
62
+ }
63
+ & .completed {
64
+ & .step-number {
65
+ background-color: var(--color-success);
66
+ }
67
+ }
68
+
69
+ & .active {
70
+ filter: brightness(var(--brightness-active));
71
+ }
72
+ & .disabled {
73
+ cursor: not-allowed;
74
+ font-style: italic;
75
+ transform: none;
76
+ }
77
+ }
78
+ ${colorsToCss()}
79
+ `;
80
+
81
+ return function Stepper(...args) {
82
+ let [
83
+ {
84
+ color,
85
+ variant = "plain",
86
+ size,
87
+ stepperDefs = [],
88
+ activeStepIndex,
89
+ ...props
90
+ },
91
+ ...children
92
+ ] = toPropsAndChildren(args);
93
+
94
+ const stepperState = bau.state(
95
+ stepperDefs.map((stepper, index) => ({ ...stepper, index }))
96
+ );
97
+
98
+ const stepperCurrentState = bau.derive(
99
+ () => stepperState.val[activeStepIndex.val]
100
+ );
101
+
102
+ const StepperHeader = (stepper) => {
103
+ const { Header, disabled, name, index } = stepper;
104
+ return li(
105
+ {
106
+ class: () =>
107
+ classNames(
108
+ stepperCurrentState.val.name == name && "active",
109
+ activeStepIndex.val < index && "not-completed",
110
+ activeStepIndex.val > index && "completed",
111
+ disabled && "disabled"
112
+ ),
113
+ },
114
+ span({ class: "step-number" }, index + 1),
115
+ span({ class: "step-label" }, () => Header(stepper))
116
+ );
117
+ };
118
+
119
+ const rootEl = div(
120
+ {
121
+ class: classNames(
122
+ "stepper",
123
+ variant,
124
+ size,
125
+ color,
126
+ className,
127
+ options?.class,
128
+ props.class
129
+ ),
130
+ },
131
+ // Header
132
+ bau.loop(stepperState, ul(), StepperHeader),
133
+ // Content
134
+ // No automatic binding possible in this case. Content contains states that would be automatically binded.
135
+ bau.bind({
136
+ deps: [stepperCurrentState],
137
+ render: () => (stepperCurrent) =>
138
+ stepperCurrent.Content ? stepperCurrent.Content({}) : "",
139
+ })
140
+ );
141
+
142
+ // rootEl.addEventListener(
143
+ // "stepper.select",
144
+ // (event) => {
145
+ // const { stepperName } = event.detail;
146
+ // const nextStepper = stepperByName(stepperName);
147
+ // if (!nextStepper) {
148
+ // return;
149
+ // }
150
+ // stepperCurrentState.val.exit?.call();
151
+ // stepperCurrentState.val = nextStepper;
152
+ // nextStepper.enter?.call();
153
+ // },
154
+ // false
155
+ // );
156
+
157
+ return rootEl;
158
+ };
159
+ }
@@ -13,7 +13,7 @@ export default function (context, options) {
13
13
  --table-border-width: 1px;
14
14
  --table-border-color: var(--color-emphasis-300);
15
15
  --table-head-background: inherit;
16
- --table-head-color: inherit;
16
+ --table-head-color: var(--font-color-secondary);
17
17
  --table-cell-color: inherit;
18
18
  }
19
19
 
@@ -56,8 +56,7 @@ export default function (context, options) {
56
56
  const className = css`
57
57
  display: inline-block;
58
58
  border: 1px solid var(--color-emphasis-50);
59
- box-shadow: var(--shadow-s);
60
- border-radius: var(--global-radius);
59
+ width: fit-content;
61
60
  `;
62
61
 
63
62
  return function TableContainer(...args) {
@@ -0,0 +1,10 @@
1
+ declare module "@grucloud/bau-ui/tableOfContent" {
2
+ type DefaultDesignProps = import("../constants").DefaultDesignProps;
3
+ type ComponentOption = import("../bau-ui").ComponentOption;
4
+
5
+ export type TableOfContentProps = {} & DefaultDesignProps;
6
+
7
+ type Component = import("../bau-ui").Component<TableOfContentProps>;
8
+
9
+ export default function (context: any, option?: ComponentOption): Component;
10
+ }
@@ -0,0 +1 @@
1
+ export { default } from "./tableOfContent";
@@ -0,0 +1,159 @@
1
+ import classNames from "@grucloud/bau-css/classNames.js";
2
+ import { toPropsAndChildren } from "@grucloud/bau/bau.js";
3
+
4
+ export default function (context, options = {}) {
5
+ const { bau, css, window } = context;
6
+ const { nav, ul, li, a } = bau.tags;
7
+ const { headerSelector = "h2,h3" } = options;
8
+ const activeHeadingId = bau.state("no");
9
+
10
+ const debounce = (callback, wait) => {
11
+ let timeoutId = null;
12
+ return (...args) => {
13
+ window.clearTimeout(timeoutId);
14
+ timeoutId = window.setTimeout(() => callback(...args), wait);
15
+ };
16
+ };
17
+
18
+ const className = css`
19
+ grid-area: toc;
20
+ position: sticky;
21
+ right: 0;
22
+ z-index: 1;
23
+ top: calc(var(--header-height));
24
+ height: fit-content;
25
+ max-height: calc(100vh - var(--header-height));
26
+ background-color: var(--background-color);
27
+ border-left: 1px solid var(--color-emphasis-200);
28
+ & ul {
29
+ padding-left: 0rem;
30
+ & ul {
31
+ padding-left: 1rem;
32
+ }
33
+ }
34
+ & li {
35
+ display: block;
36
+ &::before {
37
+ content: "";
38
+ border: 1px solid transparent;
39
+ margin-right: 1rem;
40
+ display: inline;
41
+ height: 100%;
42
+ vertical-align: middle;
43
+ }
44
+ &.active::before {
45
+ transition: all 0.4s ease-in-out;
46
+ border-color: var(--link-color);
47
+ }
48
+ }
49
+ & a {
50
+ font-size: 0.8rem;
51
+ text-decoration: none;
52
+ color: var(--color-content-secondary);
53
+ &:hover {
54
+ text-decoration: underline;
55
+ }
56
+ &.active {
57
+ color: var(--link-color);
58
+ }
59
+ }
60
+ `;
61
+
62
+ const TocItem = ({ value, id, children = [] }) => {
63
+ const link = a({
64
+ class: () => (activeHeadingId.val == id ? "active" : ""),
65
+ href: `#${id}`,
66
+ });
67
+ link.innerHTML = value;
68
+ return li(
69
+ { class: () => (activeHeadingId.val == id ? "active" : "") },
70
+ link,
71
+ children.length > 0 && ul(children.map(TocItem))
72
+ );
73
+ };
74
+
75
+ const headerLevel = (el) => el.tagName.charAt(1);
76
+ const createToc = ({ contentEl }) => {
77
+ const headings = contentEl.querySelectorAll(headerSelector);
78
+
79
+ let levelCurrent = 2;
80
+ let newNode = {};
81
+ let nodeCurrent = { children: [] };
82
+ let parentNode = nodeCurrent;
83
+ const tree = parentNode;
84
+ let parents = [parentNode];
85
+ [...headings].forEach((heading) => {
86
+ const level = headerLevel(heading);
87
+ heading.setAttribute("id", heading.textContent);
88
+ //TODO
89
+ if (heading.innerHTML.includes("<button")) {
90
+ return;
91
+ }
92
+ newNode = {
93
+ value: heading.innerHTML,
94
+ id: heading.id ?? heading.textContent,
95
+ children: [],
96
+ };
97
+ if (levelCurrent == level) {
98
+ nodeCurrent = newNode;
99
+ parentNode.children.push(nodeCurrent);
100
+ } else if (levelCurrent < level) {
101
+ parents.push(parentNode);
102
+ parentNode = nodeCurrent;
103
+ nodeCurrent.children.push(newNode);
104
+ nodeCurrent = newNode;
105
+ } else if (levelCurrent > level) {
106
+ parentNode = parents[level - 1];
107
+ parents = parents.slice(0, level - 1);
108
+ parentNode.children.push(newNode);
109
+ nodeCurrent = newNode;
110
+ }
111
+ levelCurrent = level;
112
+ });
113
+
114
+ return tree;
115
+ };
116
+
117
+ return function TableOfContent(...args) {
118
+ let [{ color, variant, size = "md", contentEl, ...props }] =
119
+ toPropsAndChildren(args);
120
+
121
+ const toc = createToc({ contentEl });
122
+
123
+ const handleScroll = debounce(() => {
124
+ const headings = contentEl.querySelectorAll(headerSelector);
125
+ const activeHeading = [...headings].find((heading) => {
126
+ const { top, height } = heading.getBoundingClientRect();
127
+ //TODO
128
+ if (top + height > 60) {
129
+ return true;
130
+ }
131
+ });
132
+ if (activeHeading) {
133
+ activeHeadingId.val = activeHeading?.id;
134
+ }
135
+ }, 100);
136
+
137
+ return nav(
138
+ {
139
+ ...props,
140
+ class: classNames(
141
+ "tableOfContent",
142
+ size,
143
+ variant,
144
+ color,
145
+ className,
146
+ options?.class,
147
+ props?.class
148
+ ),
149
+ bauMounted: (/*{ element }*/) => {
150
+ window.addEventListener("scroll", handleScroll);
151
+ },
152
+ bauUnmounted: (/*{ element }*/) => {
153
+ window.removeEventListener("scroll", handleScroll);
154
+ },
155
+ },
156
+ toc.children && ul(toc.children.map(TocItem))
157
+ );
158
+ };
159
+ }