timvir 0.1.47 → 0.2.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.
@@ -7,24 +7,34 @@ import * as Icons from 'react-feather';
7
7
  * ```js
8
8
  * cx('red', isBig && 'big') // returns 'red big' if `isBig` is true, otherwise returns 'red'
9
9
  * ```
10
- * If arguments provided are objects, these objects are merged together, and the values are taken as class names:
10
+ * If space separated atomic styles are provided, they are deduplicated according to the first hashed valued:
11
11
  *
12
12
  * ```js
13
- * cx({ color: 'class1', textDecoration: 'class2'}, { color: 'class3' }) // returns `class3 class2`
13
+ * cx('atm_a_class1 atm_b_class2', 'atm_a_class3') // returns `atm_a_class3 atm_b_class2`
14
14
  * ```
15
15
  *
16
16
  * @returns the combined, space separated class names that can be applied directly to the class attribute
17
17
  */
18
18
  const cx = function cx() {
19
- const presentClassNames = Array.prototype.slice.call(arguments).filter(Boolean); // In the basic case, `cx` is passed all strings, and we simply need to join them together with space separators
19
+ const presentClassNames = Array.prototype.slice.call(arguments).filter(Boolean);
20
+ const atomicClasses = {};
21
+ const nonAtomicClasses = [];
20
22
 
21
- const classNamesResult = presentClassNames.filter(arg => typeof arg !== 'object'); // There might also be objects (eg. from the atomic API) such as cx('foo', {
22
- // key1: 'bar', key2: 'fizz'}, { key1: 'buzz' }) the desired behavior is to
23
- // deduplicate the values based on their properties. The object's values are
24
- // the class names
23
+ for (const className of presentClassNames) {
24
+ // className could be the output of a previous cx call, so split by ' ' first
25
+ const individualClassNames = className.split(' ');
25
26
 
26
- const styleCollectionResult = Object.values(Object.assign({}, ...presentClassNames.filter(arg => typeof arg === 'object')));
27
- return [...styleCollectionResult, ...classNamesResult].join(' ');
27
+ for (const className of individualClassNames) {
28
+ if (className.startsWith('atm_')) {
29
+ const [, keyHash] = className.split('_');
30
+ atomicClasses[keyHash] = className;
31
+ } else {
32
+ nonAtomicClasses.push(className);
33
+ }
34
+ }
35
+ }
36
+
37
+ return [...Object.values(atomicClasses), ...nonAtomicClasses].join(' ');
28
38
  };
29
39
 
30
40
  /**
@@ -7,24 +7,34 @@ import * as React from 'react';
7
7
  * ```js
8
8
  * cx('red', isBig && 'big') // returns 'red big' if `isBig` is true, otherwise returns 'red'
9
9
  * ```
10
- * If arguments provided are objects, these objects are merged together, and the values are taken as class names:
10
+ * If space separated atomic styles are provided, they are deduplicated according to the first hashed valued:
11
11
  *
12
12
  * ```js
13
- * cx({ color: 'class1', textDecoration: 'class2'}, { color: 'class3' }) // returns `class3 class2`
13
+ * cx('atm_a_class1 atm_b_class2', 'atm_a_class3') // returns `atm_a_class3 atm_b_class2`
14
14
  * ```
15
15
  *
16
16
  * @returns the combined, space separated class names that can be applied directly to the class attribute
17
17
  */
