@propellerads/editable-field 4.0.0 → 4.0.2

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 CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  ## Installation
10
10
 
11
- - `yarn add @propellerads/editable-field` or `npm install @propellerads/editable-field -S`
11
+ - `bun add @propellerads/editable-field` or `npm install @propellerads/editable-field -S`
12
12
 
13
13
  ### How to use
14
14
 
package/dist/index.js CHANGED
@@ -1,48 +1,49 @@
1
- import { jsxs as p, jsx as e } from "react/jsx-runtime";
2
- import m, { ButtonType as h } from "@propellerads/button";
3
- import C from "@propellerads/error-label";
4
- import { Color as l, Size as a, Edit as E, Check as z, Close as F } from "@propellerads/icon";
5
- import { borderRadius as u, gray80 as r, white as I, lineHeight as G, spacing as s } from "@propellerads/stylevariables";
6
- import t, { keyframes as B, css as x } from "styled-components";
7
- const D = B`
1
+ import e, { ButtonType as t } from "@propellerads/button";
2
+ import n from "@propellerads/error-label";
3
+ import { Check as r, Close as i, Color as a, Edit as o, Size as s } from "@propellerads/icon";
4
+ import { borderRadius as c, gray80 as l, lineHeight as u, spacing as d, white as f } from "@propellerads/stylevariables";
5
+ import p, { css as m, keyframes as h } from "styled-components";
6
+ import { jsx as g, jsxs as _ } from "react/jsx-runtime";
7
+ //#region src/style.tsx
8
+ var v = h`
8
9
  0% {
9
10
  transform: rotate(0deg);
10
11
  }
11
12
  100% {
12
13
  transform: rotate(360deg);
13
14
  }
14
- `, j = t.div`
15
+ `, y = p.div`
15
16
  display: flex;
16
17
  width: fit-content;
17
18
 
