@jobber/components 9.12.3 → 9.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Combobox/Combobox.contentSlots.d.ts +4 -4
- package/dist/Combobox/Combobox.d.ts +11 -11
- package/dist/Combobox/Combobox.footer.d.ts +2 -2
- package/dist/Combobox/Combobox.items.d.ts +8 -8
- package/dist/Combobox/index.cjs +1 -0
- package/dist/Combobox/index.mjs +1 -0
- package/dist/Combobox-cjs.js +4 -23
- package/dist/Combobox-es.js +5 -24
- package/dist/FieldDescription-es.js +1 -1
- package/dist/InputNumber/InputNumber.d.ts +1 -5
- package/dist/InputNumber/InputNumber.slots.d.ts +11 -0
- package/dist/InputNumber/index.cjs +3 -2
- package/dist/InputNumber/index.mjs +3 -2
- package/dist/InputNumber-cjs.js +147 -22
- package/dist/InputNumber-es.js +149 -24
- package/dist/LightBox-cjs.js +2 -21
- package/dist/LightBox-es.js +2 -21
- package/dist/NumberFieldInput-es.js +1 -1
- package/dist/Select-es.js +1 -1
- package/dist/docs/InputNumber/InputNumber.md +131 -17
- package/dist/index.cjs +1 -0
- package/dist/index.mjs +1 -0
- package/dist/slotSystem-cjs.js +30 -0
- package/dist/slotSystem-es.js +28 -0
- package/dist/styles.css +25 -14
- package/dist/unstyledPrimitives/index.mjs +1 -1
- package/dist/utils/slotSystem.d.ts +12 -0
- package/package.json +2 -2
- package/dist/Combobox/Combobox.slotFactory.d.ts +0 -7
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type SlotComponent } from "../utils/slotSystem";
|
|
2
2
|
export type ComboboxContentSlotName = "empty" | "actions" | "footer" | "loading";
|
|
3
|
-
export type ComboboxContentSlotComponent<Props, Slot extends ComboboxContentSlotName = ComboboxContentSlotName> =
|
|
4
|
-
export declare const assignComboboxContentSlot: <Props, Slot extends ComboboxContentSlotName>(component: import("react").FC<Props>, slot: Slot) =>
|
|
5
|
-
export declare const isComboboxContentSlotElement: <Props = unknown>(child: React.ReactNode) => child is import("react").ReactElement<Props,
|
|
3
|
+
export type ComboboxContentSlotComponent<Props, Slot extends ComboboxContentSlotName = ComboboxContentSlotName> = SlotComponent<Props, "comboboxContentSlot", Slot>;
|
|
4
|
+
export declare const assignComboboxContentSlot: <Props, Slot extends ComboboxContentSlotName>(component: import("react").FC<Props>, slot: Slot) => SlotComponent<Props, "comboboxContentSlot", Slot>;
|
|
5
|
+
export declare const isComboboxContentSlotElement: <Props = unknown>(child: React.ReactNode) => child is import("react").ReactElement<Props, SlotComponent<Props, "comboboxContentSlot", ComboboxContentSlotName>>;
|
|
@@ -39,12 +39,12 @@ declare const Combobox: typeof ComboboxRoot & {
|
|
|
39
39
|
Content: typeof ComboboxContent;
|
|
40
40
|
List: typeof ComboboxList;
|
|
41
41
|
Item: typeof ComboboxItem;
|
|
42
|
-
ItemDescription: import("
|
|
43
|
-
ItemLabel: import("
|
|
44
|
-
ItemPrefix: import("
|
|
45
|
-
ItemSuffix: import("
|
|
46
|
-
ActionPrefix: import("
|
|
47
|
-
ActionLabel: import("
|
|
42
|
+
ItemDescription: import("../utils/slotSystem").SlotComponent<import("./Combobox.types").ComboboxItemDescriptionProps, "comboboxItemSlot", "label" | "prefix" | "suffix" | "description">;
|
|
43
|
+
ItemLabel: import("../utils/slotSystem").SlotComponent<import("./Combobox.types").ComboboxItemLabelProps, "comboboxItemSlot", "label" | "prefix" | "suffix" | "description">;
|
|
44
|
+
ItemPrefix: import("../utils/slotSystem").SlotComponent<import("./Combobox.types").ComboboxItemPrefixProps, "comboboxItemSlot", "label" | "prefix" | "suffix" | "description">;
|
|
45
|
+
ItemSuffix: import("../utils/slotSystem").SlotComponent<import("./Combobox.types").ComboboxItemSuffixProps, "comboboxItemSlot", "label" | "prefix" | "suffix" | "description">;
|
|
46
|
+
ActionPrefix: import("../utils/slotSystem").SlotComponent<import("./Combobox.types").ComboboxActionPrefixProps, "comboboxActionSlot", "label" | "prefix">;
|
|
47
|
+
ActionLabel: import("../utils/slotSystem").SlotComponent<import("./Combobox.types").ComboboxActionLabelProps, "comboboxActionSlot", "label" | "prefix">;
|
|
48
48
|
Row: typeof ComboboxRow;
|
|
49
49
|
Collection: typeof ComboboxCollection;
|
|
50
50
|
Chips: typeof ComboboxChips;
|
|
@@ -54,12 +54,12 @@ declare const Combobox: typeof ComboboxRoot & {
|
|
|
54
54
|
GroupLabel: typeof ComboboxGroupLabel;
|
|
55
55
|
Separator: typeof ComboboxSeparator;
|
|
56
56
|
Status: typeof ComboboxPrimitive.Status;
|
|
57
|
-
Empty: import("
|
|
58
|
-
Loading: import("
|
|
59
|
-
Actions: import("
|
|
57
|
+
Empty: import("../utils/slotSystem").SlotComponent<ComboboxEmptyProps, "comboboxContentSlot", "empty">;
|
|
58
|
+
Loading: import("../utils/slotSystem").SlotComponent<ComboboxLoadingProps, "comboboxContentSlot", "loading">;
|
|
59
|
+
Actions: import("../utils/slotSystem").SlotComponent<import("./Combobox.types").ComboboxActionsProps, "comboboxContentSlot", "actions">;
|
|
60
60
|
Action: typeof ComboboxAction;
|
|
61
|
-
Footer: import("
|
|
62
|
-
SelectionFooter: import("
|
|
61
|
+
Footer: import("../utils/slotSystem").SlotComponent<import("./Combobox.types").ComboboxFooterProps<unknown>, "comboboxContentSlot", "footer">;
|
|
62
|
+
SelectionFooter: import("../utils/slotSystem").SlotComponent<import("./Combobox.types").ComboboxSelectionFooterProps, "comboboxContentSlot", "footer">;
|
|
63
63
|
SelectedCount: typeof ComboboxSelectedCount;
|
|
64
64
|
ClearSelection: typeof ComboboxClearSelection;
|
|
65
65
|
SelectAll: typeof ComboboxSelectAll;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { ComboboxClearSelectionProps, ComboboxFooterProps, ComboboxSelectAllProps, ComboboxSelectedCountProps, ComboboxSelectionFooterProps } from "./Combobox.types";
|
|
3
|
-
export declare const ComboboxFooter: import("
|
|
3
|
+
export declare const ComboboxFooter: import("../utils/slotSystem").SlotComponent<ComboboxFooterProps<unknown>, "comboboxContentSlot", "footer">;
|
|
4
4
|
export declare function ComboboxSelectedCount({ children, className, }: ComboboxSelectedCountProps): React.JSX.Element;
|
|
5
|
-
export declare const ComboboxSelectionFooter: import("
|
|
5
|
+
export declare const ComboboxSelectionFooter: import("../utils/slotSystem").SlotComponent<ComboboxSelectionFooterProps, "comboboxContentSlot", "footer">;
|
|
6
6
|
export declare function ComboboxClearSelection({ children, label, tabIndex, ...clearProps }: ComboboxClearSelectionProps): React.JSX.Element;
|
|
7
7
|
export declare function ComboboxSelectAll({ children, label, ...buttonProps }: ComboboxSelectAllProps): React.JSX.Element | null;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { ComboboxActionLabelProps, ComboboxActionPrefixProps, ComboboxActionProps, ComboboxActionsProps, ComboboxCollectionProps, ComboboxGroupLabelProps, ComboboxGroupProps, ComboboxItemDescriptionProps, ComboboxItemLabelProps, ComboboxItemPrefixProps, ComboboxItemProps, ComboboxItemSuffixProps, ComboboxListProps, ComboboxRowProps, ComboboxSeparatorProps } from "./Combobox.types";
|
|
3
|
-
import { type
|
|
3
|
+
import { type SlotComponent } from "../utils/slotSystem";
|
|
4
4
|
export declare function ComboboxList({ className, ...listProps }: ComboboxListProps): React.JSX.Element;
|
|
5
5
|
export declare function ComboboxItem({ children, ...itemProps }: ComboboxItemProps): React.JSX.Element;
|
|
6
|
-
declare const ComboboxItemPrefixComponent:
|
|
6
|
+
declare const ComboboxItemPrefixComponent: SlotComponent<ComboboxItemPrefixProps, "comboboxItemSlot", "label" | "prefix" | "suffix" | "description">;
|
|
7
7
|
export { ComboboxItemPrefixComponent as ComboboxItemPrefix };
|
|
8
|
-
declare const ComboboxItemLabelComponent:
|
|
8
|
+
declare const ComboboxItemLabelComponent: SlotComponent<ComboboxItemLabelProps, "comboboxItemSlot", "label" | "prefix" | "suffix" | "description">;
|
|
9
9
|
export { ComboboxItemLabelComponent as ComboboxItemLabel };
|
|
10
|
-
declare const ComboboxItemDescriptionComponent:
|
|
10
|
+
declare const ComboboxItemDescriptionComponent: SlotComponent<ComboboxItemDescriptionProps, "comboboxItemSlot", "label" | "prefix" | "suffix" | "description">;
|
|
11
11
|
export { ComboboxItemDescriptionComponent as ComboboxItemDescription };
|
|
12
|
-
declare const ComboboxItemSuffixComponent:
|
|
12
|
+
declare const ComboboxItemSuffixComponent: SlotComponent<ComboboxItemSuffixProps, "comboboxItemSlot", "label" | "prefix" | "suffix" | "description">;
|
|
13
13
|
export { ComboboxItemSuffixComponent as ComboboxItemSuffix };
|
|
14
|
-
declare const ComboboxActionPrefixComponent:
|
|
14
|
+
declare const ComboboxActionPrefixComponent: SlotComponent<ComboboxActionPrefixProps, "comboboxActionSlot", "label" | "prefix">;
|
|
15
15
|
export { ComboboxActionPrefixComponent as ComboboxActionPrefix };
|
|
16
|
-
declare const ComboboxActionLabelComponent:
|
|
16
|
+
declare const ComboboxActionLabelComponent: SlotComponent<ComboboxActionLabelProps, "comboboxActionSlot", "label" | "prefix">;
|
|
17
17
|
export { ComboboxActionLabelComponent as ComboboxActionLabel };
|
|
18
18
|
export declare function ComboboxRow(props: ComboboxRowProps): React.JSX.Element;
|
|
19
19
|
export declare function ComboboxCollection(props: ComboboxCollectionProps): React.JSX.Element;
|
|
20
20
|
export declare function ComboboxGroup(props: ComboboxGroupProps): React.JSX.Element;
|
|
21
21
|
export declare function ComboboxGroupLabel(props: ComboboxGroupLabelProps): React.JSX.Element;
|
|
22
22
|
export declare function ComboboxSeparator(props: ComboboxSeparatorProps): React.JSX.Element;
|
|
23
|
-
declare const ComboboxActionsComponent:
|
|
23
|
+
declare const ComboboxActionsComponent: SlotComponent<ComboboxActionsProps, "comboboxContentSlot", "actions">;
|
|
24
24
|
export { ComboboxActionsComponent as ComboboxActions };
|
|
25
25
|
export declare function ComboboxAction({ children, className, onClick, ...buttonProps }: ComboboxActionProps): React.JSX.Element;
|
package/dist/Combobox/index.cjs
CHANGED
|
@@ -4,6 +4,7 @@ var Combobox = require('../Combobox-cjs.js');
|
|
|
4
4
|
require('../tslib.es6-cjs.js');
|
|
5
5
|
require('react');
|
|
6
6
|
require('classnames');
|
|
7
|
+
require('../slotSystem-cjs.js');
|
|
7
8
|
require('../useAtlantisI18n-cjs.js');
|
|
8
9
|
require('../AtlantisContext-cjs.js');
|
|
9
10
|
require('../Button-cjs.js');
|
package/dist/Combobox/index.mjs
CHANGED
package/dist/Combobox-cjs.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var tslib_es6 = require('./tslib.es6-cjs.js');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var classnames = require('classnames');
|
|
6
|
+
var slotSystem = require('./slotSystem-cjs.js');
|
|
6
7
|
var useAtlantisI18n = require('./useAtlantisI18n-cjs.js');
|
|
7
8
|
var AtlantisContext = require('./AtlantisContext-cjs.js');
|
|
8
9
|
var Button = require('./Button-cjs.js');
|
|
@@ -142,27 +143,7 @@ function useComboboxContext() {
|
|
|
142
143
|
return context;
|
|
143
144
|
}
|
|
144
145
|
|
|
145
|
-
|
|
146
|
-
function assignSlot(component, slot) {
|
|
147
|
-
return Object.assign(component, {
|
|
148
|
-
[markerKey]: slot,
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
function createSlot(slot) {
|
|
152
|
-
function ComboboxSlot(props) {
|
|
153
|
-
return null;
|
|
154
|
-
}
|
|
155
|
-
return assignSlot(ComboboxSlot, slot);
|
|
156
|
-
}
|
|
157
|
-
function isSlotElement(child) {
|
|
158
|
-
return (React.isValidElement(child) &&
|
|
159
|
-
typeof child.type !== "string" &&
|
|
160
|
-
markerKey in child.type);
|
|
161
|
-
}
|
|
162
|
-
return { assignSlot, createSlot, isSlotElement };
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
const comboboxContentSlotSystem = createComboboxSlotSystem("comboboxContentSlot");
|
|
146
|
+
const comboboxContentSlotSystem = slotSystem.createSlotSystem("comboboxContentSlot");
|
|
166
147
|
const assignComboboxContentSlot = comboboxContentSlotSystem.assignSlot;
|
|
167
148
|
const isComboboxContentSlotElement = comboboxContentSlotSystem.isSlotElement;
|
|
168
149
|
|
|
@@ -322,8 +303,8 @@ function getFallbackChildren(children) {
|
|
|
322
303
|
return children[0];
|
|
323
304
|
return children;
|
|
324
305
|
}
|
|
325
|
-
const comboboxItemSlotSystem =
|
|
326
|
-
const comboboxActionSlotSystem =
|
|
306
|
+
const comboboxItemSlotSystem = slotSystem.createSlotSystem("comboboxItemSlot");
|
|
307
|
+
const comboboxActionSlotSystem = slotSystem.createSlotSystem("comboboxActionSlot");
|
|
327
308
|
const createComboboxItemSlot = comboboxItemSlotSystem.createSlot;
|
|
328
309
|
const createComboboxActionSlot = comboboxActionSlotSystem.createSlot;
|
|
329
310
|
function isComboboxItemSlotElement(child) {
|
package/dist/Combobox-es.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { _ as __rest } from './tslib.es6-es.js';
|
|
2
2
|
import React__default, { useState, useEffect } from 'react';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
|
+
import { c as createSlotSystem } from './slotSystem-es.js';
|
|
4
5
|
import { d as defineMessages, u as useAtlantisI18n } from './useAtlantisI18n-es.js';
|
|
5
6
|
import { u as useAtlantisContext } from './AtlantisContext-es.js';
|
|
6
7
|
import { B as Button } from './Button-es.js';
|
|
@@ -11,7 +12,7 @@ import { I as Icon } from './Icon-es.js';
|
|
|
11
12
|
import { m as mergeClassName } from './mergeClassName-es.js';
|
|
12
13
|
import { G as Glimmer } from './Glimmer-es.js';
|
|
13
14
|
import { H as HelperText } from './HelperText-es.js';
|
|
14
|
-
import {
|
|
15
|
+
import { c as FieldRoot, F as FieldLabel, a as FieldDescription, b as FieldError } from './FieldDescription-es.js';
|
|
15
16
|
|
|
16
17
|
function getWindowDimensions() {
|
|
17
18
|
if (!(globalThis === null || globalThis === void 0 ? void 0 : globalThis.document)) {
|
|
@@ -140,27 +141,7 @@ function useComboboxContext() {
|
|
|
140
141
|
return context;
|
|
141
142
|
}
|
|
142
143
|
|
|
143
|
-
|
|
144
|
-
function assignSlot(component, slot) {
|
|
145
|
-
return Object.assign(component, {
|
|
146
|
-
[markerKey]: slot,
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
function createSlot(slot) {
|
|
150
|
-
function ComboboxSlot(props) {
|
|
151
|
-
return null;
|
|
152
|
-
}
|
|
153
|
-
return assignSlot(ComboboxSlot, slot);
|
|
154
|
-
}
|
|
155
|
-
function isSlotElement(child) {
|
|
156
|
-
return (React__default.isValidElement(child) &&
|
|
157
|
-
typeof child.type !== "string" &&
|
|
158
|
-
markerKey in child.type);
|
|
159
|
-
}
|
|
160
|
-
return { assignSlot, createSlot, isSlotElement };
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
const comboboxContentSlotSystem = createComboboxSlotSystem("comboboxContentSlot");
|
|
144
|
+
const comboboxContentSlotSystem = createSlotSystem("comboboxContentSlot");
|
|
164
145
|
const assignComboboxContentSlot = comboboxContentSlotSystem.assignSlot;
|
|
165
146
|
const isComboboxContentSlotElement = comboboxContentSlotSystem.isSlotElement;
|
|
166
147
|
|
|
@@ -320,8 +301,8 @@ function getFallbackChildren(children) {
|
|
|
320
301
|
return children[0];
|
|
321
302
|
return children;
|
|
322
303
|
}
|
|
323
|
-
const comboboxItemSlotSystem =
|
|
324
|
-
const comboboxActionSlotSystem =
|
|
304
|
+
const comboboxItemSlotSystem = createSlotSystem("comboboxItemSlot");
|
|
305
|
+
const comboboxActionSlotSystem = createSlotSystem("comboboxActionSlot");
|
|
325
306
|
const createComboboxItemSlot = comboboxItemSlotSystem.createSlot;
|
|
326
307
|
const createComboboxActionSlot = comboboxActionSlotSystem.createSlot;
|
|
327
308
|
function isComboboxItemSlotElement(child) {
|
|
@@ -856,4 +856,4 @@ const FieldDescription = /*#__PURE__*/React.forwardRef(function FieldDescription
|
|
|
856
856
|
});
|
|
857
857
|
if (process.env.NODE_ENV !== "production") FieldDescription.displayName = "FieldDescription";
|
|
858
858
|
|
|
859
|
-
export {
|
|
859
|
+
export { FieldLabel as F, FieldDescription as a, FieldError as b, FieldRoot as c };
|
|
@@ -51,11 +51,7 @@ declare function InputNumberAffixCompound({ variation, label, icon, onClick, ari
|
|
|
51
51
|
declare namespace InputNumberAffixCompound {
|
|
52
52
|
var displayName: string;
|
|
53
53
|
}
|
|
54
|
-
/**
|
|
55
|
-
* Sugar layer: composes the parts from props. This is the same composition a
|
|
56
|
-
* consumer would write by hand with `<InputNumber.Wrapper>` and the
|
|
57
|
-
* parts — to customize a single piece, copy this tree and swap that part.
|
|
58
|
-
*/
|
|
54
|
+
/** Sugar layer: hands the parts its props describe to `Wrapper`, the same path a consumer takes. */
|
|
59
55
|
declare function InputNumber({ ref, ...props }: InputNumberProps & {
|
|
60
56
|
readonly ref?: Ref<InputNumberRef>;
|
|
61
57
|
}): React.JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type SlotComponent } from "../utils/slotSystem";
|
|
2
|
+
declare const CONTENT_SLOT_NAMES: readonly ["label", "affix", "stepper", "loading", "description", "error"];
|
|
3
|
+
declare const STRUCTURAL_SLOT_NAMES: readonly ["group", "footer"];
|
|
4
|
+
export type InputNumberContentSlotName = (typeof CONTENT_SLOT_NAMES)[number];
|
|
5
|
+
export type InputNumberStructuralSlotName = (typeof STRUCTURAL_SLOT_NAMES)[number];
|
|
6
|
+
export type InputNumberSlotName = InputNumberContentSlotName | InputNumberStructuralSlotName;
|
|
7
|
+
export type InputNumberSlotComponent<Props, Slot extends InputNumberSlotName = InputNumberSlotName> = SlotComponent<Props, "inputNumberSlot", Slot>;
|
|
8
|
+
export declare const assignInputNumberSlot: <Props, Slot extends InputNumberSlotName>(component: import("react").FC<Props>, slot: Slot) => SlotComponent<Props, "inputNumberSlot", Slot>;
|
|
9
|
+
export declare const isInputNumberSlotElement: <Props = unknown>(child: React.ReactNode) => child is import("react").ReactElement<Props, SlotComponent<Props, "inputNumberSlot", InputNumberSlotName>>;
|
|
10
|
+
export declare function isStructuralSlot(slot: InputNumberSlotName): slot is InputNumberStructuralSlotName;
|
|
11
|
+
export {};
|
|
@@ -4,6 +4,7 @@ var InputNumber = require('../InputNumber-cjs.js');
|
|
|
4
4
|
require('../tslib.es6-cjs.js');
|
|
5
5
|
require('react');
|
|
6
6
|
require('classnames');
|
|
7
|
+
require('../slotSystem-cjs.js');
|
|
7
8
|
require('../useAtlantisI18n-cjs.js');
|
|
8
9
|
require('../AtlantisContext-cjs.js');
|
|
9
10
|
require('../ActivityIndicator-cjs.js');
|
|
@@ -30,10 +31,10 @@ require('../SelectPrimitive-cjs.js');
|
|
|
30
31
|
require('../mergeClassName-cjs.js');
|
|
31
32
|
require('../SelectGroupLabel-cjs.js');
|
|
32
33
|
require('../useCompositeListItem-cjs.js');
|
|
33
|
-
require('../FieldDescription-cjs.js');
|
|
34
|
-
require('../useLabel-cjs.js');
|
|
35
34
|
require('../NumberFieldInput-cjs.js');
|
|
36
35
|
require('../stringifyLocale-cjs.js');
|
|
36
|
+
require('../FieldDescription-cjs.js');
|
|
37
|
+
require('../useLabel-cjs.js');
|
|
37
38
|
|
|
38
39
|
|
|
39
40
|
|
|
@@ -2,6 +2,7 @@ export { I as InputNumber } from '../InputNumber-es.js';
|
|
|
2
2
|
import '../tslib.es6-es.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
import 'classnames';
|
|
5
|
+
import '../slotSystem-es.js';
|
|
5
6
|
import '../useAtlantisI18n-es.js';
|
|
6
7
|
import '../AtlantisContext-es.js';
|
|
7
8
|
import '../ActivityIndicator-es.js';
|
|
@@ -28,7 +29,7 @@ import '../SelectPrimitive-es.js';
|
|
|
28
29
|
import '../mergeClassName-es.js';
|
|
29
30
|
import '../SelectGroupLabel-es.js';
|
|
30
31
|
import '../useCompositeListItem-es.js';
|
|
31
|
-
import '../FieldDescription-es.js';
|
|
32
|
-
import '../useLabel-es.js';
|
|
33
32
|
import '../NumberFieldInput-es.js';
|
|
34
33
|
import '../stringifyLocale-es.js';
|
|
34
|
+
import '../FieldDescription-es.js';
|
|
35
|
+
import '../useLabel-es.js';
|
package/dist/InputNumber-cjs.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var tslib_es6 = require('./tslib.es6-cjs.js');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var classnames = require('classnames');
|
|
6
|
+
var slotSystem = require('./slotSystem-cjs.js');
|
|
6
7
|
var useAtlantisI18n = require('./useAtlantisI18n-cjs.js');
|
|
7
8
|
require('./AtlantisContext-cjs.js');
|
|
8
9
|
var ActivityIndicator = require('./ActivityIndicator-cjs.js');
|
|
@@ -13,8 +14,16 @@ require('./BottomSheet-cjs.js');
|
|
|
13
14
|
var HelperText = require('./HelperText-cjs.js');
|
|
14
15
|
require('./SelectPrimitive-cjs.js');
|
|
15
16
|
var useRenderElement = require('./useRenderElement-cjs.js');
|
|
16
|
-
var FieldDescription = require('./FieldDescription-cjs.js');
|
|
17
17
|
var NumberFieldInput = require('./NumberFieldInput-cjs.js');
|
|
18
|
+
var FieldDescription = require('./FieldDescription-cjs.js');
|
|
19
|
+
|
|
20
|
+
const STRUCTURAL_SLOT_NAMES = ["group", "footer"];
|
|
21
|
+
const inputNumberSlotSystem = slotSystem.createSlotSystem("inputNumberSlot");
|
|
22
|
+
const assignInputNumberSlot = inputNumberSlotSystem.assignSlot;
|
|
23
|
+
const isInputNumberSlotElement = inputNumberSlotSystem.isSlotElement;
|
|
24
|
+
function isStructuralSlot(slot) {
|
|
25
|
+
return STRUCTURAL_SLOT_NAMES.includes(slot);
|
|
26
|
+
}
|
|
18
27
|
|
|
19
28
|
var styles = {"container":"-W4QiocGsR4-","inline":"_9-f2CjSVojs-","wrapper":"_4y342TRP-y8-","disabled":"d-YOq6z4ZxM-","small":"YTL0AyJdbC8-","large":"mUfanIovnVg-","center":"_8MM9keFOeD0-","right":"mTeuCQufdj4-","inputWrapper":"IgE0pfetwVM-","input":"MxShJMNKSB4-","stepper":"SE8DXlYN02U-","loadingIndicator":"VmKH2-NlbDI-","label":"f1OiicY3UzU-","hideLabel":"j9oUhNvNwsE-","affixLabel":"oR6I7xtSbL4-","prefix":"s-WnNh4k-kw-","suffix":"Ep7K8jug-Xc-","affixIcon":"E3w3BEJoBFE-","compoundAffix":"znvaejix3iE-","affixLabelText":"m1ZP5T4QOAQ-","stepperButton":"_22AXoGKVAjc-","belowField":"kkywg49kgrg-","description":"buIzMqBEpSQ-","spinning":"p8ebLlGf8JY-"};
|
|
20
29
|
|
|
@@ -49,6 +58,116 @@ const DEFAULT_FORMAT = {
|
|
|
49
58
|
maximumFractionDigits: 12,
|
|
50
59
|
};
|
|
51
60
|
const InputNumberContext = React.createContext(null);
|
|
61
|
+
function isFragmentElement(child) {
|
|
62
|
+
return React.isValidElement(child) && child.type === React.Fragment;
|
|
63
|
+
}
|
|
64
|
+
/** Conditional JSX often wraps parts in a fragment; unwrap so the parser sees them. */
|
|
65
|
+
function flattenFragments(children) {
|
|
66
|
+
const flattened = [];
|
|
67
|
+
React.Children.forEach(children, child => {
|
|
68
|
+
if (isFragmentElement(child)) {
|
|
69
|
+
flattened.push(...flattenFragments(child.props.children));
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
flattened.push(child);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
return flattened;
|
|
76
|
+
}
|
|
77
|
+
/** An `Error` with no message renders nothing, so it must not suppress the description. */
|
|
78
|
+
function hasRenderableChildren(child) {
|
|
79
|
+
return React.isValidElement(child)
|
|
80
|
+
? Boolean(child.props.children)
|
|
81
|
+
: false;
|
|
82
|
+
}
|
|
83
|
+
/** Placement policy; the shared slot system only tags and detects. */
|
|
84
|
+
function parseInputNumberChildren(children) {
|
|
85
|
+
const labels = [];
|
|
86
|
+
const indicators = [];
|
|
87
|
+
const descriptions = [];
|
|
88
|
+
const errors = [];
|
|
89
|
+
const parsed = {
|
|
90
|
+
prefixAffixes: [],
|
|
91
|
+
suffixAffixes: [],
|
|
92
|
+
insideInput: [],
|
|
93
|
+
footer: [],
|
|
94
|
+
structural: [],
|
|
95
|
+
unknown: [],
|
|
96
|
+
};
|
|
97
|
+
flattenFragments(children).forEach(child => {
|
|
98
|
+
if (!isInputNumberSlotElement(child)) {
|
|
99
|
+
parsed.unknown.push(child);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const slot = child.type.inputNumberSlot;
|
|
103
|
+
if (isStructuralSlot(slot)) {
|
|
104
|
+
parsed.structural.push(child);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
switch (slot) {
|
|
108
|
+
case "label":
|
|
109
|
+
labels.push(child);
|
|
110
|
+
break;
|
|
111
|
+
case "affix":
|
|
112
|
+
if (child.props.variation === "suffix") {
|
|
113
|
+
parsed.suffixAffixes.push(child);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
parsed.prefixAffixes.push(child);
|
|
117
|
+
}
|
|
118
|
+
break;
|
|
119
|
+
case "stepper":
|
|
120
|
+
case "loading":
|
|
121
|
+
indicators.push(child);
|
|
122
|
+
break;
|
|
123
|
+
case "description":
|
|
124
|
+
descriptions.push(child);
|
|
125
|
+
break;
|
|
126
|
+
case "error":
|
|
127
|
+
errors.push(child);
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
parsed.insideInput.push(...labels, ...indicators);
|
|
132
|
+
parsed.footer.push(...(errors.some(hasRenderableChildren) ? [] : descriptions), ...errors);
|
|
133
|
+
return parsed;
|
|
134
|
+
}
|
|
135
|
+
function hasContentParts(parsed) {
|
|
136
|
+
return (parsed.prefixAffixes.length > 0 ||
|
|
137
|
+
parsed.suffixAffixes.length > 0 ||
|
|
138
|
+
parsed.insideInput.length > 0 ||
|
|
139
|
+
parsed.footer.length > 0);
|
|
140
|
+
}
|
|
141
|
+
function resolveWrapperContent(children) {
|
|
142
|
+
const parsed = parseInputNumberChildren(children);
|
|
143
|
+
const hasContent = hasContentParts(parsed);
|
|
144
|
+
if (parsed.structural.length > 0) {
|
|
145
|
+
if (hasContent) {
|
|
146
|
+
throw new Error("<InputNumber.Wrapper> received both structural parts (Group/Footer) " +
|
|
147
|
+
"and loose content parts (Label/Affix/Stepper/Loading/Description/Error). " +
|
|
148
|
+
"Pass content parts alone to have Wrapper build the field, or nest them " +
|
|
149
|
+
"inside the structural parts to compose the tree yourself.");
|
|
150
|
+
}
|
|
151
|
+
return children;
|
|
152
|
+
}
|
|
153
|
+
// A consumer component may render `Group` itself; synthesizing would give it a second field.
|
|
154
|
+
if (!hasContent && parsed.unknown.length > 0)
|
|
155
|
+
return children;
|
|
156
|
+
return renderSynthesizedField(parsed);
|
|
157
|
+
}
|
|
158
|
+
function renderSynthesizedField(parsed) {
|
|
159
|
+
return (React.createElement(React.Fragment, null,
|
|
160
|
+
React.createElement(InputNumberGroup, null,
|
|
161
|
+
keyed(parsed.prefixAffixes),
|
|
162
|
+
React.createElement(InputNumberInput, null, keyed(parsed.insideInput)),
|
|
163
|
+
keyed(parsed.suffixAffixes)),
|
|
164
|
+
parsed.footer.length > 0 && (React.createElement(InputNumberFooter, null, keyed(parsed.footer))),
|
|
165
|
+
keyed(parsed.unknown)));
|
|
166
|
+
}
|
|
167
|
+
/** Flattening fragments drops the keys `React.Children.toArray` would have assigned. */
|
|
168
|
+
function keyed(children) {
|
|
169
|
+
return React.Children.toArray(children);
|
|
170
|
+
}
|
|
52
171
|
function useInputNumberContext(consumer) {
|
|
53
172
|
const context = React.useContext(InputNumberContext);
|
|
54
173
|
if (context === null) {
|
|
@@ -135,7 +254,7 @@ function InputNumberWrapper(_a) {
|
|
|
135
254
|
]);
|
|
136
255
|
const rootProps = useRenderElement.mergeProps({ className: classnames(styles.container, inline && styles.inline) }, { className, style });
|
|
137
256
|
return (React.createElement(FieldDescription.FieldRoot, Object.assign({}, rootProps, { disabled: disabled, invalid: invalid || undefined, name: name }),
|
|
138
|
-
React.createElement(InputNumberContext.Provider, { value: contextValue }, children)));
|
|
257
|
+
React.createElement(InputNumberContext.Provider, { value: contextValue }, resolveWrapperContent(children))));
|
|
139
258
|
}
|
|
140
259
|
function InputNumberGroup({ children, className, style, }) {
|
|
141
260
|
var _a, _b;
|
|
@@ -222,6 +341,11 @@ function InputNumberAffixCompound({ variation, label, icon, onClick, ariaLabel,
|
|
|
222
341
|
label && React.createElement("span", { className: styles.affixLabelText }, label),
|
|
223
342
|
children));
|
|
224
343
|
}
|
|
344
|
+
/** Carries the sugar's `prefix`/`suffix` through routing, adding no element of its own. */
|
|
345
|
+
function InputNumberPropAffix({ variation, affix }) {
|
|
346
|
+
const ctx = useInputNumberContext("Affix");
|
|
347
|
+
return renderDefaultAffix(variation, affix, ctx.size);
|
|
348
|
+
}
|
|
225
349
|
/**
|
|
226
350
|
* Renders the prop-driven `prefix`/`suffix` affixes for the sugar component.
|
|
227
351
|
* Icons sit outside the input area; labels render next to the typed value
|
|
@@ -259,31 +383,22 @@ function resolveAutoComplete(autoComplete) {
|
|
|
259
383
|
return undefined;
|
|
260
384
|
return autoComplete;
|
|
261
385
|
}
|
|
262
|
-
/**
|
|
263
|
-
* Sugar layer: composes the parts from props. This is the same composition a
|
|
264
|
-
* consumer would write by hand with `<InputNumber.Wrapper>` and the
|
|
265
|
-
* parts — to customize a single piece, copy this tree and swap that part.
|
|
266
|
-
*/
|
|
386
|
+
/** Sugar layer: hands the parts its props describe to `Wrapper`, the same path a consumer takes. */
|
|
267
387
|
function InputNumber(_a) {
|
|
268
|
-
var _b;
|
|
269
388
|
var { ref } = _a, props = tslib_es6.__rest(_a, ["ref"]);
|
|
270
389
|
const { t } = useAtlantisI18n.useAtlantisI18n(inputNumberMessages);
|
|
271
390
|
const { label, description, error, prefix, suffix } = props, config = tslib_es6.__rest(props, ["label", "description", "error", "prefix", "suffix"]);
|
|
272
|
-
const size = (_b = config.size) !== null && _b !== void 0 ? _b : "default";
|
|
273
391
|
return (React.createElement(InputNumberWrapper, Object.assign({}, config, { invalid: config.invalid || Boolean(error), ref: ref }),
|
|
274
|
-
React.createElement(
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
(description || error) && (React.createElement(InputNumberFooter, null,
|
|
285
|
-
React.createElement(InputNumberDescription, null, description),
|
|
286
|
-
React.createElement(InputNumberError, null, error)))));
|
|
392
|
+
prefix ? (React.createElement(InputNumberPropAffix, { affix: prefix, variation: "prefix" })) : null,
|
|
393
|
+
React.createElement(InputNumberLabel, null, label),
|
|
394
|
+
config.loading ? (React.createElement(InputNumberLoading, null)) : (React.createElement(InputNumberStepper, { incrementLabel: t("Increase {label}", {
|
|
395
|
+
label: label !== null && label !== void 0 ? label : t("value"),
|
|
396
|
+
}), decrementLabel: t("Decrease {label}", {
|
|
397
|
+
label: label !== null && label !== void 0 ? label : t("value"),
|
|
398
|
+
}) })),
|
|
399
|
+
suffix ? (React.createElement(InputNumberPropAffix, { affix: suffix, variation: "suffix" })) : null,
|
|
400
|
+
description ? (React.createElement(InputNumberDescription, null, description)) : null,
|
|
401
|
+
error ? React.createElement(InputNumberError, null, error) : null));
|
|
287
402
|
}
|
|
288
403
|
InputNumberWrapper.displayName = "InputNumber.Wrapper";
|
|
289
404
|
InputNumber.displayName = "InputNumber";
|
|
@@ -298,6 +413,16 @@ InputNumberStepper.displayName = "InputNumber.Stepper";
|
|
|
298
413
|
InputNumberIncrement.displayName = "InputNumber.Increment";
|
|
299
414
|
InputNumberDecrement.displayName = "InputNumber.Decrement";
|
|
300
415
|
InputNumberAffixCompound.displayName = "InputNumber.Affix";
|
|
416
|
+
// Tagged here so the parts stay plain declarations, which the docs prop-table generator needs.
|
|
417
|
+
assignInputNumberSlot(InputNumberGroup, "group");
|
|
418
|
+
assignInputNumberSlot(InputNumberFooter, "footer");
|
|
419
|
+
assignInputNumberSlot(InputNumberLabel, "label");
|
|
420
|
+
assignInputNumberSlot(InputNumberDescription, "description");
|
|
421
|
+
assignInputNumberSlot(InputNumberError, "error");
|
|
422
|
+
assignInputNumberSlot(InputNumberLoading, "loading");
|
|
423
|
+
assignInputNumberSlot(InputNumberStepper, "stepper");
|
|
424
|
+
assignInputNumberSlot(InputNumberAffixCompound, "affix");
|
|
425
|
+
assignInputNumberSlot(InputNumberPropAffix, "affix");
|
|
301
426
|
InputNumber.Wrapper = InputNumberWrapper;
|
|
302
427
|
InputNumber.Group = InputNumberGroup;
|
|
303
428
|
InputNumber.Footer = InputNumberFooter;
|