@mrshmllw/smores-react 9.12.0 → 9.13.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.
@@ -12,6 +12,11 @@ type Props = {
|
|
12
12
|
limit?: number;
|
13
13
|
badges: Omit<BadgeListBadge, 'zIndex'>[];
|
14
14
|
};
|
15
|
+
/**
|
16
|
+
* A list of badges with optional tooltips.
|
17
|
+
* @param limit - The maximum number of badges to display. If the number of badges exceeds the limit, a badge will be displayed indicating the number of hidden excess badges.
|
18
|
+
* @returns
|
19
|
+
*/
|
15
20
|
export declare function BadgeList({ badges, limit, size }: Props): React.JSX.Element;
|
16
21
|
type WithTooltipProps = {
|
17
22
|
badge: BadgeListBadge;
|
@@ -5,19 +5,24 @@ import styled from 'styled-components';
|
|
5
5
|
import { Tooltip } from '../Tooltip';
|
6
6
|
import { Text } from '../Text';
|
7
7
|
import { theme } from '../theme';
|
8
|
+
/**
|
9
|
+
* A list of badges with optional tooltips.
|
10
|
+
* @param limit - The maximum number of badges to display. If the number of badges exceeds the limit, a badge will be displayed indicating the number of hidden excess badges.
|
11
|
+
* @returns
|
12
|
+
*/
|
8
13
|
export function BadgeList({ badges, limit, size }) {
|
9
14
|
const badgeZIndexMax = badges.length * 10 + 10;
|
10
15
|
const limitExcess =
|
11
16
|
// TODO: off by one adjustments work, just hard to read, refactor for human eyes 👁️👄👁️
|
12
|
-
limit && (badges.length
|
17
|
+
limit && (badges.length > limit ? badges.length - limit : 0);
|
13
18
|
const maxBadges = limit ? limit - 1 : undefined;
|
14
19
|
return (React.createElement(Container, { flex: true },
|
15
|
-
badges.slice(0, maxBadges).map((badge, index) => (React.createElement(WithTooltip, { key: typeof badge.src === 'string' ? badge.src : index, badge: {
|
20
|
+
badges.slice(0, limitExcess ? maxBadges : undefined).map((badge, index) => (React.createElement(WithTooltip, { key: typeof badge.src === 'string' ? badge.src : index, badge: {
|
16
21
|
...badge,
|
17
22
|
zIndex: badgeZIndexMax - index * 10,
|
18
23
|
size,
|
19
24
|
} }))),
|
20
|
-
limitExcess !== undefined && Boolean(limitExcess) && (React.createElement(Badge, { title: `+${limitExcess}`, borderColour: "oatmeal", size: size, src: React.createElement(ExcessBadge, { excess: limitExcess }), zIndex: badgeZIndexMax, disabled: true }))));
|
25
|
+
limitExcess !== undefined && Boolean(limitExcess) && (React.createElement(Badge, { title: `+${limitExcess}`, borderColour: "oatmeal", size: size, src: React.createElement(ExcessBadge, { excess: limitExcess + 1 }), zIndex: badgeZIndexMax, disabled: true }))));
|
21
26
|
}
|
22
27
|
function ExcessBadge({ excess }) {
|
23
28
|
return (React.createElement(ExcessBadgeContainer, null,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"BadgeList.js","sourceRoot":"","sources":["../../src/BadgeList/BadgeList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACvC,OAAO,EAAE,KAAK,EAAmB,MAAM,gBAAgB,CAAA;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAC5B,OAAO,MAAM,MAAM,mBAAmB,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEpC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAchC,MAAM,UAAU,SAAS,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAS;IACtD,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,GAAG,EAAE,GAAG,EAAE,CAAA;IAC9C,MAAM,WAAW;IACf,yFAAyF;IACzF,KAAK,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,
|
1
|
+
{"version":3,"file":"BadgeList.js","sourceRoot":"","sources":["../../src/BadgeList/BadgeList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO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gB;YAE9B,oBAAC,OAAO,IACN,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,QAAQ,EACtC,KAAK,EAAE,OAAO,EAAE,KAAK,EACrB,OAAO,EAAE,OAAO,CAAC,OAAO;gBAExB,oBAAC,KAAK,OAAK,KAAK,GAAI,CACZ,CACN,CACP,CAAA;IACH,CAAC;IAED,OAAO,CACL,6BACE,SAAS,EAAE,UAAU,EACrB,KAAK,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,EAC/B,YAAY,EAAE,gBAAgB,EAC9B,YAAY,EAAE,gBAAgB;QAE9B,oBAAC,KAAK,OAAK,KAAK,GAAI,CAChB,CACP,CAAA;AACH,CAAC,CAAA;AAED,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;;;;;;;;;;;;;;CAc5B,CAAA"}
|
@@ -7,8 +7,10 @@ interface Props extends CommonFieldProps {
|
|
7
7
|
value: string;
|
8
8
|
onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
|
9
9
|
}
|
10
|
+
type AutoComplete = 'off' | 'bday-day' | 'bday-month' | 'bday-year';
|
11
|
+
type InputMode = 'text' | 'email' | 'numeric';
|
10
12
|
/** on change or on input required */
|
11
|
-
type InputProps = {
|
13
|
+
type InputProps = ({
|
12
14
|
/** on change is required and on input optional */
|
13
15
|
onChange: (e: string) => void;
|
14
16
|
onInputChange?: (e: FormEvent<HTMLInputElement>) => void;
|
@@ -16,6 +18,9 @@ type InputProps = {
|
|
16
18
|
/** on input is required and on change optional */
|
17
19
|
onChange?: (e: string) => void;
|
18
20
|
onInputChange: (e: FormEvent<HTMLInputElement>) => void;
|
21
|
+
}) & {
|
22
|
+
autoComplete?: AutoComplete;
|
23
|
+
inputMode?: InputMode;
|
19
24
|
};
|
20
25
|
export type TextInputProps = Props & InputProps;
|
21
26
|
export declare const TextInput: React.ForwardRefExoticComponent<TextInputProps & React.RefAttributes<HTMLInputElement>>;
|
@@ -3,15 +3,15 @@ import { Box } from '../Box';
|
|
3
3
|
import { Field } from '../fields/Field';
|
4
4
|
import { Input, StyledFrontIcon, StyledTrailingIcon, } from '../fields/components/CommonInput';
|
5
5
|
import { useUniqueId } from '../utils/id';
|
6
|
-
export const TextInput = forwardRef(function TextInput({ id: idProp, type = 'text', placeholder, name, value, error = false, onBlur, onChange, onInputChange, disabled = false, frontIcon, trailingIcon, fallbackStyle, ...fieldProps }, ref) {
|
6
|
+
export const TextInput = forwardRef(function TextInput({ id: idProp, type = 'text', placeholder, name, value, error = false, onBlur, onChange, onInputChange, disabled = false, frontIcon, trailingIcon, fallbackStyle, autoComplete = 'off', inputMode, ...fieldProps }, ref) {
|
7
7
|
const id = useUniqueId(idProp);
|
8
8
|
return (React.createElement(Field, { ...fieldProps, htmlFor: id, error: error },
|
9
9
|
React.createElement(Box, { flex: true, alignItems: "center", justifyContent: "flex-start" },
|
10
10
|
frontIcon && (React.createElement(StyledFrontIcon, { "$disabled": disabled, render: frontIcon, color: "sesame" })),
|
11
|
-
React.createElement(Input, { disabled: disabled, type: type, id: id, name: name, ref: ref, placeholder: placeholder, value: value, "$error": error, "$frontIcon": frontIcon, "$fallbackStyle": fallbackStyle, autoComplete:
|
11
|
+
React.createElement(Input, { disabled: disabled, type: type, id: id, name: name, ref: ref, placeholder: placeholder, value: value, "$error": error, "$frontIcon": frontIcon, "$fallbackStyle": fallbackStyle, autoComplete: autoComplete, onChange: (e) => {
|
12
12
|
onChange && onChange(e.currentTarget.value);
|
13
13
|
onInputChange && onInputChange(e);
|
14
|
-
}, onBlur: onBlur }),
|
14
|
+
}, onBlur: onBlur, inputMode: inputMode }),
|
15
15
|
trailingIcon && (React.createElement(StyledTrailingIcon, { "$disabled": disabled, render: trailingIcon, color: "sesame" })))));
|
16
16
|
});
|
17
17
|
//# sourceMappingURL=TextInput.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"TextInput.js","sourceRoot":"","sources":["../../src/TextInput/TextInput.tsx"],"names":[],"mappings":"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