@utrecht/form-fieldset-css 1.0.0 → 1.1.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/dist/index.css ADDED
@@ -0,0 +1,74 @@
1
+ /**
2
+ * @license EUPL-1.2
3
+ * Copyright (c) 2021 Robbert Broersma
4
+ */
5
+ /**
6
+ * @license EUPL-1.2
7
+ * Copyright (c) 2021 Robbert Broersma
8
+ */
9
+ /**
10
+ * @license EUPL-1.2
11
+ * Copyright (c) 2021 Robbert Broersma
12
+ */
13
+ /* stylelint-disable-next-line block-no-empty */
14
+ .utrecht-form-fieldset {
15
+ margin-block-end: calc(var(--utrecht-space-around, 0) * var(--utrecht-form-fieldset-margin-block-end, 0));
16
+ margin-block-start: calc(var(--utrecht-space-around, 0) * var(--utrecht-form-fieldset-margin-block-start, 0));
17
+ }
18
+
19
+ .utrecht-form-fieldset--html-fieldset,
20
+ .utrecht-form-fieldset__fieldset--html-fieldset {
21
+ /* `all: revert` unfortunately has as side-effect that the `hidde` attribute has no effect */
22
+ all: revert;
23
+ border: 0;
24
+ margin-inline-end: 0;
25
+ margin-inline-start: 0;
26
+ min-inline-size: 0;
27
+ padding-block-end: 0;
28
+ padding-block-start: 0.01em;
29
+ padding-inline-end: 0;
30
+ padding-inline-start: 0;
31
+ }
32
+
33
+ .utrecht-form-fieldset__legend--html-legend {
34
+ display: table;
35
+ inline-size: 100%;
36
+ padding-inline-end: 0;
37
+ padding-inline-start: 0;
38
+ }
39
+
40
+ .utrecht-form-fieldset--distanced {
41
+ --utrecht-space-around: 1;
42
+ }
43
+
44
+ .utrecht-form-fieldset--section {
45
+ background-color: var(--utrecht-form-fieldset-section-background-color);
46
+ color: var(--utrecht-form-fieldset-section-color);
47
+ }
48
+
49
+ .utrecht-form-fieldset__legend {
50
+ break-inside: avoid;
51
+ color: var(--utrecht-form-fieldset-legend-color, var(--utrecht-document-color, inherit));
52
+ font-family: var(--utrecht-form-fieldset-legend-font-family, var(--utrecht-document-font-family));
53
+ font-size: var(--utrecht-form-fieldset-legend-font-size);
54
+ font-weight: var(--utrecht-form-fieldset-legend-font-weight);
55
+ line-height: var(--utrecht-form-fieldset-legend-line-height);
56
+ page-break-after: avoid;
57
+ page-break-inside: avoid;
58
+ }
59
+
60
+ .utrecht-form-fieldset__legend--disabled {
61
+ color: var(--utrecht-form-fieldset-legend-disabled-color, var(--utrecht-form-fieldset-legend-color, var(--utrecht-document-color, inherit)));
62
+ }
63
+
64
+ .utrecht-form-fieldset__legend--distanced {
65
+ margin-block-end: calc(var(--utrecht-space-around, 0) * var(--utrecht-form-fieldset-legend-margin-block-end, 0));
66
+ margin-block-start: calc(var(--utrecht-space-around, 0) * var(--utrecht-form-fieldset-legend-margin-block-start, 0));
67
+ }
68
+
69
+ .utrecht-form-fieldset--invalid {
70
+ border-inline-start-color: var(--utrecht-form-fieldset-invalid-border-inline-start-color, var(--utrecht-form-field-invalid-border-inline-start-color));
71
+ border-inline-start-style: solid;
72
+ border-inline-start-width: var(--utrecht-form-fieldset-invalid-border-inline-start-width, var(--utrecht-form-field-invalid-border-inline-start-width));
73
+ padding-inline-start: var(--utrecht-form-fieldset-invalid-padding-inline-start, var(--utrecht-form-field-invalid-padding-inline-start));
74
+ }
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ var undefined$1 = undefined;export{undefined$1 as default};
package/package.json CHANGED
@@ -1,18 +1,25 @@
1
1
  {
2
- "version": "1.0.0",
2
+ "version": "1.1.0",
3
3
  "author": "Community for NL Design System",
4
4
  "description": "Form fieldset component for the Municipality of Utrecht based on the NL Design System architecture",
5
5
  "license": "EUPL-1.2",
6
6
  "name": "@utrecht/form-fieldset-css",
7
7
  "files": [
8
- "dist/"
8
+ "dist/",
9
+ "src/"
9
10
  ],
10
- "devDependencies": {},
11
+ "main": "dist/index.css",
12
+ "devDependencies": {
13
+ "rollup": "3.29.4"
14
+ },
11
15
  "keywords": [
12
16
  "nl-design-system"
13
17
  ],
14
18
  "publishConfig": {
15
19
  "access": "public"
16
20
  },
17
- "scripts": {}
21
+ "scripts": {
22
+ "build": "rollup -c ../rollup.config.mjs",
23
+ "clean": "rimraf dist"
24
+ }
18
25
  }
