@justeattakeaway/pie-text-input 0.0.0-snapshot-release-20240521111651

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/README.md ADDED
@@ -0,0 +1,146 @@
1
+ <p align="center">
2
+ <img align="center" src="../../../readme_image.png" height="200" alt="">
3
+ </p>
4
+
5
+ <p align="center">
6
+ <a href="https://www.npmjs.com/@justeattakeaway/pie-text-input">
7
+ <img alt="GitHub Workflow Status" src="https://img.shields.io/npm/v/@justeattakeaway/pie-text-input.svg">
8
+ </a>
9
+ </p>
10
+
11
+ # Table of Contents
12
+
13
+ 1. [Introduction](#pie-text-input)
14
+ 2. [Installation](#installation)
15
+ 3. [Importing the component](#importing-the-component)
16
+ 4. [Peer Dependencies](#peer-dependencies)
17
+ 5. [Props](#props)
18
+ 6. [Events](#events)
19
+ 7. [Slots](#slots)
20
+ 8. [Contributing](#contributing)
21
+
22
+ ## pie-text-input
23
+
24
+ `pie-text-input` is a Web Component built using the Lit library.
25
+
26
+ This component can be easily integrated into various frontend frameworks and customized through a set of properties.
27
+
28
+
29
+ ## Installation
30
+
31
+ To install `pie-text-input` in your application, run the following on your command line:
32
+
33
+ ```bash
34
+ # npm
35
+ $ npm i @justeattakeaway/pie-text-input
36
+
37
+ # yarn
38
+ $ yarn add @justeattakeaway/pie-text-input
39
+ ```
40
+
41
+ For full information on using PIE components as part of an application, check out the [Getting Started Guide](https://github.com/justeattakeaway/pie/wiki/Getting-started-with-PIE-Web-Components).
42
+
43
+
44
+ ### Importing the component
45
+
46
+ #### JavaScript
47
+ ```js
48
+ // Default – for Native JS Applications, Vue, Angular, Svelte, etc.
49
+ import { PieTextInput } from '@justeattakeaway/pie-text-input';
50
+
51
+ // If you don't need to reference the imported object, you can simply
52
+ // import the module which registers the component as a custom element.
53
+ import '@justeattakeaway/pie-text-input';
54
+ ```
55
+
56
+ #### React
57
+ ```js
58
+ // React
59
+ // For React, you will need to import our React-specific component build
60
+ // which wraps the web component using ​@lit/react
61
+ import { PieTextInput } from '@justeattakeaway/pie-text-input/dist/react';
62
+ ```
63
+
64
+ > [!NOTE]
65
+ > When using the React version of the component, please make sure to also
66
+ > include React as a [peer dependency](#peer-dependencies) in your project.
67
+
68
+
69
+ ## Peer Dependencies
70
+
71
+ > [!IMPORTANT]
72
+ > When using `pie-text-input`, you will also need to include a couple of dependencies to ensure the component renders as expected. See [the PIE Wiki](https://github.com/justeattakeaway/pie/wiki/Getting-started-with-PIE-Web-Components#expected-dependencies) for more information and how to include these in your application.
73
+
74
+
75
+ ## Props
76
+
77
+ | Property | Type | Default | Description |
78
+ |----------|------|---------|-------------|
79
+ | `autocomplete` | `string` | - | Allows the user to enable or disable autocomplete functionality on the input field. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete) for more information and values. |
80
+ | `autoFocus` | `boolean` | - | If true, the input will be focused on the first render. No more than one element in the document or dialog may have the autofocus attribute. If applied to multiple elements the first one will receive focus. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autofocus) for more information. |
81
+ | `inputmode` | `'none'`, `'text'`, `'tel'`, `'url'`, `'email'`, `'numeric'`, `'decimal'`, `'search'` | - | Provides a hint to browsers as to the type of virtual keyboard configuration to use when editing this element. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#inputmode) for more information. |
82
+ | `maxlength` | `number` | - | Maximum length (number of characters) of value. Only applies to types: `text`, `url`, `tel`, `email`, and `password`. |
83
+ | `minlength` | `number` | - | Minimum length (number of characters) of value. Only applies to types: `text`, `url`, `tel`, `email`, and `password`. |
84
+ | `name` | `string` | - | The name of the input (used as a key/value pair with `value`). This is required in order to work properly with forms. |
85
+ | `pattern` | `string` | - | Specifies a regular expression the form control's value should match. |
86
+ | `placeholder` | `string` | - | The placeholder text to display when the input is empty. Only applies to types: `text`, `url`, `tel`, `email`, and `password`. |
87
+ | `readonly` | `boolean` | - | When true, the user cannot edit the control. Not the same as disabled. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/readonly) for more information. |
88
+ | `type` | `'text'`, `'number'`, `'password'`, `'url'`, `'email'`, `'tel'` | `text` | The type of HTML input to render. |
89
+ | `value` | `string` | `''` | The value of the input (used as a key/value pair in HTML forms with `name`). |
90
+ | `assistiveText` | `string` | `''` | Allows assistive text to be displayed below the input element. |
91
+ | `status` | `'error'`, `'success'` | `undefined` | The status of the input component / assistive text. |
92
+ | `step` | `number` | - | An optional amount that value should be incremented or decremented by when using the up and down arrows in the input. Only applies when type is `number`. |
93
+ | `min` | `number` | - | The minimum value of the input. Only applies when type is `number`. If the value provided is lower, the input is invalid. |
94
+ | `max` | `number` | - | The maximum value of the input. Only applies when type is `number`. If the value provided is higher, the input is invalid. |
95
+ | `size` | `'small'`, `'medium'`, `'large'` | `medium` | The size of the input field. Can be `small`, `medium`, or `large`. Defaults to `medium`. |
96
+ | `required` | `boolean` | `false` | If true, the input is required to have a value before submitting the form. If there is no value, then the component validity state will be invalid. |
97
+
98
+ In your markup or JSX, you can then use these to set the properties for the `pie-text-input` component:
99
+
100
+ ```html
101
+ <!-- Native HTML -->
102
+ <pie-text-input
103
+ autocomplete="on"
104
+ autoFocus
105
+ inputmode="text"
106
+ maxlength="8"
107
+ minlength="4"
108
+ name="myinput"
109
+ pattern="[a-z]{4,8}"
110
+ placeholder="Please enter a value"
111
+ readonly
112
+ type="text"
113
+ value="">
114
+ </pie-text-input>
115
+
116
+ <!-- JSX -->
117
+ <PieTextInput
118
+ autocomplete="on"
119
+ autoFocus
120
+ inputmode="text"
121
+ maxlength={8}
122
+ minlength={4}
123
+ name="myinput"
124
+ pattern="[a-z]{4,8}"
125
+ placeholder="Please enter a value"
126
+ readonly
127
+ type="text"
128
+ value="">
129
+ </PieTextInput>
130
+ ```
131
+
132
+ ## Events
133
+ | Event | Type | Description |
134
+ |-------|------|-------------|
135
+ | `change` | `CustomEvent` | Triggered when the input loses focus after it's value has changed. |
136
+ | `input` | `InputEvent` | Triggered when the input value is changed. |
137
+
138
+ ## Slots
139
+ | Slot | Description |
140
+ |------|-------------|
141
+ | `leading` | An icon or short text to display at the start of the input. |
142
+ | `trailing` | An icon or short text to display at the end of the input. |
143
+
144
+ ## Contributing
145
+
146
+ Check out our [contributing guide](https://github.com/justeattakeaway/pie/wiki/Contributing-Guide) for more information on [local development](https://github.com/justeattakeaway/pie/wiki/Contributing-Guide#local-development) and how to run specific [component tests](https://github.com/justeattakeaway/pie/wiki/Contributing-Guide#testing).