@propellerads/editable-field 4.0.4 → 5.0.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/README.md +109 -14
- package/dist/index.css +1 -0
- package/dist/index.d.ts +82 -4
- package/dist/index.js +197 -163
- package/dist/index.js.map +1 -1
- package/package.json +22 -6
package/README.md
CHANGED
|
@@ -1,29 +1,124 @@
|
|
|
1
1
|
# EditableField
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A value that turns into an input in place — the name of an offer, an audience,
|
|
4
|
+
a token in a table row, the title of a page. Version 5 stands on
|
|
5
|
+
[@propellerads/input](../Input/README.md) — the same 36px box and `!` mark as
|
|
6
|
+
every other field — and on [@propellerads/button](../Button/README.md) for the
|
|
7
|
+
pencil and the actions. The blue contour while editing stays from v4.
|
|
8
|
+
|
|
4
9
|

|
|
5
10
|
|
|
6
11
|
[NPM](https://www.npmjs.com/package/@propellerads/editable-field) |
|
|
7
|
-
[Github](https://github.com/propellerads/ui-components/tree/master/Components/
|
|
12
|
+
[Github](https://github.com/propellerads/ui-components/tree/master/Components/EditableField)
|
|
8
13
|
|
|
9
14
|
## Installation
|
|
10
15
|
|
|
11
|
-
|
|
16
|
+
```sh
|
|
17
|
+
bun add @propellerads/editable-field
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The built entry imports its own stylesheet. The tokens are the app's:
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import '@propellerads/tokens/common.css';
|
|
24
|
+
import '@propellerads/tokens/propellerads.css'; // or monetag / propush / zeydoo
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Use
|
|
12
28
|
|
|
13
|
-
|
|
29
|
+
The caller holds the state, as in v4:
|
|
14
30
|
|
|
15
|
-
|
|
16
|
-
|
|
31
|
+
```tsx
|
|
32
|
+
import EditableField from '@propellerads/editable-field';
|
|
17
33
|
|
|
34
|
+
<EditableField
|
|
35
|
+
elementId={`audience-name-${id}`}
|
|
36
|
+
value={isEditable ? draft : name}
|
|
37
|
+
isEditable={isEditable}
|
|
38
|
+
isLoading={isSaving}
|
|
39
|
+
errors={errors}
|
|
40
|
+
onFocus={() => setEditable(true)}
|
|
41
|
+
onChange={(event) => setDraft(event.target.value)}
|
|
42
|
+
onSave={save}
|
|
43
|
+
onCancel={() => setEditable(false)}
|
|
44
|
+
/>
|
|
18
45
|
```
|
|
46
|
+
|
|
47
|
+
A warning is an error that does not stop the value: the same mark and contour
|
|
48
|
+
in the warning colour. Whether save goes through is still the caller's call.
|
|
49
|
+
|
|
50
|
+
```tsx
|
|
19
51
|
<EditableField
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
onSave={() => console.log('onSave')}
|
|
25
|
-
onCancel={() => console.log('onCancel')}
|
|
26
|
-
onChange={(value) => console.log('onChange', value)}
|
|
27
|
-
elementId="stories-default-view"
|
|
52
|
+
{...props}
|
|
53
|
+
textStyle="h1"
|
|
54
|
+
errors={name.length > 32 ? ['It will be cut in the table'] : []}
|
|
55
|
+
tone="warning"
|
|
28
56
|
/>
|
|
29
57
|
```
|
|
58
|
+
|
|
59
|
+
## How it behaves
|
|
60
|
+
|
|
61
|
+
- **The field is as large as it looks.** In view it is the text and the pencil:
|
|
62
|
+
no box, no inset, so it lines up with the text around it. In edit the box is
|
|
63
|
+
drawn outward, 12px past the text on each side — the input's own inset — so
|
|
64
|
+
the text stays where it was.
|
|
65
|
+
- **The type is the value's.** `textStyle` sets it from the tokens — `h1` to
|
|
66
|
+
`h4`, `text`, `paragraph` — in view and in edit alike.
|
|
67
|
+
- **The pencil is an inline button** in the action tone — the icon alone, the
|
|
68
|
+
way a button sits in a line of text — named "Edit", so the keyboard can open
|
|
69
|
+
the field too. With no value the field is the pencil and nothing else.
|
|
70
|
+
- **The actions float.** Save — a primary button — and cancel — a secondary
|
|
71
|
+
one — drop under the end of the box, over whatever is below it: a table row
|
|
72
|
+
keeps its height, a form does not jump. They stand on a pad in the page colour
|
|
73
|
+
with `--shadow-middle`, so what they cover does not show through the secondary
|
|
74
|
+
button or a save switched off. They are rendered right after the
|
|
75
|
+
input and placed by Floating UI with `position: fixed`, so a cell with
|
|
76
|
+
`overflow: hidden` does not clip them, and at the bottom of the screen they
|
|
77
|
+
flip above the field. They appear from 95% in `--duration-200`, the way
|
|
78
|
+
shadcn's popovers do.
|
|
79
|
+
- **The keyboard.** The input takes focus when the field opens. Tab goes from
|
|
80
|
+
the input to save and cancel, Shift+Tab back. Enter saves, Escape cancels —
|
|
81
|
+
this field only, not every field open on the page. When the edit ends, the
|
|
82
|
+
focus comes back to the pencil.
|
|
83
|
+
- **A hint** is a note on what the value is for: a grey `i` mark at the end of
|
|
84
|
+
the input while the field is edited, with the dark tooltip the products use
|
|
85
|
+
(SmartTooltip's) behind it, made of `--color-dark-inversion` and
|
|
86
|
+
`--color-light-inversion`, so it turns over with the theme. It gives way to
|
|
87
|
+
errors, and marks nothing invalid.
|
|
88
|
+
- **Opening and closing fade.** The contour comes in over `--duration-200` and
|
|
89
|
+
goes over `--duration-100`, the actions with it; only then does the text take
|
|
90
|
+
the box's place, in the same spot.
|
|
91
|
+
- **An empty value** is saved, and the field is left with the pencil alone.
|
|
92
|
+
With `isRequired` it cannot be: save is off and Enter does nothing while the
|
|
93
|
+
input holds only spaces.
|
|
94
|
+
- **A click outside does nothing.** An edit is not thrown away by a stray click;
|
|
95
|
+
it ends with save or cancel.
|
|
96
|
+
- **Saving** switches the input off, puts the spinner on save and switches
|
|
97
|
+
cancel off. In view the spinner stands on the pencil.
|
|
98
|
+
|
|
99
|
+
## Props
|
|
100
|
+
|
|
101
|
+
| Prop | Type | Default | What it does |
|
|
102
|
+
|-----------------|-------------------------------|---------------|---------------------------------------------------------|
|
|
103
|
+
| `value` | `string` | — | The text in view, the input's value in edit |
|
|
104
|
+
| `isEditable` | `boolean` | — | Edit instead of view. Controlled |
|
|
105
|
+
| `isLoading` | `boolean` | — | Spinner on the pencil or on save, input and cancel off |
|
|
106
|
+
| `errors` | `readonly string[]` | `[]` | The `!` mark and, in edit, the contour in the tone |
|
|
107
|
+
| `tone` | `'danger' \| 'warning'` | `'danger'` | The colour of the errors |
|
|
108
|
+
| `hint` | `string` | — | A note behind a grey `i` mark; gives way to `errors` |
|
|
109
|
+
| `textStyle` | `'h1'`…`'h4'` `'text'` `'paragraph'` | `'text'` | The type of the value, from the tokens |
|
|
110
|
+
| `isRequired` | `boolean` | `false` | An empty value cannot be saved |
|
|
111
|
+
| `elementId` | `string` | — | Names the parts: `-editable-field-icon`, `-save`, `-cancel` |
|
|
112
|
+
| `onFocus` | `() => void` | — | A click on the text or the pencil |
|
|
113
|
+
| `onChange` | `ChangeEventHandler` | — | The input's change |
|
|
114
|
+
| `onSave` | `() => void` | — | The save button, or Enter |
|
|
115
|
+
| `onCancel` | `() => void` | — | The cancel button, or Escape |
|
|
116
|
+
| `onErrorClick` | `() => void` | — | A click on the `!` mark |
|
|
117
|
+
| `fieldClassName`| `string` | — | On the text in view and on the input in edit |
|
|
118
|
+
| `editIconColor` | `EditIconColor` | — | Deprecated and ignored: the pencil is a button |
|
|
119
|
+
| `editIconSize` | `EditIconSize` | — | Deprecated and ignored: the pencil is a button |
|
|
120
|
+
| `containerDirection` | `'row' \| 'column'` | — | Deprecated and ignored: the actions float |
|
|
121
|
+
|
|
122
|
+
`--editable-field-z-index` is 3000 by default, the layer of Dialog: inside a
|
|
123
|
+
dialog the actions draw on top of it. A modal of its own that stands higher
|
|
124
|
+
needs the variable raised.
|
package/dist/index.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.editable-field{--editable-field-font:var(--font-text);--editable-field-inset:var(--space-12);vertical-align:middle;width:fit-content;min-width:0;max-width:100%;color:var(--color-dark-inversion);font:var(--editable-field-font);font-family:var(--font-family);display:inline-flex}.editable-field[data-editing]{width:100%;display:flex}.editable-field[data-text-style=h1]{--editable-field-font:var(--font-h1)}.editable-field[data-text-style=h2]{--editable-field-font:var(--font-h2)}.editable-field[data-text-style=h3]{--editable-field-font:var(--font-h3)}.editable-field[data-text-style=h4]{--editable-field-font:var(--font-h4)}.editable-field[data-text-style=paragraph]{--editable-field-font:var(--font-paragraph)}.editable-field__view{align-items:center;gap:var(--space-8);min-width:0;min-height:36px;display:flex}.editable-field__value{overflow-wrap:anywhere;cursor:text;min-width:0}.editable-field__view .error-label{margin-inline-end:var(--space-0)}.editable-field__edit{flex:none}.editable-field .editable-field__box{width:calc(100% + 2 * var(--editable-field-inset));margin-inline:calc(-1 * var(--editable-field-inset));font:var(--editable-field-font);font-family:var(--font-family)}.editable-field[data-editing] .editable-field__box:not([data-focus-visible]){outline-color:#0000}.editable-field .editable-field__box:not([data-invalid]){--input-contour:var(--color-action)}@starting-style{.editable-field .editable-field__box{box-shadow:inset 0 0 0 var(--space-1) transparent}}.editable-field[data-closing] .editable-field__box.editable-field__box{--input-contour:transparent;transition-duration:var(--duration-100);outline-color:#0000}.editable-field[data-loading] .editable-field__box:not([data-invalid]){--input-contour:var(--color-rich)}.editable-field__positioner{z-index:var(--editable-field-z-index,3000)}.editable-field__actions{--editable-field-shift:calc(-1 * var(--space-4));gap:var(--space-8);padding:var(--space-4);border-radius:calc(var(--radius-8) + var(--space-4));background-color:var(--color-light-inversion);box-shadow:var(--shadow-middle);transform-origin:100% 0;transition:opacity var(--duration-200) var(--ease-enter), transform var(--duration-200) var(--ease-enter);display:flex}.editable-field__actions[data-side=top]{--editable-field-shift:var(--space-4);transform-origin:100% 100%}@starting-style{.editable-field__actions{opacity:0;transform:translateY(var(--editable-field-shift)) scale(.95)}}.editable-field[data-closing] .editable-field__actions{opacity:0;transform:translateY(var(--editable-field-shift)) scale(.95);transition-duration:var(--duration-100);transition-timing-function:var(--ease-exit);pointer-events:none}.editable-field__hint{flex:none;align-items:center;display:inline-flex}.editable-field__hint-mark{box-sizing:border-box;width:20px;height:20px;padding:var(--space-0);background-color:var(--color-quiet);color:var(--color-light-inversion);outline:var(--space-2) solid transparent;outline-offset:var(--space-1);font:var(--font-h4);font-family:var(--font-family);cursor:pointer;transition:background-color var(--duration-200) var(--ease-flat), outline-color var(--duration-200) var(--ease-flat);border:0;border-radius:50%;flex:none;justify-content:center;align-items:center;line-height:1;display:inline-flex}.editable-field__hint-mark:hover,.editable-field__hint-mark[data-popup-open]{background-color:color-mix(in srgb, var(--over-deepen), var(--color-quiet))}.editable-field__hint-mark:focus-visible{outline-color:var(--color-action)}.editable-field__hint-positioner{z-index:var(--editable-field-z-index,3000)}.editable-field__hint-popup{--editable-field-hint-shift:var(--space-2);box-sizing:border-box;max-width:min(240px, calc(100vw - 2 * var(--space-8)));padding:var(--space-8) var(--space-12);border-radius:var(--radius-8);background-color:var(--color-dark-inversion);box-shadow:var(--shadow-middle);color:var(--color-light-inversion);font:var(--font-description);font-family:var(--font-family);transform-origin:var(--transform-origin);transition:opacity var(--duration-200) var(--ease-enter), transform var(--duration-200) var(--ease-enter)}.editable-field__hint-popup:focus-visible{outline:none}.editable-field__hint-popup[data-side=bottom]{--editable-field-hint-shift:calc(-1 * var(--space-2))}.editable-field__hint-popup[data-starting-style],.editable-field__hint-popup[data-ending-style]{opacity:0;transform:translateY(var(--editable-field-hint-shift)) scale(.95)}.editable-field__hint-popup[data-ending-style]{transition-duration:var(--duration-100);transition-timing-function:var(--ease-exit)}.editable-field__hint-popup[data-instant]{transition:none}.editable-field__hint-arrow{width:var(--space-8);height:var(--space-8);background-color:inherit;transform:rotate(45deg)}.editable-field__hint-arrow[data-side=top]{bottom:calc(-1 * var(--space-4))}.editable-field__hint-arrow[data-side=bottom]{top:calc(-1 * var(--space-4))}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,38 +1,116 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ChangeEventHandler } from 'react';
|
|
2
3
|
|
|
4
|
+
/** Which colour the errors are shown in. */
|
|
5
|
+
declare const EditableFieldTone: {
|
|
6
|
+
/** Something is wrong and has to be fixed. */
|
|
7
|
+
readonly Danger: "danger";
|
|
8
|
+
/** Something is allowed but worth a second look. */
|
|
9
|
+
readonly Warning: "warning";
|
|
10
|
+
};
|
|
11
|
+
type EditableFieldTone = (typeof EditableFieldTone)[keyof typeof EditableFieldTone];
|
|
12
|
+
/**
|
|
13
|
+
* The type the value is set in, from @propellerads/tokens. The same in view and
|
|
14
|
+
* in edit. The description and the hint sizes are left out: a value that small
|
|
15
|
+
* is not something to edit in place. So is hero: it does not fit the 36px box.
|
|
16
|
+
*/
|
|
17
|
+
declare const EditableFieldTextStyle: {
|
|
18
|
+
readonly H1: "h1";
|
|
19
|
+
readonly H2: "h2";
|
|
20
|
+
readonly H3: "h3";
|
|
21
|
+
readonly H4: "h4";
|
|
22
|
+
readonly Text: "text";
|
|
23
|
+
readonly Paragraph: "paragraph";
|
|
24
|
+
};
|
|
25
|
+
type EditableFieldTextStyle = (typeof EditableFieldTextStyle)[keyof typeof EditableFieldTextStyle];
|
|
26
|
+
/** @deprecated The pencil is an inline button in the action tone now. Accepted and ignored. */
|
|
3
27
|
declare const EditIconColor: {
|
|
4
28
|
readonly Gray: "gray-dark";
|
|
5
29
|
readonly Blue: "blue";
|
|
6
30
|
};
|
|
7
31
|
type EditIconColor = (typeof EditIconColor)[keyof typeof EditIconColor];
|
|
32
|
+
/** @deprecated The pencil takes the button's icon size now. Accepted and ignored. */
|
|
8
33
|
declare const EditIconSize: {
|
|
9
34
|
readonly Small: "small";
|
|
10
35
|
readonly Medium: "medium";
|
|
11
36
|
};
|
|
12
37
|
type EditIconSize = (typeof EditIconSize)[keyof typeof EditIconSize];
|
|
38
|
+
/**
|
|
39
|
+
* @deprecated The actions float over the page now and take no room beside the
|
|
40
|
+
* field, so there is no direction to lay them out in. Accepted and ignored.
|
|
41
|
+
*/
|
|
13
42
|
declare const ContainerDirection: {
|
|
14
43
|
readonly Row: "row";
|
|
15
44
|
readonly Column: "column";
|
|
16
45
|
};
|
|
17
46
|
type ContainerDirection = (typeof ContainerDirection)[keyof typeof ContainerDirection];
|
|
18
47
|
type EditableFieldProps = {
|
|
19
|
-
errors?: string
|
|
48
|
+
errors?: ReadonlyArray<string>;
|
|
49
|
+
/** Which colour the errors are shown in. @default 'danger' */
|
|
50
|
+
tone?: EditableFieldTone;
|
|
51
|
+
/**
|
|
52
|
+
* A note on what the value is for, behind a grey `i` mark at the end of the
|
|
53
|
+
* input while the field is edited. It gives way to `errors`.
|
|
54
|
+
*/
|
|
55
|
+
hint?: string;
|
|
20
56
|
value: string;
|
|
57
|
+
/** The type the value is set in, in view and in edit. @default 'text' */
|
|
58
|
+
textStyle?: EditableFieldTextStyle;
|
|
59
|
+
/**
|
|
60
|
+
* Forbids saving an empty value: save is switched off and Enter does nothing
|
|
61
|
+
* while the input holds only spaces. Otherwise an empty value is saved and
|
|
62
|
+
* leaves the pencil alone. @default false
|
|
63
|
+
*/
|
|
64
|
+
isRequired?: boolean;
|
|
65
|
+
/** Spinner on the pencil or on save, and the input switched off. */
|
|
21
66
|
isLoading: boolean;
|
|
67
|
+
/** The input and its actions, instead of the text and the pencil. Controlled by the caller. */
|
|
22
68
|
isEditable: boolean;
|
|
69
|
+
/** On the text in view and on the `<input>` in edit, as in v4. */
|
|
23
70
|
fieldClassName?: string;
|
|
71
|
+
/** @deprecated Accepted and ignored: the pencil is an inline button in the action tone. */
|
|
24
72
|
editIconColor?: EditIconColor;
|
|
73
|
+
/** @deprecated Accepted and ignored: the pencil takes the button's icon size. */
|
|
25
74
|
editIconSize?: EditIconSize;
|
|
75
|
+
/** @deprecated Accepted and ignored: the actions float. */
|
|
26
76
|
containerDirection?: ContainerDirection;
|
|
77
|
+
/**
|
|
78
|
+
* Names the parts, as v4 did: the pencil is `${elementId}-editable-field-icon`,
|
|
79
|
+
* the actions `${elementId}-editable-field-save` and `-cancel`.
|
|
80
|
+
*/
|
|
27
81
|
elementId: string;
|
|
82
|
+
/** Asks to edit: a click on the text or the pencil. */
|
|
28
83
|
onFocus: () => void;
|
|
84
|
+
/** The cancel button, or Escape. */
|
|
29
85
|
onCancel: () => void;
|
|
86
|
+
/** The save button, or Enter in the input. */
|
|
30
87
|
onSave: () => void;
|
|
31
88
|
onChange: ChangeEventHandler<HTMLInputElement>;
|
|
89
|
+
/** Called when the `!` mark is clicked. */
|
|
32
90
|
onErrorClick?: () => void;
|
|
33
91
|
};
|
|
34
92
|
|
|
35
|
-
|
|
93
|
+
/**
|
|
94
|
+
* A value that turns into an input in place.
|
|
95
|
+
*
|
|
96
|
+
* In view the field is as large as its text and the pencil: no box, no inset.
|
|
97
|
+
* In edit the box is drawn outward, around the text, so the text stays where it
|
|
98
|
+
* was and nothing beside the field moves.
|
|
99
|
+
*
|
|
100
|
+
* The save and cancel buttons float under the field instead of standing beside
|
|
101
|
+
* it: they take no room, so a table row does not grow and a form does not jump.
|
|
102
|
+
* They are rendered right after the input and placed by Floating UI with
|
|
103
|
+
* `position: fixed` — so Tab goes from the input to the actions and on, and a
|
|
104
|
+
* cell with `overflow: hidden` still does not clip them. At the bottom of the
|
|
105
|
+
* screen they flip above the field.
|
|
106
|
+
*
|
|
107
|
+
* An empty value can be saved unless the field is required; saved, it leaves
|
|
108
|
+
* the pencil alone.
|
|
109
|
+
*
|
|
110
|
+
* Enter saves and Escape cancels. A click outside does nothing: an edit is not
|
|
111
|
+
* thrown away by a stray click.
|
|
112
|
+
*/
|
|
113
|
+
declare const EditableField: ({ value, errors, tone, hint, textStyle, isRequired, isLoading, isEditable, fieldClassName, editIconColor: _editIconColor, editIconSize: _editIconSize, containerDirection: _containerDirection, elementId, onFocus, onCancel, onSave, onChange, onErrorClick, }: EditableFieldProps) => react_jsx_runtime.JSX.Element;
|
|
36
114
|
|
|
37
|
-
export { ContainerDirection, EditIconColor, EditIconSize, EditableField as default };
|
|
115
|
+
export { ContainerDirection, EditIconColor, EditIconSize, EditableFieldTextStyle, EditableFieldTone, EditableField as default };
|
|
38
116
|
export type { EditableFieldProps };
|
package/dist/index.js
CHANGED
|
@@ -1,171 +1,205 @@
|
|
|
1
|
-
import
|
|
2
|
-
import n from "@
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
display: inline-flex;
|
|
29
|
-
flex-direction: row;
|
|
30
|
-
align-items: center;
|
|
31
|
-
padding-right: 4px;
|
|
32
|
-
|
|
33
|
-
&:hover {
|
|
34
|
-
box-shadow: inset 0 0 0 1px ${l};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
${(e) => e.$isEditable && m`
|
|
38
|
-
box-shadow: inset 0 0 0 1px ${e?.theme?.actionColor?.main || "#1787fc"} !important;
|
|
39
|
-
width: 100%;
|
|
40
|
-
`}
|
|
41
|
-
|
|
42
|
-
${(e) => e.$isLoading && m`
|
|
43
|
-
box-shadow: inset 0 0 0 1px ${l} !important;
|
|
44
|
-
padding-right: 20px;
|
|
45
|
-
`}
|
|
46
|
-
`, x = p.div`
|
|
47
|
-
position: relative;
|
|
48
|
-
|
|
49
|
-
&:after {
|
|
50
|
-
content: '';
|
|
51
|
-
position: absolute;
|
|
52
|
-
display: block;
|
|
53
|
-
height: 14px;
|
|
54
|
-
width: 14px;
|
|
55
|
-
border: 1px solid;
|
|
56
|
-
border-color: ${f} ${l} ${l};
|
|
57
|
-
border-radius: 50%;
|
|
58
|
-
animation: ${v} 0.5s linear infinite;
|
|
59
|
-
margin-top: -7px;
|
|
60
|
-
}
|
|
61
|
-
`, S = p.input`
|
|
62
|
-
outline: none;
|
|
63
|
-
width: 100%;
|
|
64
|
-
background: transparent;
|
|
65
|
-
border: 0;
|
|
66
|
-
resize: none;
|
|
67
|
-
padding: ${d * 2}px;
|
|
68
|
-
height: ${u}px;
|
|
69
|
-
`, C = p.div`
|
|
70
|
-
outline: none;
|
|
71
|
-
width: 100%;
|
|
72
|
-
background: transparent;
|
|
73
|
-
border: 0;
|
|
74
|
-
resize: none;
|
|
75
|
-
padding: ${d * 2}px;
|
|
76
|
-
`, w = p.div`
|
|
77
|
-
pointer-events: none;
|
|
78
|
-
`, T = p.div`
|
|
79
|
-
display: flex;
|
|
80
|
-
margin-top: ${d * 2}px;
|
|
81
|
-
|
|
82
|
-
button {
|
|
83
|
-
margin-left: ${d * 2}px;
|
|
84
|
-
width: 36px;
|
|
85
|
-
height: 36px;
|
|
86
|
-
border-radius: ${c}px;
|
|
87
|
-
border: solid 1px ${l};
|
|
88
|
-
padding: 0;
|
|
89
|
-
cursor: pointer;
|
|
90
|
-
outline: none;
|
|
91
|
-
display: inline-flex;
|
|
92
|
-
align-items: center;
|
|
93
|
-
justify-content: center;
|
|
94
|
-
|
|
95
|
-
&:hover {
|
|
96
|
-
background-color: #e6e6e6;
|
|
97
|
-
border-color: gray;
|
|
98
|
-
color: #000;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
`, E = {
|
|
102
|
-
Gray: a.GrayDark,
|
|
103
|
-
Blue: a.Blue
|
|
104
|
-
}, D = {
|
|
105
|
-
Small: s.Small,
|
|
106
|
-
Medium: s.Medium
|
|
107
|
-
}, O = {
|
|
1
|
+
import { Popover as e } from "@base-ui-components/react/popover";
|
|
2
|
+
import { autoUpdate as t, flip as n, offset as r, shift as i, useFloating as ee } from "@floating-ui/react-dom";
|
|
3
|
+
import a, { ButtonVariant as o } from "@propellerads/button";
|
|
4
|
+
import s, { errorLabelTextId as c } from "@propellerads/error-label";
|
|
5
|
+
import { Check as te, Close as ne, Color as l, Edit as u, Size as d } from "@propellerads/icon";
|
|
6
|
+
import { InputGroup as f, InputGroupAddon as re, InputGroupInput as p } from "@propellerads/input";
|
|
7
|
+
import { useEffect as m, useRef as h, useState as g } from "react";
|
|
8
|
+
import { clsx as _ } from "clsx";
|
|
9
|
+
import { jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
10
|
+
import './index.css';//#region src/cn.ts
|
|
11
|
+
var ie = (...e) => _(e), b = {
|
|
12
|
+
Danger: "danger",
|
|
13
|
+
Warning: "warning"
|
|
14
|
+
}, x = {
|
|
15
|
+
H1: "h1",
|
|
16
|
+
H2: "h2",
|
|
17
|
+
H3: "h3",
|
|
18
|
+
H4: "h4",
|
|
19
|
+
Text: "text",
|
|
20
|
+
Paragraph: "paragraph"
|
|
21
|
+
}, S = {
|
|
22
|
+
Gray: l.GrayDark,
|
|
23
|
+
Blue: l.Blue
|
|
24
|
+
}, C = {
|
|
25
|
+
Small: d.Small,
|
|
26
|
+
Medium: d.Medium
|
|
27
|
+
}, w = {
|
|
108
28
|
Row: "row",
|
|
109
29
|
Column: "column"
|
|
110
|
-
},
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
30
|
+
}, T = !0, E = !1, ae = () => {
|
|
31
|
+
E || (E = !0, document.addEventListener("keydown", (e) => {
|
|
32
|
+
!e.metaKey && !e.altKey && !e.ctrlKey && (T = !0);
|
|
33
|
+
}, !0), document.addEventListener("pointerdown", () => {
|
|
34
|
+
T = !1;
|
|
35
|
+
}, !0));
|
|
36
|
+
}, D = (e) => `${e}-editable-field-hint-text`, O = ({ elementId: t, hint: n }) => /* @__PURE__ */ y("span", {
|
|
37
|
+
className: "editable-field__hint",
|
|
38
|
+
children: [/* @__PURE__ */ v("span", {
|
|
39
|
+
id: D(t),
|
|
40
|
+
hidden: !0,
|
|
41
|
+
children: n
|
|
42
|
+
}), /* @__PURE__ */ y(e.Root, { children: [/* @__PURE__ */ v(e.Trigger, {
|
|
43
|
+
id: `${t}-editable-field-hint`,
|
|
44
|
+
className: "editable-field__hint-mark",
|
|
45
|
+
"aria-label": "Hint",
|
|
46
|
+
openOnHover: !0,
|
|
47
|
+
delay: 100,
|
|
48
|
+
closeDelay: 100,
|
|
49
|
+
children: "i"
|
|
50
|
+
}), /* @__PURE__ */ v(e.Portal, { children: /* @__PURE__ */ v(e.Positioner, {
|
|
51
|
+
className: "editable-field__hint-positioner",
|
|
52
|
+
side: "top",
|
|
53
|
+
sideOffset: 8,
|
|
54
|
+
collisionPadding: 8,
|
|
55
|
+
children: /* @__PURE__ */ y(e.Popup, {
|
|
56
|
+
className: "editable-field__hint-popup",
|
|
57
|
+
children: [/* @__PURE__ */ v(e.Arrow, { className: "editable-field__hint-arrow" }), n]
|
|
58
|
+
})
|
|
59
|
+
}) })] })]
|
|
60
|
+
}), k = ({ value: e, errors: l = [], tone: _ = b.Danger, hint: E, textStyle: k = x.Text, isRequired: A = !1, isLoading: j, isEditable: M, fieldClassName: N, editIconColor: oe = S.Gray, editIconSize: se = C.Medium, containerDirection: ce = w.Column, elementId: P, onFocus: F, onCancel: I, onSave: L, onChange: R, onErrorClick: z }) => {
|
|
61
|
+
let B = h(null), V = h(null), H = h(M), [U, W] = g(!1), [G, K] = g(!1), [le, ue] = g(M);
|
|
62
|
+
M !== le && (ue(M), K(!M));
|
|
63
|
+
let q = M || G;
|
|
64
|
+
m(() => {
|
|
65
|
+
if (!G) return;
|
|
66
|
+
let e = setTimeout(() => K(!1), 400);
|
|
67
|
+
return () => clearTimeout(e);
|
|
68
|
+
}, [G]);
|
|
69
|
+
let J = l.length > 0, Y = q && !J && E !== void 0 && E.trim() !== "", X = e.trim() === "", Z = A && X;
|
|
70
|
+
m(ae, []);
|
|
71
|
+
let { refs: Q, floatingStyles: de, placement: fe } = ee({
|
|
72
|
+
open: q,
|
|
73
|
+
strategy: "fixed",
|
|
74
|
+
placement: "bottom-end",
|
|
75
|
+
middleware: [
|
|
76
|
+
r({
|
|
77
|
+
mainAxis: 4,
|
|
78
|
+
crossAxis: 4
|
|
132
79
|
}),
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
80
|
+
n({ padding: 8 }),
|
|
81
|
+
i({ padding: 8 })
|
|
82
|
+
],
|
|
83
|
+
whileElementsMounted: t
|
|
84
|
+
});
|
|
85
|
+
m(() => {
|
|
86
|
+
if (H.current && !q) {
|
|
87
|
+
let e = document.activeElement;
|
|
88
|
+
(e === null || e === document.body || B.current?.contains(e)) && V.current?.focus();
|
|
89
|
+
}
|
|
90
|
+
H.current = q;
|
|
91
|
+
}, [q]);
|
|
92
|
+
let pe = (e) => {
|
|
93
|
+
G || (e.key === "Enter" && !j && (e.preventDefault(), Z || L()), e.key === "Escape" && (e.preventDefault(), I()));
|
|
94
|
+
}, me = (e) => {
|
|
95
|
+
e.key === "Escape" && !j && !G && (e.preventDefault(), I());
|
|
96
|
+
}, $ = J ? /* @__PURE__ */ v(s, {
|
|
97
|
+
elementId: P,
|
|
98
|
+
errors: l,
|
|
99
|
+
tone: _,
|
|
100
|
+
onClick: z
|
|
101
|
+
}) : Y && /* @__PURE__ */ v(O, {
|
|
102
|
+
elementId: P,
|
|
103
|
+
hint: E
|
|
104
|
+
});
|
|
105
|
+
return /* @__PURE__ */ y("div", {
|
|
106
|
+
ref: B,
|
|
107
|
+
className: "editable-field",
|
|
108
|
+
"data-editing": q || void 0,
|
|
109
|
+
"data-closing": G || void 0,
|
|
110
|
+
"data-loading": j || void 0,
|
|
111
|
+
"data-text-style": k,
|
|
112
|
+
children: [q ? /* @__PURE__ */ y(f, {
|
|
113
|
+
ref: Q.setReference,
|
|
114
|
+
tone: _,
|
|
115
|
+
isInvalid: J,
|
|
116
|
+
className: "editable-field__box",
|
|
117
|
+
"data-focus-visible": U || void 0,
|
|
118
|
+
onTransitionEnd: (e) => {
|
|
119
|
+
G && e.target === e.currentTarget && e.propertyName === "box-shadow" && K(!1);
|
|
120
|
+
},
|
|
121
|
+
children: [/* @__PURE__ */ v(p, {
|
|
122
|
+
className: N,
|
|
123
|
+
value: e,
|
|
124
|
+
onChange: R,
|
|
125
|
+
onKeyDown: pe,
|
|
126
|
+
onFocus: () => W(T),
|
|
127
|
+
onBlur: () => W(!1),
|
|
128
|
+
onPointerDown: () => W(!1),
|
|
129
|
+
disabled: j,
|
|
130
|
+
readOnly: G,
|
|
131
|
+
tabIndex: G ? -1 : void 0,
|
|
132
|
+
autoFocus: !0,
|
|
133
|
+
"aria-label": "Value",
|
|
134
|
+
...J ? {
|
|
135
|
+
"aria-invalid": !0,
|
|
136
|
+
"aria-describedby": c(P)
|
|
137
|
+
} : {},
|
|
138
|
+
...Y ? { "aria-describedby": D(P) } : {}
|
|
139
|
+
}), (J || Y) && /* @__PURE__ */ v(re, { children: $ })]
|
|
140
|
+
}) : /* @__PURE__ */ y("div", {
|
|
141
|
+
className: "editable-field__view",
|
|
142
|
+
children: [
|
|
143
|
+
!X && /* @__PURE__ */ v("span", {
|
|
144
|
+
className: ie("editable-field__value", N),
|
|
145
|
+
onClick: F,
|
|
146
|
+
children: e
|
|
143
147
|
}),
|
|
144
|
-
|
|
145
|
-
|
|
148
|
+
$,
|
|
149
|
+
/* @__PURE__ */ v(a, {
|
|
150
|
+
ref: V,
|
|
151
|
+
id: `${P}-editable-field-icon`,
|
|
152
|
+
className: "editable-field__edit",
|
|
153
|
+
variant: o.Inline,
|
|
154
|
+
icon: /* @__PURE__ */ v(u, {
|
|
155
|
+
color: "currentColor",
|
|
156
|
+
size: d.Small
|
|
157
|
+
}),
|
|
158
|
+
"aria-label": "Edit",
|
|
159
|
+
isLoading: j,
|
|
160
|
+
onClick: F
|
|
161
|
+
})
|
|
162
|
+
]
|
|
163
|
+
}), q && /* @__PURE__ */ v("div", {
|
|
164
|
+
ref: Q.setFloating,
|
|
165
|
+
className: "editable-field__positioner",
|
|
166
|
+
style: de,
|
|
167
|
+
children: /* @__PURE__ */ y("div", {
|
|
168
|
+
className: "editable-field__actions",
|
|
169
|
+
"data-side": fe.startsWith("top") ? "top" : "bottom",
|
|
170
|
+
"aria-hidden": G || void 0,
|
|
171
|
+
onKeyDown: me,
|
|
172
|
+
children: [/* @__PURE__ */ v(a, {
|
|
173
|
+
id: `${P}-editable-field-save`,
|
|
174
|
+
variant: o.Primary,
|
|
175
|
+
icon: /* @__PURE__ */ v(te, {
|
|
176
|
+
color: "currentColor",
|
|
177
|
+
size: d.Small
|
|
178
|
+
}),
|
|
179
|
+
"aria-label": "Save",
|
|
180
|
+
isLoading: j,
|
|
181
|
+
isDisabled: Z,
|
|
182
|
+
onClick: () => {
|
|
183
|
+
G || L();
|
|
184
|
+
}
|
|
185
|
+
}), /* @__PURE__ */ v(a, {
|
|
186
|
+
id: `${P}-editable-field-cancel`,
|
|
187
|
+
variant: o.Secondary,
|
|
188
|
+
icon: /* @__PURE__ */ v(ne, {
|
|
189
|
+
color: "currentColor",
|
|
190
|
+
size: d.Small
|
|
191
|
+
}),
|
|
192
|
+
"aria-label": "Cancel",
|
|
193
|
+
isDisabled: j,
|
|
194
|
+
onClick: () => {
|
|
195
|
+
G || I();
|
|
196
|
+
}
|
|
197
|
+
})]
|
|
146
198
|
})
|
|
147
|
-
]
|
|
148
|
-
})
|
|
149
|
-
|
|
150
|
-
variant: t.Plain,
|
|
151
|
-
icon: /* @__PURE__ */ g(r, {
|
|
152
|
-
color: a.GrayDark,
|
|
153
|
-
size: s.Small
|
|
154
|
-
}),
|
|
155
|
-
"aria-label": "Save",
|
|
156
|
-
onClick: h
|
|
157
|
-
}), /* @__PURE__ */ g(e, {
|
|
158
|
-
id: `${N}-editable-field-cancel`,
|
|
159
|
-
variant: t.Plain,
|
|
160
|
-
icon: /* @__PURE__ */ g(i, {
|
|
161
|
-
color: a.GrayDark,
|
|
162
|
-
size: s.Small
|
|
163
|
-
}),
|
|
164
|
-
"aria-label": "Cancel",
|
|
165
|
-
onClick: m
|
|
166
|
-
})] })]
|
|
167
|
-
});
|
|
199
|
+
})]
|
|
200
|
+
});
|
|
201
|
+
};
|
|
168
202
|
//#endregion
|
|
169
|
-
export {
|
|
203
|
+
export { w as ContainerDirection, S as EditIconColor, C as EditIconSize, x as EditableFieldTextStyle, b as EditableFieldTone, k as default };
|
|
170
204
|
|
|
171
205
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/style.tsx","../src/types.ts","../src/index.tsx"],"sourcesContent":["import {borderRadius, gray80, lineHeight, spacing, white} from '@propellerads/stylevariables';\nimport styled, {css, keyframes} from 'styled-components';\nimport {ContainerDirection} from './types';\n\nconst spin = keyframes`\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n`;\n\ntype StyledEditableFieldWrapperProps = {\n $isEditable: boolean;\n $direction: ContainerDirection;\n};\n\ntype StyledEditableFieldInputWrapperProps = {\n $isEditable: boolean;\n $isLoading: boolean;\n};\n\nconst StyledEditableFieldWrapper = styled.div<StyledEditableFieldWrapperProps>`\n display: flex;\n width: fit-content;\n\n ${(props) =>\n props.$isEditable &&\n css`\n align-items: flex-end;\n flex-direction: ${props.$direction};\n width: 100%;\n `}\n`;\n\nconst StyledEditableFieldInputWrapper = styled.div<StyledEditableFieldInputWrapperProps>`\n box-shadow: inset 0 0 0 1px transparent;\n transition: box-shadow 0.3s ease, width 0.3s ease;\n border-radius: ${borderRadius}px;\n display: inline-flex;\n flex-direction: row;\n align-items: center;\n padding-right: 4px;\n\n &:hover {\n box-shadow: inset 0 0 0 1px ${gray80};\n }\n\n ${(props) =>\n props.$isEditable &&\n css`\n box-shadow: inset 0 0 0 1px ${props?.theme?.actionColor?.main || '#1787fc'} !important;\n width: 100%;\n `}\n\n ${(props) =>\n props.$isLoading &&\n css`\n box-shadow: inset 0 0 0 1px ${gray80} !important;\n padding-right: 20px;\n `}\n`;\n\nconst StyledEditableFieldInputSpinner = styled.div`\n position: relative;\n\n &:after {\n content: '';\n position: absolute;\n display: block;\n height: 14px;\n width: 14px;\n border: 1px solid;\n border-color: ${white} ${gray80} ${gray80};\n border-radius: 50%;\n animation: ${spin} 0.5s linear infinite;\n margin-top: -7px;\n }\n`;\n\nconst StyledEditableFieldInput = styled.input`\n outline: none;\n width: 100%;\n background: transparent;\n border: 0;\n resize: none;\n padding: ${spacing * 2}px;\n height: ${lineHeight}px;\n`;\n\nconst StyledEditableFieldValue = styled.div`\n outline: none;\n width: 100%;\n background: transparent;\n border: 0;\n resize: none;\n padding: ${spacing * 2}px;\n`;\n\nconst StyledEditableFieldIcon = styled.div`\n pointer-events: none;\n`;\n\nconst StyledEditableFieldActions = styled.div`\n display: flex;\n margin-top: ${spacing * 2}px;\n\n button {\n margin-left: ${spacing * 2}px;\n width: 36px;\n height: 36px;\n border-radius: ${borderRadius}px;\n border: solid 1px ${gray80};\n padding: 0;\n cursor: pointer;\n outline: none;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n\n &:hover {\n background-color: #e6e6e6;\n border-color: gray;\n color: #000;\n }\n }\n`;\n\nexport {\n StyledEditableFieldActions,\n StyledEditableFieldIcon,\n StyledEditableFieldInput,\n StyledEditableFieldInputSpinner,\n StyledEditableFieldInputWrapper,\n StyledEditableFieldValue,\n StyledEditableFieldWrapper,\n};\n","import type {ChangeEventHandler} from 'react';\nimport {Color, Size} from '@propellerads/icon';\n\nexport const EditIconColor = {\n Gray: Color.GrayDark,\n Blue: Color.Blue,\n} as const;\nexport type EditIconColor = (typeof EditIconColor)[keyof typeof EditIconColor];\n\nexport const EditIconSize = {\n Small: Size.Small,\n Medium: Size.Medium,\n} as const;\nexport type EditIconSize = (typeof EditIconSize)[keyof typeof EditIconSize];\n\nexport const ContainerDirection = {\n Row: 'row',\n Column: 'column',\n} as const;\nexport type ContainerDirection = (typeof ContainerDirection)[keyof typeof ContainerDirection];\n\nexport type EditableFieldProps = {\n errors?: string[];\n value: string;\n isLoading: boolean;\n isEditable: boolean;\n fieldClassName?: string;\n editIconColor?: EditIconColor;\n editIconSize?: EditIconSize;\n containerDirection?: ContainerDirection;\n elementId: string;\n onFocus: () => void;\n onCancel: () => void;\n onSave: () => void;\n onChange: ChangeEventHandler<HTMLInputElement>;\n onErrorClick?: () => void;\n};\n","import Button, {ButtonVariant} from '@propellerads/button';\nimport ErrorLabel from '@propellerads/error-label';\nimport {Check, Close, Color, Edit, Size} from '@propellerads/icon';\nimport type {FC} from 'react';\nimport {\n StyledEditableFieldActions,\n StyledEditableFieldIcon,\n StyledEditableFieldInput,\n StyledEditableFieldInputSpinner,\n StyledEditableFieldInputWrapper,\n StyledEditableFieldValue,\n StyledEditableFieldWrapper,\n} from './style';\nimport {ContainerDirection, type EditableFieldProps, EditIconColor, EditIconSize} from './types';\n\nconst EditableField: FC<EditableFieldProps> = ({\n value,\n errors = [],\n isLoading,\n isEditable,\n onFocus,\n fieldClassName = '',\n onCancel,\n onSave,\n onChange,\n onErrorClick,\n editIconColor = EditIconColor.Gray,\n editIconSize = EditIconSize.Medium,\n containerDirection = ContainerDirection.Column,\n elementId,\n}) => (\n <StyledEditableFieldWrapper $isEditable={isEditable} $direction={containerDirection}>\n <StyledEditableFieldInputWrapper $isEditable={isEditable} $isLoading={isLoading}>\n {isEditable && (\n <StyledEditableFieldInput className={fieldClassName} value={value} disabled={isLoading} onChange={onChange} />\n )}\n {!isEditable && (\n <StyledEditableFieldValue className={fieldClassName} onClick={onFocus}>\n {value}\n </StyledEditableFieldValue>\n )}\n <ErrorLabel elementId={elementId} errors={errors} {...(onErrorClick ? {onClick: onErrorClick} : {})} />\n {isLoading && <StyledEditableFieldInputSpinner />}\n {!isEditable && !isLoading && (\n <Button\n id={`${elementId}-editable-field-icon`}\n variant={ButtonVariant.Plain}\n icon={\n <StyledEditableFieldIcon className={fieldClassName}>\n <Edit color={editIconColor} size={editIconSize} />\n </StyledEditableFieldIcon>\n }\n aria-label=\"Edit\"\n onClick={onFocus}\n />\n )}\n </StyledEditableFieldInputWrapper>\n {isEditable && !isLoading && (\n <StyledEditableFieldActions>\n <Button\n id={`${elementId}-editable-field-save`}\n variant={ButtonVariant.Plain}\n icon={<Check color={Color.GrayDark} size={Size.Small} />}\n aria-label=\"Save\"\n onClick={onSave}\n />\n <Button\n id={`${elementId}-editable-field-cancel`}\n variant={ButtonVariant.Plain}\n icon={<Close color={Color.GrayDark} size={Size.Small} />}\n aria-label=\"Cancel\"\n onClick={onCancel}\n />\n </StyledEditableFieldActions>\n )}\n </StyledEditableFieldWrapper>\n);\n\nexport default EditableField;\nexport type {EditableFieldProps} from './types';\nexport {ContainerDirection, EditIconColor, EditIconSize} from './types';\n"],"mappings":";;;;;;;AAIA,IAAM,IAAO,CAAS;;;;;;;GAmBhB,IAA6B,EAAO,GAAoC;;;;KAIzE,MACD,EAAM,eACN,CAAG;;wBAEiB,EAAM,WAAW;;MAEnC;GAGA,IAAkC,EAAO,GAAyC;;;mBAGrE,EAAa;;;;;;;kCAOE,EAAO;;;KAGpC,MACD,EAAM,eACN,CAAG;oCAC6B,GAAO,OAAO,aAAa,QAAQ,UAAU;;MAE3E;;KAED,MACD,EAAM,cACN,CAAG;oCAC6B,EAAO;;MAErC;GAGA,IAAkC,EAAO,GAAG;;;;;;;;;;oBAU9B,EAAM,GAAG,EAAO,GAAG,EAAO;;iBAE7B,EAAK;;;GAKhB,IAA2B,EAAO,KAAK;;;;;;aAMhC,IAAU,EAAE;YACb,EAAW;GAGjB,IAA2B,EAAO,GAAG;;;;;;aAM9B,IAAU,EAAE;GAGnB,IAA0B,EAAO,GAAG;;GAIpC,IAA6B,EAAO,GAAG;;gBAE7B,IAAU,EAAE;;;mBAGT,IAAU,EAAE;;;qBAGV,EAAa;wBACV,EAAO;;;;;;;;;;;;;;GC9Gl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AAO,EAAM;GAAU,MAAM,EAAK;GAAS,CAAA;EACxD,cAAW;EACX,SAAS;EACT,CAAA,CACyB,EAAA,CAAA,CAEJ"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/cn.ts","../src/types.ts","../src/index.tsx"],"sourcesContent":["import {type ClassValue, clsx} from 'clsx';\n\n/**\n * Joins class names. There is no tailwind-merge here on purpose: the editable field\n * ships its own stylesheet instead of utility classes, so there is nothing to\n * deduplicate.\n */\nconst cn = (...inputs: ClassValue[]): string => clsx(inputs);\n\nexport {cn};\n","import {Color, Size} from '@propellerads/icon';\nimport type {ChangeEventHandler} from 'react';\n\n/** Which colour the errors are shown in. */\nexport const EditableFieldTone = {\n /** Something is wrong and has to be fixed. */\n Danger: 'danger',\n /** Something is allowed but worth a second look. */\n Warning: 'warning',\n} as const;\nexport type EditableFieldTone = (typeof EditableFieldTone)[keyof typeof EditableFieldTone];\n\n/**\n * The type the value is set in, from @propellerads/tokens. The same in view and\n * in edit. The description and the hint sizes are left out: a value that small\n * is not something to edit in place. So is hero: it does not fit the 36px box.\n */\nexport const EditableFieldTextStyle = {\n H1: 'h1',\n H2: 'h2',\n H3: 'h3',\n H4: 'h4',\n Text: 'text',\n Paragraph: 'paragraph',\n} as const;\nexport type EditableFieldTextStyle = (typeof EditableFieldTextStyle)[keyof typeof EditableFieldTextStyle];\n\n/** @deprecated The pencil is an inline button in the action tone now. Accepted and ignored. */\nexport const EditIconColor = {\n Gray: Color.GrayDark,\n Blue: Color.Blue,\n} as const;\nexport type EditIconColor = (typeof EditIconColor)[keyof typeof EditIconColor];\n\n/** @deprecated The pencil takes the button's icon size now. Accepted and ignored. */\nexport const EditIconSize = {\n Small: Size.Small,\n Medium: Size.Medium,\n} as const;\nexport type EditIconSize = (typeof EditIconSize)[keyof typeof EditIconSize];\n\n/**\n * @deprecated The actions float over the page now and take no room beside the\n * field, so there is no direction to lay them out in. Accepted and ignored.\n */\nexport const ContainerDirection = {\n Row: 'row',\n Column: 'column',\n} as const;\nexport type ContainerDirection = (typeof ContainerDirection)[keyof typeof ContainerDirection];\n\nexport type EditableFieldProps = {\n errors?: ReadonlyArray<string>;\n /** Which colour the errors are shown in. @default 'danger' */\n tone?: EditableFieldTone;\n /**\n * A note on what the value is for, behind a grey `i` mark at the end of the\n * input while the field is edited. It gives way to `errors`.\n */\n hint?: string;\n value: string;\n /** The type the value is set in, in view and in edit. @default 'text' */\n textStyle?: EditableFieldTextStyle;\n /**\n * Forbids saving an empty value: save is switched off and Enter does nothing\n * while the input holds only spaces. Otherwise an empty value is saved and\n * leaves the pencil alone. @default false\n */\n isRequired?: boolean;\n /** Spinner on the pencil or on save, and the input switched off. */\n isLoading: boolean;\n /** The input and its actions, instead of the text and the pencil. Controlled by the caller. */\n isEditable: boolean;\n /** On the text in view and on the `<input>` in edit, as in v4. */\n fieldClassName?: string;\n /** @deprecated Accepted and ignored: the pencil is an inline button in the action tone. */\n editIconColor?: EditIconColor;\n /** @deprecated Accepted and ignored: the pencil takes the button's icon size. */\n editIconSize?: EditIconSize;\n /** @deprecated Accepted and ignored: the actions float. */\n containerDirection?: ContainerDirection;\n /**\n * Names the parts, as v4 did: the pencil is `${elementId}-editable-field-icon`,\n * the actions `${elementId}-editable-field-save` and `-cancel`.\n */\n elementId: string;\n /** Asks to edit: a click on the text or the pencil. */\n onFocus: () => void;\n /** The cancel button, or Escape. */\n onCancel: () => void;\n /** The save button, or Enter in the input. */\n onSave: () => void;\n onChange: ChangeEventHandler<HTMLInputElement>;\n /** Called when the `!` mark is clicked. */\n onErrorClick?: () => void;\n};\n","import {Popover} from '@base-ui-components/react/popover';\nimport {autoUpdate, flip, offset, shift, useFloating} from '@floating-ui/react-dom';\nimport Button, {ButtonVariant} from '@propellerads/button';\nimport ErrorLabel, {errorLabelTextId} from '@propellerads/error-label';\nimport {Check, Close, Edit, Size} from '@propellerads/icon';\nimport {InputGroup, InputGroupAddon, InputGroupInput} from '@propellerads/input';\nimport {type KeyboardEvent, useEffect, useRef, useState} from 'react';\nimport './editable-field.css';\nimport {cn} from './cn';\nimport {\n ContainerDirection,\n type EditableFieldProps,\n EditableFieldTextStyle,\n EditableFieldTone,\n EditIconColor,\n EditIconSize,\n} from './types';\n\n/*\n * Whether the last thing done on the page was a key or a pointer. A text input\n * matches :focus-visible on a click as well — a browser expects typing either\n * way — so the ring cannot lean on it: a click already turns the contour blue,\n * and the ring is for the keyboard. Kept once for the page, as the\n * focus-visible polyfill did.\n */\nlet isKeyboardModality = true;\nlet isTrackingModality = false;\n\nconst trackModality = (): void => {\n if (isTrackingModality) {\n return;\n }\n isTrackingModality = true;\n document.addEventListener(\n 'keydown',\n (event) => {\n if (!event.metaKey && !event.altKey && !event.ctrlKey) {\n isKeyboardModality = true;\n }\n },\n true,\n );\n document.addEventListener(\n 'pointerdown',\n () => {\n isKeyboardModality = false;\n },\n true,\n );\n};\n\n/** The id of the hidden hint text the input is described by. */\nconst hintTextId = (elementId: string): string => `${elementId}-editable-field-hint-text`;\n\n/**\n * The `i` mark and the hint behind it. The mark is ErrorLabel's in shape — a\n * 20px disc, the glyph in the page colour — and grey, in the icon colour,\n * because nothing is wrong. The hint is the dark tooltip the products use,\n * made of the two ends that turn over with the theme. It opens on hover and on\n * click, and the same text is kept beside the mark for a screen reader.\n */\nconst HintMark = ({elementId, hint}: {elementId: string; hint: string}) => (\n <span className=\"editable-field__hint\">\n <span id={hintTextId(elementId)} hidden>\n {hint}\n </span>\n <Popover.Root>\n <Popover.Trigger\n id={`${elementId}-editable-field-hint`}\n className=\"editable-field__hint-mark\"\n aria-label=\"Hint\"\n openOnHover\n delay={100}\n closeDelay={100}\n >\n i\n </Popover.Trigger>\n <Popover.Portal>\n <Popover.Positioner className=\"editable-field__hint-positioner\" side=\"top\" sideOffset={8} collisionPadding={8}>\n <Popover.Popup className=\"editable-field__hint-popup\">\n <Popover.Arrow className=\"editable-field__hint-arrow\" />\n {hint}\n </Popover.Popup>\n </Popover.Positioner>\n </Popover.Portal>\n </Popover.Root>\n </span>\n);\n\n/**\n * A value that turns into an input in place.\n *\n * In view the field is as large as its text and the pencil: no box, no inset.\n * In edit the box is drawn outward, around the text, so the text stays where it\n * was and nothing beside the field moves.\n *\n * The save and cancel buttons float under the field instead of standing beside\n * it: they take no room, so a table row does not grow and a form does not jump.\n * They are rendered right after the input and placed by Floating UI with\n * `position: fixed` — so Tab goes from the input to the actions and on, and a\n * cell with `overflow: hidden` still does not clip them. At the bottom of the\n * screen they flip above the field.\n *\n * An empty value can be saved unless the field is required; saved, it leaves\n * the pencil alone.\n *\n * Enter saves and Escape cancels. A click outside does nothing: an edit is not\n * thrown away by a stray click.\n */\nconst EditableField = ({\n value,\n errors = [],\n tone = EditableFieldTone.Danger,\n hint,\n textStyle = EditableFieldTextStyle.Text,\n isRequired = false,\n isLoading,\n isEditable,\n fieldClassName,\n // Accepted for v4 and ignored: the pencil is a button of its own now.\n editIconColor: _editIconColor = EditIconColor.Gray,\n editIconSize: _editIconSize = EditIconSize.Medium,\n // Accepted for v4 and ignored: the actions float.\n containerDirection: _containerDirection = ContainerDirection.Column,\n elementId,\n onFocus,\n onCancel,\n onSave,\n onChange,\n onErrorClick,\n}: EditableFieldProps) => {\n const rootRef = useRef<HTMLDivElement>(null);\n const editRef = useRef<HTMLButtonElement>(null);\n const wasOpen = useRef(isEditable);\n const [isFocusVisible, setFocusVisible] = useState(false);\n\n // The edit leaves the way it came: for a moment after the caller closes the\n // field, the box stays, its contour fades and the actions drop away, and only\n // then the text takes its place. The input and the text stand in the same\n // spot and the box is the page colour, so the swap itself does not show.\n // Worked out while rendering, so there is no frame without the box.\n const [isClosing, setClosing] = useState(false);\n const [lastEditable, setLastEditable] = useState(isEditable);\n if (isEditable !== lastEditable) {\n setLastEditable(isEditable);\n setClosing(!isEditable);\n }\n const isOpen = isEditable || isClosing;\n\n // The fade ends the closing; the timer is there for when no transition runs —\n // no tokens, or a stylesheet that switches motion off.\n useEffect(() => {\n if (!isClosing) {\n return undefined;\n }\n const timer = setTimeout(() => setClosing(false), 400);\n return () => clearTimeout(timer);\n }, [isClosing]);\n\n const isInvalid = errors.length > 0;\n // A hint belongs to the edit, as errors do: the value in view says nothing\n // more. It gives way to errors — when something is wrong, that is what to say.\n const hasHint = isOpen && !isInvalid && hint !== undefined && hint.trim() !== '';\n const isEmpty = value.trim() === '';\n const isSaveBlocked = isRequired && isEmpty;\n\n useEffect(trackModality, []);\n\n // Base UI's Popover would place the actions too, but it manages the focus of\n // what it portals: with no trigger to hand the focus back to, it takes the\n // buttons out of the tab order once the focus has left them. Floating UI\n // only places them.\n const {refs, floatingStyles, placement} = useFloating({\n open: isOpen,\n strategy: 'fixed',\n placement: 'bottom-end',\n // Four pixels under the box, and four to the right: the pad's own inset, so\n // the buttons, not the pad, line up with the end of the box.\n middleware: [offset({mainAxis: 4, crossAxis: 4}), flip({padding: 8}), shift({padding: 8})],\n whileElementsMounted: autoUpdate,\n });\n\n // When the edit ends, the input goes and the focus with it. If it was inside\n // the field, it comes back to the pencil, so the keyboard stays where it was.\n useEffect(() => {\n if (wasOpen.current && !isOpen) {\n const active = document.activeElement;\n if (active === null || active === document.body || rootRef.current?.contains(active)) {\n editRef.current?.focus();\n }\n }\n wasOpen.current = isOpen;\n }, [isOpen]);\n\n const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>): void => {\n if (isClosing) {\n return;\n }\n\n if (event.key === 'Enter' && !isLoading) {\n event.preventDefault();\n if (!isSaveBlocked) {\n onSave();\n }\n }\n\n if (event.key === 'Escape') {\n event.preventDefault();\n onCancel();\n }\n };\n\n // Escape on one of the actions cancels this field too.\n const handleActionsKeyDown = (event: KeyboardEvent<HTMLDivElement>): void => {\n if (event.key === 'Escape' && !isLoading && !isClosing) {\n event.preventDefault();\n onCancel();\n }\n };\n\n const errorLabel = isInvalid ? (\n <ErrorLabel elementId={elementId} errors={errors} tone={tone} onClick={onErrorClick} />\n ) : (\n hasHint && <HintMark elementId={elementId} hint={hint} />\n );\n\n return (\n <div\n ref={rootRef}\n className=\"editable-field\"\n data-editing={isOpen || undefined}\n data-closing={isClosing || undefined}\n data-loading={isLoading || undefined}\n data-text-style={textStyle}\n >\n {isOpen ? (\n <InputGroup\n ref={refs.setReference}\n tone={tone}\n isInvalid={isInvalid}\n className=\"editable-field__box\"\n data-focus-visible={isFocusVisible || undefined}\n onTransitionEnd={(event) => {\n if (isClosing && event.target === event.currentTarget && event.propertyName === 'box-shadow') {\n setClosing(false);\n }\n }}\n >\n <InputGroupInput\n className={fieldClassName}\n value={value}\n onChange={onChange}\n onKeyDown={handleKeyDown}\n onFocus={() => setFocusVisible(isKeyboardModality)}\n onBlur={() => setFocusVisible(false)}\n onPointerDown={() => setFocusVisible(false)}\n disabled={isLoading}\n readOnly={isClosing}\n tabIndex={isClosing ? -1 : undefined}\n // The field opens because it was asked to; the typing goes straight in.\n autoFocus\n aria-label=\"Value\"\n {...(isInvalid ? {'aria-invalid': true, 'aria-describedby': errorLabelTextId(elementId)} : {})}\n {...(hasHint ? {'aria-describedby': hintTextId(elementId)} : {})}\n />\n {(isInvalid || hasHint) && <InputGroupAddon>{errorLabel}</InputGroupAddon>}\n </InputGroup>\n ) : (\n <div className=\"editable-field__view\">\n {!isEmpty && (\n // biome-ignore lint/a11y/useKeyWithClickEvents: the pencil beside it is the keyboard's way in; this is a larger target for the pointer.\n <span className={cn('editable-field__value', fieldClassName)} onClick={onFocus}>\n {value}\n </span>\n )}\n {errorLabel}\n <Button\n ref={editRef}\n id={`${elementId}-editable-field-icon`}\n className=\"editable-field__edit\"\n variant={ButtonVariant.Inline}\n icon={<Edit color=\"currentColor\" size={Size.Small} />}\n aria-label=\"Edit\"\n isLoading={isLoading}\n onClick={onFocus}\n />\n </div>\n )}\n\n {/*\n Right after the input, so Tab goes to them next. The caller owns the open\n state, and nothing here changes it: Escape is handled for this one field,\n and a click outside is ignored on purpose.\n */}\n {isOpen && (\n <div ref={refs.setFloating} className=\"editable-field__positioner\" style={floatingStyles}>\n <div\n className=\"editable-field__actions\"\n data-side={placement.startsWith('top') ? 'top' : 'bottom'}\n aria-hidden={isClosing || undefined}\n onKeyDown={handleActionsKeyDown}\n >\n <Button\n id={`${elementId}-editable-field-save`}\n variant={ButtonVariant.Primary}\n icon={<Check color=\"currentColor\" size={Size.Small} />}\n aria-label=\"Save\"\n isLoading={isLoading}\n isDisabled={isSaveBlocked}\n onClick={() => {\n if (!isClosing) {\n onSave();\n }\n }}\n />\n <Button\n id={`${elementId}-editable-field-cancel`}\n variant={ButtonVariant.Secondary}\n icon={<Close color=\"currentColor\" size={Size.Small} />}\n aria-label=\"Cancel\"\n isDisabled={isLoading}\n onClick={() => {\n if (!isClosing) {\n onCancel();\n }\n }}\n />\n </div>\n </div>\n )}\n </div>\n );\n};\n\nexport default EditableField;\n\nexport type {EditableFieldProps} from './types';\nexport {ContainerDirection, EditableFieldTextStyle, EditableFieldTone, EditIconColor, EditIconSize} from './types';\n"],"mappings":";;;;;;;;;;AAOA,IAAM,MAAM,GAAG,MAAiC,EAAK,EAAO,ECH/C,IAAoB;CAE/B,QAAQ;CAER,SAAS;CACV,EAQY,IAAyB;CACpC,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,MAAM;CACN,WAAW;CACZ,EAIY,IAAgB;CAC3B,MAAM,EAAM;CACZ,MAAM,EAAM;CACb,EAIY,IAAe;CAC1B,OAAO,EAAK;CACZ,QAAQ,EAAK;CACd,EAOY,IAAqB;CAChC,KAAK;CACL,QAAQ;CACT,ECvBG,IAAqB,IACrB,IAAqB,IAEnB,WAA4B;CAC5B,MAGJ,IAAqB,IACrB,SAAS,iBACP,YACC,MAAU;EACT,AAAI,CAAC,EAAM,WAAW,CAAC,EAAM,UAAU,CAAC,EAAM,YAC5C,IAAqB;IAGzB,GACD,EACD,SAAS,iBACP,qBACM;EACJ,IAAqB;IAEvB,GACD;GAIG,KAAc,MAA8B,GAAG,EAAU,4BASzD,KAAY,EAAC,cAAW,cAC5B,kBAAC,QAAD;CAAM,WAAU;WAAh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EAAU;KACjB,SAAS,EAAc;KACvB,MAAM,kBAAC,IAAD;MAAO,OAAM;MAAe,MAAM,EAAK;MAAS,CAAA;KACtD,cAAW;KACX,YAAY;KACZ,eAAe;MACb,AAAK,KACH,GAAU;;KAGd,CAAA,CACE;;GACF,CAAA,CAEJ"}
|
package/package.json
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@propellerads/editable-field",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
|
+
"style": "dist/index.css",
|
|
6
7
|
"exports": {
|
|
7
8
|
".": {
|
|
8
9
|
"types": "./dist/index.d.ts",
|
|
9
10
|
"import": "./dist/index.js"
|
|
10
|
-
}
|
|
11
|
+
},
|
|
12
|
+
"./index.css": "./dist/index.css"
|
|
11
13
|
},
|
|
14
|
+
"sideEffects": [
|
|
15
|
+
"**/*.css"
|
|
16
|
+
],
|
|
12
17
|
"files": [
|
|
13
18
|
"dist"
|
|
14
19
|
],
|
|
@@ -24,22 +29,33 @@
|
|
|
24
29
|
"homepage": "https://github.com/propellerads/ui-components#readme",
|
|
25
30
|
"private": false,
|
|
26
31
|
"dependencies": {
|
|
32
|
+
"@base-ui-components/react": "1.0.0-rc.0",
|
|
33
|
+
"@floating-ui/react-dom": "^2.1.6",
|
|
27
34
|
"@propellerads/button": "^11.0.0",
|
|
28
|
-
"@propellerads/error-label": "^
|
|
35
|
+
"@propellerads/error-label": "^6.0.0",
|
|
29
36
|
"@propellerads/icon": "^8.0.0",
|
|
30
|
-
"@propellerads/
|
|
31
|
-
"
|
|
37
|
+
"@propellerads/input": "^0.1.0",
|
|
38
|
+
"clsx": "^2.1.1"
|
|
32
39
|
},
|
|
33
40
|
"peerDependencies": {
|
|
41
|
+
"@propellerads/tokens": ">=0.2.0",
|
|
34
42
|
"react": "^18.0.0 || ^19.0.0",
|
|
43
|
+
"react-dom": "^18.0.0 || ^19.0.0",
|
|
35
44
|
"styled-components": "^5.1.1 || ^6.0.0"
|
|
36
45
|
},
|
|
46
|
+
"peerDependenciesMeta": {
|
|
47
|
+
"@propellerads/tokens": {
|
|
48
|
+
"optional": true
|
|
49
|
+
}
|
|
50
|
+
},
|
|
37
51
|
"devDependencies": {
|
|
52
|
+
"@propellerads/tokens": "workspace:^",
|
|
38
53
|
"@types/react": "^19.2.14",
|
|
39
54
|
"@vitejs/plugin-react": "^6.0.1",
|
|
40
55
|
"rollup": "^4.60.3",
|
|
41
56
|
"rollup-plugin-dts": "^6.4.1",
|
|
42
57
|
"typescript": "^6.0.3",
|
|
43
|
-
"vite": "^8.0.10"
|
|
58
|
+
"vite": "^8.0.10",
|
|
59
|
+
"vite-plugin-lib-inject-css": "^2.2.2"
|
|
44
60
|
}
|
|
45
61
|
}
|