@rocket.chat/fuselage-forms 1.5.1 → 2.0.0-rc.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.
- package/README.md +126 -57
- package/dist/cjs/Field/Field.js +18 -3
- package/dist/cjs/Field/Field.js.map +1 -1
- package/dist/cjs/Field/FieldContext.js +35 -30
- package/dist/cjs/Field/FieldContext.js.map +1 -1
- package/dist/cjs/Field/FieldDescription.js +14 -2
- package/dist/cjs/Field/FieldDescription.js.map +1 -1
- package/dist/cjs/Field/FieldError.js +14 -2
- package/dist/cjs/Field/FieldError.js.map +1 -1
- package/dist/cjs/Field/FieldHint.js +14 -2
- package/dist/cjs/Field/FieldHint.js.map +1 -1
- package/dist/cjs/Field/FieldProvider.js.map +1 -1
- package/dist/cjs/Field/Label/FieldLabel.js +9 -6
- package/dist/cjs/Field/Label/FieldLabel.js.map +1 -1
- package/dist/cjs/Field/Label/HiddenLabel.js +16 -2
- package/dist/cjs/Field/Label/HiddenLabel.js.map +1 -1
- package/dist/cjs/Field/Label/LabelFor.js +16 -2
- package/dist/cjs/Field/Label/LabelFor.js.map +1 -1
- package/dist/cjs/Field/Label/ReferencedLabel.js +16 -2
- package/dist/cjs/Field/Label/ReferencedLabel.js.map +1 -1
- package/dist/cjs/Field/Label/index.js +7 -4
- package/dist/cjs/Field/Label/index.js.map +1 -1
- package/dist/cjs/Field/index.js +8 -5
- package/dist/cjs/Field/index.js.map +1 -1
- package/dist/cjs/Inputs/WrappedInputComponents.js +1 -1
- package/dist/cjs/Inputs/WrappedInputComponents.js.map +1 -1
- package/dist/cjs/Inputs/withLabelHelpers.js +13 -9
- package/dist/cjs/Inputs/withLabelHelpers.js.map +1 -1
- package/dist/esm/Field/Field.d.ts.map +1 -1
- package/dist/esm/Field/Field.js +17 -10
- package/dist/esm/Field/Field.js.map +1 -1
- package/dist/esm/Field/FieldContext.d.ts +7 -20
- package/dist/esm/Field/FieldContext.d.ts.map +1 -1
- package/dist/esm/Field/FieldContext.js +60 -65
- package/dist/esm/Field/FieldContext.js.map +1 -1
- package/dist/esm/Field/FieldDescription.d.ts.map +1 -1
- package/dist/esm/Field/FieldDescription.js +19 -9
- package/dist/esm/Field/FieldDescription.js.map +1 -1
- package/dist/esm/Field/FieldError.d.ts.map +1 -1
- package/dist/esm/Field/FieldError.js +19 -9
- package/dist/esm/Field/FieldError.js.map +1 -1
- package/dist/esm/Field/FieldHint.d.ts.map +1 -1
- package/dist/esm/Field/FieldHint.js +19 -9
- package/dist/esm/Field/FieldHint.js.map +1 -1
- package/dist/esm/Field/FieldProvider.d.ts.map +1 -1
- package/dist/esm/Field/FieldProvider.js +15 -17
- package/dist/esm/Field/FieldProvider.js.map +1 -1
- package/dist/esm/Field/Label/FieldLabel.d.ts.map +1 -1
- package/dist/esm/Field/Label/FieldLabel.js +10 -15
- package/dist/esm/Field/Label/FieldLabel.js.map +1 -1
- package/dist/esm/Field/Label/HiddenLabel.d.ts +1 -1
- package/dist/esm/Field/Label/HiddenLabel.d.ts.map +1 -1
- package/dist/esm/Field/Label/HiddenLabel.js +21 -9
- package/dist/esm/Field/Label/HiddenLabel.js.map +1 -1
- package/dist/esm/Field/Label/LabelFor.d.ts +1 -1
- package/dist/esm/Field/Label/LabelFor.d.ts.map +1 -1
- package/dist/esm/Field/Label/LabelFor.js +21 -9
- package/dist/esm/Field/Label/LabelFor.js.map +1 -1
- package/dist/esm/Field/Label/ReferencedLabel.d.ts +1 -1
- package/dist/esm/Field/Label/ReferencedLabel.d.ts.map +1 -1
- package/dist/esm/Field/Label/ReferencedLabel.js +21 -9
- package/dist/esm/Field/Label/ReferencedLabel.js.map +1 -1
- package/dist/esm/Field/Label/index.d.ts +1 -1
- package/dist/esm/Field/Label/index.d.ts.map +1 -1
- package/dist/esm/Field/Label/index.js +4 -14
- package/dist/esm/Field/Label/index.js.map +1 -1
- package/dist/esm/Field/index.d.ts +3 -3
- package/dist/esm/Field/index.d.ts.map +1 -1
- package/dist/esm/Field/index.js +8 -37
- package/dist/esm/Field/index.js.map +1 -1
- package/dist/esm/Inputs/WrappedInputComponents.d.ts +25 -14
- package/dist/esm/Inputs/WrappedInputComponents.d.ts.map +1 -1
- package/dist/esm/Inputs/WrappedInputComponents.js +17 -20
- package/dist/esm/Inputs/WrappedInputComponents.js.map +1 -1
- package/dist/esm/Inputs/index.js +1 -17
- package/dist/esm/Inputs/index.js.map +1 -1
- package/dist/esm/Inputs/withLabelHelpers.d.ts +1 -1
- package/dist/esm/Inputs/withLabelHelpers.d.ts.map +1 -1
- package/dist/esm/Inputs/withLabelHelpers.js +23 -24
- package/dist/esm/Inputs/withLabelHelpers.js.map +1 -1
- package/dist/esm/index.js +2 -18
- package/dist/esm/index.js.map +1 -1
- package/package.json +39 -46
- package/dist/cjs/Field/Field.d.ts +0 -8
- package/dist/cjs/Field/Field.d.ts.map +0 -1
- package/dist/cjs/Field/FieldContext.d.ts +0 -40
- package/dist/cjs/Field/FieldContext.d.ts.map +0 -1
- package/dist/cjs/Field/FieldDescription.d.ts +0 -8
- package/dist/cjs/Field/FieldDescription.d.ts.map +0 -1
- package/dist/cjs/Field/FieldError.d.ts +0 -8
- package/dist/cjs/Field/FieldError.d.ts.map +0 -1
- package/dist/cjs/Field/FieldHint.d.ts +0 -8
- package/dist/cjs/Field/FieldHint.d.ts.map +0 -1
- package/dist/cjs/Field/FieldProvider.d.ts +0 -7
- package/dist/cjs/Field/FieldProvider.d.ts.map +0 -1
- package/dist/cjs/Field/Label/FieldLabel.d.ts +0 -6
- package/dist/cjs/Field/Label/FieldLabel.d.ts.map +0 -1
- package/dist/cjs/Field/Label/HiddenLabel.d.ts +0 -6
- package/dist/cjs/Field/Label/HiddenLabel.d.ts.map +0 -1
- package/dist/cjs/Field/Label/LabelFor.d.ts +0 -6
- package/dist/cjs/Field/Label/LabelFor.d.ts.map +0 -1
- package/dist/cjs/Field/Label/ReferencedLabel.d.ts +0 -6
- package/dist/cjs/Field/Label/ReferencedLabel.d.ts.map +0 -1
- package/dist/cjs/Field/Label/index.d.ts +0 -5
- package/dist/cjs/Field/Label/index.d.ts.map +0 -1
- package/dist/cjs/Field/index.d.ts +0 -9
- package/dist/cjs/Field/index.d.ts.map +0 -1
- package/dist/cjs/Inputs/WrappedInputComponents.d.ts +0 -116
- package/dist/cjs/Inputs/WrappedInputComponents.d.ts.map +0 -1
- package/dist/cjs/Inputs/index.d.ts +0 -2
- package/dist/cjs/Inputs/index.d.ts.map +0 -1
- package/dist/cjs/Inputs/withLabelHelpers.d.ts +0 -32
- package/dist/cjs/Inputs/withLabelHelpers.d.ts.map +0 -1
- package/dist/cjs/index.d.ts +0 -3
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/esm/tsdoc-metadata.json +0 -11
package/README.md
CHANGED
|
@@ -1,101 +1,170 @@
|
|
|
1
|
-
|
|
1
|
+
# `@rocket.chat/fuselage-forms`
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
<a href="https://rocket.chat" title="Rocket.Chat">
|
|
5
|
-
<img src="https://github.com/RocketChat/Rocket.Chat.Artwork/raw/master/Logos/2020/png/logo-horizontal-red.png" alt="Rocket.Chat" />
|
|
6
|
-
</a>
|
|
7
|
-
</p>
|
|
3
|
+
> Accessible form fields for Fuselage: inputs that wire up their label, description, hint and error automatically.
|
|
8
4
|
|
|
9
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/@rocket.chat/fuselage-forms) [](https://www.npmjs.com/package/@rocket.chat/fuselage-forms)
|
|
10
6
|
|
|
11
|
-
|
|
7
|
+
This package wraps the field and input components of [`@rocket.chat/fuselage`](https://www.npmjs.com/package/@rocket.chat/fuselage). Inside a `Field`, the wrapped components generate their own ids and set the ARIA attributes that tie an input to its label and messages, so you do not pass `id`, `htmlFor`, `aria-labelledby` or `aria-describedby` by hand.
|
|
12
8
|
|
|
13
|
-
|
|
9
|
+
- The input is labelled by its `FieldLabel`, whichever way the input needs it (`htmlFor`, `aria-labelledby`, or a visually hidden label for checkboxes, radio buttons and toggles).
|
|
10
|
+
- `aria-describedby` points at the `FieldDescription`, `FieldError` and `FieldHint` that are rendered.
|
|
11
|
+
- `aria-invalid` is `true` while a `FieldError` is rendered, and the error is announced with `role="alert"`.
|
|
12
|
+
- Clicking the label of a checkbox, radio button or toggle switch activates it.
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
## Installation
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
```sh
|
|
17
|
+
npm install @rocket.chat/fuselage-forms @rocket.chat/fuselage @rocket.chat/fuselage-hooks react@19 react-dom@19
|
|
18
|
+
```
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
`@rocket.chat/fuselage`, `@rocket.chat/fuselage-hooks`, `react` and `react-dom` are peer dependencies. `@rocket.chat/fuselage` has its own peer dependencies and stylesheet; see its README. The components rely on React 19 (they read `ref` as a regular prop).
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
The package ships CommonJS and ES module builds with TypeScript declarations.
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
## Usage
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
Import the field parts and the inputs from this package instead of from `@rocket.chat/fuselage`:
|
|
26
27
|
|
|
27
|
-
```
|
|
28
|
-
|
|
28
|
+
```tsx
|
|
29
|
+
import { Field, FieldDescription, FieldError, FieldHint, FieldLabel, FieldRow, TextInput } from '@rocket.chat/fuselage-forms';
|
|
30
|
+
import { useState } from 'react';
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
function EmailField() {
|
|
33
|
+
const [email, setEmail] = useState('');
|
|
34
|
+
const invalid = email !== '' && !email.includes('@');
|
|
31
35
|
|
|
32
|
-
|
|
36
|
+
return (
|
|
37
|
+
<Field>
|
|
38
|
+
<FieldLabel required>Email</FieldLabel>
|
|
39
|
+
<FieldDescription>We send the confirmation link here.</FieldDescription>
|
|
40
|
+
<FieldRow>
|
|
41
|
+
<TextInput value={email} onChange={(e) => setEmail(e.currentTarget.value)} />
|
|
42
|
+
</FieldRow>
|
|
43
|
+
{invalid && <FieldError>Enter a valid email address</FieldError>}
|
|
44
|
+
<FieldHint>You can change it later in your account settings.</FieldHint>
|
|
45
|
+
</Field>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
33
48
|
```
|
|
34
49
|
|
|
35
|
-
|
|
50
|
+
The input gets an id that matches the label's `htmlFor`, `aria-describedby` lists the description, error and hint, and `aria-invalid` follows the error.
|
|
36
51
|
|
|
37
|
-
|
|
38
|
-
|
|
52
|
+
### Checkboxes, radio buttons and toggle switches
|
|
53
|
+
|
|
54
|
+
Put the label and the control in the same `FieldRow`. The control renders a visually hidden copy of the label text, and clicking the visible label toggles it:
|
|
39
55
|
|
|
40
|
-
|
|
56
|
+
```tsx
|
|
57
|
+
import { Field, FieldDescription, FieldLabel, FieldRow, ToggleSwitch } from '@rocket.chat/fuselage-forms';
|
|
58
|
+
|
|
59
|
+
<Field>
|
|
60
|
+
<FieldRow>
|
|
61
|
+
<FieldLabel>Email notifications</FieldLabel>
|
|
62
|
+
<ToggleSwitch defaultChecked />
|
|
63
|
+
</FieldRow>
|
|
64
|
+
<FieldDescription>Send a summary of unread messages every day.</FieldDescription>
|
|
65
|
+
</Field>;
|
|
66
|
+
```
|
|
41
67
|
|
|
42
|
-
|
|
68
|
+
### Grouping fields
|
|
69
|
+
|
|
70
|
+
`FieldGroup`, `FieldRow`, `FieldLink` and `FieldLabelInfo` are re-exported from `@rocket.chat/fuselage` unchanged, so a whole form can import from one place:
|
|
71
|
+
|
|
72
|
+
```tsx
|
|
73
|
+
import { Field, FieldGroup, FieldLabel, FieldLabelInfo, FieldRow, PasswordInput, TextInput } from '@rocket.chat/fuselage-forms';
|
|
74
|
+
|
|
75
|
+
<FieldGroup>
|
|
76
|
+
<Field>
|
|
77
|
+
<FieldLabel>Username</FieldLabel>
|
|
78
|
+
<FieldRow>
|
|
79
|
+
<TextInput />
|
|
80
|
+
</FieldRow>
|
|
81
|
+
</Field>
|
|
82
|
+
<Field>
|
|
83
|
+
<FieldLabel>
|
|
84
|
+
Password
|
|
85
|
+
<FieldLabelInfo title='At least 8 characters' />
|
|
86
|
+
</FieldLabel>
|
|
87
|
+
<FieldRow>
|
|
88
|
+
<PasswordInput />
|
|
89
|
+
</FieldRow>
|
|
90
|
+
</Field>
|
|
91
|
+
</FieldGroup>;
|
|
43
92
|
```
|
|
44
93
|
|
|
45
|
-
|
|
94
|
+
### Custom inputs
|
|
46
95
|
|
|
47
|
-
|
|
96
|
+
To connect your own input to a `Field`, use one of the context hooks and spread its result onto the element:
|
|
48
97
|
|
|
49
|
-
|
|
98
|
+
```tsx
|
|
99
|
+
import { useFieldReferencedByInput } from '@rocket.chat/fuselage-forms';
|
|
50
100
|
|
|
51
|
-
|
|
52
|
-
|
|
101
|
+
function ColorInput(props: { value: string; onChange: (value: string) => void }) {
|
|
102
|
+
const fieldProps = useFieldReferencedByInput(); // { id, 'aria-describedby', 'aria-invalid' }
|
|
53
103
|
|
|
54
|
-
|
|
104
|
+
return <input type='color' {...fieldProps} value={props.value} onChange={(e) => props.onChange(e.currentTarget.value)} />;
|
|
105
|
+
}
|
|
106
|
+
```
|
|
55
107
|
|
|
56
|
-
|
|
108
|
+
## API
|
|
57
109
|
|
|
58
|
-
|
|
110
|
+
### Field parts
|
|
59
111
|
|
|
60
|
-
|
|
112
|
+
| Export | Description |
|
|
113
|
+
| ------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
|
|
114
|
+
| `Field` | Fuselage `Field` wrapped in a `FieldProvider`. Every labelled input needs one. |
|
|
115
|
+
| `FieldLabel` | Renders the right kind of label for the input in the same `Field`. |
|
|
116
|
+
| `FieldDescription` | Fuselage `FieldDescription`, registered as a description of the input. |
|
|
117
|
+
| `FieldError` | Fuselage `FieldError` with `role="alert"`; marks the input as invalid while rendered. |
|
|
118
|
+
| `FieldHint` | Fuselage `FieldHint`, registered as a description of the input. |
|
|
119
|
+
| `FieldProvider` | Context provider used by `Field`. Use it directly to give a field context to a different container. |
|
|
120
|
+
| `LabelFor`, `ReferencedLabel`, `HiddenLabel` | The three label variants `FieldLabel` chooses from. Use them only to force a variant. |
|
|
121
|
+
| `FieldGroup`, `FieldRow`, `FieldLink`, `FieldLabelInfo` | Re-exported from `@rocket.chat/fuselage`. |
|
|
61
122
|
|
|
62
|
-
|
|
63
|
-
yarn build
|
|
64
|
-
```
|
|
123
|
+
### Inputs
|
|
65
124
|
|
|
66
|
-
|
|
125
|
+
Each input takes the same props as the Fuselage component with the same name.
|
|
67
126
|
|
|
68
|
-
|
|
127
|
+
| Labelled by | Inputs |
|
|
128
|
+
| ----------------------------------- | ----------------------------------------------------------------------------------------------------- |
|
|
129
|
+
| `<label htmlFor>` and an input `id` | `TextInput`, `EmailInput`, `PasswordInput`, `SearchInput`, `TextAreaInput`, `NumberInput`, `UrlInput` |
|
|
130
|
+
| `aria-labelledby` | `Select`, `Slider`, `MultiSelect`, `MultiSelectFiltered`, `AutoComplete` (deprecated) |
|
|
131
|
+
| A visually hidden label | `CheckBox`, `RadioButton`, `ToggleSwitch` |
|
|
69
132
|
|
|
70
|
-
|
|
71
|
-
Before commiting, check if your code fits our style by running:
|
|
133
|
+
`AutoComplete` is deprecated; use `MultiSelectFiltered`, or `SelectFiltered` from `@rocket.chat/fuselage` for single selection.
|
|
72
134
|
|
|
73
|
-
|
|
135
|
+
### Context hooks
|
|
74
136
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
137
|
+
| Hook | Returns |
|
|
138
|
+
| ----------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
139
|
+
| `useFieldReferencedByInput()` | `{ id, 'aria-describedby', 'aria-invalid' }` for an input that a `<label htmlFor>` points at. |
|
|
140
|
+
| `useFieldReferencedByLabel()` | `{ 'aria-labelledby', 'aria-describedby', 'aria-invalid' }` for a control labelled by the label's id. |
|
|
141
|
+
| `useFieldReferencedByLabelWithId()` | Same as above, plus an `id` (for controls that need one for `aria-controls`). |
|
|
142
|
+
| `useFieldWrappedByInputLabel()` | `[label, props, ref]`: the label content to render hidden, the ARIA props, and a ref for the control, which is focused and clicked when the visible label is clicked. |
|
|
143
|
+
| `useFieldLabel()` | `[ref, id]` for building a custom label. |
|
|
144
|
+
| `useFieldDescriptorId(type)` | Registers a `'description'`, `'error'`, `'hint'` or `'placeholder'` element and returns its id. |
|
|
145
|
+
| `useFieldFieldType()` | The current field type: `'referencedByInput'`, `'referencedByLabel'` or `'wrappedByLabel'`. |
|
|
78
146
|
|
|
79
|
-
|
|
147
|
+
`FieldContext` and the types `FieldContextValue`, `FieldType` and `LabelTypes` are exported for advanced use.
|
|
80
148
|
|
|
81
|
-
|
|
149
|
+
## Development
|
|
82
150
|
|
|
83
|
-
|
|
151
|
+
This package lives in the [Rocket.Chat monorepo](https://github.com/RocketChat/Rocket.Chat/tree/develop/packages/fuselage-forms). From the repository root:
|
|
84
152
|
|
|
85
153
|
```sh
|
|
86
|
-
yarn
|
|
154
|
+
yarn workspace @rocket.chat/fuselage-forms build
|
|
155
|
+
yarn workspace @rocket.chat/fuselage-forms testunit
|
|
156
|
+
yarn workspace @rocket.chat/fuselage-forms typecheck
|
|
157
|
+
yarn workspace @rocket.chat/fuselage-forms lint
|
|
158
|
+
yarn workspace @rocket.chat/fuselage-forms lint:fix
|
|
87
159
|
```
|
|
88
160
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
### Running tests
|
|
92
|
-
|
|
93
|
-
Whenever possible, add tests to describe exactly what your code do. You can run them by yourself:
|
|
94
|
-
|
|
95
|
-
<!--yarn(test)-->
|
|
161
|
+
Run Storybook to try every input inside a `Field`:
|
|
96
162
|
|
|
97
163
|
```sh
|
|
98
|
-
yarn
|
|
164
|
+
yarn workspace @rocket.chat/fuselage-forms storybook
|
|
165
|
+
yarn workspace @rocket.chat/fuselage-forms build-storybook
|
|
99
166
|
```
|
|
100
167
|
|
|
101
|
-
|
|
168
|
+
## License
|
|
169
|
+
|
|
170
|
+
MIT — see [LICENSE](https://github.com/RocketChat/Rocket.Chat/blob/develop/LICENSE).
|
package/dist/cjs/Field/Field.js
CHANGED
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
17
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
18
|
const fuselage_1 = require("@rocket.chat/fuselage");
|
|
5
|
-
const FieldProvider_1 = require("./FieldProvider");
|
|
6
|
-
function Field(
|
|
7
|
-
|
|
19
|
+
const FieldProvider_1 = __importDefault(require("./FieldProvider"));
|
|
20
|
+
function Field(_a) {
|
|
21
|
+
var { children } = _a, props = __rest(_a, ["children"]);
|
|
22
|
+
return ((0, jsx_runtime_1.jsx)(FieldProvider_1.default, { children: (0, jsx_runtime_1.jsx)(fuselage_1.Field, Object.assign({}, props, { children: children })) }));
|
|
8
23
|
}
|
|
9
24
|
exports.default = Field;
|
|
10
25
|
//# sourceMappingURL=Field.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field.js","sourceRoot":"","sources":["../../../src/Field/Field.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Field.js","sourceRoot":"","sources":["../../../src/Field/Field.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,oDAAgE;AAGhE,oEAA4C;AAI5C,SAAS,KAAK,CAAC,EAAkC;QAAlC,EAAE,QAAQ,OAAwB,EAAnB,KAAK,cAApB,YAAsB,CAAF;IAClC,OAAO,CACN,uBAAC,uBAAa,cACb,uBAAC,gBAAc,oBAAK,KAAK,cAAG,QAAQ,IAAkB,GACvC,CAChB,CAAC;AACH,CAAC;kBAEc,KAAK"}
|
|
@@ -4,15 +4,15 @@ exports.useFieldWrappedByInputLabel = exports.useFieldReferencedByLabelWithId =
|
|
|
4
4
|
const fuselage_hooks_1 = require("@rocket.chat/fuselage-hooks");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
exports.FieldContext = (0, react_1.createContext)({
|
|
7
|
-
setDescriptor: () =>
|
|
8
|
-
setLabel: () =>
|
|
7
|
+
setDescriptor: () => undefined,
|
|
8
|
+
setLabel: () => undefined,
|
|
9
9
|
descriptors: new Set(),
|
|
10
10
|
label: null,
|
|
11
11
|
id: '',
|
|
12
12
|
fieldType: 'referencedByLabel',
|
|
13
|
-
setFieldType: () =>
|
|
14
|
-
emitAction: () =>
|
|
15
|
-
onAction: () =>
|
|
13
|
+
setFieldType: () => undefined,
|
|
14
|
+
emitAction: () => undefined,
|
|
15
|
+
onAction: () => () => undefined,
|
|
16
16
|
});
|
|
17
17
|
const getTextFromNode = (node) => {
|
|
18
18
|
if (!node.textContent) {
|
|
@@ -32,9 +32,14 @@ const useFieldLabel = () => {
|
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
setLabel(getTextFromNode(node));
|
|
35
|
+
const observer = new MutationObserver(() => setLabel(getTextFromNode(node)));
|
|
36
|
+
observer.observe(node, { childList: true, characterData: true, subtree: true });
|
|
35
37
|
const onClick = () => emitAction();
|
|
36
38
|
node.addEventListener('click', onClick);
|
|
37
|
-
return () =>
|
|
39
|
+
return () => {
|
|
40
|
+
observer.disconnect();
|
|
41
|
+
node.removeEventListener('click', onClick);
|
|
42
|
+
};
|
|
38
43
|
}, [setLabel, emitAction]));
|
|
39
44
|
return [setLabelRef, `${id}-label`];
|
|
40
45
|
};
|
|
@@ -62,8 +67,9 @@ const getDescribedBy = (descriptors, id) => {
|
|
|
62
67
|
.filter(Boolean)
|
|
63
68
|
.join(' ');
|
|
64
69
|
};
|
|
65
|
-
const getInputId = (id
|
|
66
|
-
|
|
70
|
+
const getInputId = (id) => `${id}-label`;
|
|
71
|
+
const getLabelledBy = (id, descriptors) => {
|
|
72
|
+
return `${getInputId(id)}${descriptors.has('placeholder') ? ` ${id}-placeholder` : ''}`;
|
|
67
73
|
};
|
|
68
74
|
const getAriaInvalid = (descriptors) => {
|
|
69
75
|
if (descriptors.has('error')) {
|
|
@@ -77,11 +83,12 @@ const useFieldReferencedByInput = () => {
|
|
|
77
83
|
(0, react_1.useEffect)(() => {
|
|
78
84
|
setFieldType('referencedByInput');
|
|
79
85
|
}, [setFieldType]);
|
|
80
|
-
return (0, react_1.useMemo)(() =>
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
return (0, react_1.useMemo)(() => {
|
|
87
|
+
if (!id) {
|
|
88
|
+
return {};
|
|
89
|
+
}
|
|
90
|
+
return Object.assign({ 'id': getInputId(id), 'aria-describedby': getDescribedBy(descriptors, id) }, getAriaInvalid(descriptors));
|
|
91
|
+
}, [descriptors, id]);
|
|
85
92
|
};
|
|
86
93
|
exports.useFieldReferencedByInput = useFieldReferencedByInput;
|
|
87
94
|
// label has id and input is aria-labelledby
|
|
@@ -90,11 +97,12 @@ const useFieldReferencedByLabel = () => {
|
|
|
90
97
|
(0, react_1.useEffect)(() => {
|
|
91
98
|
setFieldType('referencedByLabel');
|
|
92
99
|
}, [setFieldType]);
|
|
93
|
-
return (0, react_1.useMemo)(() =>
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
100
|
+
return (0, react_1.useMemo)(() => {
|
|
101
|
+
if (!id) {
|
|
102
|
+
return {};
|
|
103
|
+
}
|
|
104
|
+
return Object.assign({ 'aria-labelledby': getLabelledBy(id, descriptors), 'aria-describedby': getDescribedBy(descriptors, id) }, getAriaInvalid(descriptors));
|
|
105
|
+
}, [descriptors, id]);
|
|
98
106
|
};
|
|
99
107
|
exports.useFieldReferencedByLabel = useFieldReferencedByLabel;
|
|
100
108
|
// label has id and input is aria-labelledby + has id for aria-controls
|
|
@@ -103,12 +111,12 @@ const useFieldReferencedByLabelWithId = () => {
|
|
|
103
111
|
(0, react_1.useEffect)(() => {
|
|
104
112
|
setFieldType('referencedByLabel');
|
|
105
113
|
}, [setFieldType]);
|
|
106
|
-
return (0, react_1.useMemo)(() =>
|
|
107
|
-
id
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
114
|
+
return (0, react_1.useMemo)(() => {
|
|
115
|
+
if (!id) {
|
|
116
|
+
return {};
|
|
117
|
+
}
|
|
118
|
+
return Object.assign({ id, 'aria-labelledby': getLabelledBy(id, descriptors), 'aria-describedby': getDescribedBy(descriptors, id) }, getAriaInvalid(descriptors));
|
|
119
|
+
}, [descriptors, id]);
|
|
112
120
|
};
|
|
113
121
|
exports.useFieldReferencedByLabelWithId = useFieldReferencedByLabelWithId;
|
|
114
122
|
// label is rendered visually hidden inside the inputs wrapper label
|
|
@@ -121,18 +129,15 @@ const useFieldWrappedByInputLabel = () => {
|
|
|
121
129
|
if (!node) {
|
|
122
130
|
return;
|
|
123
131
|
}
|
|
124
|
-
onAction(() => {
|
|
132
|
+
return onAction(() => {
|
|
125
133
|
node.focus();
|
|
126
134
|
node.click();
|
|
127
135
|
});
|
|
128
136
|
}, [onAction]));
|
|
129
137
|
return (0, react_1.useMemo)(() => [
|
|
130
138
|
label,
|
|
131
|
-
|
|
132
|
-
'aria-describedby': getDescribedBy(descriptors, id),
|
|
133
|
-
'id': getInputId(id, descriptors),
|
|
134
|
-
...getAriaInvalid(descriptors),
|
|
135
|
-
},
|
|
139
|
+
id
|
|
140
|
+
? Object.assign({ 'aria-describedby': getDescribedBy(descriptors, id), 'id': getInputId(id) }, getAriaInvalid(descriptors)) : {},
|
|
136
141
|
refCallback,
|
|
137
142
|
], [label, descriptors, id, refCallback]);
|
|
138
143
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldContext.js","sourceRoot":"","sources":["../../../src/Field/FieldContext.ts"],"names":[],"mappings":";;;AAAA,gEAAiE;AAEjE,
|
|
1
|
+
{"version":3,"file":"FieldContext.js","sourceRoot":"","sources":["../../../src/Field/FieldContext.ts"],"names":[],"mappings":";;;AAAA,gEAAiE;AAEjE,iCAAmF;AActE,QAAA,YAAY,GAAG,IAAA,qBAAa,EAAoB;IAC5D,aAAa,EAAE,GAAG,EAAE,CAAC,SAAS;IAC9B,QAAQ,EAAE,GAAG,EAAE,CAAC,SAAS;IACzB,WAAW,EAAE,IAAI,GAAG,EAAE;IACtB,KAAK,EAAE,IAAI;IACX,EAAE,EAAE,EAAE;IACN,SAAS,EAAE,mBAAmB;IAC9B,YAAY,EAAE,GAAG,EAAE,CAAC,SAAS;IAC7B,UAAU,EAAE,GAAG,EAAE,CAAC,SAAS;IAC3B,QAAQ,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,SAAS;CAC/B,CAAC,CAAC;AAMH,MAAM,eAAe,GAAG,CAAC,IAAiB,EAAE,EAAE;IAC7C,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IACb,CAAC;IAED,MAAM,IAAI,GAAG,EAAE,CAAC;IAChB,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,IAAI,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC;IAEnF,OAAO,UAAU,CAAC,QAAQ,EAAE,EAAE,CAAC;QAC9B,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO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YAAY,CAAC,CAAC;IAEpF,IAAA,iBAAS,EAAC,GAAG,EAAE;QACd,YAAY,CAAC,gBAAgB,CAAC,CAAC;IAChC,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAEnB,MAAM,WAAW,GAAG,IAAA,mCAAkB,EACrC,IAAA,mBAAW,EACV,CAAC,IAAiB,EAAE,EAAE;QACrB,IAAI,CAAC,IAAI,EAAE,CAAC;YACX,OAAO;QACR,CAAC;QAED,OAAO,QAAQ,CAAC,GAAG,EAAE;YACpB,IAAI,CAAC,KAAK,EAAE,CAAC;YACb,IAAI,CAAC,KAAK,EAAE,CAAC;QACd,CAAC,CAAC,CAAC;IACJ,CAAC,EACD,CAAC,QAAQ,CAAC,CACV,CACD,CAAC;IAEF,OAAO,IAAA,eAAO,EACb,GAAG,EAAE,CAAC;QACL,KAAK;QACL,EAAE;YACD,CAAC,iBACC,kBAAkB,EAAE,cAAc,CAAC,WAAW,EAAE,EAAE,CAAC,EACnD,IAAI,EAAE,UAAU,CAAC,EAAE,CAAC,IACjB,cAAc,CAAC,WAAW,CAAC,EAEhC,CAAC,CAAC,EAAE;QACL,WAAW;KACX,EACD,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,WAAW,CAAC,CACrC,CAAC;AACH,CAAC,CAAC;AA7CW,QAAA,2BAA2B,GAA3B,2BAA2B,CA6CtC"}
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
14
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
15
|
const fuselage_1 = require("@rocket.chat/fuselage");
|
|
5
16
|
const FieldContext_1 = require("./FieldContext");
|
|
6
|
-
const FieldDescription = (
|
|
17
|
+
const FieldDescription = (_a) => {
|
|
18
|
+
var { children } = _a, props = __rest(_a, ["children"]);
|
|
7
19
|
const id = (0, FieldContext_1.useFieldDescriptorId)('description');
|
|
8
|
-
return ((0, jsx_runtime_1.jsx)(fuselage_1.FieldDescription, {
|
|
20
|
+
return ((0, jsx_runtime_1.jsx)(fuselage_1.FieldDescription, Object.assign({}, props, { id: id, children: children })));
|
|
9
21
|
};
|
|
10
22
|
exports.default = FieldDescription;
|
|
11
23
|
//# sourceMappingURL=FieldDescription.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldDescription.js","sourceRoot":"","sources":["../../../src/Field/FieldDescription.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FieldDescription.js","sourceRoot":"","sources":["../../../src/Field/FieldDescription.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,oDAAsF;AAGtF,iDAAsD;AAItD,MAAM,gBAAgB,GAAG,CAAC,EAA6C,EAAE,EAAE;QAAjD,EAAE,QAAQ,OAAmC,EAA9B,KAAK,cAApB,YAAsB,CAAF;IAC7C,MAAM,EAAE,GAAG,IAAA,mCAAoB,EAAC,aAAa,CAAC,CAAC;IAE/C,OAAO,CACN,uBAAC,2BAAyB,oBAAK,KAAK,IAAE,EAAE,EAAE,EAAE,YAC1C,QAAQ,IACkB,CAC5B,CAAC;AACH,CAAC,CAAC;kBAEa,gBAAgB"}
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
14
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
15
|
const fuselage_1 = require("@rocket.chat/fuselage");
|
|
5
16
|
const FieldContext_1 = require("./FieldContext");
|
|
6
|
-
const FieldError = (
|
|
17
|
+
const FieldError = (_a) => {
|
|
18
|
+
var { children } = _a, props = __rest(_a, ["children"]);
|
|
7
19
|
const id = (0, FieldContext_1.useFieldDescriptorId)('error');
|
|
8
|
-
return ((0, jsx_runtime_1.jsx)(fuselage_1.FieldError, {
|
|
20
|
+
return ((0, jsx_runtime_1.jsx)(fuselage_1.FieldError, Object.assign({}, props, { id: id, role: 'alert', children: children })));
|
|
9
21
|
};
|
|
10
22
|
exports.default = FieldError;
|
|
11
23
|
//# sourceMappingURL=FieldError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldError.js","sourceRoot":"","sources":["../../../src/Field/FieldError.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FieldError.js","sourceRoot":"","sources":["../../../src/Field/FieldError.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,oDAA0E;AAG1E,iDAAsD;AAItD,MAAM,UAAU,GAAG,CAAC,EAAuC,EAAE,EAAE;QAA3C,EAAE,QAAQ,OAA6B,EAAxB,KAAK,cAApB,YAAsB,CAAF;IACvC,MAAM,EAAE,GAAG,IAAA,mCAAoB,EAAC,OAAO,CAAC,CAAC;IACzC,OAAO,CACN,uBAAC,qBAAmB,oBAAK,KAAK,IAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAC,OAAO,YAClD,QAAQ,IACY,CACtB,CAAC;AACH,CAAC,CAAC;kBAEa,UAAU"}
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
14
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
15
|
const fuselage_1 = require("@rocket.chat/fuselage");
|
|
5
16
|
const FieldContext_1 = require("./FieldContext");
|
|
6
|
-
const FieldHint = (
|
|
17
|
+
const FieldHint = (_a) => {
|
|
18
|
+
var { children } = _a, props = __rest(_a, ["children"]);
|
|
7
19
|
const id = (0, FieldContext_1.useFieldDescriptorId)('hint');
|
|
8
|
-
return ((0, jsx_runtime_1.jsx)(fuselage_1.FieldHint, {
|
|
20
|
+
return ((0, jsx_runtime_1.jsx)(fuselage_1.FieldHint, Object.assign({}, props, { id: id, children: children })));
|
|
9
21
|
};
|
|
10
22
|
exports.default = FieldHint;
|
|
11
23
|
//# sourceMappingURL=FieldHint.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldHint.js","sourceRoot":"","sources":["../../../src/Field/FieldHint.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FieldHint.js","sourceRoot":"","sources":["../../../src/Field/FieldHint.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,oDAAwE;AAGxE,iDAAsD;AAItD,MAAM,SAAS,GAAG,CAAC,EAAsC,EAAE,EAAE;QAA1C,EAAE,QAAQ,OAA4B,EAAvB,KAAK,cAApB,YAAsB,CAAF;IACtC,MAAM,EAAE,GAAG,IAAA,mCAAoB,EAAC,MAAM,CAAC,CAAC;IAExC,OAAO,CACN,uBAAC,oBAAkB,oBAAK,KAAK,IAAE,EAAE,EAAE,EAAE,YACnC,QAAQ,IACW,CACrB,CAAC;AACH,CAAC,CAAC;kBAEa,SAAS"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldProvider.js","sourceRoot":"","sources":["../../../src/Field/FieldProvider.tsx"],"names":[],"mappings":";;;AAAA,kDAA+C;AAE/C,iCAA8C;AAC9C,2CAAmC;AAGnC,iDAA8C;AAI9C,SAAS,aAAa,CAAC,EAAE,QAAQ,EAAsB;
|
|
1
|
+
{"version":3,"file":"FieldProvider.js","sourceRoot":"","sources":["../../../src/Field/FieldProvider.tsx"],"names":[],"mappings":";;;AAAA,kDAA+C;AAE/C,iCAA8C;AAC9C,2CAAmC;AAGnC,iDAA8C;AAI9C,SAAS,aAAa,CAAC,EAAE,QAAQ,EAAsB;IACtD,MAAM,EAAE,GAAG,IAAA,kBAAK,GAAE,CAAC;IACnB,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAmB,IAAI,CAAC,CAAC;IAC3D,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,IAAA,gBAAQ,EAAC,IAAI,GAAG,EAAc,CAAC,CAAC;IACtE,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,IAAA,gBAAQ,EAAY,mBAAmB,CAAC,CAAC;IAC3E,MAAM,CAAC,OAAO,CAAC,GAAG,IAAA,gBAAQ,EAAC,GAAG,EAAE,CAAC,IAAI,iBAAO,EAAoB,CAAC,CAAC;IAElE,MAAM,aAAa,GAAG,IAAA,mBAAW,EAAC,CAAC,IAAgB,EAAE,UAAoB,EAAE,EAAE;QAC5E,cAAc,CAAC,CAAC,MAAM,EAAE,EAAE;YACzB,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;YAElC,IAAI,UAAU,EAAE,CAAC;gBAChB,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBACvB,OAAO,SAAS,CAAC;YAClB,CAAC;YAED,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACpB,OAAO,SAAS,CAAC;QAClB,CAAC,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,UAAU,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QACnC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACxB,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,MAAM,QAAQ,GAAG,IAAA,mBAAW,EAC3B,CAAC,EAAc,EAAE,EAAE;QAClB,OAAO,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IACjC,CAAC,EACD,CAAC,OAAO,CAAC,CACT,CAAC;IAEF,OAAO,CACN,uBAAC,2BAAY,CAAC,QAAQ,IACrB,KAAK,EAAE;YACN,UAAU;YACV,QAAQ;YACR,aAAa;YACb,QAAQ;YACR,WAAW;YACX,KAAK;YACL,EAAE;YACF,SAAS;YACT,YAAY;SACZ,YAEA,QAAQ,GACc,CACxB,CAAC;AACH,CAAC;kBAEc,aAAa"}
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
7
|
const FieldContext_1 = require("../FieldContext");
|
|
5
|
-
const HiddenLabel_1 = require("./HiddenLabel");
|
|
6
|
-
const LabelFor_1 = require("./LabelFor");
|
|
7
|
-
const ReferencedLabel_1 = require("./ReferencedLabel");
|
|
8
|
+
const HiddenLabel_1 = __importDefault(require("./HiddenLabel"));
|
|
9
|
+
const LabelFor_1 = __importDefault(require("./LabelFor"));
|
|
10
|
+
const ReferencedLabel_1 = __importDefault(require("./ReferencedLabel"));
|
|
8
11
|
const FieldLabel = (props) => {
|
|
9
12
|
const fieldType = (0, FieldContext_1.useFieldFieldType)();
|
|
10
13
|
if (fieldType === 'wrappedByLabel') {
|
|
11
|
-
return (0, jsx_runtime_1.jsx)(HiddenLabel_1.default, {
|
|
14
|
+
return (0, jsx_runtime_1.jsx)(HiddenLabel_1.default, Object.assign({}, props));
|
|
12
15
|
}
|
|
13
16
|
if (fieldType === 'referencedByInput') {
|
|
14
|
-
return (0, jsx_runtime_1.jsx)(ReferencedLabel_1.default, {
|
|
17
|
+
return (0, jsx_runtime_1.jsx)(ReferencedLabel_1.default, Object.assign({}, props));
|
|
15
18
|
}
|
|
16
19
|
// referencedByLabel
|
|
17
|
-
return (0, jsx_runtime_1.jsx)(LabelFor_1.default, {
|
|
20
|
+
return (0, jsx_runtime_1.jsx)(LabelFor_1.default, Object.assign({}, props));
|
|
18
21
|
};
|
|
19
22
|
exports.default = FieldLabel;
|
|
20
23
|
//# sourceMappingURL=FieldLabel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldLabel.js","sourceRoot":"","sources":["../../../../src/Field/Label/FieldLabel.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FieldLabel.js","sourceRoot":"","sources":["../../../../src/Field/Label/FieldLabel.tsx"],"names":[],"mappings":";;;;;;AAGA,kDAAoD;AACpD,gEAAwC;AACxC,0DAAkC;AAClC,wEAAgD;AAIhD,MAAM,UAAU,GAAG,CAAC,KAAsB,EAAE,EAAE;IAC7C,MAAM,SAAS,GAAG,IAAA,gCAAiB,GAAE,CAAC;IAEtC,IAAI,SAAS,KAAK,gBAAgB,EAAE,CAAC;QACpC,OAAO,uBAAC,qBAAW,oBAAK,KAAK,EAAI,CAAC;IACnC,CAAC;IACD,IAAI,SAAS,KAAK,mBAAmB,EAAE,CAAC;QACvC,OAAO,uBAAC,yBAAe,oBAAK,KAAK,EAAI,CAAC;IACvC,CAAC;IACD,oBAAoB;IACpB,OAAO,uBAAC,kBAAQ,oBAAK,KAAK,EAAI,CAAC;AAChC,CAAC,CAAC;kBAEa,UAAU"}
|
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
14
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
15
|
const fuselage_1 = require("@rocket.chat/fuselage");
|
|
16
|
+
const fuselage_hooks_1 = require("@rocket.chat/fuselage-hooks");
|
|
5
17
|
const FieldContext_1 = require("../FieldContext");
|
|
6
|
-
const HiddenLabel = (
|
|
18
|
+
const HiddenLabel = (_a) => {
|
|
19
|
+
var { children, ref } = _a, props = __rest(_a, ["children", "ref"]);
|
|
7
20
|
const [labelRef] = (0, FieldContext_1.useFieldLabel)();
|
|
8
|
-
|
|
21
|
+
const mergedRef = (0, fuselage_hooks_1.useMergedRefs)(ref, labelRef);
|
|
22
|
+
return ((0, jsx_runtime_1.jsx)(fuselage_1.FieldLabel, Object.assign({}, props, { ref: mergedRef, is: 'span', children: children })));
|
|
9
23
|
};
|
|
10
24
|
exports.default = HiddenLabel;
|
|
11
25
|
//# sourceMappingURL=HiddenLabel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HiddenLabel.js","sourceRoot":"","sources":["../../../../src/Field/Label/HiddenLabel.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HiddenLabel.js","sourceRoot":"","sources":["../../../../src/Field/Label/HiddenLabel.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,oDAA0E;AAC1E,gEAA4D;AAG5D,kDAAgD;AAIhD,MAAM,WAAW,GAAG,CAAC,EAA6C,EAAE,EAAE;QAAjD,EAAE,QAAQ,EAAE,GAAG,OAA8B,EAAzB,KAAK,cAAzB,mBAA2B,CAAF;IAC7C,MAAM,CAAC,QAAQ,CAAC,GAAG,IAAA,4BAAa,GAAE,CAAC;IACnC,MAAM,SAAS,GAAG,IAAA,8BAAa,EAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAE/C,OAAO,CACN,uBAAC,qBAAmB,oBAAK,KAAK,IAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EAAC,MAAM,YACvD,QAAQ,IACY,CACtB,CAAC;AACH,CAAC,CAAC;kBAEa,WAAW"}
|