18
- ${(i) => i.$isEditable && x`
19
+ ${(e) => e.$isEditable && m`
19
20
  align-items: flex-end;
20
- flex-direction: ${i.$direction};
21
+ flex-direction: ${e.$direction};
21
22
  width: 100%;
22
23
  `}
23
- `, M = t.div`
24
+ `, b = p.div`
24
25
  box-shadow: inset 0 0 0 1px transparent;
25
26
  transition: box-shadow 0.3s ease, width 0.3s ease;
26
- border-radius: ${u}px;
27
+ border-radius: ${c}px;
27
28
  display: inline-flex;
28
29
  flex-direction: row;
29
30
  align-items: center;
30
31
  padding-right: 4px;
31
32
 
32
33
  &:hover {
33
- box-shadow: inset 0 0 0 1px ${r};
34
+ box-shadow: inset 0 0 0 1px ${l};
34
35
  }
35
36
 
36
- ${(i) => i.$isEditable && x`
37
- box-shadow: inset 0 0 0 1px ${i?.theme?.actionColor?.main || "#1787fc"} !important;
37
+ ${(e) => e.$isEditable && m`
38
+ box-shadow: inset 0 0 0 1px ${e?.theme?.actionColor?.main || "#1787fc"} !important;
38
39
  width: 100%;
39
40
  `}
40
41
 
41
- ${(i) => i.$isLoading && x`
42
- box-shadow: inset 0 0 0 1px ${r} !important;
42
+ ${(e) => e.$isLoading && m`
43
+ box-shadow: inset 0 0 0 1px ${l} !important;
43
44
  padding-right: 20px;
44
45
  `}
45
- `, P = t.div`
46
+ `, x = p.div`
46
47
  position: relative;
47
48
 
48
49
  &:after {
@@ -52,38 +53,38 @@ const D = B`
52
53
  height: 14px;
53
54
  width: 14px;
54
55
  border: 1px solid;
55
- border-color: ${I} ${r} ${r};
56
+ border-color: ${f} ${l} ${l};
56
57
  border-radius: 50%;
57
- animation: ${D} 0.5s linear infinite;
58
+ animation: ${v} 0.5s linear infinite;
58
59
  margin-top: -7px;
59
60
  }
60
- `, R = t.input`
61
+ `, S = p.input`
61
62
  outline: none;
62
63
  width: 100%;
63
64
  background: transparent;
64
65
  border: 0;
65
66
  resize: none;
66
- padding: ${s * 2}px;
67
- height: ${G}px;
68
- `, W = t.div`
67
+ padding: ${d * 2}px;
68
+ height: ${u}px;
69
+ `, C = p.div`
69
70
  outline: none;
70
71
  width: 100%;
71
72
  background: transparent;
72
73
  border: 0;
73
74
  resize: none;
74
- padding: ${s * 2}px;
75
- `, A = t.div`
75
+ padding: ${d * 2}px;
76
+ `, w = p.div`
76
77
  pointer-events: none;
77
- `, H = t.div`
78
+ `, T = p.div`
78
79
  display: flex;
79
- margin-top: ${s * 2}px;
80
+ margin-top: ${d * 2}px;
80
81
 
81
82
  button {
82
- margin-left: ${s * 2}px;
83
+ margin-left: ${d * 2}px;
83
84
  width: 36px;
84
85
  height: 36px;
85
- border-radius: ${u}px;
86
- border: solid 1px ${r};
86
+ border-radius: ${c}px;
87
+ border: solid 1px ${l};
87
88
  padding: 0;
88
89
  cursor: pointer;
89
90
  outline: none;
@@ -97,47 +98,71 @@ const D = B`
97
98
  color: #000;
98
99
  }
99
100
  }
100
- `, N = {
101
- Gray: l.GrayDark,
102
- Blue: l.Blue
103
- }, T = {
104
- Small: a.Small,
105
- Medium: a.Medium
106
- }, V = {
107
- Row: "row",
108
- Column: "column"
109
- }, X = ({
110
- value: i,
111
- errors: y = [],
112
- isLoading: o,
113
- isEditable: n,
114
- onFocus: b,
115
- fieldClassName: c = "",
116
- onCancel: f,
117
- onSave: g,
118
- onChange: w,
119
- onErrorClick: $,
120
- editIconColor: S = N.Gray,
121
- editIconSize: k = T.Medium,
122
- containerDirection: v = V.Column,
123
- elementId: d
124
- }) => /* @__PURE__ */ p(j, { $isEditable: n, $direction: v, children: [
125
- /* @__PURE__ */ p(M, { $isEditable: n, $isLoading: o, children: [
126
- n && /* @__PURE__ */ e(R, { className: c, value: i, disabled: o, onChange: w }),
127
- !n && /* @__PURE__ */ e(W, { className: c, onClick: b, children: i }),
128
- /* @__PURE__ */ e(C, { elementId: d, errors: y, ...$ ? { onClick: $ } : {} }),
129
- o && /* @__PURE__ */ e(P, {}),
130
- !n && !o && /* @__PURE__ */ e(m, { elementId: `${d}-editable-field-icon`, type: h.Plain, onClick: b, children: /* @__PURE__ */ e(A, { className: c, children: /* @__PURE__ */ e(E, { color: S, size: k }) }) })
131
- ] }),
132
- n && !o && /* @__PURE__ */ p(H, { children: [
133
- /* @__PURE__ */ e(m, { elementId: `${d}-editable-field-save`, type: h.Plain, onClick: g, children: /* @__PURE__ */ e(z, { color: l.GrayDark, size: a.Small }) }),
134
- /* @__PURE__ */ e(m, { elementId: `${d}-editable-field-cancel`, type: h.Plain, onClick: f, children: /* @__PURE__ */ e(F, { color: l.GrayDark, size: a.Small }) })
135
- ] })
136
- ] });
137
- export {
138
- V as ContainerDirection,
139
- N as EditIconColor,
140
- T as EditIconSize,
141
- X as default
142
- };
143
- //# sourceMappingURL=index.js.map
101
+ `, E = {
102
+ Gray: a.GrayDark,
103
+ Blue: a.Blue
104
+ }, D = {
105
+ Small: s.Small,
106
+ Medium: s.Medium
107
+ }, O = {
108
+ Row: "row",
109
+ Column: "column"
110
+ }, k = ({ value: c, errors: l = [], isLoading: u, isEditable: d, onFocus: f, fieldClassName: p = "", onCancel: m, onSave: h, onChange: v, onErrorClick: k, editIconColor: A = E.Gray, editIconSize: j = D.Medium, containerDirection: M = O.Column, elementId: N }) => /* @__PURE__ */ _(y, {
111
+ $isEditable: d,
112
+ $direction: M,
113
+ children: [/* @__PURE__ */ _(b, {
114
+ $isEditable: d,
115
+ $isLoading: u,
116
+ children: [
117
+ d && /* @__PURE__ */ g(S, {
118
+ className: p,
119
+ value: c,
120
+ disabled: u,
121
+ onChange: v
122
+ }),
123
+ !d && /* @__PURE__ */ g(C, {
124
+ className: p,
125
+ onClick: f,
126
+ children: c
127
+ }),
128
+ /* @__PURE__ */ g(n, {
129
+ elementId: N,
130
+ errors: l,
131
+ ...k ? { onClick: k } : {}
132
+ }),
133
+ u && /* @__PURE__ */ g(x, {}),
134
+ !d && !u && /* @__PURE__ */ g(e, {
135
+ elementId: `${N}-editable-field-icon`,
136
+ type: t.Plain,
137
+ onClick: f,
138
+ children: /* @__PURE__ */ g(w, {
139
+ className: p,
140
+ children: /* @__PURE__ */ g(o, {
141
+ color: A,
142
+ size: j
143
+ })
144
+ })
145
+ })
146
+ ]
147
+ }), d && !u && /* @__PURE__ */ _(T, { children: [/* @__PURE__ */ g(e, {
148
+ elementId: `${N}-editable-field-save`,
149
+ type: t.Plain,
150
+ onClick: h,
151
+ children: /* @__PURE__ */ g(r, {
152
+ color: a.GrayDark,
153
+ size: s.Small
154
+ })
155
+ }), /* @__PURE__ */ g(e, {
156
+ elementId: `${N}-editable-field-cancel`,
157
+ type: t.Plain,
158
+ onClick: m,
159
+ children: /* @__PURE__ */ g(i, {
160
+ color: a.GrayDark,
161
+ size: s.Small
162
+ })
163
+ })] })]
164
+ });
165
+ //#endregion
166
+ export { O as ContainerDirection, E as EditIconColor, D as EditIconSize, k as default };
167
+
168
+ //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","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 type {THEME} from '../../../ThemeComponent/types';\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 theme: THEME;\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, {ButtonType} 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, EditIconColor, EditIconSize, type EditableFieldProps} 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 elementId={`${elementId}-editable-field-icon`} type={ButtonType.Plain} onClick={onFocus}>\n <StyledEditableFieldIcon className={fieldClassName}>\n <Edit color={editIconColor} size={editIconSize} />\n </StyledEditableFieldIcon>\n </Button>\n )}\n </StyledEditableFieldInputWrapper>\n {isEditable && !isLoading && (\n <StyledEditableFieldActions>\n <Button elementId={`${elementId}-editable-field-save`} type={ButtonType.Plain} onClick={onSave}>\n <Check color={Color.GrayDark} size={Size.Small} />\n </Button>\n <Button elementId={`${elementId}-editable-field-cancel`} type={ButtonType.Plain} onClick={onCancel}>\n <Close color={Color.GrayDark} size={Size.Small} />\n </Button>\n </StyledEditableFieldActions>\n )}\n </StyledEditableFieldWrapper>\n);\n\nexport default EditableField;\nexport {ContainerDirection, EditIconColor, EditIconSize} from './types';\nexport type {EditableFieldProps} from './types';\n"],"names":["spin","keyframes","StyledEditableFieldWrapper","styled","props","css","StyledEditableFieldInputWrapper","borderRadius","gray80","StyledEditableFieldInputSpinner","white","StyledEditableFieldInput","spacing","lineHeight","StyledEditableFieldValue","StyledEditableFieldIcon","StyledEditableFieldActions","EditIconColor","Color","EditIconSize","Size","ContainerDirection","EditableField","value","errors","isLoading","isEditable","onFocus","fieldClassName","onCancel","onSave","onChange","onErrorClick","editIconColor","editIconSize","containerDirection","elementId","jsxs","jsx","ErrorLabel","Button","ButtonType","Edit","Check","Close"],"mappings":";;;;;;AAKA,MAAMA,IAAOC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAoBPC,IAA6BC,EAAO;AAAA;AAAA;AAAA;AAAA,IAItC,CAACC,MACDA,EAAM,eACNC;AAAA;AAAA,wBAEoBD,EAAM,UAAU;AAAA;AAAA,KAEnC;AAAA,GAGCE,IAAkCH,EAAO;AAAA;AAAA;AAAA,mBAG5BI,CAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kCAOGC,CAAM;AAAA;AAAA;AAAA,IAGpC,CAACJ,MACDA,EAAM,eACNC;AAAA,oCACgCD,GAAO,OAAO,aAAa,QAAQ,SAAS;AAAA;AAAA,KAE3E;AAAA;AAAA,IAED,CAACA,MACDA,EAAM,c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.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, {ButtonType} 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, EditIconColor, EditIconSize, type EditableFieldProps} 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 elementId={`${elementId}-editable-field-icon`} type={ButtonType.Plain} onClick={onFocus}>\n <StyledEditableFieldIcon className={fieldClassName}>\n <Edit color={editIconColor} size={editIconSize} />\n </StyledEditableFieldIcon>\n </Button>\n )}\n </StyledEditableFieldInputWrapper>\n {isEditable && !isLoading && (\n <StyledEditableFieldActions>\n <Button elementId={`${elementId}-editable-field-save`} type={ButtonType.Plain} onClick={onSave}>\n <Check color={Color.GrayDark} size={Size.Small} />\n </Button>\n <Button elementId={`${elementId}-editable-field-cancel`} type={ButtonType.Plain} onClick={onCancel}>\n <Close color={Color.GrayDark} size={Size.Small} />\n </Button>\n </StyledEditableFieldActions>\n )}\n </StyledEditableFieldWrapper>\n);\n\nexport default EditableField;\nexport {ContainerDirection, EditIconColor, EditIconSize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AA0B,WAAW;IAAgB,SAAS;cAC3D;IACwB,CAAA;GAE7B,kBAAC,GAAD;IAAuB;IAAmB;IAAQ,GAAK,IAAe,EAAC,SAAS,GAAa,GAAG,EAAE;IAAK,CAAA;GACtG,KAAa,kBAAC,GAAD,EAAmC,CAAA;GAChD,CAAC,KAAc,CAAC,KACf,kBAAC,GAAD;IAAQ,WAAW,GAAG,EAAU;IAAuB,MAAM,EAAW;IAAO,SAAS;cACtF,kBAAC,GAAD;KAAyB,WAAW;eAClC,kBAAC,GAAD;MAAM,OAAO;MAAe,MAAM;MAAgB,CAAA;KAC1B,CAAA;IACnB,CAAA;GAEqB;KACjC,KAAc,CAAC,KACd,kBAAC,GAAD,EAAA,UAAA,CACE,kBAAC,GAAD;EAAQ,WAAW,GAAG,EAAU;EAAuB,MAAM,EAAW;EAAO,SAAS;YACtF,kBAAC,GAAD;GAAO,OAAO,EAAM;GAAU,MAAM,EAAK;GAAS,CAAA;EAC3C,CAAA,EACT,kBAAC,GAAD;EAAQ,WAAW,GAAG,EAAU;EAAyB,MAAM,EAAW;EAAO,SAAS;YACxF,kBAAC,GAAD;GAAO,OAAO,EAAM;GAAU,MAAM,EAAK;GAAS,CAAA;EAC3C,CAAA,CACkB,EAAA,CAAA,CAEJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@propellerads/editable-field",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "type": "module",
5
5
  "types": "dist/index.d.ts",
6
6
  "exports": {
@@ -19,15 +19,16 @@
19
19
  "url": "https://github.com/propellerads/ui-components/issues"
20
20
  },
21
21
  "scripts": {
22
- "build": "tsc && vite build && rollup -c rollup.dts.config.mjs"
22
+ "build": "tsc && vite build && bunx rollup -c rollup.dts.config.mjs"
23
23
  },
24
24
  "homepage": "https://github.com/propellerads/ui-components#readme",
25
25
  "private": false,
26
26
  "dependencies": {
27
- "@propellerads/button": "^9.0.2",
27
+ "@propellerads/button": "^9.0.3",
28
28
  "@propellerads/error-label": "^5.0.2",
29
- "@propellerads/icon": "^7.1.1",
30
- "@propellerads/stylevariables": "^2.0.2"
29
+ "@propellerads/icon": "^8.0.0",
30
+ "@propellerads/stylevariables": "^2.0.2",
31
+ "@propellerads/theme-annotation": "^2.1.1"
31
32
  },
32
33
  "peerDependencies": {
33
34
  "react": "^18.0.0 || ^19.0.0",
@@ -35,10 +36,10 @@
35
36
  },
36
37
  "devDependencies": {
37
38
  "@types/react": "^19.2.14",
38
- "@vitejs/plugin-react": "^5.1.4",
39
- "rollup": "^4.58.0",
40
- "rollup-plugin-dts": "^6.3.0",
41
- "typescript": "^5.9.3",
42
- "vite": "^7.3.1"
39
+ "@vitejs/plugin-react": "^6.0.1",
40
+ "rollup": "^4.60.3",
41
+ "rollup-plugin-dts": "^6.4.1",
42
+ "typescript": "^6.0.3",
43
+ "vite": "^8.0.10"
43
44
  }
44
45
  }