@kvdbil/components 8.5.0 → 8.6.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.
@@ -0,0 +1,29 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("styled-components"),l=require("../../theme.js"),r=require("../../typography/BodyText/index.js"),n=require("../Button/index.js"),a=require("../Chip/index.js"),i=require("../Textfield/index.js");function u(v){return v&&typeof v=="object"&&"default"in v?v:{default:v}}require("../../shared/media-queries.js"),require("../Spinner/index.js"),require("../../typography/ButtonText/index.js"),require("../Button/styles.js"),require("../../icons/components/CloseIcon.js"),require("../Chip/styles.js"),require("../FieldLabel.js"),require("../../shared/helpers.js");var o=u(e),d=u(t);const s=d.default.div`
2
+ display: flex;
3
+ border-bottom: 1px solid ${l.default.colors.gray.light5};
4
+ `,f=d.default.form`
5
+ flex: 1;
6
+ flex-direction: column;
7
+ margin-bottom: 1rem;
8
+ `,c=d.default(i.TextField)`
9
+ max-width: 20rem;
10
+ `,m=d.default.div`
11
+ flex: 1;
12
+ display: flex;
13
+ align-items: flex-end;
14
+ justify-content: flex-end;
15
+ margin-top: 1rem;
16
+ `,p=d.default(n.Button)`
17
+ min-width: 5rem;
18
+ `,x=d.default(n.Button)`
19
+ min-width: 5rem;
20
+ margin-right: 1rem;
21
+ `,y=d.default(r.BodyLink)`
22
+ margin-right: 2rem;
23
+ `,h=d.default(r.BodyText)`
24
+ flex: 1rem;
25
+ `,g=d.default.div`
26
+ display: flex;
27
+ `,j=d.default(a.Chip)`
28
+ margin: 0 0.25rem;
29
+ `;exports.default=({value:v,label:T,onEdit:F,options:_=[],inputProps:I={},editText:M,saveText:O,cancelText:$,formatterFunc:D,isSingleSelect:z,color:S="secondary"})=>{const[q,b]=e.useState(v),[A,G]=e.useState(v),[k,L]=e.useState(!1),B=typeof q=="string",H=D&&B?D(q):q,J=B?H:q.join(", "),P=()=>{k?b(A):G(q),L(E=>!E)};return o.default.createElement(s,null,!k&&o.default.createElement(o.default.Fragment,null,o.default.createElement(y,null,T),o.default.createElement(h,null,J),o.default.createElement(n.Button,{variant:"flat",color:S,onClick:P},M)),k&&o.default.createElement(f,{onSubmit:E=>{E.preventDefault(),F==null||F(q),L(!1)}},o.default.createElement(y,null,T),B&&o.default.createElement(c,{...I,autoFocus:!0,value:q,label:T,onChange:E=>b(E.target.value)}),!B&&o.default.createElement(g,null,_.map(E=>o.default.createElement(j,{color:S,onClick:K=>{K.preventDefault(),(C=>{if(typeof q!="object")throw new Error("Cannot toggle chip on other than array");if(z)b([C]);else if(q.includes(C)){const w=q.filter(N=>N!==C);b(w)}else b(w=>[...w,C])})(E)},key:E,variant:q.includes(E)?"solid":"outline"},E))),o.default.createElement(m,null,o.default.createElement(x,{type:"button",variant:"flat",color:"neutral",onClick:P},$),o.default.createElement(p,{type:"submit",color:S},O))))};
@@ -0,0 +1,29 @@
1
+ import t,{useState as c}from"react";import r from"styled-components";import L from"../../theme.js";import{BodyLink as D,BodyText as I}from"../../typography/BodyText/index.js";import{Button as d}from"../Button/index.js";import{Chip as R}from"../Chip/index.js";import{TextField as _}from"../Textfield/index.js";import"../../shared/media-queries.js";import"../Spinner/index.js";import"../../typography/ButtonText/index.js";import"../Button/styles.js";import"../../icons/components/CloseIcon.js";import"../Chip/styles.js";import"../FieldLabel.js";import"../../shared/helpers.js";const q=r.div`
2
+ display: flex;
3
+ border-bottom: 1px solid ${L.colors.gray.light5};
4
+ `,O=r.form`
5
+ flex: 1;
6
+ flex-direction: column;
7
+ margin-bottom: 1rem;
8
+ `,$=r(_)`
9
+ max-width: 20rem;
10
+ `,z=r.div`
11
+ flex: 1;
12
+ display: flex;
13
+ align-items: flex-end;
14
+ justify-content: flex-end;
15
+ margin-top: 1rem;
16
+ `,A=r(d)`
17
+ min-width: 5rem;
18
+ `,G=r(d)`
19
+ min-width: 5rem;
20
+ margin-right: 1rem;
21
+ `,y=r(D)`
22
+ margin-right: 2rem;
23
+ `,H=r(I)`
24
+ flex: 1rem;
25
+ `,J=r.div`
26
+ display: flex;
27
+ `,K=r(R)`
28
+ margin: 0 0.25rem;
29
+ `,M=({value:u,label:s,onEdit:p,options:x=[],inputProps:E={},editText:j,saveText:C,cancelText:v,formatterFunc:f,isSingleSelect:B,color:a="secondary"})=>{const[n,o]=c(u),[b,w]=c(u),[m,h]=c(!1),l=typeof n=="string",S=f&&l?f(n):n,F=l?S:n.join(", "),g=()=>{m?o(b):w(n),h(e=>!e)},T=e=>{e.preventDefault(),p==null||p(n),h(!1)},k=e=>{if(typeof n!="object")throw new Error("Cannot toggle chip on other than array");if(B){o([e]);return}if(n.includes(e)){const i=n.filter(V=>V!==e);o(i);return}o(i=>[...i,e])};return t.createElement(q,null,!m&&t.createElement(t.Fragment,null,t.createElement(y,null,s),t.createElement(H,null,F),t.createElement(d,{variant:"flat",color:a,onClick:g},j)),m&&t.createElement(O,{onSubmit:T},t.createElement(y,null,s),l&&t.createElement($,{...E,autoFocus:!0,value:n,label:s,onChange:e=>o(e.target.value)}),!l&&t.createElement(J,null,x.map(e=>t.createElement(K,{color:a,onClick:i=>{i.preventDefault(),k(e)},key:e,variant:n.includes(e)?"solid":"outline"},e))),t.createElement(z,null,t.createElement(G,{type:"button",variant:"flat",color:"neutral",onClick:g},v),t.createElement(A,{type:"submit",color:a},C))))};export{M as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kvdbil/components",
3
- "version": "8.5.0",
3
+ "version": "8.6.0",
4
4
  "sideEffects": false,
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -103,7 +103,7 @@
103
103
  "storybook-addon-designs": "^6.2.0",
104
104
  "styled-components": "^5.2.0",
105
105
  "tslib": "^2.0.1",
106
- "typescript": "4.3.5"
106
+ "typescript": "^4.6.2"
107
107
  },
