@moda/om 20.4.0 → 21.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +1433 -1504
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1433 -1504
- package/dist/index.esm.js.map +1 -1
- package/dist/src/components/Checkbox/Checkbox.d.ts +1 -1
- package/dist/src/components/Field/Field.d.ts +1 -1
- package/dist/src/components/PasswordInput/PasswordInput.d.ts +1 -1
- package/dist/src/components/Popover/Popover.d.ts +1 -1
- package/dist/src/components/PromoBanner/PromoBanner.d.ts +1 -1
- package/dist/src/components/RadioButton/RadioButton.d.ts +1 -1
- package/dist/src/components/Select/useSelect.d.ts +3 -3
- package/dist/src/components/Tabs/Tab.d.ts +1 -1
- package/dist/src/components/Text/Text.d.ts +2 -2
- package/dist/src/hooks/useClickOutside.d.ts +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/utilities/States/State.d.ts +6 -7
- package/dist/src/utilities/States/StateProps.d.ts +7 -0
- package/dist/src/utilities/States/States.d.ts +6 -7
- package/dist/src/utilities/States/Styles.d.ts +14 -0
- package/dist/src/utilities/States/index.d.ts +1 -0
- package/dist/src/utilities/index.d.ts +7 -0
- package/dist/src/utilities/isEmpty.d.ts +1 -0
- package/dist/src/utilities/isRenderProps.d.ts +5 -0
- package/dist/src/utilities/stringifyProps.d.ts +1 -0
- package/dist/src/utilities/truncate.d.ts +1 -0
- package/dist/styles.css +1 -1
- package/package.json +64 -61
- package/src/components/AspectRatioBox/AspectRatioBox.stories.tsx +1 -1
- package/src/components/Badge/Badge.stories.tsx +1 -1
- package/src/components/Breadcrumbs/Breadcrumbs.stories.tsx +1 -1
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +2 -2
- package/src/components/Button/Button.stories.tsx +2 -2
- package/src/components/Checkbox/Checkbox.stories.tsx +1 -1
- package/src/components/Checkbox/Checkbox.tsx +1 -1
- package/src/components/Clickable/Clickable.stories.tsx +1 -1
- package/src/components/ColorSwatch/ColorSwatch.stories.tsx +1 -1
- package/src/components/ControlLink/ControlLink.stories.tsx +1 -1
- package/src/components/CreditCardNumberInput/CreditCardNumberInput.stories.tsx +1 -1
- package/src/components/CreditCardNumberInput/CreditCardNumberInput.test.tsx +3 -6
- package/src/components/CreditCardNumberInput/CreditCardNumberInput.tsx +5 -13
- package/src/components/DefinitionList/DefinitionList.stories.tsx +1 -1
- package/src/components/Divider/Divider.stories.tsx +1 -1
- package/src/components/Expandable/Expandable.stories.tsx +1 -1
- package/src/components/Field/Field.stories.tsx +1 -1
- package/src/components/Field/Field.tsx +1 -1
- package/src/components/Label/Label.stories.tsx +1 -1
- package/src/components/LoadingItemsLavenderBlue/LoadingItems.stories.tsx +1 -1
- package/src/components/LoadingItemsPinkGreen/LoadingItems.stories.tsx +1 -1
- package/src/components/LoadingShapes/LoadingShapes.stories.tsx +1 -1
- package/src/components/LoadingShapesLavenderBlue/LoadingShapesLavenderBlue.stories.tsx +1 -1
- package/src/components/LoadingShapesPinkGreen/LoadingShapesPinkGreen.stories.tsx +1 -1
- package/src/components/Overlay/Overlay.stories.tsx +1 -1
- package/src/components/PasswordInput/PasswordInput.stories.tsx +1 -1
- package/src/components/Popover/Popover.stories.tsx +1 -1
- package/src/components/Popover/Popover.tsx +1 -1
- package/src/components/PromoBanner/PromoBanner.stories.tsx +1 -1
- package/src/components/PromoBanner/PromoBanner.tsx +1 -1
- package/src/components/RadioButton/RadioButton.stories.tsx +1 -1
- package/src/components/RadioButton/RadioButton.tsx +1 -1
- package/src/components/SearchInput/SearchInput.stories.tsx +1 -1
- package/src/components/Select/Select.stories.tsx +2 -3
- package/src/components/Select/Select.test.tsx +5 -5
- package/src/components/SelectableButton/SelectableButton.stories.tsx +1 -1
- package/src/components/Shape/Shape.stories.tsx +1 -1
- package/src/components/Stack/Stack.stories.tsx +1 -1
- package/src/components/Tabs/Tab.tsx +1 -1
- package/src/components/Tabs/Tabs.stories.tsx +1 -1
- package/src/components/Tag/Tag.stories.tsx +1 -1
- package/src/components/Text/Text.stories.tsx +1 -1
- package/src/components/Text/Text.tsx +2 -2
- package/src/components/TextInput/TextInput.stories.tsx +1 -1
- package/src/components/Textarea/Textarea.stories.tsx +1 -1
- package/src/components/Toast/Toast.stories.tsx +1 -1
- package/src/components/VerticalDivider/VerticalDivider.stories.tsx +1 -1
- package/src/hooks/useClickOutside.ts +4 -1
- package/src/utilities/States/State.tsx +13 -13
- package/src/utilities/States/StateProps.tsx +28 -0
- package/src/utilities/States/States.tsx +9 -11
- package/src/utilities/States/Styles.tsx +43 -0
- package/src/utilities/States/index.ts +1 -0
- package/src/utilities/index.ts +7 -0
- package/src/utilities/isEmpty.ts +1 -0
- package/src/utilities/isRenderProps.ts +9 -0
- package/src/utilities/{States/stringifyProps.tsx → stringifyProps.ts} +2 -7
- package/src/utilities/truncate.ts +5 -0
- package/dist/src/utilities/States/StatesProps.d.ts +0 -8
- package/dist/src/utilities/States/isRenderProps.d.ts +0 -4
- package/dist/src/utilities/States/stringifyProps.d.ts +0 -1
- package/src/utilities/States/State.scss +0 -11
- package/src/utilities/States/States.scss +0 -5
- package/src/utilities/States/StatesProps.scss +0 -24
- package/src/utilities/States/StatesProps.tsx +0 -31
- package/src/utilities/States/isRenderProps.ts +0 -7
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
if (!string) return null;
|
|
3
|
-
const ellipsis = string.length > maxLength;
|
|
4
|
-
return `${string.substring(0, maxLength)}${ellipsis ? '...' : ''}`;
|
|
5
|
-
};
|
|
1
|
+
import { truncate } from './truncate';
|
|
6
2
|
|
|
7
|
-
|
|
8
|
-
export const stringifyProps = (props: any) => {
|
|
3
|
+
export const stringifyProps = (props: unknown) => {
|
|
9
4
|
const stringifiedProps = Object.entries(props || {}).reduce((memo: string, [key, value]) => {
|
|
10
5
|
if (key === 'children') return `${memo} children={...}`;
|
|
11
6
|
if (typeof value === 'string') return `${memo} ${key}="${truncate(value)}"`;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const stringifyProps: (props: any) => string;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
@use '~@moda/om';
|
|
2
|
-
|
|
3
|
-
.StatesProps {
|
|
4
|
-
@include om.text(body1, $font: code);
|
|
5
|
-
|
|
6
|
-
padding-top: om.space(2);
|
|
7
|
-
color: om.color(fog);
|
|
8
|
-
border-top: 1px dotted om.color(elephant);
|
|
9
|
-
|
|
10
|
-
> strong {
|
|
11
|
-
text-decoration: underline;
|
|
12
|
-
color: om.color(ink);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
&::before {
|
|
16
|
-
content: '<';
|
|
17
|
-
color: om.color(elephant);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
&::after {
|
|
21
|
-
content: '/>';
|
|
22
|
-
color: om.color(elephant);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Stack } from '../../components/Stack';
|
|
3
|
-
import { omit } from '../omit';
|
|
4
|
-
import { isRenderProps } from './isRenderProps';
|
|
5
|
-
import { stringifyProps } from './stringifyProps';
|
|
6
|
-
import './StatesProps.scss';
|
|
7
|
-
|
|
8
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
9
|
-
interface Props {
|
|
10
|
-
children: any;
|
|
11
|
-
props: any;
|
|
12
|
-
}
|
|
13
|
-
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
14
|
-
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
-
const isEmpty = (obj?: any) => Object.entries(obj || {}).length === 0;
|
|
17
|
-
|
|
18
|
-
export const StatesProps: React.FC<Props> = ({ props, children }) => {
|
|
19
|
-
const childrenProps = omit(children.props, ...Object.keys(props || {}));
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<Stack className='StatesProps' space={2} direction='horizontal'>
|
|
23
|
-
<span>{children.type.displayName || children.type.name}</span>
|
|
24
|
-
{!isEmpty(props) && <strong>{stringifyProps(props)}</strong>}
|
|
25
|
-
{!isRenderProps(children) && !isEmpty(childrenProps) && (
|
|
26
|
-
<span>{stringifyProps(childrenProps)}</span>
|
|
27
|
-
)}
|
|
28
|
-
<span> </span>
|
|
29
|
-
</Stack>
|
|
30
|
-
);
|
|
31
|
-
};
|