@strapi/design-system 1.5.0 → 1.6.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Accordion/Accordion.cjs +8 -8
- package/dist/Accordion/Accordion.js +73 -67
- package/dist/Accordion/AccordionContent.cjs +1 -1
- package/dist/Accordion/AccordionContent.js +20 -17
- package/dist/Accordion/AccordionContext.cjs +1 -1
- package/dist/Accordion/AccordionContext.js +10 -4
- package/dist/Accordion/AccordionGroup.cjs +20 -20
- package/dist/Accordion/AccordionGroup.js +98 -59
- package/dist/Accordion/AccordionToggle.cjs +3 -3
- package/dist/Accordion/AccordionToggle.js +108 -89
- package/dist/Accordion/utils.cjs +1 -1
- package/dist/Accordion/utils.js +4 -4
- package/dist/Alert/Alert.cjs +7 -7
- package/dist/Alert/Alert.js +92 -85
- package/dist/Avatar/Avatar.cjs +6 -6
- package/dist/Avatar/Avatar.js +68 -67
- package/dist/Avatar/constants.cjs +1 -1
- package/dist/Avatar/constants.js +1 -1
- package/dist/Badge/Badge.cjs +4 -4
- package/dist/Badge/Badge.js +37 -37
- package/dist/BaseButton/BaseButton.cjs +3 -3
- package/dist/BaseButton/BaseButton.js +39 -27
- package/dist/BaseCheckbox/BaseCheckbox.cjs +6 -6
- package/dist/BaseCheckbox/BaseCheckbox.js +77 -59
- package/dist/BaseLink/BaseLink.cjs +2 -2
- package/dist/BaseLink/BaseLink.js +20 -27
- package/dist/BaseRadio/BaseRadio.cjs +7 -7
- package/dist/BaseRadio/BaseRadio.js +55 -35
- package/dist/BaseRadio/RadioGroup.cjs +1 -1
- package/dist/BaseRadio/RadioGroup.js +31 -28
- package/dist/BaseRadio/context.cjs +1 -1
- package/dist/BaseRadio/context.js +8 -4
- package/dist/BaseRadio/utils.cjs +1 -1
- package/dist/BaseRadio/utils.js +1 -1
- package/dist/Box/Box.cjs +31 -32
- package/dist/Box/Box.js +182 -59
- package/dist/Breadcrumbs/Breadcrumbs.cjs +3 -3
- package/dist/Breadcrumbs/Breadcrumbs.js +50 -39
- package/dist/Button/Button.cjs +20 -20
- package/dist/Button/Button.js +83 -74
- package/dist/Button/utils.cjs +23 -23
- package/dist/Button/utils.js +15 -15
- package/dist/Card/Card.cjs +1 -1
- package/dist/Card/Card.js +28 -29
- package/dist/Card/CardAction.cjs +4 -4
- package/dist/Card/CardAction.js +12 -6
- package/dist/Card/CardAsset.cjs +4 -4
- package/dist/Card/CardAsset.js +32 -26
- package/dist/Card/CardBadge.cjs +3 -3
- package/dist/Card/CardBadge.js +14 -10
- package/dist/Card/CardBody.cjs +1 -1
- package/dist/Card/CardBody.js +11 -10
- package/dist/Card/CardCheckbox.cjs +1 -1
- package/dist/Card/CardCheckbox.js +16 -13
- package/dist/Card/CardContent.cjs +2 -2
- package/dist/Card/CardContent.js +11 -11
- package/dist/Card/CardContext.cjs +1 -1
- package/dist/Card/CardContext.js +3 -1
- package/dist/Card/CardHeader.cjs +2 -2
- package/dist/Card/CardHeader.js +9 -7
- package/dist/Card/CardTimer.cjs +2 -2
- package/dist/Card/CardTimer.js +21 -16
- package/dist/Card/CardTitle.cjs +1 -1
- package/dist/Card/CardTitle.js +11 -9
- package/dist/CarouselInput/Carousel.cjs +4 -4
- package/dist/CarouselInput/Carousel.js +8 -9
- package/dist/Combobox/Combobox.cjs +1 -1
- package/dist/Combobox/Combobox.js +32 -33
- package/dist/DatePicker/DatePicker.cjs +1 -1
- package/dist/DatePicker/DatePicker.js +26 -29
- package/dist/Flex/Flex.cjs +5 -5
- package/dist/Flex/Flex.js +29 -17
- package/dist/Icon/Icon.cjs +3 -3
- package/dist/Icon/Icon.js +23 -19
- package/dist/JSONInput/JSONInput.cjs +1 -0
- package/dist/JSONInput/JSONInput.js +97 -0
- package/dist/JSONInput/JSONInputContainer.cjs +30 -0
- package/dist/JSONInput/JSONInputContainer.js +36 -0
- package/dist/JSONInput/index.cjs +1 -0
- package/dist/JSONInput/index.js +4 -0
- package/dist/JSONInput/utils/decorationExtension.cjs +1 -0
- package/dist/JSONInput/utils/decorationExtension.js +24 -0
- package/dist/KeyboardNavigable/KeyboardNavigable.cjs +1 -1
- package/dist/KeyboardNavigable/KeyboardNavigable.js +44 -49
- package/dist/Link/Link.cjs +5 -5
- package/dist/Link/Link.js +1 -1
- package/dist/LiveRegions/LiveRegions.cjs +1 -1
- package/dist/LiveRegions/LiveRegions.js +22 -20
- package/dist/LiveRegions/index.cjs +1 -1
- package/dist/LiveRegions/index.js +4 -2
- package/dist/MainNav/NavCondense.cjs +3 -3
- package/dist/MainNav/NavCondense.js +1 -2
- package/dist/MainNav/NavSections.cjs +3 -3
- package/dist/MainNav/NavSections.js +5 -5
- package/dist/ModalLayout/ModalHeader.cjs +2 -2
- package/dist/ModalLayout/ModalHeader.js +1 -1
- package/dist/NumberInput/NumberInput.cjs +2 -2
- package/dist/NumberInput/NumberInput.js +1 -1
- package/dist/Pagination/components.cjs +6 -6
- package/dist/Pagination/components.js +16 -17
- package/dist/Searchbar/Searchbar.cjs +7 -7
- package/dist/Searchbar/Searchbar.js +7 -8
- package/dist/Select/Select.cjs +2 -2
- package/dist/Select/Select.js +4 -5
- package/dist/Select/SelectTags.cjs +3 -3
- package/dist/Select/SelectTags.js +1 -1
- package/dist/SimpleMenu/SimpleMenu.cjs +9 -9
- package/dist/SimpleMenu/SimpleMenu.js +1 -1
- package/dist/Stack/Stack.cjs +5 -5
- package/dist/Stack/Stack.js +33 -33
- package/dist/SubNav/SubNavHeader.cjs +2 -2
- package/dist/SubNav/SubNavHeader.js +1 -1
- package/dist/SubNav/SubNavLink.cjs +4 -4
- package/dist/SubNav/SubNavLink.js +4 -4
- package/dist/SubNav/SubNavLinkSection.cjs +2 -2
- package/dist/SubNav/SubNavLinkSection.js +1 -1
- package/dist/SubNav/SubNavSectionLabel.cjs +3 -3
- package/dist/SubNav/SubNavSectionLabel.js +1 -1
- package/dist/TextButton/TextButton.cjs +6 -6
- package/dist/TextButton/TextButton.js +51 -50
- package/dist/ThemeProvider/ThemeProvider.cjs +2 -2
- package/dist/ThemeProvider/ThemeProvider.js +12 -11
- package/dist/TimePicker/TimePicker.cjs +2 -2
- package/dist/TimePicker/TimePicker.js +1 -1
- package/dist/Typography/Typography.cjs +7 -7
- package/dist/Typography/Typography.js +28 -17
- package/dist/Typography/utils.cjs +2 -2
- package/dist/Typography/utils.js +6 -6
- package/dist/helpers/arrays.cjs +1 -0
- package/dist/helpers/arrays.js +6 -0
- package/dist/helpers/handleResponsiveValues.cjs +1 -5
- package/dist/helpers/handleResponsiveValues.js +21 -15
- package/dist/helpers/objects.cjs +1 -0
- package/dist/helpers/objects.js +26 -0
- package/dist/helpers/setOpacity.cjs +1 -1
- package/dist/helpers/setOpacity.js +1 -1
- package/dist/helpers/theme.cjs +1 -0
- package/dist/helpers/theme.js +7 -0
- package/dist/helpers/useIntersection.cjs +1 -1
- package/dist/helpers/useIntersection.js +8 -8
- package/dist/hooks/useControllableState.cjs +1 -1
- package/dist/hooks/useControllableState.js +13 -16
- package/dist/index.cjs +1 -1
- package/dist/index.js +205 -201
- package/dist/themes/extendTheme.cjs +4 -4
- package/dist/themes/extendTheme.js +13 -21
- package/dist/v2/Breadcrumbs/CrumbSimpleMenu.cjs +2 -2
- package/dist/v2/Breadcrumbs/CrumbSimpleMenu.js +1 -1
- package/dist/v2/Link/Link.cjs +4 -4
- package/dist/v2/Link/Link.js +1 -1
- package/dist/v2/MainNav/NavCondense.cjs +3 -3
- package/dist/v2/MainNav/NavCondense.js +1 -2
- package/dist/v2/MainNav/NavSections.cjs +3 -3
- package/dist/v2/MainNav/NavSections.js +5 -5
- package/dist/v2/Pagination/components.cjs +7 -7
- package/dist/v2/Pagination/components.js +18 -19
- package/dist/v2/SimpleMenu/SimpleMenu.cjs +9 -9
- package/dist/v2/SimpleMenu/SimpleMenu.js +96 -89
- package/dist/v2/SubNav/SubNavHeader.cjs +2 -2
- package/dist/v2/SubNav/SubNavHeader.js +1 -1
- package/dist/v2/SubNav/SubNavLink.cjs +4 -4
- package/dist/v2/SubNav/SubNavLink.js +1 -1
- package/dist/v2/SubNav/SubNavLinkSection.cjs +4 -4
- package/dist/v2/SubNav/SubNavLinkSection.js +1 -1
- package/dist/v2/SubNav/SubNavSectionLabel.cjs +3 -3
- package/dist/v2/SubNav/SubNavSectionLabel.js +1 -1
- package/package.json +18 -15
- package/dist/Box/BoxProps.cjs +0 -1
- package/dist/Box/BoxProps.js +0 -51
- package/dist/Flex/FlexProps.cjs +0 -1
- package/dist/Flex/FlexProps.js +0 -41
- package/dist/FocusTrap/ExampleComponent.cjs +0 -1
- package/dist/FocusTrap/ExampleComponent.js +0 -71
- package/dist/LiveRegions/StoryComponent.cjs +0 -1
- package/dist/LiveRegions/StoryComponent.js +0 -18
- package/dist/Typography/TypographyProps.cjs +0 -1
- package/dist/Typography/TypographyProps.js +0 -31
- package/dist/themes/ColorButton.cjs +0 -3
- package/dist/themes/ColorButton.js +0 -25
- package/dist/themes/colors.cjs +0 -1
- package/dist/themes/colors.js +0 -49
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import o, { useState as y, useRef as E, useEffect as U, useLayoutEffect as Ee, Children as _, cloneElement as xe } from "react";
|
|
2
2
|
import e from "prop-types";
|
|
3
|
-
import ve from "@strapi/icons
|
|
4
|
-
import ye from "@strapi/icons/Cross";
|
|
3
|
+
import { Cross as ve, CarretDown as ye } from "@strapi/icons";
|
|
5
4
|
import { useId as Ie } from "../helpers/useId.js";
|
|
6
5
|
import { filterOptions as j, maintainScrollVisibility as ke, getActionFromKey as Oe, MenuActions as b, getUpdatedIndex as $ } from "./utils.js";
|
|
7
6
|
import { Flex as q } from "../Flex/Flex.js";
|
|
@@ -45,14 +44,14 @@ const I = ({
|
|
|
45
44
|
placeholder: oe,
|
|
46
45
|
required: F,
|
|
47
46
|
value: d,
|
|
48
|
-
...
|
|
47
|
+
...ne
|
|
49
48
|
}) => {
|
|
50
|
-
const
|
|
51
|
-
if (!g && !
|
|
49
|
+
const re = () => s.find((t) => t.props?.value.toLowerCase() === d.toLowerCase()).props?.children, [a, T] = y(0), [ae, ie] = y(null), [l, A] = y(s), [u, le] = y(!1), [r, k] = y(""), C = E(), O = E(!1), v = E(), P = E(), se = E(), V = E(!0), i = Ie("combobox"), K = `${i}-label`;
|
|
50
|
+
if (!g && !ne["aria-label"])
|
|
52
51
|
throw new Error('The Combobox component needs a "label" or an "aria-label" props');
|
|
53
52
|
U(() => {
|
|
54
|
-
A(j(s,
|
|
55
|
-
}, [
|
|
53
|
+
A(j(s, r));
|
|
54
|
+
}, [r, s]), U(() => {
|
|
56
55
|
u && C.current && ke(C.current);
|
|
57
56
|
}, [a, u]), Ee(() => {
|
|
58
57
|
V.current && (V.current = !1);
|
|
@@ -61,11 +60,11 @@ const I = ({
|
|
|
61
60
|
S(null), k("");
|
|
62
61
|
}, pe = (t) => {
|
|
63
62
|
D && D(t);
|
|
64
|
-
const
|
|
65
|
-
A(j(s,
|
|
63
|
+
const n = v.current.value;
|
|
64
|
+
A(j(s, n)), T(0), ie(null), r !== n && k(n), u || f(!0, !1);
|
|
66
65
|
}, de = (t) => {
|
|
67
|
-
const { key:
|
|
68
|
-
switch (d && !
|
|
66
|
+
const { key: n } = t, p = x && r ? l.length : l.length - 1, h = Oe(n, u);
|
|
67
|
+
switch (d && !r && n === Ue.BACKSPACE && N(), h) {
|
|
69
68
|
case b.Next: {
|
|
70
69
|
if (a === p) {
|
|
71
70
|
m(0);
|
|
@@ -114,25 +113,25 @@ const I = ({
|
|
|
114
113
|
}, H = () => {
|
|
115
114
|
O.current = !0;
|
|
116
115
|
}, w = (t) => {
|
|
117
|
-
const
|
|
118
|
-
if (k(""),
|
|
119
|
-
S(
|
|
116
|
+
const n = l[t];
|
|
117
|
+
if (k(""), n) {
|
|
118
|
+
S(n.props.value), f(!1);
|
|
120
119
|
return;
|
|
121
120
|
}
|
|
122
|
-
x && (ee(
|
|
123
|
-
}, f = (t,
|
|
124
|
-
le(t),
|
|
125
|
-
}, me = _.toArray(l).map((t,
|
|
126
|
-
const p = a ===
|
|
121
|
+
x && (ee(r), f(!1));
|
|
122
|
+
}, f = (t, n = !0) => {
|
|
123
|
+
le(t), n && v.current.focus();
|
|
124
|
+
}, me = _.toArray(l).map((t, n) => {
|
|
125
|
+
const p = a === n;
|
|
127
126
|
return xe(t, {
|
|
128
|
-
id: `${i}-${
|
|
129
|
-
"aria-selected": ae ===
|
|
130
|
-
"aria-posinset":
|
|
127
|
+
id: `${i}-${n}`,
|
|
128
|
+
"aria-selected": ae === n,
|
|
129
|
+
"aria-posinset": n + 1,
|
|
131
130
|
"aria-setsize": _.toArray(l).length,
|
|
132
131
|
ref(h) {
|
|
133
132
|
p && (C.current = h);
|
|
134
133
|
},
|
|
135
|
-
onClick: () => ue(
|
|
134
|
+
onClick: () => ue(n),
|
|
136
135
|
onMouseDown: H,
|
|
137
136
|
isSelected: p
|
|
138
137
|
});
|
|
@@ -141,8 +140,8 @@ const I = ({
|
|
|
141
140
|
}, ge = () => {
|
|
142
141
|
v.current.focus(), f(!0);
|
|
143
142
|
}, Ce = () => {
|
|
144
|
-
const t = l.findIndex((
|
|
145
|
-
return
|
|
143
|
+
const t = l.findIndex((n) => n.props?.children === r);
|
|
144
|
+
return r && t === -1;
|
|
146
145
|
}, he = (t) => {
|
|
147
146
|
t.preventDefault(), f(t, !0);
|
|
148
147
|
};
|
|
@@ -165,9 +164,9 @@ const I = ({
|
|
|
165
164
|
hasError: M
|
|
166
165
|
}, /* @__PURE__ */ o.createElement(Be, {
|
|
167
166
|
wrap: "wrap"
|
|
168
|
-
}, !
|
|
167
|
+
}, !r && d && /* @__PURE__ */ o.createElement(De, {
|
|
169
168
|
id: `${i}-selected-value`
|
|
170
|
-
}, /* @__PURE__ */ o.createElement(z, null,
|
|
169
|
+
}, /* @__PURE__ */ o.createElement(z, null, re())), /* @__PURE__ */ o.createElement(Fe, {
|
|
171
170
|
"aria-activedescendant": ce,
|
|
172
171
|
"aria-autocomplete": "list",
|
|
173
172
|
"aria-controls": `${i}-listbox`,
|
|
@@ -189,8 +188,8 @@ const I = ({
|
|
|
189
188
|
role: "combobox",
|
|
190
189
|
spellCheck: "off",
|
|
191
190
|
type: "text",
|
|
192
|
-
value:
|
|
193
|
-
})), /* @__PURE__ */ o.createElement(q, null, (d ||
|
|
191
|
+
value: r
|
|
192
|
+
})), /* @__PURE__ */ o.createElement(q, null, (d || r) && /* @__PURE__ */ o.createElement(Me, {
|
|
194
193
|
id: `${i}-clear`,
|
|
195
194
|
"aria-label": G,
|
|
196
195
|
disabled: c,
|
|
@@ -198,7 +197,7 @@ const I = ({
|
|
|
198
197
|
as: "button",
|
|
199
198
|
onClick: be,
|
|
200
199
|
type: "button"
|
|
201
|
-
}, /* @__PURE__ */ o.createElement(
|
|
200
|
+
}, /* @__PURE__ */ o.createElement(ve, null)), /* @__PURE__ */ o.createElement(Le, {
|
|
202
201
|
disabled: c,
|
|
203
202
|
paddingLeft: 3,
|
|
204
203
|
"aria-hidden": !0,
|
|
@@ -206,7 +205,7 @@ const I = ({
|
|
|
206
205
|
onClick: ge,
|
|
207
206
|
tabIndex: -1,
|
|
208
207
|
type: "button"
|
|
209
|
-
}, /* @__PURE__ */ o.createElement(
|
|
208
|
+
}, /* @__PURE__ */ o.createElement(ye, null)))), /* @__PURE__ */ o.createElement(Ke, null), /* @__PURE__ */ o.createElement(Ne, null)), u && /* @__PURE__ */ o.createElement(we, {
|
|
210
209
|
id: `${i}-popover`,
|
|
211
210
|
source: P,
|
|
212
211
|
spacing: 4,
|
|
@@ -229,7 +228,7 @@ const I = ({
|
|
|
229
228
|
onMouseDown: H,
|
|
230
229
|
onClick: () => w(),
|
|
231
230
|
taindex: 0
|
|
232
|
-
}, J(
|
|
231
|
+
}, J(r))), !l.length && !x && !L && /* @__PURE__ */ o.createElement($e, {
|
|
233
232
|
paddingLeft: 4,
|
|
234
233
|
paddingRight: 4,
|
|
235
234
|
paddingTop: 2,
|
|
@@ -237,7 +236,7 @@ const I = ({
|
|
|
237
236
|
ref: C
|
|
238
237
|
}, /* @__PURE__ */ o.createElement(z, {
|
|
239
238
|
textColor: "neutral800"
|
|
240
|
-
}, Z(
|
|
239
|
+
}, Z(r))), L && /* @__PURE__ */ o.createElement(q, {
|
|
241
240
|
justifyContent: "center",
|
|
242
241
|
alignItems: "center",
|
|
243
242
|
paddingTop: 2,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react"),z=require("prop-types"),v=require("@strapi/icons"),I=require("../themes/sizes.cjs"),S=require("../TextInput/TextInput.cjs"),u=require("./components.cjs"),B=require("./DatePickerCalendar.cjs"),C=require("./utils/formatDate.cjs"),M=require("../helpers/getDefaultLocale.cjs"),h=t=>t&&typeof t=="object"&&"default"in t?t:{default:t},a=h(o),e=h(z),f=({ariaLabel:t,initialDate:k,selectedDate:n,onChange:P,label:i,locale:q,selectedDateLabel:y,onClear:d,clearLabel:R,disabled:l,id:j,minDate:E,maxDate:T,...x})=>{const[p,c]=o.useState(!1),r=o.useRef(null),D=o.useRef(null),m=q||M.getDefaultLocale(),b=n?C.formatDate(n,m):"",g=()=>{l||c(s=>!s)},L=()=>{l||(d(),D.current.focus())},O=s=>{P(s),c(!1)},_=()=>{c(!1)};return a.default.createElement(u.DatePickerWrapper,{bold:p},a.default.createElement(S.TextInput,{ref:r,onClick:g,onChange:()=>{},value:b,startAction:a.default.createElement(u.DatePickerButton,{ref:D,onClick:g,"aria-label":n?y(C.formatDate(n,m)):i||t,type:"button","aria-disabled":l},a.default.createElement(v.Calendar,{"aria-hidden":!0})),endAction:d&&b?a.default.createElement(u.IconBox,{as:"button",onClick:L,"aria-label":R,"aria-disabled":l},a.default.createElement(v.Cross,null)):void 0,"aria-autocomplete":"none",label:i,"aria-label":t,disabled:l,id:j,...x}),r.current&&r.current.inputWrapperRef&&p&&a.default.createElement(B.DatePickerCalendar,{selectedDate:n,initialDate:k,onChange:O,onEscape:_,popoverSource:r.current.inputWrapperRef,label:i||t,minDate:E,maxDate:T}))};f.defaultProps={ariaLabel:void 0,clearLabel:void 0,disabled:!1,id:void 0,label:void 0,locale:void 0,initialDate:new Date,minDate:void 0,maxDate:void 0,onClear:void 0,placeholder:void 0,selectedDate:void 0,size:"M"};f.propTypes={ariaLabel:e.default.string,clearLabel:e.default.string,disabled:e.default.bool,id:e.default.string,initialDate:e.default.instanceOf(Date),label:e.default.string,locale:e.default.string,maxDate:e.default.instanceOf(Date),minDate:e.default.instanceOf(Date),onChange:e.default.func.isRequired,onClear:e.default.func,placeholder:e.default.string,selectedDate:e.default.instanceOf(Date),selectedDateLabel:e.default.func.isRequired,size:e.default.oneOf(Object.keys(I.sizes.input))};exports.DatePicker=f;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import t, { useState as
|
|
1
|
+
import t, { useState as B, useRef as D } from "react";
|
|
2
2
|
import e from "prop-types";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { DatePickerCalendar as V } from "./DatePickerCalendar.js";
|
|
3
|
+
import { Calendar as T, Cross as W } from "@strapi/icons";
|
|
4
|
+
import { sizes as q } from "../themes/sizes.js";
|
|
5
|
+
import { TextInput as A } from "../TextInput/TextInput.js";
|
|
6
|
+
import { DatePickerWrapper as I, DatePickerButton as S, IconBox as V } from "./components.js";
|
|
7
|
+
import { DatePickerCalendar as _ } from "./DatePickerCalendar.js";
|
|
9
8
|
import { formatDate as b } from "./utils/formatDate.js";
|
|
10
|
-
import { getDefaultLocale as
|
|
9
|
+
import { getDefaultLocale as j } from "../helpers/getDefaultLocale.js";
|
|
11
10
|
const v = ({
|
|
12
11
|
ariaLabel: o,
|
|
13
12
|
initialDate: g,
|
|
@@ -24,49 +23,49 @@ const v = ({
|
|
|
24
23
|
maxDate: O,
|
|
25
24
|
...x
|
|
26
25
|
}) => {
|
|
27
|
-
const [
|
|
26
|
+
const [f, l] = B(!1), n = D(null), p = D(null), u = h || j(), m = a ? b(a, u) : "", d = () => {
|
|
28
27
|
r || l((c) => !c);
|
|
29
28
|
}, y = () => {
|
|
30
|
-
r || (s(),
|
|
31
|
-
},
|
|
29
|
+
r || (s(), p.current.focus());
|
|
30
|
+
}, L = (c) => {
|
|
32
31
|
C(c), l(!1);
|
|
33
|
-
},
|
|
32
|
+
}, z = () => {
|
|
34
33
|
l(!1);
|
|
35
34
|
};
|
|
36
|
-
return /* @__PURE__ */ t.createElement(
|
|
37
|
-
bold:
|
|
38
|
-
}, /* @__PURE__ */ t.createElement(
|
|
35
|
+
return /* @__PURE__ */ t.createElement(I, {
|
|
36
|
+
bold: f
|
|
37
|
+
}, /* @__PURE__ */ t.createElement(A, {
|
|
39
38
|
ref: n,
|
|
40
|
-
onClick:
|
|
39
|
+
onClick: d,
|
|
41
40
|
onChange: () => {
|
|
42
41
|
},
|
|
43
42
|
value: m,
|
|
44
|
-
startAction: /* @__PURE__ */ t.createElement(
|
|
45
|
-
ref:
|
|
46
|
-
onClick:
|
|
47
|
-
"aria-label": a ? k(b(a,
|
|
43
|
+
startAction: /* @__PURE__ */ t.createElement(S, {
|
|
44
|
+
ref: p,
|
|
45
|
+
onClick: d,
|
|
46
|
+
"aria-label": a ? k(b(a, u)) : i || o,
|
|
48
47
|
type: "button",
|
|
49
48
|
"aria-disabled": r
|
|
50
|
-
}, /* @__PURE__ */ t.createElement(
|
|
49
|
+
}, /* @__PURE__ */ t.createElement(T, {
|
|
51
50
|
"aria-hidden": !0
|
|
52
51
|
})),
|
|
53
|
-
endAction: s && m ? /* @__PURE__ */ t.createElement(
|
|
52
|
+
endAction: s && m ? /* @__PURE__ */ t.createElement(V, {
|
|
54
53
|
as: "button",
|
|
55
54
|
onClick: y,
|
|
56
55
|
"aria-label": E,
|
|
57
56
|
"aria-disabled": r
|
|
58
|
-
}, /* @__PURE__ */ t.createElement(
|
|
57
|
+
}, /* @__PURE__ */ t.createElement(W, null)) : void 0,
|
|
59
58
|
"aria-autocomplete": "none",
|
|
60
59
|
label: i,
|
|
61
60
|
"aria-label": o,
|
|
62
61
|
disabled: r,
|
|
63
62
|
id: R,
|
|
64
63
|
...x
|
|
65
|
-
}), n.current && n.current.inputWrapperRef &&
|
|
64
|
+
}), n.current && n.current.inputWrapperRef && f && /* @__PURE__ */ t.createElement(_, {
|
|
66
65
|
selectedDate: a,
|
|
67
66
|
initialDate: g,
|
|
68
|
-
onChange:
|
|
69
|
-
onEscape:
|
|
67
|
+
onChange: L,
|
|
68
|
+
onEscape: z,
|
|
70
69
|
popoverSource: n.current.inputWrapperRef,
|
|
71
70
|
label: i || o,
|
|
72
71
|
minDate: P,
|
|
@@ -84,7 +83,6 @@ v.defaultProps = {
|
|
|
84
83
|
minDate: void 0,
|
|
85
84
|
maxDate: void 0,
|
|
86
85
|
onClear: void 0,
|
|
87
|
-
parentFieldId: void 0,
|
|
88
86
|
placeholder: void 0,
|
|
89
87
|
selectedDate: void 0,
|
|
90
88
|
size: "M"
|
|
@@ -101,11 +99,10 @@ v.propTypes = {
|
|
|
101
99
|
minDate: e.instanceOf(Date),
|
|
102
100
|
onChange: e.func.isRequired,
|
|
103
101
|
onClear: e.func,
|
|
104
|
-
parentFieldId: e.string,
|
|
105
102
|
placeholder: e.string,
|
|
106
103
|
selectedDate: e.instanceOf(Date),
|
|
107
104
|
selectedDateLabel: e.func.isRequired,
|
|
108
|
-
size: e.oneOf(Object.keys(
|
|
105
|
+
size: e.oneOf(Object.keys(q.input))
|
|
109
106
|
};
|
|
110
107
|
export {
|
|
111
108
|
v as DatePicker
|
package/dist/Flex/Flex.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
2
|
-
align-items: ${({alignItems:e})=>e};
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("styled-components"),s=require("../Box/Box.cjs"),l=require("../helpers/handleResponsiveValues.cjs"),n=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},i=n(o),r={direction:!0},a=i.default(s.Box).withConfig({shouldForwardProp:(e,t)=>!r[e]&&t(e)})`
|
|
2
|
+
align-items: ${({alignItems:e="center"})=>e};
|
|
3
3
|
display: ${({inline:e})=>e?"inline-flex":"flex"};
|
|
4
|
-
flex-direction: ${({direction:e})=>e};
|
|
4
|
+
flex-direction: ${({direction:e="row"})=>e};
|
|
5
5
|
flex-shrink: ${({shrink:e})=>e};
|
|
6
6
|
flex-wrap: ${({wrap:e})=>e};
|
|
7
|
-
${({gap:e,theme:
|
|
7
|
+
${({gap:e,theme:t})=>l("gap",e,t)};
|
|
8
8
|
justify-content: ${({justifyContent:e})=>e};
|
|
9
|
-
`;
|
|
9
|
+
`;exports.Flex=a;
|
package/dist/Flex/Flex.js
CHANGED
|
@@ -1,22 +1,34 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Box as
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
const f = {
|
|
1
|
+
import i from "styled-components";
|
|
2
|
+
import { Box as r } from "../Box/Box.js";
|
|
3
|
+
import t from "../helpers/handleResponsiveValues.js";
|
|
4
|
+
const n = {
|
|
6
5
|
direction: !0
|
|
7
|
-
},
|
|
8
|
-
shouldForwardProp: (e, o) => !
|
|
6
|
+
}, a = i(r).withConfig({
|
|
7
|
+
shouldForwardProp: (e, o) => !n[e] && o(e)
|
|
9
8
|
})`
|
|
10
|
-
align-items: ${({
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
align-items: ${({
|
|
10
|
+
alignItems: e = "center"
|
|
11
|
+
}) => e};
|
|
12
|
+
display: ${({
|
|
13
|
+
inline: e
|
|
14
|
+
}) => e ? "inline-flex" : "flex"};
|
|
15
|
+
flex-direction: ${({
|
|
16
|
+
direction: e = "row"
|
|
17
|
+
}) => e};
|
|
18
|
+
flex-shrink: ${({
|
|
19
|
+
shrink: e
|
|
20
|
+
}) => e};
|
|
21
|
+
flex-wrap: ${({
|
|
22
|
+
wrap: e
|
|
23
|
+
}) => e};
|
|
24
|
+
${({
|
|
25
|
+
gap: e,
|
|
26
|
+
theme: o
|
|
27
|
+
}) => t("gap", e, o)};
|
|
28
|
+
justify-content: ${({
|
|
29
|
+
justifyContent: e
|
|
30
|
+
}) => e};
|
|
17
31
|
`;
|
|
18
|
-
r.defaultProps = s;
|
|
19
|
-
r.propTypes = p;
|
|
20
32
|
export {
|
|
21
|
-
|
|
33
|
+
a as Flex
|
|
22
34
|
};
|
package/dist/Icon/Icon.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("react/jsx-runtime"),l=require("react"),u=require("styled-components"),a=require("../Box/Box.cjs"),d=require("../helpers/theme.cjs"),o=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},i=o(l),f=o(u),m=f.default(a.Box)`
|
|
2
2
|
path {
|
|
3
|
-
fill: ${({color:e,theme:t})=>t.colors
|
|
3
|
+
fill: ${({color:e,theme:t})=>d.extractStyleFromTheme(t.colors,e,void 0)};
|
|
4
4
|
}
|
|
5
5
|
${({theme:e,colors:t})=>t(e)}
|
|
6
|
-
`,
|
|
6
|
+
`,r=i.default.forwardRef(({color:e="neutral600",colors:t=()=>"",...c},s)=>n.jsx(m,{ref:s,color:e,colors:t,...c}));r.displayName="Icon";exports.Icon=r;
|
package/dist/Icon/Icon.js
CHANGED
|
@@ -1,26 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import f from "react";
|
|
3
3
|
import c from "styled-components";
|
|
4
4
|
import { Box as l } from "../Box/Box.js";
|
|
5
|
-
|
|
5
|
+
import { extractStyleFromTheme as p } from "../helpers/theme.js";
|
|
6
|
+
const a = c(l)`
|
|
6
7
|
path {
|
|
7
|
-
fill: ${({
|
|
8
|
+
fill: ${({
|
|
9
|
+
color: o,
|
|
10
|
+
theme: r
|
|
11
|
+
}) => p(r.colors, o, void 0)};
|
|
8
12
|
}
|
|
9
|
-
${({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
${({
|
|
14
|
+
theme: o,
|
|
15
|
+
colors: r
|
|
16
|
+
}) => r(o)}
|
|
17
|
+
`, n = f.forwardRef(({
|
|
18
|
+
color: o = "neutral600",
|
|
19
|
+
colors: r = () => "",
|
|
20
|
+
...t
|
|
21
|
+
}, e) => m(a, {
|
|
22
|
+
ref: e,
|
|
23
|
+
color: o,
|
|
24
|
+
colors: r,
|
|
25
|
+
...t
|
|
13
26
|
}));
|
|
14
|
-
|
|
15
|
-
t.defaultProps = {
|
|
16
|
-
color: "neutral600",
|
|
17
|
-
colors: () => {
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
t.propTypes = {
|
|
21
|
-
color: p.string,
|
|
22
|
-
colors: p.func
|
|
23
|
-
};
|
|
27
|
+
n.displayName = "Icon";
|
|
24
28
|
export {
|
|
25
|
-
|
|
29
|
+
n as Icon
|
|
26
30
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("react"),L=require("prop-types"),S=require("@codemirror/lang-json"),_=require("@uiw/react-codemirror"),x=require("../Field/Field.cjs"),A=require("../Field/FieldLabel.cjs");require("../Field/FieldInput.cjs");const H=require("../Field/FieldHint.cjs"),R=require("../Field/FieldError.cjs");require("../Field/FieldContext.cjs");require("../Field/FieldAction.cjs");const T=require("../Stack/Stack.cjs"),P=require("./JSONInputContainer.cjs"),s=require("./utils/decorationExtension.cjs"),b=n=>n&&typeof n=="object"&&"default"in n?n:{default:n},o=b(l),t=b(L),f=({label:n,value:m,error:g,hint:q,required:j,onChange:C,disabled:O,labelAction:k,...y})=>{const u=l.useRef(),a=l.useRef(null),c=l.useRef(null),h=Boolean(g),J=e=>a.current?.doc?.line(e),N=e=>{const{text:r,to:i}=J(e),d=i-r.trimStart().length;i>d&&c.current?.dispatch({effects:s.addMarks.of([s.lineHighlightMark.range(d,i)])})},v=()=>{const e=a.current?.doc?.length||0;c.current?.dispatch({effects:s.filterMarks.of((r,i)=>i<=0||r>=e)})},p=e=>{const{view:r,state:i}=e;c.current=r,a.current=i,v();const E=S.jsonParseLinter()(r);E.length&&N(i.doc.lineAt(E[0].from).number)},I=(e,r)=>{p(r),C(e)},M=(e,r)=>{c.current=e,a.current=r,p({view:e,state:r})},{setContainer:F}=_.useCodeMirror({value:m,onCreateEditor:M,theme:"dark",onChange:I,editable:!O,container:u.current,extensions:[S.json(),s.markField],basicSetup:{lineNumbers:!0,bracketMatching:!0,closeBrackets:!0,indentOnInput:!0,syntaxHighlighting:!0,highlightSelectionMatches:!0,tabSize:2,defaultCharacterWidth:5}});return l.useEffect(()=>{const e=u.current;e&&F(e)},[F,h]),o.default.createElement(x.Field,{error:g,hint:q,required:j},o.default.createElement(T.Stack,{spacing:1},n&&o.default.createElement(A.FieldLabel,{action:k},n),o.default.createElement(P.JSONInputContainer,{ref:u,hasError:h,alignItems:"stretch",fontSize:2,hasRadius:!0,...y}),o.default.createElement(R.FieldError,null),o.default.createElement(H.FieldHint,null)))};f.defaultProps={label:void 0,labelAction:void 0,value:"",error:void 0,hint:void 0,required:!1,disabled:!1,onChange(){}};f.propTypes={label:t.default.string,labelAction:t.default.element,value:t.default.string,error:t.default.oneOfType([t.default.string,t.default.bool]),hint:t.default.oneOfType([t.default.string,t.default.node,t.default.arrayOf(t.default.node)]),required:t.default.bool,disabled:t.default.bool,onChange:t.default.func};exports.JSONInput=f;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import o, { useRef as s, useEffect as J } from "react";
|
|
2
|
+
import t from "prop-types";
|
|
3
|
+
import { json as x, jsonParseLinter as H } from "@codemirror/lang-json";
|
|
4
|
+
import { useCodeMirror as I } from "@uiw/react-codemirror";
|
|
5
|
+
import { Field as L } from "../Field/Field.js";
|
|
6
|
+
import { FieldLabel as T } from "../Field/FieldLabel.js";
|
|
7
|
+
import "../Field/FieldInput.js";
|
|
8
|
+
import { FieldHint as P } from "../Field/FieldHint.js";
|
|
9
|
+
import { FieldError as R } from "../Field/FieldError.js";
|
|
10
|
+
import "../Field/FieldContext.js";
|
|
11
|
+
import "../Field/FieldAction.js";
|
|
12
|
+
import { Stack as j } from "../Stack/Stack.js";
|
|
13
|
+
import { JSONInputContainer as q } from "./JSONInputContainer.js";
|
|
14
|
+
import { markField as z, addMarks as B, lineHighlightMark as _, filterMarks as w } from "./utils/decorationExtension.js";
|
|
15
|
+
const g = ({ label: d, value: E, error: u, hint: b, required: S, onChange: C, disabled: O, labelAction: k, ...F }) => {
|
|
16
|
+
const a = s(), i = s(null), l = s(null), m = Boolean(u), v = (e) => i.current?.doc?.line(e), y = (e) => {
|
|
17
|
+
const { text: r, to: n } = v(e), c = n - r.trimStart().length;
|
|
18
|
+
n > c && l.current?.dispatch({
|
|
19
|
+
effects: B.of([_.range(c, n)])
|
|
20
|
+
});
|
|
21
|
+
}, M = () => {
|
|
22
|
+
const e = i.current?.doc?.length || 0;
|
|
23
|
+
l.current?.dispatch({
|
|
24
|
+
effects: w.of((r, n) => n <= 0 || r >= e)
|
|
25
|
+
});
|
|
26
|
+
}, f = (e) => {
|
|
27
|
+
const { view: r, state: n } = e;
|
|
28
|
+
l.current = r, i.current = n, M();
|
|
29
|
+
const p = H()(r);
|
|
30
|
+
p.length && y(n.doc.lineAt(p[0].from).number);
|
|
31
|
+
}, N = (e, r) => {
|
|
32
|
+
f(r), C(e);
|
|
33
|
+
}, A = (e, r) => {
|
|
34
|
+
l.current = e, i.current = r, f({ view: e, state: r });
|
|
35
|
+
}, { setContainer: h } = I({
|
|
36
|
+
value: E,
|
|
37
|
+
onCreateEditor: A,
|
|
38
|
+
theme: "dark",
|
|
39
|
+
onChange: N,
|
|
40
|
+
editable: !O,
|
|
41
|
+
container: a.current,
|
|
42
|
+
extensions: [x(), z],
|
|
43
|
+
basicSetup: {
|
|
44
|
+
lineNumbers: !0,
|
|
45
|
+
bracketMatching: !0,
|
|
46
|
+
closeBrackets: !0,
|
|
47
|
+
indentOnInput: !0,
|
|
48
|
+
syntaxHighlighting: !0,
|
|
49
|
+
highlightSelectionMatches: !0,
|
|
50
|
+
tabSize: 2,
|
|
51
|
+
defaultCharacterWidth: 5
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return J(() => {
|
|
55
|
+
const e = a.current;
|
|
56
|
+
e && h(e);
|
|
57
|
+
}, [h, m]), /* @__PURE__ */ o.createElement(L, {
|
|
58
|
+
error: u,
|
|
59
|
+
hint: b,
|
|
60
|
+
required: S
|
|
61
|
+
}, /* @__PURE__ */ o.createElement(j, {
|
|
62
|
+
spacing: 1
|
|
63
|
+
}, d && /* @__PURE__ */ o.createElement(T, {
|
|
64
|
+
action: k
|
|
65
|
+
}, d), /* @__PURE__ */ o.createElement(q, {
|
|
66
|
+
ref: a,
|
|
67
|
+
hasError: m,
|
|
68
|
+
alignItems: "stretch",
|
|
69
|
+
fontSize: 2,
|
|
70
|
+
hasRadius: !0,
|
|
71
|
+
...F
|
|
72
|
+
}), /* @__PURE__ */ o.createElement(R, null), /* @__PURE__ */ o.createElement(P, null)));
|
|
73
|
+
};
|
|
74
|
+
g.defaultProps = {
|
|
75
|
+
label: void 0,
|
|
76
|
+
labelAction: void 0,
|
|
77
|
+
value: "",
|
|
78
|
+
error: void 0,
|
|
79
|
+
hint: void 0,
|
|
80
|
+
required: !1,
|
|
81
|
+
disabled: !1,
|
|
82
|
+
onChange() {
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
g.propTypes = {
|
|
86
|
+
label: t.string,
|
|
87
|
+
labelAction: t.element,
|
|
88
|
+
value: t.string,
|
|
89
|
+
error: t.oneOfType([t.string, t.bool]),
|
|
90
|
+
hint: t.oneOfType([t.string, t.node, t.arrayOf(t.node)]),
|
|
91
|
+
required: t.bool,
|
|
92
|
+
disabled: t.bool,
|
|
93
|
+
onChange: t.func
|
|
94
|
+
};
|
|
95
|
+
export {
|
|
96
|
+
g as JSONInput
|
|
97
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("styled-components"),r=require("../themes/utils.cjs"),s=require("../Flex/Flex.cjs"),l=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},n=l(o),c=n.default(s.Flex)`
|
|
2
|
+
line-height: ${({theme:e})=>e.lineHeights[2]};
|
|
3
|
+
|
|
4
|
+
.cm-editor {
|
|
5
|
+
/*
|
|
6
|
+
Hard coded since the color is the same between themes,
|
|
7
|
+
theme.colors.neutral800 changes between themes
|
|
8
|
+
*/
|
|
9
|
+
background-color: #32324d;
|
|
10
|
+
width: 100%;
|
|
11
|
+
outline: none;
|
|
12
|
+
border: 1px solid ${({theme:e,hasError:t})=>t?e.colors.danger600:e.colors.neutral200};
|
|
13
|
+
/* inputFocusStyle will receive hasError prop */
|
|
14
|
+
${r.inputFocusStyle()}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.cm-editor,
|
|
18
|
+
.cm-scroller {
|
|
19
|
+
border-radius: ${({theme:e})=>e.borderRadius};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.cm-gutters,
|
|
23
|
+
.cm-activeLineGutter {
|
|
24
|
+
/*
|
|
25
|
+
Hard coded since the color is the same between themes,
|
|
26
|
+
theme.colors.neutral700 changes between themes
|
|
27
|
+
*/
|
|
28
|
+
background-color: #4a4a6a;
|
|
29
|
+
}
|
|
30
|
+
`;exports.JSONInputContainer=c;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import r from "styled-components";
|
|
2
|
+
import { inputFocusStyle as t } from "../themes/utils.js";
|
|
3
|
+
import { Flex as c } from "../Flex/Flex.js";
|
|
4
|
+
const l = r(c)`
|
|
5
|
+
line-height: ${({ theme: e }) => e.lineHeights[2]};
|
|
6
|
+
|
|
7
|
+
.cm-editor {
|
|
8
|
+
/*
|
|
9
|
+
Hard coded since the color is the same between themes,
|
|
10
|
+
theme.colors.neutral800 changes between themes
|
|
11
|
+
*/
|
|
12
|
+
background-color: #32324d;
|
|
13
|
+
width: 100%;
|
|
14
|
+
outline: none;
|
|
15
|
+
border: 1px solid ${({ theme: e, hasError: o }) => o ? e.colors.danger600 : e.colors.neutral200};
|
|
16
|
+
/* inputFocusStyle will receive hasError prop */
|
|
17
|
+
${t()}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.cm-editor,
|
|
21
|
+
.cm-scroller {
|
|
22
|
+
border-radius: ${({ theme: e }) => e.borderRadius};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.cm-gutters,
|
|
26
|
+
.cm-activeLineGutter {
|
|
27
|
+
/*
|
|
28
|
+
Hard coded since the color is the same between themes,
|
|
29
|
+
theme.colors.neutral700 changes between themes
|
|
30
|
+
*/
|
|
31
|
+
background-color: #4a4a6a;
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
34
|
+
export {
|
|
35
|
+
l as JSONInputContainer
|
|
36
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./JSONInput.cjs");exports.JSONInput=e.JSONInput;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("@codemirror/state"),t=require("@codemirror/view"),a=i.StateEffect.define(),d=i.StateEffect.define(),s=t.Decoration.mark({attributes:{style:"background-color: yellow; color: black"}}),n=i.StateField.define({create(){return t.Decoration.none},update(e,o){return e=e.map(o.changes),o.effects.forEach(r=>{r.is(a)?e=e.update({add:r.value,sort:!0}):r.is(d)&&(e=e.update({filter:r.value}))}),e},provide:e=>t.EditorView.decorations.from(e)});exports.addMarks=a;exports.filterMarks=d;exports.lineHighlightMark=s;exports.markField=n;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { StateEffect as o, StateField as d } from "@codemirror/state";
|
|
2
|
+
import { Decoration as i, EditorView as a } from "@codemirror/view";
|
|
3
|
+
const n = o.define(), s = o.define(), l = i.mark({
|
|
4
|
+
attributes: { style: "background-color: yellow; color: black" }
|
|
5
|
+
}), m = d.define({
|
|
6
|
+
create() {
|
|
7
|
+
return i.none;
|
|
8
|
+
},
|
|
9
|
+
update(r, t) {
|
|
10
|
+
return r = r.map(t.changes), t.effects.forEach((e) => {
|
|
11
|
+
e.is(n) ? r = r.update({
|
|
12
|
+
add: e.value,
|
|
13
|
+
sort: !0
|
|
14
|
+
}) : e.is(s) && (r = r.update({ filter: e.value }));
|
|
15
|
+
}), r;
|
|
16
|
+
},
|
|
17
|
+
provide: (r) => a.decorations.from(r)
|
|
18
|
+
});
|
|
19
|
+
export {
|
|
20
|
+
n as addMarks,
|
|
21
|
+
s as filterMarks,
|
|
22
|
+
l as lineHighlightMark,
|
|
23
|
+
m as markField
|
|
24
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=require("react/jsx-runtime"),m=require("../Box/Box.cjs"),s=require("../helpers/keyboardKeys.cjs"),b=({tagName:r,attributeName:d="",...f})=>{const c=()=>{const e=document.activeElement;return e?r?e.tagName.toLowerCase()===r:e.hasAttribute(d):!1},l=e=>r?e.querySelectorAll(r):e.querySelectorAll(`[${d}]`),i=e=>{switch(e.key){case s.KeyboardKeys.RIGHT:case s.KeyboardKeys.DOWN:{if(c()){e.preventDefault();const n=document.activeElement,t=[...l(e.currentTarget)],o=t.findIndex(a=>a===n),u=o+1<t.length?o+1:0;t[u].focus()}break}case s.KeyboardKeys.LEFT:case s.KeyboardKeys.UP:{if(c()){e.preventDefault();const n=document.activeElement,t=[...l(e.currentTarget)],o=t.findIndex(a=>a===n),u=o-1>-1?o-1:t.length-1;t[u].focus()}break}case s.KeyboardKeys.HOME:{c()&&(e.preventDefault(),l(e.currentTarget).item(0).focus());break}case s.KeyboardKeys.END:{if(c()){e.preventDefault();const n=l(e.currentTarget);n.item(n.length-1).focus()}break}}};return y.jsx(m.Box,{onKeyDown:i,...f})};exports.KeyboardNavigable=b;
|