@atom-learning/components 2.3.0 → 2.4.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/CHANGELOG.md +2 -2
- package/dist/components/index.d.ts +1 -0
- package/dist/components/search-field/SearchField.d.ts +15 -0
- package/dist/components/search-field/SearchField.js +1 -0
- package/dist/components/search-field/index.d.ts +1 -0
- package/dist/components/search-input/SearchInput.d.ts +1 -2
- package/dist/components/search-input/SearchInput.js +1 -1
- package/dist/components/search-input/index.d.ts +1 -0
- package/dist/docgen.json +1 -1
- package/dist/docs/SearchField.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,9 +1,9 @@
|
|
|
1
|
-
# [2.
|
|
1
|
+
# [2.4.0](https://github.com/Atom-Learning/components/compare/v2.3.0...v2.4.0) (2022-09-21)
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
### Features
|
|
5
5
|
|
|
6
|
-
*
|
|
6
|
+
* search field ([745c5bd](https://github.com/Atom-Learning/components/commit/745c5bd06206abbc5afc64399be3a9b5ee3d3db9))
|
|
7
7
|
|
|
8
8
|
# [1.4.0](https://github.com/Atom-Learning/components/compare/v1.3.0...v1.4.0) (2022-04-11)
|
|
9
9
|
|
|
@@ -47,6 +47,7 @@ export { RadioButton, RadioButtonGroup } from './radio-button';
|
|
|
47
47
|
export { RadioButtonField } from './radio-button-field';
|
|
48
48
|
export { RadioCard, RadioCardGroup } from './radio-card';
|
|
49
49
|
export { SearchInput } from './search-input';
|
|
50
|
+
export { SearchField } from './search-field';
|
|
50
51
|
export { Select } from './select';
|
|
51
52
|
export { SelectField } from './select-field';
|
|
52
53
|
export { Slider } from './slider';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ValidationOptions } from '../../components/form';
|
|
3
|
+
import { SearchInputProps } from '../../components/search-input';
|
|
4
|
+
declare type SearchFieldProps = SearchInputProps & {
|
|
5
|
+
description?: string;
|
|
6
|
+
label: string;
|
|
7
|
+
name: string;
|
|
8
|
+
prompt?: {
|
|
9
|
+
link: string;
|
|
10
|
+
label: string;
|
|
11
|
+
};
|
|
12
|
+
validation?: ValidationOptions;
|
|
13
|
+
};
|
|
14
|
+
export declare const SearchField: React.FC<SearchFieldProps>;
|
|
15
|
+
export {};
|
|
@@ -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 u}from"../form/useFieldError.js";import{SearchInput as F}from"../search-input/SearchInput.js";const m=({css:p,label:a,name:r,validation:e,prompt:l,description:d,...n})=>{const{register:o}=c(),{error:t}=u(r),s=e?o(e):o;return i.createElement(f,{css:p,description:d,error:t,fieldId:r,label:a,prompt:l,required:Boolean(e==null?void 0:e.required)},i.createElement(F,{id:r,name:r,ref:s,...t&&{state:"error"},...n}))};m.displayName="SearchField";export{m as SearchField};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SearchField } from './SearchField';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Input } from '../../components/input';
|
|
3
3
|
import { CSS } from '../../stitches';
|
|
4
|
-
declare type SearchInputProps = React.ComponentProps<typeof Input> & {
|
|
4
|
+
export declare type SearchInputProps = React.ComponentProps<typeof Input> & {
|
|
5
5
|
size: 'sm' | 'md';
|
|
6
6
|
css?: CSS;
|
|
7
7
|
value?: string;
|
|
@@ -9,4 +9,3 @@ declare type SearchInputProps = React.ComponentProps<typeof Input> & {
|
|
|
9
9
|
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
10
10
|
};
|
|
11
11
|
export declare const SearchInput: React.FC<SearchInputProps>;
|
|
12
|
-
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Search as
|
|
1
|
+
import{Search as z,Close as y}from"@atom-learning/icons";import*as t from"react";import{ActionIcon as H}from"../action-icon/ActionIcon.js";import{Box as I}from"../box/Box.js";import{Icon as l}from"../icon/Icon.js";import{Input as k}from"../input/Input.js";import{styled as p}from"../../stitches.js";import{useCallbackRef as L}from"../../utilities/hooks/useCallbackRef.js";var $=(e=>(e.SEARCH="SEARCH",e.CLEAR="CLEAR",e))($||{});const x=p(l,{color:"$tonal300",position:"absolute",pointerEvents:"none",variants:{size:{sm:{top:"$2",right:"$2",size:"$1"},md:{top:10,right:10,size:20}}}}),O=p(k,{'&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, & input[type="search"]::-webkit-search-results-decoration':{display:"none"}}),u=t.forwardRef(({size:e="md",css:m,value:n,clearText:E="Clear",onChange:a,...h},b)=>{const[i,f]=L(),[v,C]=t.useState(n||""),[d,R]=t.useState(n?"CLEAR":"SEARCH");t.useImperativeHandle(b,()=>i.current);const A=()=>{var r,c;const o=i.current;if(!o)return;const s=(r=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value"))==null?void 0:r.set;(c=s==null?void 0:s.call)==null||c.call(s,o,"");const w=new Event("input",{bubbles:!0});o.dispatchEvent(w),o.focus()},S=r=>{C(r.target.value),R(r.target.value?"CLEAR":"SEARCH"),a==null||a(r)},g=()=>d==="SEARCH"?t.createElement(x,{is:z,size:e,css:{size:e=="sm"?"$1":20}}):t.createElement(H,{label:E,theme:"neutral",size:e,css:{position:"absolute",top:"0",right:"$1"},onClick:A},t.createElement(l,{is:y}));return t.createElement(I,{css:{position:"relative",...m}},t.createElement(O,{ref:f,size:e,type:"search",...h,value:v,onChange:S,css:{pr:e==="sm"?"$5":"$6"}}),g())});u.displayName="SearchInput";export{u as SearchInput};
|