@instructure/ui-editable 8.25.1-snapshot.0 → 8.26.1-snapshot-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,29 +1,30 @@
1
- import { Component } from 'react';
2
- import type { EditableProps } from './props';
1
+ import React, { Component } from 'react';
2
+ import { EditableState } from './props';
3
+ import type { EditableProps, GetContainerProps, GetEditButtonProps, GetEditorProps, GetViewerProps } from './props';
3
4
  /**
4
5
  ---
5
6
  category: components
6
- experimental: true
7
7
  ---
8
+ @tsProps
8
9
  **/
9
10
  declare class Editable extends Component<EditableProps> {
10
11
  static propTypes: import("@instructure/shared-types/types/UtilityTypes").PropValidators<keyof {
11
12
  mode: "view" | "edit";
12
- onChangeMode: (...args: any[]) => any;
13
- children?: ((...args: any[]) => any) | undefined;
14
- render?: ((...args: any[]) => any) | undefined;
13
+ onChangeMode: (newMode: string) => void;
14
+ children?: ((props: import("./props").EditableRenderProps) => React.ReactNode) | undefined;
15
+ render?: ((props: import("./props").EditableRenderProps) => React.ReactNode) | undefined;
15
16
  value?: any;
16
- onChange?: ((...args: any[]) => any) | undefined;
17
+ onChange?: ((value: any) => void) | undefined;
17
18
  readOnly?: boolean | undefined;
18
19
  elementRef?: ((element: Element | null) => void) | undefined;
19
20
  }>;
20
21
  static allowedProps: readonly (keyof {
21
22
  mode: "view" | "edit";
22
- onChangeMode: (...args: any[]) => any;
23
- children?: ((...args: any[]) => any) | undefined;
24
- render?: ((...args: any[]) => any) | undefined;
23
+ onChangeMode: (newMode: string) => void;
24
+ children?: ((props: import("./props").EditableRenderProps) => React.ReactNode) | undefined;
25
+ render?: ((props: import("./props").EditableRenderProps) => React.ReactNode) | undefined;
25
26
  value?: any;
26
- onChange?: ((...args: any[]) => any) | undefined;
27
+ onChange?: ((value: any) => void) | undefined;
27
28
  readOnly?: boolean | undefined;
28
29
  elementRef?: ((element: Element | null) => void) | undefined;
29
30
  })[];
@@ -31,51 +32,30 @@ declare class Editable extends Component<EditableProps> {
31
32
  readOnly: boolean;
32
33
  children: null;
33
34
  };
34
- state: {
35
- showModeToggle: boolean;
36
- valueOnEdit: null;
37
- };
38
- _editorRef: null;
39
- _editButtonRef: null;
40
- constructor(props: any);
35
+ state: EditableState;
36
+ _editorRef: HTMLInputElement | null;
37
+ _editButtonRef: HTMLButtonElement | null;
38
+ constructor(props: EditableProps);
41
39
  componentDidMount(): void;
42
- componentWillUnmount(): void;
43
- componentDidUpdate(prevProps: any): void;
40
+ componentDidUpdate(prevProps: EditableProps): void;
44
41
  focusEditor(): void;
45
42
  enterView(): void;
46
43
  enterEdit(): void;
47
- handleEditESC: (event: any) => void;
48
- handleViewMouseOver: (event: any) => void;
49
- handleViewMouseOut: (event: any) => void;
50
- handleViewClick: (event: any) => void;
51
- handleEditBlur: (event: any) => void;
52
- handleEditButtonFocus: (event: any) => void;
53
- handleEditButtonBlur: (event: any) => void;
54
- handleEditButtonClick: (event: any) => void;
44
+ handleEditESC: (event: React.KeyboardEvent) => void;
45
+ handleViewMouseOver: (event: React.MouseEvent) => void;
46
+ handleViewMouseOut: (event: React.MouseEvent) => void;
47
+ handleViewClick: (event: React.MouseEvent) => void;
48
+ handleEditBlur: () => void;
49
+ handleEditButtonFocus: () => void;
50
+ handleEditButtonBlur: () => void;
51
+ handleEditButtonClick: () => void;
55
52
  ref: Element | null;
56
53
  handleContainerRef: (el: Element | null) => void;
57
- getContainerProps: (props?: {}) => {
58
- ref: (el: Element | null) => void;
59
- onMouseOver: (event: any) => void;
60
- onMouseOut: (event: any) => void;
61
- onMouseDown: ((event: any) => void) | null;
62
- onKeyUp: ((event: any) => void) | null;
63
- readOnly: boolean | undefined;
64
- };
65
- getViewerProps: (props?: {}) => {
66
- mode: "view" | "edit";
67
- readOnly: boolean | undefined;
68
- };
69
- getEditorProps: (props: any) => any;
70
- getEditButtonProps: (props?: {}) => {
71
- onClick: (event: any) => void;
72
- onFocus: (event: any) => void;
73
- onBlur: (event: any) => void;
74
- isVisible: boolean;
75
- buttonRef: (el: any) => void;
76
- readOnly: boolean | undefined;
77
- };
78
- render(): any;
54
+ getContainerProps: GetContainerProps;
55
+ getViewerProps: GetViewerProps;
56
+ getEditorProps: GetEditorProps;
57
+ getEditButtonProps: GetEditButtonProps;
58
+ render(): React.ReactNode;
79
59
  }