18
18
  const cx = function cx() {
19
- const presentClassNames = Array.prototype.slice.call(arguments).filter(Boolean); // In the basic case, `cx` is passed all strings, and we simply need to join them together with space separators
19
+ const presentClassNames = Array.prototype.slice.call(arguments).filter(Boolean);
20
+ const atomicClasses = {};
21
+ const nonAtomicClasses = [];
20
22
 
21
- const classNamesResult = presentClassNames.filter(arg => typeof arg !== 'object'); // There might also be objects (eg. from the atomic API) such as cx('foo', {
22
- // key1: 'bar', key2: 'fizz'}, { key1: 'buzz' }) the desired behavior is to
23
- // deduplicate the values based on their properties. The object's values are
24
- // the class names
23
+ for (const className of presentClassNames) {
24
+ // className could be the output of a previous cx call, so split by ' ' first
25
+ const individualClassNames = className.split(' ');
25
26
 
26
- const styleCollectionResult = Object.values(Object.assign({}, ...presentClassNames.filter(arg => typeof arg === 'object')));
27
- return [...styleCollectionResult, ...classNamesResult].join(' ');
27
+ for (const className of individualClassNames) {
28
+ if (className.startsWith('atm_')) {
29
+ const [, keyHash] = className.split('_');
30
+ atomicClasses[keyHash] = className;
31
+ } else {
32
+ nonAtomicClasses.push(className);
33
+ }
34
+ }
35
+ }
36
+
37
+ return [...Object.values(atomicClasses), ...nonAtomicClasses].join(' ');
28
38
  };
29
39
 
30
40
  /**
@@ -11,24 +11,34 @@ import * as Icons from 'react-feather';
11
11
  * ```js
12
12
  * cx('red', isBig && 'big') // returns 'red big' if `isBig` is true, otherwise returns 'red'
13
13
  * ```
14
- * If arguments provided are objects, these objects are merged together, and the values are taken as class names:
14
+ * If space separated atomic styles are provided, they are deduplicated according to the first hashed valued:
15
15
  *
16
16
  * ```js
17
- * cx({ color: 'class1', textDecoration: 'class2'}, { color: 'class3' }) // returns `class3 class2`
17
+ * cx('atm_a_class1 atm_b_class2', 'atm_a_class3') // returns `atm_a_class3 atm_b_class2`
18
18
  * ```
19
19
  *
20
20
  * @returns the combined, space separated class names that can be applied directly to the class attribute
21
21
  */
22
22
  const cx = function cx() {
23
- const presentClassNames = Array.prototype.slice.call(arguments).filter(Boolean); // In the basic case, `cx` is passed all strings, and we simply need to join them together with space separators
23
+ const presentClassNames = Array.prototype.slice.call(arguments).filter(Boolean);
24
+ const atomicClasses = {};
25
+ const nonAtomicClasses = [];
24
26
 
25
- const classNamesResult = presentClassNames.filter(arg => typeof arg !== 'object'); // There might also be objects (eg. from the atomic API) such as cx('foo', {
26
- // key1: 'bar', key2: 'fizz'}, { key1: 'buzz' }) the desired behavior is to
27
- // deduplicate the values based on their properties. The object's values are
28
- // the class names
27
+ for (const className of presentClassNames) {
28
+ // className could be the output of a previous cx call, so split by ' ' first
29
+ const individualClassNames = className.split(' ');
29
30
 
30
- const styleCollectionResult = Object.values(Object.assign({}, ...presentClassNames.filter(arg => typeof arg === 'object')));
31
- return [...styleCollectionResult, ...classNamesResult].join(' ');
31
+ for (const className of individualClassNames) {
32
+ if (className.startsWith('atm_')) {
33
+ const [, keyHash] = className.split('_');
34
+ atomicClasses[keyHash] = className;
35
+ } else {
36
+ nonAtomicClasses.push(className);
37
+ }
38
+ }
39
+ }
40
+
41
+ return [...Object.values(atomicClasses), ...nonAtomicClasses].join(' ');
32
42
  };
33
43
 
