@mpen/react-basic-inputs 0.1.11 → 0.2.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.
@@ -1,33 +0,0 @@
1
- import { Key, ReactNode } from 'react';
2
- import { Resolvable } from '../util/resolvable';
3
- import { EventCallback, HtmlSelectElement, NonNil, OverrideProps } from "../types/utility";
4
- export type SelectOption<T> = OverrideProps<'option', {
5
- value: T;
6
- text: ReactNode;
7
- key?: Resolvable<Key, [SelectOption<T>, number]>;
8
- }, 'children' | 'selected'>;
9
- export interface SelectChangeEvent<T> {
10
- value: T;
11
- index: number;
12
- type: 'change';
13
- timeStamp: number;
14
- target: HtmlSelectElement;
15
- }
16
- export type SelectChangeEventHandler<T> = EventCallback<SelectChangeEvent<T>>;
17
- export type InvalidValueToOption<T> = (value: T) => SelectOption<T>;
18
- export type SelectProps<T extends NonNil> = OverrideProps<'select', {
19
- options: SelectOption<T>[];
20
- value?: T | null;
21
- onChange?: SelectChangeEventHandler<T>;
22
- /**
23
- * Function used to create an <option> when `value` cannot be found in the list of `options`.
24
- * Set to `null` to disable this behavior.
25
- * By default, stringifies `value`.
26
- */
27
- invalidValueOption?: InvalidValueToOption<T> | null;
28
- /**
29
- * Text to display when `value` is nullish.
30
- */
31
- placeholder?: ReactNode;
32
- }, 'children' | 'defaultValue'>;
33
- export declare function Select<T extends NonNil>({ options, value, invalidValueOption, onChange, placeholder, ...selectAttrs }: SelectProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -1,14 +0,0 @@
1
- /// <reference types="react" />
2
- import { HtmlTextAreaElement, OverrideProps, VoidFn } from '../types/utility';
3
- export type TextAreaRef = {
4
- element: HtmlTextAreaElement;
5
- adjustHeight: VoidFn;
6
- };
7
- export type TextAreaProps = OverrideProps<'textarea', {
8
- /** Initial/minimum height. "0" or "auto" are good choices. Defaults to "auto" */
9
- initialHeight?: string;
10
- }>;
11
- export declare const TextArea: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "ref">, "initialHeight"> & {
12
- /** Initial/minimum height. "0" or "auto" are good choices. Defaults to "auto" */
13
- initialHeight?: string;
14
- } & import("react").RefAttributes<TextAreaRef>>;
@@ -1,3 +0,0 @@
1
- import { InputProps } from "./Input";
2
- export type TextInputProps = Omit<InputProps, 'text'>;
3
- export declare function TextInput({ formatOnChange, ...otherProps }: TextInputProps): import("react/jsx-runtime").JSX.Element;
@@ -1,6 +0,0 @@
1
- import { AnyFn, EventCallback } from "../types/utility";
2
- /**
3
- * @see https://github.com/reactjs/rfcs/blob/useevent/text/0000-useevent.md
4
- */
5
- export declare let useEventHandler: <TCallback extends AnyFn>(callback: TCallback) => TCallback;
6
- export default function useEvent<T>(handler: EventCallback<T>): EventCallback<T>;
@@ -1,31 +0,0 @@
1
- export type Fn<TArgs extends ReadonlyArray<unknown> = unknown[], TRet = unknown> = (...args: TArgs[]) => TRet;
2
- export type AnyFn = (...args: any[]) => any;
3
- export type EventCallback<T = never> = (ev: T) => void;
4
- export type VoidFn = () => void;
5
- export type EmptyObject = Record<PropertyKey, never>;
6
- export type UnknownObject = Record<PropertyKey, unknown>;
7
- export type Override<Base, Extension, DeleteKeys extends PropertyKey = never> = Omit<Base, keyof Extension | DeleteKeys> & Extension;
8
- export type PartiallyRequired<Type, Key extends keyof Type> = Omit<Type, Key> & Required<Pick<Type, Key>>;
9
- export type Optionalize<T1 extends T2, T2> = Omit<T1, keyof T2> & Partial<Pick<T1, keyof T2>>;
10
- /**
11
- * Nullish. Either `null` or `undefined`.
12
- */
13
- export type nil = null | undefined;
14
- /**
15
- * Not null or undefined.
16
- */
17
- export type NonNil = {};
18
- export type OverrideProps<Base extends import('react').ElementType, Extension, DeleteKeys extends PropertyKey = never> = Override<import('react').ComponentPropsWithoutRef<Base>, Extension, DeleteKeys>;
19
- export type OmitProps<Base extends import('react').ElementType, DeleteKeys extends PropertyKey> = Omit<import('react').ComponentPropsWithoutRef<Base>, DeleteKeys>;
20
- export type MapKeyType<M> = M extends Map<infer K, any> ? K : never;
21
- export type MapValueType<M> = M extends Map<any, infer V> ? V : never;
22
- /** Hack to de-conflict React's HTMLInputElement vs the standard dom lib */
23
- export type HtmlTextAreaElement = HTMLElementTagNameMap['textarea'];
24
- export type HtmlInputElement = HTMLElementTagNameMap['input'];
25
- export type HtmlSelectElement = HTMLElementTagNameMap['select'];
26
- export type HtmlInputChangeEvent = import('react').ChangeEvent<HtmlInputElement>;
27
- export type ArrayType<T extends any[]> = T[number];
28
- type _UnionKeys<T> = T extends T ? keyof T : never;
29
- type _StrictUnionHelper<T, TAll> = T extends any ? T & Partial<Record<Exclude<_UnionKeys<TAll>, keyof T>, never>> : never;
30
- export type XOR<T> = _StrictUnionHelper<T, T>;
31
- export {};
@@ -1 +0,0 @@
1
- export declare function cast<T>(val: any): asserts val is T;
@@ -1,5 +0,0 @@
1
- import { AnyFn, NonNil } from "../types/utility";
2
- export declare const EMPTY_OBJECT: Readonly<NonNil>;
3
- export declare const EMPTY_ARRAY: ReadonlyArray<any>;
4
- export declare const NOOP: AnyFn;
5
- export declare function identity<T>(x: T): T;
@@ -1,9 +0,0 @@
1
- import { nil } from "../types/utility";
2
- export declare function collapseWhitespace(str: string | nil): string;
3
- export declare function formatEmail(str: string | nil): string;
4
- export declare function formatUrl(str: string | nil): string;
5
- export declare function fullWide(n: number): string;
6
- export declare function stringToNumber(n: string): number;
7
- export declare function numberToString(f: number): string;
8
- export declare function formatStrNumber(n: string): string;
9
- export declare function formatUsername(str: string | nil): string;
@@ -1,8 +0,0 @@
1
- import { Key } from 'react';
2
- /**
3
- * Produces unique React Keys from an option.
4
- */
5
- export declare class KeyFixer {
6
- usedKeys: Map<Key, number>;
7
- fix(opt: any, idx: number): Key;
8
- }
@@ -1,4 +0,0 @@
1
- import { Fn } from "../types/utility";
2
- export type Resolvable<TValue = unknown, TArgs extends ReadonlyArray<unknown> = []> = TValue extends any ? TValue | ((...args: TArgs) => TValue) : never;
3
- export type Resolved<T> = T extends Fn ? ReturnType<T> : T;
4
- export declare function resolveValue<TValue, TArgs extends ReadonlyArray<any>>(val: Resolvable<TValue, TArgs>, ...args: TArgs): TValue;