80
60
  export default Editable;
81
61
  export { Editable };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Editable/index.tsx"],"names":[],"mappings":"AAuBA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAOjC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE5C;;;;;GAKG;AACH,cAAM,QAAS,SAAQ,SAAS,CAAC,aAAa,CAAC;IAC7C,MAAM,CAAC,SAAS;;;;;;;;;OAAY;IAC5B,MAAM,CAAC,YAAY;;;;;;;;;SAAe;IAClC,MAAM,CAAC,YAAY;;;MAGlB;IAED,KAAK;;;MAGJ;IAED,UAAU,OAAO;IACjB,cAAc,OAAO;gBAGT,KAAK,KAAA;IASjB,iBAAiB;IAKjB,oBAAoB;IAGpB,kBAAkB,CAAC,SAAS,KAAA;IAmB5B,WAAW;IAWX,SAAS;IAOT,SAAS;IAUT,aAAa,uBAIZ;IAGD,mBAAmB,uBAMlB;IAGD,kBAAkB,uBAOjB;IAGD,eAAe,uBAMd;IAGD,cAAc,uBAEb;IAGD,qBAAqB,uBAEpB;IAGD,oBAAoB,uBAEnB;IAGD,qBAAqB,uBAEpB;IAED,GAAG,EAAE,OAAO,GAAG,IAAI,CAAO;IAE1B,kBAAkB,OAAQ,OAAO,GAAG,IAAI,UAQvC;IAGD,iBAAiB;kBAXS,OAAO,GAAG,IAAI;;;;;;MAsBvC;IAED,cAAc;;;MAMb;IAGD,cAAc,sBAWb;IAED,kBAAkB;;;;;;;MAajB;IAED,MAAM;CAeP;AAED,eAAe,QAAQ,CAAA;AACvB,OAAO,EAAE,QAAQ,EAAE,CA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,12 +1,78 @@
1
+ import React from 'react';
1
2
  import type { PropValidators } from '@instructure/shared-types';