@@ -0,0 +1,71 @@
1
+ /**
2
+ * @license EUPL-1.2
3
+ * Copyright (c) 2021 Robbert Broersma
4
+ */
5
+
6
+ @import "./reset";
7
+
8
+ @mixin utrecht-form-fieldset {
9
+ margin-block-end: calc(var(--utrecht-space-around, 0) * var(--utrecht-form-fieldset-margin-block-end, 0));
10
+ margin-block-start: calc(var(--utrecht-space-around, 0) * var(--utrecht-form-fieldset-margin-block-start, 0));
11
+ }
12
+
13
+ @mixin utrecht-form-fieldset--html-fieldset {
14
+ @include reset-fieldset;
15
+ }
16
+
17
+ @mixin utrecht-form-fieldset--distanced {
18
+ --utrecht-space-around: 1;
19
+ }
20
+
21
+ @mixin utrecht-form-fieldset--invalid {
22
+ border-inline-start-color: var(
23
+ --utrecht-form-fieldset-invalid-border-inline-start-color,
24
+ var(--utrecht-form-field-invalid-border-inline-start-color)
25
+ );
26
+ border-inline-start-style: solid;
27
+ border-inline-start-width: var(
28
+ --utrecht-form-fieldset-invalid-border-inline-start-width,
29
+ var(--utrecht-form-field-invalid-border-inline-start-width)
30
+ );
31
+ padding-inline-start: var(
32
+ --utrecht-form-fieldset-invalid-padding-inline-start,
33
+ var(--utrecht-form-field-invalid-padding-inline-start)
34
+ );
35
+ }
36
+
37
+ @mixin utrecht-form-fieldset--section {
38
+ background-color: var(--utrecht-form-fieldset-section-background-color);
39
+ color: var(--utrecht-form-fieldset-section-color);
40
+ }
41
+
42
+ /* stylelint-disable-next-line block-no-empty */
43
+ @mixin utrecht-form-fieldset__fieldset {
44
+ }
45
+
46
+ @mixin utrecht-form-fieldset__legend {
47
+ break-inside: avoid;
48
+ color: var(--utrecht-form-fieldset-legend-color, var(--utrecht-document-color, inherit));
49
+ font-family: var(--utrecht-form-fieldset-legend-font-family, var(--utrecht-document-font-family));
50
+ font-size: var(--utrecht-form-fieldset-legend-font-size);
51
+ font-weight: var(--utrecht-form-fieldset-legend-font-weight);
52
+ line-height: var(--utrecht-form-fieldset-legend-line-height);
53
+ page-break-after: avoid;
54
+ page-break-inside: avoid;
55
+ }
56
+
57
+ @mixin utrecht-form-fieldset__legend--disabled {
58
+ color: var(
59
+ --utrecht-form-fieldset-legend-disabled-color,
60
+ var(--utrecht-form-fieldset-legend-color, var(--utrecht-document-color, inherit))
61
+ );
62
+ }
63
+
64
+ @mixin utrecht-form-fieldset__legend--html-legend {
65
+ @include reset-legend;
66
+ }
67
+
68
+ @mixin utrecht-form-fieldset__legend--distanced {
69
+ margin-block-end: calc(var(--utrecht-space-around, 0) * var(--utrecht-form-fieldset-legend-margin-block-end, 0));
70
+ margin-block-start: calc(var(--utrecht-space-around, 0) * var(--utrecht-form-fieldset-legend-margin-block-start, 0));
71
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @license EUPL-1.2
3
+ * Copyright (c) 2021 Robbert Broersma
4
+ */
5
+
6
+ @mixin reset-fieldset {
7
+ /* `all: revert` unfortunately has as side-effect that the `hidde` attribute has no effect */
8
+ all: revert;
9
+ border: 0;
10
+ margin-inline-end: 0;
11
+ margin-inline-start: 0;
12
+ min-inline-size: 0;
13
+ padding-block-end: 0;
14
+ padding-block-start: 0.01em;
15
+ padding-inline-end: 0;
16
+ padding-inline-start: 0;
17
+ }
18
+
19
+ @mixin reset-legend {
20
+ display: table;
21
+ inline-size: 100%;
22
+ padding-inline-end: 0;
23
+ padding-inline-start: 0;
24
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @license EUPL-1.2
3
+ * Copyright (c) 2021 Robbert Broersma
4
+ */
5
+
6
+ @import "../mixin";
7
+
8
+ @mixin utrecht-html-fieldset {
9
+ fieldset {
10
+ @include utrecht-form-fieldset;
11
+ @include utrecht-form-fieldset--html-fieldset;
12
+ @include utrecht-form-fieldset--distanced;
13
+ }
14
+
15
+ fieldset[hidden] {
16
+ display: none;
17
+ }
18
+ }
19
+
20
+ @mixin utrecht-html-legend {
21
+ legend {
22
+ @include utrecht-form-fieldset__legend;
23
+ @include utrecht-form-fieldset__legend--html-legend;
24
+ @include utrecht-form-fieldset__legend--distanced;
25
+ }
26
+
27
+ legend[hidden] {
28
+ display: none;
29
+ }
30
+
31
+ fieldset:disabled > legend {
32
+ @include utrecht-form-fieldset__legend--disabled;
33
+ }
34
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @license EUPL-1.2
3
+ * Copyright (c) 2021 Robbert Broersma
4
+ */
5
+
6
+ @import "./mixin";
7
+
8
+ @include utrecht-html-fieldset;
9
+ @include utrecht-html-legend;
package/src/index.scss ADDED
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @license EUPL-1.2
3
+ * Copyright (c) 2021 Robbert Broersma
4
+ */
5
+
6
+ @import "./mixin";
7
+
8
+ .utrecht-form-fieldset {
9
+ @include utrecht-form-fieldset;
10
+ }
11
+
12
+ .utrecht-form-fieldset__fieldset {
13
+ @include utrecht-form-fieldset__fieldset;
14
+ }
15
+
16
+ .utrecht-form-fieldset--html-fieldset,
17
+ .utrecht-form-fieldset__fieldset--html-fieldset {
18
+ @include utrecht-form-fieldset--html-fieldset;
19
+ }
20
+
21
+ .utrecht-form-fieldset__legend--html-legend {
22
+ @include utrecht-form-fieldset__legend--html-legend;
23
+ }
24
+
25
+ .utrecht-form-fieldset--distanced {
26
+ @include utrecht-form-fieldset--distanced;
27
+ }
28
+
29
+ .utrecht-form-fieldset--section {
30
+ @include utrecht-form-fieldset--section;
31
+ }
32
+
33
+ .utrecht-form-fieldset__legend {
34
+ @include utrecht-form-fieldset__legend;
35
+ }
36
+
37
+ .utrecht-form-fieldset__legend--disabled {
38
+ @include utrecht-form-fieldset__legend--disabled;
39
+ }
40
+
41
+ .utrecht-form-fieldset__legend--distanced {
42
+ @include utrecht-form-fieldset__legend--distanced;
43
+ }
44
+
45
+ .utrecht-form-fieldset--invalid {
46
+ @include utrecht-form-fieldset--invalid;
47
+ }
@@ -0,0 +1,140 @@
1
+ /*
2
+ * @license EUPL-1.2
3
+ * Copyright (c) 2020-2022 Gemeente Utrecht
4
+ * Copyright (c) 2020-2022 Frameless B.V.
5
+ */
6
+
7
+ import clsx from 'clsx';
8
+ import parse from 'html-react-parser';
9
+ import React from 'react';
10
+
11
+ export const argTypes = {
12
+ disabled: {
13
+ description: 'Disabled',
14
+ control: 'boolean',
15
+ },
16
+ div: {
17
+ description: 'Use div elements instead of semantic HTML',
18
+ type: 'boolean',
19
+ },
20
+ innerHTML: {
21
+ description: 'Set the content of the fieldset',
22
+ control: 'text',
23
+ },
24
+ invalid: {
25
+ description: 'Invalid',
26
+ control: 'boolean',
27
+ },
28
+ legend: {
29
+ description: 'Set the content of the legend',
30
+ control: 'text',
31
+ },
32
+ role: {
33
+ control: { type: 'select' },
34
+ options: ['', 'group', 'radiogroup'],
35
+ },
36
+ section: {
37
+ description: 'Section appearance',
38
+ type: 'boolean',
39
+ },
40
+ };
41
+
42
+ export const defaultArgs = {
43
+ div: false,
44
+ disabled: false,
45
+ innerHTML: '',
46
+ invalid: false,
47
+ legend: '',
48
+ role: '',
49
+ section: false,
50
+ };
51
+
52
+ export const exampleArgs = {
53
+ disabled: false,
54
+ id: '4f8af453-db3f-4261-b103-5086dcd01b98',
55
+ innerHTML: '<p>Fieldset body</p>',
56
+ legend: 'Fieldset legend',
57
+ };
58
+
59
+ export const FormFieldsetLegend = ({ children, disabled = false, div = defaultArgs.div, id }) =>
60
+ div ? (
61
+ <div
62
+ className={clsx('utrecht-form-fieldset__legend', {
63
+ 'utrecht-form-fieldset__legend--disabled': disabled,
64
+ })}
65
+ id={id}
66
+ >
67
+ {children}
68
+ </div>
69
+ ) : (
70
+ <legend
71
+ className={clsx('utrecht-form-fieldset__legend', 'utrecht-form-fieldset__legend--html-legend', {
72
+ 'utrecht-form-fieldset__legend--disabled': disabled,
73
+ })}
74
+ >
75
+ {children}
76
+ </legend>
77
+ );
78
+
79
+ export const FormFieldset = ({
80
+ className,
81
+ children,
82
+ disabled = false,
83
+ div = defaultArgs.div,
84
+ id,
85
+ innerHTML = defaultArgs.innerHTML,
86
+ invalid = defaultArgs.invalid,
87
+ legend = defaultArgs.legend,
88
+ role = defaultArgs.role,
89
+ section = defaultArgs.section,
90
+ ...restProps
91
+ }) => {
92
+ const labelId = id && `${id}-legend`;
93
+ const content = (
94
+ <>
95
+ {legend && (
96
+ <FormFieldsetLegend div={div} id={labelId}>
97
+ {legend}
98
+ </FormFieldsetLegend>
99
+ )}
100
+ {children}
101
+ {parse(innerHTML)}
102
+ </>
103
+ );
104
+ return div ? (
105
+ <div
106
+ className={clsx('utrecht-form-fieldset', {
107
+ 'utrecht-form-fieldset--invalid': invalid,
108
+ 'utrecht-form-fieldset--section': section,
109
+ className,
110
+ })}
111
+ aria-disabled={disabled ? 'true' : undefined}
112
+ aria-invalid={invalid ? 'true' : undefined}
113
+ role={role || 'group'}
114
+ aria-labelledby={labelId}
115
+ {...restProps}
116
+ >
117
+ {content}
118
+ </div>
119
+ ) : (
120
+ <div
121
+ className={clsx('utrecht-form-fieldset', {
122
+ 'utrecht-form-fieldset--invalid': invalid,
123
+ 'utrecht-form-fieldset--section': section,
124
+ className,
125
+ })}
126
+ >
127
+ <fieldset
128
+ className={clsx('utrecht-form-fieldset__fieldset', 'utrecht-form-fieldset__fieldset--html-fieldset')}
129
+ aria-invalid={invalid ? 'true' : undefined}
130
+ disabled={disabled}
131
+ role={role || undefined}
132
+ {...restProps}
133
+ >
134
+ {content}
135
+ </fieldset>
136
+ </div>
137
+ );
138
+ };
139
+
140
+ export default FormFieldset;
@@ -0,0 +1,136 @@
1
+ {
2
+ "utrecht": {
3
+ "form-fieldset": {
4
+ "margin-block-end": {
5
+ "$extensions": {
6
+ "nl.nldesignsystem.css.property": {
7
+ "syntax": "<length>",
8
+ "inherits": true
9
+ }
10
+ }
11
+ },
12
+ "margin-block-start": {
13
+ "$extensions": {
14
+ "nl.nldesignsystem.css.property": {
15
+ "syntax": "<length>",
16
+ "inherits": true
17
+ }
18
+ }
19
+ },
20
+ "invalid": {
21
+ "border-inline-start-color": {
22
+ "color": {
23
+ "$extensions": {
24
+ "nl.nldesignsystem.css.property": {
25
+ "syntax": "<color>",
26
+ "inherits": true
27
+ }
28
+ }
29
+ }
30
+ },
31
+ "border-inline-start-width": {
32
+ "$extensions": {
33
+ "nl.nldesignsystem.css.property": {
34
+ "syntax": "<length>",
35
+ "inherits": true
36
+ }
37
+ }
38
+ },
39
+ "padding-inline-start": {
40
+ "$extensions": {
41
+ "nl.nldesignsystem.css.property": {
42
+ "syntax": "<length>",
43
+ "inherits": true
44
+ }
45
+ }
46
+ }
47
+ },
48
+ "section": {
49
+ "background-color": {
50
+ "$extensions": {
51
+ "nl.nldesignsystem.css.property": {
52
+ "syntax": "<color>",
53
+ "inherits": true
54
+ }
55
+ }
56
+ },
57
+ "color": {
58
+ "$extensions": {
59
+ "nl.nldesignsystem.css.property": {
60
+ "syntax": "<color>",
61
+ "inherits": true
62
+ }
63
+ }
64
+ }
65
+ },
66
+ "legend": {
67
+ "color": {
68
+ "$extensions": {
69
+ "nl.nldesignsystem.css.property": {
70
+ "syntax": "<color>",
71
+ "inherits": true
72
+ }
73
+ }
74
+ },
75
+ "font-family": {
76
+ "$extensions": {
77
+ "nl.nldesignsystem.css.property": {
78
+ "syntax": "*",
79
+ "inherits": true
80
+ }
81
+ }
82
+ },
83
+ "font-size": {
84
+ "$extensions": {
85
+ "nl.nldesignsystem.css.property": {
86
+ "syntax": "<length>",
87
+ "inherits": true
88
+ }
89
+ }
90
+ },
91
+ "font-weight": {
92
+ "$extensions": {
93
+ "nl.nldesignsystem.css.property": {
94
+ "syntax": "<number>",
95
+ "inherits": true
96
+ }
97
+ }
98
+ },
99
+ "line-height": {
100
+ "$extensions": {
101
+ "nl.nldesignsystem.css.property": {
102
+ "syntax": "<length>",
103
+ "inherits": true
104
+ }
105
+ }
106
+ },
107
+ "margin-block-end": {
108
+ "$extensions": {
109
+ "nl.nldesignsystem.css.property": {
110
+ "syntax": "<length>",
111
+ "inherits": true
112
+ }
113
+ }
114
+ },
115
+ "margin-block-start": {
116
+ "$extensions": {
117
+ "nl.nldesignsystem.css.property": {
118
+ "syntax": "<length>",
119
+ "inherits": true
120
+ }
121
+ }
122
+ },
123
+ "disabled": {
124
+ "color": {
125
+ "$extensions": {
126
+ "nl.nldesignsystem.css.property": {
127
+ "syntax": "<color>",
128
+ "inherits": true
129
+ }
130
+ }
131
+ }
132
+ }
133
+ }
134
+ }
135
+ }
136
+ }