108
108
  "description": "KVDBil components library",
109
109
  "repository": {
@@ -15,5 +15,5 @@ interface Props {
15
15
  as?: keyof JSX.IntrinsicElements;
16
16
  }
17
17
  export declare type ButtonProps = ComponentPropsWithRef<'button'> & Props;
18
- export declare const Button: React.ForwardRefExoticComponent<Pick<ButtonProps, "form" | "slot" | "style" | "title" | "type" | "name" | "key" | "value" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "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" | "size" | "disabled" | "as" | "autoFocus" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "fullWidth" | "sufixIcon" | "prefixIcon" | "isLoading" | "minWidth" | "variant" | "isDisabled"> & React.RefAttributes<HTMLElement>>;
18
+ export declare const Button: React.ForwardRefExoticComponent<Pick<ButtonProps, "form" | "slot" | "style" | "title" | "type" | "name" | "key" | "value" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "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" | "as" | "autoFocus" | "disabled" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "size" | "fullWidth" | "sufixIcon" | "prefixIcon" | "isLoading" | "minWidth" | "variant" | "isDisabled"> & React.RefAttributes<HTMLElement>>;
19
19
  export default Button;
@@ -4,7 +4,7 @@ export declare const getFontSize: (size?: Size) => string;
4
4
  export declare const getBackgroundColor: ({ isDisabled, variant, color, theme, }: ItemProps) => string;
5
5
  export declare const getColor: ({ isDisabled, variant, color, theme, }: ItemProps) => string;
6
6
  export declare const getBorderColor: ({ color, isDisabled, variant, theme, }: ItemProps) => string;
7
- export declare const getCursorType: ({ isDisabled, isClickable, isDeletable, }: ItemProps) => "auto" | "not-allowed" | "pointer";
7
+ export declare const getCursorType: ({ isDisabled, isClickable, isDeletable, }: ItemProps) => "auto" | "pointer" | "not-allowed";
8
8
  export declare const getHoverBackgroundColor: ({ variant, color, theme, }: ItemProps) => string;
9
9
  export declare const getHoverBorderColor: ({ variant, color, theme }: ItemProps) => string;
10
10
  export declare const getHoverColor: ({ variant, color, theme }: ItemProps) => "#e8a100" | "#007069" | "#a63640" | "#004773" | "#269940" | "#1a2030" | "#ffffff";
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { Color } from '../../Types';
3
+ import { TextFieldProps } from '../Textfield';
4
+ export interface EditRowProps {
5
+ value: string | string[];
6
+ label: string;
7
+ editText: string;
8
+ saveText: string;
9
+ cancelText: string;
10
+ color?: Color;
11
+ options?: string[];
12
+ isSingleSelect?: boolean;
13
+ inputProps?: TextFieldProps;
14
+ onEdit?<T>(value: T): void;
15
+ formatterFunc?(value: string): string;
16
+ }
17
+ declare const EditRow: React.FC<EditRowProps>;
18
+ export default EditRow;