3
+ declare type GetContainerProps = (props?: Record<string, any>) => {
4
+ ref: React.RefCallback<any>;
5
+ onMouseOver: (event: React.MouseEvent) => void;
6
+ onMouseOut: (event: React.MouseEvent) => void;
7
+ onMouseDown?: (event: React.MouseEvent) => void;
8
+ onKeyUp?: (event: React.KeyboardEvent) => void;
9
+ readOnly?: boolean;
10
+ } & Record<string, any>;
11
+ declare type GetViewerProps = (props?: Record<string, any>) => {
12
+ mode: 'view' | 'edit';
13
+ readOnly?: boolean;
14
+ } & Record<string, any>;
15
+ declare type GetEditorProps = (props?: Record<string, any>) => {
16
+ mode: 'view' | 'edit';
17
+ onBlur: () => void;
18
+ editorRef: (el: HTMLElement | null) => void;
19
+ readOnly?: boolean;
20
+ } & Record<string, any>;
21
+ declare type GetEditButtonProps = (props?: Record<string, any>) => {
22
+ onClick: () => void;
23
+ onFocus: () => void;
24
+ onBlur: () => void;
25
+ isVisible: boolean;
26
+ buttonRef: (el: Element) => void;
27
+ readOnly?: boolean;
28
+ } & Record<string, any>;
29
+ declare type EditableRenderProps = {
30
+ mode: string;
31
+ getContainerProps: GetContainerProps;
32
+ getViewerProps: GetViewerProps;
33
+ getEditorProps: GetEditorProps;
34
+ getEditButtonProps: GetEditButtonProps;
35
+ };
2
36
  declare type EditableOwnProps = {
37
+ /**
38
+ * If `'view'`: the view component is rendered,
39
+ * if `'edit'`: the edit component is rendered
40
+ */
3
41
  mode: 'view' | 'edit';
4
- onChangeMode: (...args: any[]) => any;
5
- children?: (...args: any[]) => any;
6
- render?: (...args: any[]) => any;
42
+ /**
43
+ * Called when the component's mode changes.
44
+ */
45
+ onChangeMode: (newMode: string) => void;
46
+ /**
47
+ * Function that you can supply that will return the children of this component.
48
+ * It has one parameter has the following fields:
49
+ * - mode: `view` or `edit`, depending on whether the view or the editor should be rendered.
50
+ * - getContainerProps(props) - Props to be spread onto the container element
51
+ * - getEditorProps(props) - Props to be spread onto the editor element
52
+ * - getEditButtonProps(props) - Props to be spread onto the edit button element
53
+ */
54
+ children?: (props: EditableRenderProps) => React.ReactNode;
55
+ /**
56
+ * Identical to children
57
+ */
58
+ render?: (props: EditableRenderProps) => React.ReactNode;
59
+ /**
60
+ * The current value.
61
+ * The value is managed by the consuming app, but we need to tell Editable
62
+ * it's changed or it won't re-render
63
+ */
7
64
  value?: any;
8
- onChange?: (...args: any[]) => any;
65
+ /**
66
+ * Called when Editable switches from edit to view mode and the value has changed.
67
+ */
68
+ onChange?: (value: any) => void;
69
+ /**
70
+ * The mode is fixed as 'view'
71
+ */
9
72
  readOnly?: boolean;
73
+ /**
74
+ * provides a reference to the underlying html root element (container)
75
+ */
10
76
  elementRef?: (element: Element | null) => void;
11
77
  };
12
78
  declare type PropKeys = keyof EditableOwnProps;
@@ -14,6 +80,10 @@ declare type AllowedPropKeys = Readonly<Array<PropKeys>>;
14
80
  declare type EditableProps = EditableOwnProps;
15
81
  declare const propTypes: PropValidators<PropKeys>;
16
82
  declare const allowedProps: AllowedPropKeys;
17
- export type { EditableProps };
83
+ declare type EditableState = {
84
+ showModeToggle: boolean;
85
+ valueOnEdit: any;
86
+ };
87
+ export type { EditableProps, EditableRenderProps, EditableState, GetContainerProps, GetEditButtonProps, GetEditorProps, GetViewerProps };
18
88
  export { propTypes, allowedProps };
19
89
  //# sourceMappingURL=props.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../src/Editable/props.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAE/D,aAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;IACrB,YAAY,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAA;IACrC,QAAQ,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAA;IACl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1
1
  /** @jsx jsx */
2
2
  import { Component } from 'react';
3
+ import type { IconButtonProps } from '@instructure/ui-buttons';
3
4
  import { jsx } from '@instructure/emotion';
4
5
  import type { InPlaceEditProps } from './props';
6
+ import type { EditableRenderProps } from '../Editable/props';
5
7
  /**
6
8
  ---
7
9
  category: components
8
10
  ---
11
+ @tsProps
9
12
  **/
