@atom-learning/components 2.9.2 → 2.11.0-canary.0.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/CHANGELOG.md +0 -8
- package/dist/components/image/Image.d.ts +3 -1
- package/dist/components/image/Image.js +1 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/components/number-input/NumberInput.d.ts +23 -0
- package/dist/components/number-input/NumberInput.js +1 -0
- package/dist/components/number-input/NumberInputStepper.d.ts +9 -0
- package/dist/components/number-input/NumberInputStepper.js +1 -0
- package/dist/components/number-input/index.d.ts +1 -0
- package/dist/components/number-input-field/NumberInputField.d.ts +16 -0
- package/dist/components/number-input-field/NumberInputField.js +1 -0
- package/dist/components/number-input-field/index.d.ts +1 -0
- package/dist/docgen.json +1 -1
- package/dist/docs/NumberInput.mdx +37 -0
- package/dist/docs/NumberInputField.mdx +26 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
## [2.9.2](https://github.com/Atom-Learning/components/compare/v2.9.1...v2.9.2) (2022-10-19)
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
### Bug Fixes
|
|
5
|
-
|
|
6
|
-
* change size prop to optional ([04f5d0f](https://github.com/Atom-Learning/components/commit/04f5d0f9f55aa8812008895d16fda06437797b3b))
|
|
7
|
-
* consolidate field element props ([b82f96d](https://github.com/Atom-Learning/components/commit/b82f96db924f58dca8829499653ee925b6e4500c))
|
|
8
|
-
|
|
9
1
|
# [1.4.0](https://github.com/Atom-Learning/components/compare/v1.3.0...v1.4.0) (2022-04-11)
|
|
10
2
|
|
|
11
3
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Override } from '../../utilities/types';
|
|
3
|
-
export declare const StyledImage: import("@stitches/react/types/styled-component").StyledComponent<"img", {
|
|
3
|
+
export declare const StyledImage: import("@stitches/react/types/styled-component").StyledComponent<"img", {
|
|
4
|
+
fluid?: boolean | "true" | undefined;
|
|
5
|
+
}, {
|
|
4
6
|
sm: string;
|
|
5
7
|
md: string;
|
|
6
8
|
lg: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{styled as
|
|
1
|
+
import{styled as a}from"../../stitches.js";const t=a("img",{verticalAlign:"middle",maxWidth:"100%",variants:{fluid:{true:{"&[width]":{width:"auto"},"&[width][height]":{height:"auto"},'&[src$=".svg"]':{width:"100%",height:"auto",maxWidth:"none"}}}},defaultVariants:{fluid:"true"}}),i=t;i.displayName="Image";export{i as Image,t as StyledImage};
|
|
@@ -66,3 +66,5 @@ export { ToggleGroup } from './toggle-group';
|
|
|
66
66
|
export { Tooltip } from './tooltip';
|
|
67
67
|
export { Video } from './video';
|
|
68
68
|
export { NavigationMenu } from './navigation';
|
|
69
|
+
export { NumberInput } from './number-input';
|
|
70
|
+
export { NumberInputField } from './number-input-field';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { CSS } from '../../stitches';
|
|
3
|
+
export interface NumberInputProps {
|
|
4
|
+
name: string;
|
|
5
|
+
min?: number;
|
|
6
|
+
max?: number;
|
|
7
|
+
step?: number;
|
|
8
|
+
initialValue?: number;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
readonly?: boolean;
|
|
11
|
+
size?: 'sm' | 'md';
|
|
12
|
+
onChange?: (value: number) => void;
|
|
13
|
+
stepperButtonLabels?: {
|
|
14
|
+
increment?: string;
|
|
15
|
+
decrement?: string;
|
|
16
|
+
};
|
|
17
|
+
disabledTooltipContent?: {
|
|
18
|
+
increment?: string;
|
|
19
|
+
decrement?: string;
|
|
20
|
+
};
|
|
21
|
+
css?: CSS;
|
|
22
|
+
}
|
|
23
|
+
export declare const NumberInput: React.ForwardRefExoticComponent<NumberInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Minus as $,Plus as B}from"@atom-learning/icons";import*as n from"react";import{Flex as F}from"../flex/Flex.js";import{Input as H}from"../input/Input.js";import{NumberInputStepper as x}from"./NumberInputStepper.js";const N=n.forwardRef((g,k)=>{const{name:E,min:o=0,max:l=Number.MAX_SAFE_INTEGER,step:s=1,initialValue:y=0,disabled:u=!1,readonly:m=!1,size:v="md",onChange:C,stepperButtonLabels:T,disabledTooltipContent:A,css:I,...L}=g,[r,M]=n.useState(y),i=n.useRef(null);n.useImperativeHandle(k,()=>i.current);const w={increment:"increment",decrement:"decrement",...T},R={decrement:`Cannot enter values below ${o}`,increment:`Cannot enter values above ${l}`,...A},d=r>=l,c=r<=o,p=n.useCallback(e=>Math.min(Math.max(e,o),l),[l,o]),a=n.useCallback(e=>{M(e),C==null||C(Number(e))},[C]),z=n.useCallback(e=>{const t=e.target.value.replace(/\D/g,"");a(t)},[a]),b=n.useCallback(()=>{var e;if(d||m)return;(e=i==null?void 0:i.current)==null||e.focus();let t;r===""?t=s:t=Number(r)+s,a(p(t))},[p,d,m,s,a,r]),f=n.useCallback(()=>{var e;if(c||m)return;(e=i==null?void 0:i.current)==null||e.focus();let t;r===""?t=o:t=Number(r)-s,a(p(t))},[p,c,m,o,s,a,r]),D=n.useCallback(e=>{if(e.nativeEvent.isComposing)return;const t=e.key,h={ArrowUp:b,ArrowRight:b,ArrowDown:f,ArrowLeft:f,Home:()=>a(o),End:()=>a(l)}[t];h&&(e.preventDefault(),h(e))},[b,f,a,o,l]),S={name:E,type:"number",value:r,...L,onChange:z,onKeyDown:D,size:v,css:{borderRadius:"0px",width:"$6","&:disabled":{opacity:.3,pointerEvents:"none"}},ref:i,readOnly:m,disabled:u,"aria-valuemin":o,"aria-valuemax":l,"aria-valuenow":Number(r),role:"spinbutton"};return n.createElement(F,{css:I},n.createElement(x,{onClick:f,icon:$,css:{borderRight:"none",borderTopRightRadius:"0px",borderBottomRightRadius:"0px"},size:v,disabled:c||u,showTooltip:c&&!u,disabledTooltipContent:R.decrement,label:w.decrement}),n.createElement(H,{...S}),n.createElement(x,{onClick:b,icon:B,css:{borderLeft:"none",borderTopLeftRadius:"0px",borderBottomLeftRadius:"0px"},size:v,disabled:d||u,showTooltip:d&&!u,disabledTooltipContent:R.increment,label:w.increment}))});N.displayName="NumberInput";export{N as NumberInput};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ActionIcon } from '../action-icon';
|
|
3
|
+
declare type NumberInputStepperProps = Omit<React.ComponentProps<typeof ActionIcon>, 'children'> & {
|
|
4
|
+
icon: React.FC<React.SVGProps<SVGSVGElement>>;
|
|
5
|
+
showTooltip?: boolean;
|
|
6
|
+
disabledTooltipContent?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const NumberInputStepper: React.ForwardRefExoticComponent<NumberInputStepperProps>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{styled as t}from"@stitches/react";import*as e from"react";import{ActionIcon as m}from"../action-icon/ActionIcon.js";import{Icon as p}from"../icon/Icon.js";import{Tooltip as o}from"../tooltip/Tooltip.js";const s=t("span",{zIndex:1}),d=t(m,{borderColor:"$tonal400 !important",zIndex:1,"&:hover":{bg:"$tonal50",svg:{color:"$tonal400"}},svg:{color:"$tonal300"},"&:active":{bg:"$tonal100",svg:{color:"$tonal500"}},"&:disabled":{opacity:.3,pointerEvents:"none"}}),b=e.forwardRef((n,r)=>{const{icon:l,disabledTooltipContent:a,showTooltip:i,...c}=n;return e.createElement(o,null,e.createElement(o.Trigger,{asChild:!0},e.createElement(s,{tabIndex:-1},e.createElement(d,{tabIndex:-1,appearance:"outline",ref:r,...c},e.createElement(p,{is:l})))),i&&e.createElement(o.Content,null,a))});export{b as NumberInputStepper};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NumberInput } from './NumberInput';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ValidationOptions } from '../../components/form';
|
|
3
|
+
import type { CSS } from '../../stitches';
|
|
4
|
+
import type { NumberInputProps } from '../number-input/NumberInput';
|
|
5
|
+
export interface NumberInputFieldProps extends NumberInputProps {
|
|
6
|
+
css?: CSS;
|
|
7
|
+
description?: string;
|
|
8
|
+
label: string;
|
|
9
|
+
name: string;
|
|
10
|
+
prompt?: {
|
|
11
|
+
link: string;
|
|
12
|
+
label: string;
|
|
13
|
+
};
|
|
14
|
+
validation?: ValidationOptions;
|
|
15
|
+
}
|
|
16
|
+
export declare const NumberInputField: React.FC<NumberInputFieldProps>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as i from"react";import{useFormContext as c}from"react-hook-form";import{FieldWrapper as f}from"../field-wrapper/FieldWrapper.js";import"../field-wrapper/InlineFieldWrapper.js";import"../form/Form.js";import{useFieldError as b}from"../form/useFieldError.js";import{NumberInput as F}from"../number-input/NumberInput.js";const m=({css:p,label:n,name:r,validation:e,prompt:a,description:l,...d})=>{const{register:o,trigger:s}=c(),{error:t}=b(r),u=e?o(e):o;return i.createElement(f,{css:p,description:l,error:t,fieldId:r,label:n,prompt:a,required:Boolean(e==null?void 0:e.required)},i.createElement(F,{id:r,name:r,ref:u,...t&&{state:"error","aria-invalid":!0},...d,onChange:s}))};m.displayName="NumberInputField";export{m as NumberInputField};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NumberInputField } from './NumberInputField';
|