-
Notifications
You must be signed in to change notification settings - Fork 3.1k
docs(input): input masking examples #2993
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
8af4759
fix(tabs): correct router playground src (#2957)
thetaPC 0e98782
docs(app-store): add reference to App Store Connect (#2198)
jstjnsn ba7a19f
docs(developing): update Java instructions to mention JDK 11 for late…
AustineA a27bbc4
docs(react): remove IonContent from tabs example (#2958)
liamdebeasi 860713a
docs(vue): remove IonContent from tabs example (#2959)
liamdebeasi 8dad7c3
docs(dark-mode): replace deprecated addListener() usage (#1908)
eyecatchup d0cf7e1
docs(quickstart): remove typescript for imports and tests (#2216)
praxxys c81e699
fix(CodeColor, LayeredColorsSelect): fix invalid DOM nesting (#2963)
averyjohnston 374b2c0
docs(react): remove unopened closing tag (#2964)
mapsandapps 3def4a7
fix: Ionic CLI links to latest docs page (#2961)
zakuru 6e811ef
docs(tabs): angular usage does not use explicit ion-router-outlet (#2…
sean-perkins 06b82b6
doc(CORS): update the native options (#2954)
kensodemann a209f34
feat(playground): inline dependencies per framework example (#2970)
sean-perkins 016c429
wip: maskito docs
sean-perkins 2dd0e3f
chore: use inline deps
sean-perkins 6704bca
chore: bump version
sean-perkins 44acaf5
fix(angular): async mask predicate
sean-perkins 3c6444c
chore: react and vue examples
sean-perkins f06a4f0
docs: input masking examples
sean-perkins ab0076a
chore: cleanup
sean-perkins 8e6c64c
Update docs/api/input.md
sean-perkins 98231eb
Update static/usage/v7/input/mask/angular/example_component_html.md
sean-perkins 271435b
Update static/usage/v7/input/mask/demo.html
sean-perkins d5bea93
chore: javascript respects mode selection
sean-perkins 43da931
chore: angular respects mode selection
sean-perkins 7777a37
chore: phone number casing
sean-perkins ff7da42
chore: relocate masking examples above theming
sean-perkins 3241459
fix: use ion-content and padding for js example
sean-perkins 04ed660
fix: react example maintains cursor position
sean-perkins 4f6201a
fix: vue example uses async predicate
sean-perkins 0367ecb
docs: install steps, bug reports/support
sean-perkins b5e7bba
Merge remote-tracking branch 'origin/feature-7.1' into sp/maskito
sean-perkins ec24dcf
chore: revert formatting
sean-perkins File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
```ts | ||
import { NgModule } from '@angular/core'; | ||
import { FormsModule } from '@angular/forms'; | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
|
||
import { IonicModule } from '@ionic/angular'; | ||
|
||
import { AppComponent } from './app.component'; | ||
import { ExampleComponent } from './example.component'; | ||
|
||
import { MaskitoModule } from '@maskito/angular'; | ||
|
||
@NgModule({ | ||
imports: [BrowserModule, FormsModule, MaskitoModule, IonicModule.forRoot({})], | ||
declarations: [AppComponent, ExampleComponent], | ||
bootstrap: [AppComponent], | ||
}) | ||
export class AppModule {} | ||
``` |
20 changes: 20 additions & 0 deletions
20
static/usage/v7/input/mask/angular/example_component_html.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
```html | ||
<ion-list> | ||
<ion-item> | ||
<ion-input | ||
label="Card number" | ||
placeholder="0000 0000 0000 0000" | ||
[maskito]="cardMask" | ||
[maskitoElement]="maskPredicate" | ||
></ion-input> | ||
</ion-item> | ||
<ion-item> | ||
<ion-input | ||
label="US phone number" | ||
placeholder="+1 (xxx) xxx-xxxx" | ||
[maskito]="phoneMask" | ||
[maskitoElement]="maskPredicate" | ||
></ion-input> | ||
</ion-item> | ||
</ion-list> | ||
``` |
31 changes: 31 additions & 0 deletions
31
static/usage/v7/input/mask/angular/example_component_ts.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
```ts | ||
import { Component } from '@angular/core'; | ||
|
||
import { MaskitoOptions, MaskitoElementPredicateAsync } from '@maskito/core'; | ||
|
||
@Component({ | ||
selector: 'app-example', | ||
templateUrl: 'example.component.html', | ||
}) | ||
export class ExampleComponent { | ||
readonly phoneMask: MaskitoOptions = { | ||
mask: ['+', '1', ' ', '(', /\d/, /\d/, /\d/, ')', ' ', /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/], | ||
}; | ||
|
||
readonly cardMask: MaskitoOptions = { | ||
mask: [ | ||
...Array(4).fill(/\d/), | ||
' ', | ||
...Array(4).fill(/\d/), | ||
' ', | ||
...Array(4).fill(/\d/), | ||
' ', | ||
...Array(4).fill(/\d/), | ||
' ', | ||
...Array(4).fill(/\d/), | ||
], | ||
}; | ||
|
||
readonly maskPredicate: MaskitoElementPredicateAsync = async (el) => (el as HTMLIonInputElement).getInputElement(); | ||
} | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Input</title> | ||
<link rel="stylesheet" href="../../../common.css" /> | ||
<script src="../../../common.js"></script> | ||
<script type="module" src="https://cdn.jsdelivr.net/npm/@ionic/core@7/dist/ionic/ionic.esm.js"></script> | ||
<script type="module"> | ||
import { Maskito } from 'https://cdn.jsdelivr.net/npm/@maskito/core/index.esm.js'; | ||
window.Maskito = Maskito; | ||
</script> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@ionic/core@7/css/ionic.bundle.css" /> | ||
|
||
<style> | ||
ion-list { | ||
width: 100%; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<ion-app> | ||
<ion-content> | ||
<div class="container"> | ||
<ion-list> | ||
<ion-item> | ||
<ion-input id="card" label="Card number" placeholder="0000 0000 0000 0000"></ion-input> | ||
</ion-item> | ||
<ion-item> | ||
<ion-input id="phone" label="US phone number" placeholder="+1 (xxx) xxx-xxxx"></ion-input> | ||
</ion-item> | ||
</ion-list> | ||
</div> | ||
</ion-content> | ||
</ion-app> | ||
<script> | ||
async function initPhoneMask() { | ||
const ionInput = document.querySelector('#phone'); | ||
const nativeEl = await ionInput.getInputElement(); | ||
|
||
new window.Maskito(nativeEl, { | ||
mask: ['+', '1', ' ', '(', /\d/, /\d/, /\d/, ')', ' ', /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/], | ||
}); | ||
} | ||
|
||
async function initCardMask() { | ||
const ionInput = document.querySelector('#card'); | ||
const nativeEl = await ionInput.getInputElement(); | ||
|
||
new window.Maskito(nativeEl, { | ||
mask: [ | ||
...Array(4).fill(/\d/), | ||
' ', | ||
...Array(4).fill(/\d/), | ||
' ', | ||
...Array(4).fill(/\d/), | ||
' ', | ||
...Array(4).fill(/\d/), | ||
' ', | ||
...Array(4).fill(/\d/), | ||
], | ||
}); | ||
} | ||
|
||
window.addEventListener('appload', () => { | ||
initCardMask(); | ||
initPhoneMask(); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import Playground from '@site/src/components/global/Playground'; | ||
|
||
import javascript_index_html from './javascript/index_html.md'; | ||
import javascript_index_ts from './javascript/index_ts.md'; | ||
|
||
import react_main_tsx from './react.md'; | ||
|
||
import vue_example_vue from './vue.md'; | ||
|
||
import angular_app_module_ts from './angular/app_module_ts.md'; | ||
import angular_example_component_html from './angular/example_component_html.md'; | ||
import angular_example_component_ts from './angular/example_component_ts.md'; | ||
|
||
<Playground | ||
version="7" | ||
code={{ | ||
javascript: { | ||
files: { | ||
'index.html': javascript_index_html, | ||
'index.ts': javascript_index_ts, | ||
}, | ||
dependencies: { | ||
'@maskito/core': '^0.16.0', | ||
}, | ||
}, | ||
react: { | ||
files: { | ||
'src/main.tsx': react_main_tsx, | ||
}, | ||
dependencies: { | ||
'@maskito/react': '^0.16.0', | ||
'@maskito/core': '^0.16.0', | ||
}, | ||
}, | ||
vue: { | ||
files: { | ||
'src/components/Example.vue': vue_example_vue, | ||
}, | ||
dependencies: { | ||
'@maskito/vue': '^0.16.0', | ||
'@maskito/core': '^0.16.0', | ||
}, | ||
}, | ||
angular: { | ||
files: { | ||
'src/app/app.module.ts': angular_app_module_ts, | ||
'src/app/example.component.html': angular_example_component_html, | ||
'src/app/example.component.ts': angular_example_component_ts, | ||
}, | ||
dependencies: { | ||
'@maskito/angular': '^0.16.0', | ||
'@maskito/core': '^0.16.0', | ||
}, | ||
}, | ||
}} | ||
src="usage/v7/input/mask/demo.html" | ||
size="300px" | ||
/> |
sean-perkins marked this conversation as resolved.
Show resolved
Hide resolved
sean-perkins marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
```html | ||
<html> | ||
<head> | ||
<link rel="stylesheet" type="text/css" href="https://cdn.skypack.dev/@ionic/core@7/css/core.css" /> | ||
<link rel="stylesheet" type="text/css" href="https://cdn.skypack.dev/@ionic/core@7/css/ionic.bundle.css" /> | ||
</head> | ||
liamdebeasi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
<body> | ||
<ion-app> | ||
<ion-content class="ion-padding"> | ||
<ion-list> | ||
<ion-item> | ||
<ion-input id="card" label="Card number" placeholder="0000 0000 0000 0000"></ion-input> | ||
</ion-item> | ||
<ion-item> | ||
<ion-input id="phone" label="US phone number" placeholder="+1 (xxx) xxx-xxxx"></ion-input> | ||
</ion-item> | ||
</ion-list> | ||
</ion-content> | ||
|
||
<script> | ||
async function initPhoneMask() { | ||
const ionInput = document.querySelector('#phone'); | ||
const nativeEl = await ionInput.getInputElement(); | ||
|
||
new window.Maskito(nativeEl, { | ||
mask: ['+', '1', ' ', '(', /\d/, /\d/, /\d/, ')', ' ', /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/], | ||
}); | ||
} | ||
|
||
async function initCardMask() { | ||
const ionInput = document.querySelector('#card'); | ||
const nativeEl = await ionInput.getInputElement(); | ||
|
||
new window.Maskito(nativeEl, { | ||
mask: [ | ||
...Array(4).fill(/\d/), | ||
' ', | ||
...Array(4).fill(/\d/), | ||
' ', | ||
...Array(4).fill(/\d/), | ||
' ', | ||
...Array(4).fill(/\d/), | ||
' ', | ||
...Array(4).fill(/\d/), | ||
], | ||
}); | ||
} | ||
|
||
window.addEventListener('appload', () => { | ||
initCardMask(); | ||
initPhoneMask(); | ||
}); | ||
</script> | ||
</ion-app> | ||
</body> | ||
</html> | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
```ts | ||
import { defineCustomElements } from '@ionic/core/loader'; | ||
|
||
import { Maskito } from '@maskito/core'; | ||
|
||
/* Core CSS required for Ionic components to work properly */ | ||
import '@ionic/core/css/core.css'; | ||
|
||
/* Basic CSS for apps built with Ionic */ | ||
import '@ionic/core/css/normalize.css'; | ||
import '@ionic/core/css/structure.css'; | ||
import '@ionic/core/css/typography.css'; | ||
|
||
/* Optional CSS utils that can be commented out */ | ||
import '@ionic/core/css/padding.css'; | ||
import '@ionic/core/css/float-elements.css'; | ||
import '@ionic/core/css/text-alignment.css'; | ||
import '@ionic/core/css/text-transformation.css'; | ||
import '@ionic/core/css/flex-utils.css'; | ||
import '@ionic/core/css/display.css'; | ||
|
||
/* Theme variables */ | ||
import './theme/variables.css'; | ||
|
||
defineCustomElements(); | ||
|
||
(window as any).Maskito = Maskito; | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.