10
13
  declare class InPlaceEdit extends Component<InPlaceEditProps> {
11
14
  static readonly componentId = "InPlaceEdit";
12
15
  static propTypes: import("@instructure/shared-types/types/UtilityTypes").PropValidators<keyof {
13
- renderViewer: (...args: any[]) => any;
14
- renderEditor: (...args: any[]) => any;
15
- renderEditButton: (...args: any[]) => any;
16
+ renderViewer: () => import("react").ReactNode;
17
+ renderEditor: ({ onBlur, editorRef }: {
18
+ onBlur: () => void;
19
+ editorRef: (el: HTMLElement | null) => void;
20
+ }) => import("react").ReactNode;
21
+ renderEditButton: (props: {
22
+ elementRef?: ((el: HTMLButtonElement) => void) | undefined;
23
+ onClick: () => void;
24
+ onFocus: () => void;
25
+ onBlur: () => void;
26
+ isVisible: boolean;
27
+ readOnly?: boolean | undefined;
28
+ }) => import("react").ReactNode;
16
29
  mode: "view" | "edit";
17
- onChangeMode: (...args: any[]) => any;
30
+ onChangeMode: (newMode: string) => void;
18
31
  value?: any;
19
- onChange?: ((...args: any[]) => any) | undefined;
32
+ onChange?: ((value: any) => void) | undefined;
20
33
  readOnly?: boolean | undefined;
21
34
  showFocusRing?: boolean | undefined;
22
35
  editButtonPlacement?: "start" | "end" | undefined;
23
36
  inline?: boolean | undefined;
24
37
  }>;
25
38
  static allowedProps: readonly (keyof {
26
- renderViewer: (...args: any[]) => any;
27
- renderEditor: (...args: any[]) => any;
28
- renderEditButton: (...args: any[]) => any;
39
+ renderViewer: () => import("react").ReactNode;
40
+ renderEditor: ({ onBlur, editorRef }: {
41
+ onBlur: () => void;
42
+ editorRef: (el: HTMLElement | null) => void;
43
+ }) => import("react").ReactNode;
44
+ renderEditButton: (props: {
45
+ elementRef?: ((el: HTMLButtonElement) => void) | undefined;
46
+ onClick: () => void;
47
+ onFocus: () => void;
48
+ onBlur: () => void;
49
+ isVisible: boolean;
50
+ readOnly?: boolean | undefined;
51
+ }) => import("react").ReactNode;
29
52
  mode: "view" | "edit";
30
- onChangeMode: (...args: any[]) => any;
53
+ onChangeMode: (newMode: string) => void;
31
54
  value?: any;
32
- onChange?: ((...args: any[]) => any) | undefined;
55
+ onChange?: ((value: any) => void) | undefined;
33
56
  readOnly?: boolean | undefined;
34
57
  showFocusRing?: boolean | undefined;
35
58
  editButtonPlacement?: "start" | "end" | undefined;
@@ -42,37 +65,21 @@ declare class InPlaceEdit extends Component<InPlaceEditProps> {
42
65
  editButtonPlacement: string;
43
66
  };
44
67
  ref: Element | null;
68
+ _editButtonRef: HTMLButtonElement | null;
45
69
  handleRef: (el: Element | null) => void;
46
- constructor(props: any);
70
+ constructor(props: InPlaceEditProps);
47
71
  componentDidMount(): void;
48
- componentDidUpdate(prevProps: any, prevState: any, snapshot: any): void;
49
- handleEditButtonRef: (el: any) => void;
50
- renderEditor({ mode, onBlur, editorRef, readOnly }: {
51
- mode: any;
52
- onBlur: any;
53
- editorRef: any;
54
- readOnly: any;
55
- }): jsx.JSX.Element | null;
56
- renderViewer({ readOnly, mode }: {
57
- readOnly: any;
58
- mode: any;
59
- }): any;
60
- renderEditButton({ buttonRef, ...rest }: {
61
- [x: string]: any;
62
- buttonRef: any;
63
- }): any;
72
+ componentDidUpdate(): void;
73
+ handleEditButtonRef: (el: HTMLButtonElement) => void;
74
+ renderEditor({ mode, onBlur, editorRef, readOnly }: ReturnType<EditableRenderProps['getEditorProps']>): jsx.JSX.Element | null;
75
+ renderViewer({ readOnly, mode }: ReturnType<EditableRenderProps['getViewerProps']>): import("react").ReactNode;
76
+ renderEditButton({ buttonRef, ...rest }: ReturnType<EditableRenderProps['getEditButtonProps']>): import("react").ReactNode;
64
77
  static renderDefaultEditButton: ({ isVisible, readOnly, label, ...buttonProps }: {
65
- [x: string]: any;
66
- isVisible: any;
67
- readOnly: any;
68
- label: any;
69
- }) => jsx.JSX.Element | null;
70
- renderAll: ({ getContainerProps, getViewerProps, getEditorProps, getEditButtonProps }: {
71
- getContainerProps: any;
72
- getViewerProps: any;
73
- getEditorProps: any;
74
- getEditButtonProps: any;
75
- }) => jsx.JSX.Element;
78
+ isVisible: boolean;
79
+ readOnly?: boolean | undefined;
80
+ label: string;
81
+ } & Partial<IconButtonProps>) => jsx.JSX.Element | null;
82
+ renderAll: ({ getContainerProps, getViewerProps, getEditorProps, getEditButtonProps }: EditableRenderProps) => jsx.JSX.Element;
76
83
  render(): jsx.JSX.Element;
77
84
  }