34
44
  function Caption(props) {
@@ -7,24 +7,34 @@ import { useContext } from 'timvir/core';
7
7
  * ```js
8
8
  * cx('red', isBig && 'big') // returns 'red big' if `isBig` is true, otherwise returns 'red'
9
9
  * ```
10
- * If arguments provided are objects, these objects are merged together, and the values are taken as class names:
10
+ * If space separated atomic styles are provided, they are deduplicated according to the first hashed valued:
11
11
  *
12
12
  * ```js
13
- * cx({ color: 'class1', textDecoration: 'class2'}, { color: 'class3' }) // returns `class3 class2`
13
+ * cx('atm_a_class1 atm_b_class2', 'atm_a_class3') // returns `atm_a_class3 atm_b_class2`
14
14
  * ```
15
15
  *
16
16
  * @returns the combined, space separated class names that can be applied directly to the class attribute
17
17
  */
18
18
  const cx = function cx() {
19
- const presentClassNames = Array.prototype.slice.call(arguments).filter(Boolean); // In the basic case, `cx` is passed all strings, and we simply need to join them together with space separators
19
+ const presentClassNames = Array.prototype.slice.call(arguments).filter(Boolean);
20
+ const atomicClasses = {};
21
+ const nonAtomicClasses = [];
20
22
 
21
- const classNamesResult = presentClassNames.filter(arg => typeof arg !== 'object'); // There might also be objects (eg. from the atomic API) such as cx('foo', {
22
- // key1: 'bar', key2: 'fizz'}, { key1: 'buzz' }) the desired behavior is to
23
- // deduplicate the values based on their properties. The object's values are
24
- // the class names
23
+ for (const className of presentClassNames) {
24
+ // className could be the output of a previous cx call, so split by ' ' first
25
+ const individualClassNames = className.split(' ');
25
26
 
26
- const styleCollectionResult = Object.values(Object.assign({}, ...presentClassNames.filter(arg => typeof arg === 'object')));
27
- return [...styleCollectionResult, ...classNamesResult].join(' ');
27
+ for (const className of individualClassNames) {
28
+ if (className.startsWith('atm_')) {
29
+ const [, keyHash] = className.split('_');
30
+ atomicClasses[keyHash] = className;
31
+ } else {
32
+ nonAtomicClasses.push(className);
33
+ }
34
+ }
35
+ }
36
+
37
+ return [...Object.values(atomicClasses), ...nonAtomicClasses].join(' ');
28
38
  };
29
39
 
30
40
  /**
@@ -1,5 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { Bus } from "timvir/bus";
3
+ import { Node } from "../core/components/Page/types";
3
4
  export interface Value {
4
5
  bus: Bus;
5
6
  location: {
@@ -15,6 +16,7 @@ export interface Value {
15
16
  unfurl: (url: string) => Promise<any>;
16
17
  };
17
18
  };
19
+ toc: readonly Node[];
18
20
  }
19
21
  export declare const Provider: React.Provider<Value | undefined>;
20
22
  export declare function useContext(): Value;
@@ -0,0 +1,5 @@
1
+ import * as React from "react";
2
+ interface Props {
3
+ }
4
+ declare function Commands(props: Props): React.ReactPortal | null;
5
+ export default Commands;
@@ -0,0 +1 @@
1
+ export { default as Commands } from "./Commands";
@@ -0,0 +1,7 @@
1
+ import * as React from "react";
2
+ declare const Root = "div";
3
+ interface Props extends React.ComponentPropsWithoutRef<typeof Root> {
4
+ label?: React.ReactNode;
5
+ }
6
+ declare function Action(props: Props): JSX.Element;
7
+ export default Action;
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ interface Props {
3
+ open?: boolean;
4
+ onClose?: () => void;
5
+ onDispose?: () => void;
6
+ }
7
+ declare function Dialog(props: Props): JSX.Element;
8
+ export default Dialog;
@@ -0,0 +1,2 @@
1
+ export { default as Action } from "./Action";
2
+ export { default as Dialog } from "./Dialog";
@@ -56,5 +56,5 @@ interface Props extends React.ComponentProps<typeof Root> {
56
56
  */
57
57
  blocks?: Value["blocks"];
58
58
  }
59
- declare const _default: React.ForwardRefExoticComponent<Pick<Props, "search" | "key" | "dir" | "location" | "onError" | "hidden" | "color" | "style" | "translate" | "prefix" | "slot" | "title" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "draggable" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "Link" | "toc" | "mdxComponents" | "Footer" | "blocks"> & React.RefAttributes<HTMLDivElement>>;
59
+ declare const _default: React.ForwardRefExoticComponent<Pick<Props, "hidden" | "color" | "style" | "translate" | "prefix" | "slot" | "title" | "search" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "location" | "Link" | "toc" | "mdxComponents" | "Footer" | "blocks"> & React.RefAttributes<HTMLDivElement>>;
60
60
  export default _default;