78
85
  export default InPlaceEdit;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/InPlaceEdit/index.tsx"],"names":[],"mappings":"AAwBA,eAAe;AACf,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAOjC,OAAO,EAAa,GAAG,EAAE,MAAM,sBAAsB,CAAA;AAOrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE/C;;;;GAIG;AACH,cACM,WAAY,SAAQ,SAAS,CAAC,gBAAgB,CAAC;IACnD,MAAM,CAAC,QAAQ,CAAC,WAAW,iBAAgB;IAC3C,MAAM,CAAC,SAAS;;;;;;;;;;;;OAAY;IAC5B,MAAM,CAAC,YAAY;;;;;;;;;;;;SAAe;IAClC,MAAM,CAAC,YAAY;;;;;MAKlB;IAED,GAAG,EAAE,OAAO,GAAG,IAAI,CAAO;IAE1B,SAAS,OAAQ,OAAO,GAAG,IAAI,UAE9B;gBAGW,KAAK,KAAA;IASjB,iBAAiB;IAMjB,kBAAkB,CAAC,SAAS,KAAA,EAAE,SAAS,KAAA,EAAE,QAAQ,KAAA;IAMjD,mBAAmB,oBAGlB;IAGD,YAAY,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE;;;;;KAA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AAgB,CAAC,CAAC;IAmBpD,YAAY,CAAC,EACX,QAAQ,EACR,IAAI,EACL,EAAE,UAAU,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;IAIpD,gBAAgB,CAAC,EACf,SAAS,EACT,GAAG,IAAI,EACR,EAAE,UAAU,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,CAAC;IASxD,MAAM,CAAC,uBAAuB;mBAMjB,OAAO;;eAEX,MAAM;4DAgBd;IAED,SAAS,8EAKN,mBAAmB,qBAwBrB;IAED,MAAM;CAeP;AAED,eAAe,WAAW,CAAA;AAC1B,OAAO,EAAE,WAAW,EAAE,CAAA"}
@@ -1,16 +1,97 @@
1
1
  import type { PropValidators } from '@instructure/shared-types';
2
2
  import type { WithStyleProps, ComponentStyle } from '@instructure/emotion';
3
+ import type { EditableProps } from '../Editable/props';
4
+ import React from 'react';
5
+ declare type ExtendedRenderEditButton = {
6
+ elementRef?: (el: HTMLButtonElement) => void;
7
+ onClick: () => void;
8
+ onFocus: () => void;
9
+ onBlur: () => void;
10
+ isVisible: boolean;
11
+ readOnly?: boolean;
12
+ };
3
13
  declare type InPlaceEditOwnProps = {
4
- renderViewer: (...args: any[]) => any;
5
- renderEditor: (...args: any[]) => any;
6
- renderEditButton: (...args: any[]) => any;
14
+ /**
15
+ * Function to render the view mode component.
16
+ * It is the consumer's responsibility to provide the
17
+ * current value or children.
18
+ *
19
+ * Return value:
20
+ * - element: the viewer DOM sub-tree.
21
+ */
22
+ renderViewer: () => React.ReactNode;
23
+ /**
24
+ * Function to render the edit mode component
25
+ * It is the consumer's responsibility to provide the
26
+ * current value, and to attach the appropriate onChange
27
+ * event handler needed to capture the updated value. This
28
+ * new value must then be forwarded to the view mode component.
29
+ *
30
+ * Return value:
31
+ * - element: the editor DOM sub-tree.
32
+ */
33
+ renderEditor: ({ onBlur, editorRef }: {
34
+ onBlur: () => void;
35
+ editorRef: (el: HTMLElement | null) => void;
36
+ }) => React.ReactNode;
37
+ /**
38
+ * Function to render the edit button.
39
+ *
40
+ * Parameters:
41
+ * - object: { isVisible, onClick, onFocus, onBlur, buttonRef }
42
+ *
43
+ * Return value:
44
+ *
45
+ * - element: the edit button DOM sub-tree
46
+ *
47
+ * If you choose to use the default edit button, add `label` to the
48
+ * incoming `props` parameter and call `InPlaceEdit.renderDefaultEditButton(props)`
49
+ *
50
+ * If you choose to render a custom button, attach the on* event handlers
51
+ * and set `buttonRef` as a `ref` type property on the `button` element.
52
+ *
53
+ * `isVisible` is a hint as to whether the button is _typically_ shown,
54
+ * but you're free to ignore it for your use-case.
55
+ */
56
+ renderEditButton: (props: ExtendedRenderEditButton) => React.ReactNode | null;
57
+ /**
58
+ * If `'view'`: the view component is rendered,
59
+ * if `'edit'`: the edit component is rendered
60
+ */
7
61
  mode: 'view' | 'edit';
8
- onChangeMode: (...args: any[]) => any;
62
+ /**
63
+ * Called when the component's mode changes
64
+ * Parameter:
65
+ * - newMode: string
66
+ */
67
+ onChangeMode: EditableProps['onChangeMode'];
68
+ /**
69
+ * The current value.
70
+ * The value is managed by the consuming app, but we need to tell InPlaceEdit
71
+ * it's changed or it won't re-render
72
+ */
9
73
  value?: any;
10
- onChange?: (...args: any[]) => any;
74
+ /**
75
+ * Called when Editable switches from edit to view mode and the value has changed.
76
+ * Parameter:
77
+ * - value: any
78
+ */
79
+ onChange?: EditableProps['onChange'];
80
+ /**
81
+ * The mode is fixed as 'view'
82
+ */
11
83
  readOnly?: boolean;
84
+ /**
85
+ * Show a focus outline when the input is focused
86
+ */
12
87
  showFocusRing?: boolean;
88
+ /**
89
+ * Put the edit button before or after the view
90
+ */
13
91
  editButtonPlacement?: 'start' | 'end';
92
+ /**
93
+ * Render outermost element inline v. block
94
+ */
14
95
  inline?: boolean;
15
96
  };
16
97
  declare type PropKeys = keyof InPlaceEditOwnProps;
@@ -1 +1 @@
1
- {"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../src/InPlaceEdit/props.ts"],"names":[],"mappings":"AA0BA,OAAO,K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,CAAC,UAAU,CAAC,CAAA;IACpC;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,GAAG,KAAK,CAAA;IACrC;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,aAAK,QAAQ,GAAG,MAAM,mBAAmB,CAAA;AAEzC,aAAK,eAAe,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAA;AAEhD,aAAK,gBAAgB,GAAG,mBAAmB,GACzC,cAAc,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAA;AAExC,aAAK,gBAAgB,GAAG,cAAc,CAAC,aAAa,CAAC,CAAA;AAErD,QAAA,MAAM,SAAS,EAAE,cAAc,CAAC,QAAQ,CAYvC,CAAA;AAED,QAAA,MAAM,YAAY,EAAE,eAYnB,CAAA;AAED,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,CAAA"}
package/LICENSE.md DELETED
@@ -1,27 +0,0 @@
1
- ---
2
- title: The MIT License (MIT)
3
- category: Getting Started
4
- order: 9
5
- ---
6
-
7
- # The MIT License (MIT)
8
-
9
- Copyright (c) 2015 Instructure, Inc.
10
-
11
- **Permission is hereby granted, free of charge, to any person obtaining a copy
12
- of this software and associated documentation files (the "Software"), to deal
13
- in the Software without restriction, including without limitation the rights
14
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
- copies of the Software, and to permit persons to whom the Software is
16
- furnished to do so, subject to the following conditions.**
17
-
18
- The above copyright notice and this permission notice shall be included in all
19
- copies or substantial portions of the Software.
20
-
21
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
- SOFTWARE.