diff --git a/.DS_Store b/.DS_Store index 2a68903d..1a3881ff 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.github/instructions/creation doc ressources ember-ui.instructions.md b/.github/instructions/creation doc ressources ember-ui.instructions.md new file mode 100644 index 00000000..bec01ab5 --- /dev/null +++ b/.github/instructions/creation doc ressources ember-ui.instructions.md @@ -0,0 +1,770 @@ +# 🧠 GUIDE DE CRÉATION D'UNE NOUVELLE RESSOURCE DE DOCUMENTATION EMBER-UI + +## Rôle de l'agent + +Vous êtes un agent IA responsable de la création d'une nouvelle ressource de documentation dans le projet doc-app pour les composants **ember-ui**. + +Vous devez strictement suivre les instructions écrites, sans interprétation, sans déduction implicite et sans extrapolation. + +Si une information manque, est ambiguë ou contradictoire, vous devez vous arrêter et demander des clarifications. + +## Principe fondamental + +Le prompt utilisateur suivra toujours ce format : + +**"créer la ressource RESOURCE_NAME dans la section ember-ui/prefabs"** + +Par exemple : "A partir de ce context #context créer la ressource dropdown dans la section ember-ui/prefabs a partir de #dropdown" + +Conséquences obligatoires : +- Le nom de la ressource est fourni par le prompt (RESOURCE_NAME) +- La section cible est toujours `ember-ui/prefabs` +- Ce fichier fournit la structure attendue, les patterns de fichiers, les conventions de routage et les types de composants + +⚠️ **Les exemples fournis ci-dessous sont des MODÈLES DE STRUCTURE, pas des définitions fonctionnelles finales** + +--- + +## 📁 Structure du projet doc-app pour ember-ui + +``` +doc-app/ +├── app/ +│ ├── router.ts # Fichier de routage principal +│ ├── templates/ +│ │ └── dashboard.gts # Template principal avec sidebar +│ ├── routes/ +│ │ └── dashboard/ +│ │ └── docs/ +│ │ └── ember-ui/ +│ │ └── prefabs/ +│ │ └── [resource].ts # Fichier de route +│ ├── templates/ +│ │ └── dashboard/ +│ │ └── docs/ +│ │ └── ember-ui/ +│ │ └── prefabs/ +│ │ └── [resource].gts # Template de la page +│ └── components/ +│ └── docs/ +│ └── ember-ui/ +│ └── prefabs/ +│ └── [resource].gts # Composant de démonstration +│ +└── translations/ + ├── en-us.yaml + ├── fr-fr.yaml + └── ember-ui/ + └── prefabs/ + └── [resource]/ + ├── en-us.yaml + └── fr-fr.yaml +``` + +--- + +## Différences clés avec ember-input-validation + +| Aspect | ember-input-validation | ember-ui | +|--------|------------------------|----------| +| **Package** | `@triptyk/ember-input-validation` | `@triptyk/ember-ui` | +| **Composants** | 3 exemples (basic, disabled, error) | 1 exemple unique | +| **Focus** | Validation de formulaires | Composants UI génériques | +| **Propriétés typiques** | @changeset, @validationField | Varie selon le composant | +| **Clé i18n** | `emberInputValidation` | `ember-ui` | +| **Label sidebar** | "[Resource] validation prefab" | "[Resource] prefab" | + +--- + +## Tâches à effectuer (ordre obligatoire) + +### 1️⃣ Création de la route + +**Fichier à créer :** +``` +doc-app/app/routes/dashboard/docs/ember-ui/prefabs/[RESOURCE_NAME].ts +``` + +**Structure exacte :** +```typescript +import Route from '@ember/routing/route'; + +export default class DocsEmberUiPrefabs[ResourceName]Route extends Route { + model() { + return { + properties: [ + { + name: '@propertyName', + type: 'string | Function | boolean | number', + required: true, + description: 'ember-ui.prefabs.[resource-name].properties.propertyName.description', + }, + // Ajouter toutes les propriétés du composant + ], + }; + } +} +``` + +**Règles de nommage :** +- Classe : `DocsEmberUiPrefabs` + PascalCase(resource) + `Route` +- Clés i18n : `ember-ui.prefabs.[resource-kebab-case].properties.[property-name].description` + +**Exemple concret pour confirm-modal :** +```typescript +import Route from '@ember/routing/route'; + +export default class DocsEmberUiPrefabsConfirmModalRoute extends Route { + model() { + return { + properties: [ + { + name: '@onClose', + type: 'Function', + required: true, + description: 'ember-ui.prefabs.confirm-modal.properties.onClose.description', + }, + { + name: '@onConfirm', + type: 'Function', + required: true, + description: 'ember-ui.prefabs.confirm-modal.properties.onConfirm.description', + }, + { + name: '@cancelText', + type: 'string', + required: true, + description: 'ember-ui.prefabs.confirm-modal.properties.cancelText.description', + }, + // ... autres propriétés + ], + }; + } +} +``` + +--- + +### 2️⃣ Modification du router.ts + +**Fichier à modifier :** `doc-app/app/router.ts` + +**Localisation exacte :** Dans la section `ember-ui` > `prefabs` + +**Exemple avant :** +```typescript +Router.map(function () { + this.route('dashboard', { path: '/' }, function () { + this.route('docs', function () { + this.route('ember-ui', function () { + this.route('prefabs', function () { + this.route('confirm-modal'); + }); + }); + }); + }); +}); +``` + +**Exemple après (ajout de 'dropdown') :** +```typescript +Router.map(function () { + this.route('dashboard', { path: '/' }, function () { + this.route('docs', function () { + this.route('ember-ui', function () { + this.route('prefabs', function () { + this.route('confirm-modal'); + this.route('dropdown'); // ← NOUVELLE ROUTE + }); + }); + }); + }); +}); +``` + +**Contraintes strictes :** +- Respecter l'indentation existante (2 espaces par niveau) +- Ne modifier aucune autre route +- Ajouter la nouvelle route à la fin de la section `ember-ui` > `prefabs` + +--- + +### 3️⃣ Ajout dans la Sidebar + +**Fichier à modifier :** `doc-app/app/templates/dashboard.gts` + +**Localisation :** Dans le groupe `Ember UI` + +**Structure de l'entrée :** +```typescript +{ + type: 'link', + label: '[Resource Name] prefab', + route: 'dashboard.docs.ember-ui.prefabs.[resource-name]', + tooltip: '[Resource Name] prefab', +} +``` + +**Exemple concret pour 'dropdown' :** +```typescript +menuItems: SidebarItem[] = [ + // ... autres groupes + { + type: 'group', + label: 'Ember UI', + tooltip: 'Ember UI Prefab', + items: [ + { + type: 'link', + label: 'Confirm modal prefab', + route: 'dashboard.docs.ember-ui.prefabs.confirm-modal', + tooltip: 'Confirm modal prefab', + }, + { + type: 'link', + label: 'Dropdown prefab', // ← NOUVELLE ENTRÉE + route: 'dashboard.docs.ember-ui.prefabs.dropdown', + tooltip: 'Dropdown prefab', + }, + ], + }, +]; +``` + +**⚠️ Différence importante :** Le label est "[Resource Name] prefab" (sans "validation") + +--- + +### 4️⃣ Création du composant de démonstration + +**Fichier à créer :** +``` +doc-app/app/components/docs/ember-ui/prefabs/[resource-name].gts +``` + +**⚠️ UN SEUL composant (pas 3 comme ember-input-validation)** + +**Structure type :** +```typescript +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { action } from '@ember/object'; +import Tpk[ResourceName]Prefab from '@triptyk/ember-ui/components/prefabs/tpk-[resource-name]-prefab'; + +export default class [ResourceName]Example extends Component { + @tracked propriété1 = valeurInitiale; + @tracked propriété2 = valeurInitiale; + + @action + actionMethod() { + // Logique de démonstration + } + + +} +``` + +**Exemple concret pour confirm-modal :** +```typescript +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import TpkConfirmModalPrefab from '@triptyk/ember-ui/components/prefabs/tpk-confirm-modal-prefab'; +import { action } from '@ember/object'; +import TpkButtonPrefabComponent from '@triptyk/ember-input/components/prefabs/tpk-prefab-button'; + +export default class ConfirmModalExample extends Component { + @tracked isOpen = false; + confirmQuestion = 'Are you sure?'; + + @action + open() { + this.isOpen = true; + } + + @action + onClose() { + this.isOpen = false; + } + + @action + onConfirm() { + this.isOpen = false; + alert('Confirmed'); + } + + +} +``` + +**Conventions de nommage :** +- Fichier : kebab-case (ex: `confirm-modal.gts`, `dropdown.gts`) +- Classe : PascalCase + `Example` (ex: `ConfirmModalExample`, `DropdownExample`) + +--- + +### 5️⃣ Création du template de route principal + +**Fichier à créer :** +``` +doc-app/app/templates/dashboard/docs/ember-ui/prefabs/[resource-name].gts +``` + +**Structure exacte :** +```typescript +import Component from '@glimmer/component'; +import DocPage from 'doc-app/components/doc/page'; +import DocSection from 'doc-app/components/doc/section'; +import DocPropertyTable from 'doc-app/components/doc/property-table'; +import { t, type IntlService } from 'ember-intl'; +import { service } from '@ember/service'; +import CodeExampleComponent from 'doc-app/components/doc/code-example.gts'; +import CodeBlock from 'doc-app/components/doc/code-block.gts'; +import [ResourceName]Example from 'doc-app/components/docs/ember-ui/prefabs/[resource-name].gts'; + +interface Property { + name: string; + type: string; + required: boolean; + description: string; +} + +interface [ResourceName]PrefabDocsSignature { + Args: { + model: { + properties: Property[]; + }; + }; +} + +export default class [ResourceName]PrefabDocs extends Component<[ResourceName]PrefabDocsSignature> { + @service declare intl: IntlService; + + [resourceName] = \` + + \`; + + +} +``` + +**Exemple concret pour confirm-modal :** +```typescript +import Component from '@glimmer/component'; +import DocPage from 'doc-app/components/doc/page'; +import DocSection from 'doc-app/components/doc/section'; +import DocPropertyTable from 'doc-app/components/doc/property-table'; +import { t, type IntlService } from 'ember-intl'; +import { service } from '@ember/service'; +import CodeExampleComponent from 'doc-app/components/doc/code-example.gts'; +import CodeBlock from 'doc-app/components/doc/code-block.gts'; +import ConfirmModalExample from 'doc-app/components/docs/ember-ui/prefabs/confirm-modal.gts'; + +interface Property { + name: string; + type: string; + required: boolean; + description: string; +} + +interface ConfirmModalPrefabDocsSignature { + Args: { + model: { + properties: Property[]; + }; + }; +} + +export default class ConfirmModalPrefabDocs extends Component { + @service declare intl: IntlService; + + confirmModal = \` + + \`; + + +} +``` + +**Règles pour le template :** +- Classe : PascalCase de la ressource + `PrefabDocs` +- Signature : Interface nommée `[ResourceName]PrefabDocsSignature` +- Importer UNIQUEMENT le composant créé (1 seul) +- Variable de code : nom de la ressource en camelCase +- Clés i18n : `ember-ui.prefabs.[resource-name].[sous-section]` + +--- + +### 6️⃣ Ajout des traductions dans les fichiers principaux + +**Fichiers à modifier :** +- `doc-app/translations/en-us.yaml` +- `doc-app/translations/fr-fr.yaml` + +**Structure à ajouter dans en-us.yaml :** +```yaml +ember-ui: + prefabs: + [resource-name]: + title: '[Resource Name]' + description: 'Description courte et claire du composant' + examples: + title: 'Examples' + basic: 'Basic usage' +``` + +**Exemple concret pour confirm-modal :** +```yaml +ember-ui: + prefabs: + confirm-modal: + title: 'Confirm Modal' + description: 'A modal component for confirmation dialogs.' + examples: + title: 'Examples' + basic: 'Basic usage' +``` + +**Structure à ajouter dans fr-fr.yaml :** +```yaml +ember-ui: + prefabs: + [resource-name]: + title: '[Nom de la ressource]' + description: 'Description courte et claire du composant en français' + examples: + title: 'Exemples' + basic: 'Utilisation basique' +``` + +**Exemple concret pour confirm-modal :** +```yaml +ember-ui: + prefabs: + confirm-modal: + title: 'Modale de confirmation' + description: 'Un composant de modale pour les dialogues de confirmation.' + examples: + title: 'Exemples' + basic: 'Utilisation basique' +``` + +**Règles pour les traductions :** +- Clé de section : `ember-ui` (kebab-case avec tiret) +- Clé de ressource : kebab-case du nom de la ressource (ex: `confirm-modal`) +- Structure obligatoire : `title`, `description`, `examples.title`, `examples.basic` +- **NE PAS ajouter de section `properties` ici** - elles sont dans des fichiers séparés +- Le `title` est juste le nom de la ressource en Title Case +- La `description` explique brièvement l'utilité du composant +- `examples.title` : "Examples" (EN) / "Exemples" (FR) +- `examples.basic` : "Basic usage" (EN) / "Utilisation basique" (FR) + +**Placement dans le fichier :** +- Si la section `ember-ui` n'existe pas, la créer après `emberInputValidation` +- Ajouter `prefabs` si non existant +- Ajouter la ressource en ordre alphabétique sous `prefabs` + +--- + +### 7️⃣ Création des traductions de propriétés + +**Fichiers à créer :** +``` +doc-app/translations/ember-ui/prefabs/[resource-name]/en-us.yaml +doc-app/translations/ember-ui/prefabs/[resource-name]/fr-fr.yaml +``` + +**Structure en-us.yaml :** +```yaml +properties: + propertyName1: + description: 'Description of the property in English.' + propertyName2: + description: 'Description of the property in English.' + # Une entrée par propriété définie dans la route +``` + +**Structure fr-fr.yaml :** +```yaml +properties: + propertyName1: + description: 'Description de la propriété en français.' + propertyName2: + description: 'Description de la propriété en français.' + # Une entrée par propriété définie dans la route +``` + +**Exemple concret pour confirm-modal (en-us.yaml) :** +```yaml +properties: + onClose: + description: 'Function to close the modal.' + onConfirm: + description: 'Function called when the user confirms the action.' + cancelText: + description: 'Text to display on the cancel button.' + confirmText: + description: 'Text to display on the confirm button.' + confirmQuestion: + description: 'The confirmation question to display to the user.' + isOpen: + description: 'Boolean to control the modal visibility.' +``` + +**Exemple concret pour confirm-modal (fr-fr.yaml) :** +```yaml +properties: + onClose: + description: 'Fonction pour fermer la modale.' + onConfirm: + description: 'Fonction appelée lorsque l\'utilisateur confirme l\'action.' + cancelText: + description: 'Texte à afficher sur le bouton annuler.' + confirmText: + description: 'Texte à afficher sur le bouton confirmer.' + confirmQuestion: + description: 'La question de confirmation à afficher à l\'utilisateur.' + isOpen: + description: 'Booléen pour contrôler la visibilité de la modale.' +``` + +**Règles :** +- Nom de propriété en camelCase (sans le @) +- Une description par propriété +- Descriptions courtes et claires +- Cohérence entre EN et FR + +--- + +## 🔄 Tableau de correspondance des transformations + +| Type | Exemple Input | Transformation | Exemple Output | +|------|---------------|----------------|----------------| +| Route name | confirm-modal | kebab-case | `this.route('confirm-modal')` | +| Route file | confirm-modal | kebab-case | `prefabs/confirm-modal.ts` | +| Route class | confirm-modal | PascalCase | `DocsEmberUiPrefabsConfirmModalRoute` | +| Template file | confirm-modal | kebab-case | `prefabs/confirm-modal.gts` | +| Component file | confirm-modal | kebab-case | `confirm-modal.gts` | +| Component class | confirm-modal | PascalCase + suffix | `ConfirmModalExample` | +| Import name | confirm-modal | PascalCase | `ConfirmModalExample` | +| Menu label | confirm-modal | Title Case + suffix | `Confirm modal prefab` | +| Route path | confirm-modal | kebab-case | `dashboard.docs.ember-ui.prefabs.confirm-modal` | +| Translation key | confirm-modal | kebab-case with dots | `ember-ui.prefabs.confirm-modal.title` | +| Package import | confirm-modal | kebab-case | `@triptyk/ember-ui/components/prefabs/tpk-confirm-modal-prefab` | + +--- + +## ⚠️ Contraintes strictes + +### ❌ INTERDIT +- Créer plusieurs composants de démo (basic, disabled, error) comme pour ember-input-validation +- Utiliser `@triptyk/ember-input-validation` comme package +- Ajouter automatiquement des propriétés `@changeset` ou `@validationField` (sauf si explicitement demandé) +- Utiliser la clé i18n `emberInputValidation` +- Ajouter "validation" dans les labels de la sidebar +- Copier la logique métier de confirm-modal pour une autre ressource + +### ✅ OBLIGATOIRE +- Créer UN SEUL composant de démonstration +- Utiliser `@triptyk/ember-ui` comme package +- Respecter le format des clés i18n : `ember-ui.prefabs.[resource-name]` +- Label sidebar : "[Resource Name] prefab" (sans "validation") +- Créer les traductions dans les deux langues (EN et FR) +- Respecter l'indentation et la structure existantes + +### 🛑 En cas de doute +**STOP et demander des clarifications** + +--- + +## 📝 Exemple complet : Création de la ressource "tooltip" + +**Prompt utilisateur :** "créer la ressource tooltip dans la section ember-ui/prefabs" + +### Fichiers à créer : + +1. `doc-app/app/routes/dashboard/docs/ember-ui/prefabs/tooltip.ts` +2. `doc-app/app/templates/dashboard/docs/ember-ui/prefabs/tooltip.gts` +3. `doc-app/app/components/docs/ember-ui/prefabs/tooltip.gts` +4. `doc-app/translations/ember-ui/prefabs/tooltip/en-us.yaml` +5. `doc-app/translations/ember-ui/prefabs/tooltip/fr-fr.yaml` + +### Fichiers à modifier : + +1. `doc-app/app/router.ts` - Ajouter `this.route('tooltip');` +2. `doc-app/app/templates/dashboard.gts` - Ajouter l'entrée menu pour tooltip +3. `doc-app/translations/en-us.yaml` - Ajouter les traductions principales EN +4. `doc-app/translations/fr-fr.yaml` - Ajouter les traductions principales FR + +--- + +## 🎯 Checklist de validation + +Avant de considérer la tâche terminée, vérifier : + +- [ ] La route est ajoutée dans `router.ts` (section `ember-ui` > `prefabs`) +- [ ] Le fichier de route existe avec le bon nom de classe (`DocsEmberUiPrefabs[Resource]Route`) +- [ ] L'entrée de menu est ajoutée dans `dashboard.gts` (groupe "Ember UI") +- [ ] Le label du menu est "[Resource] prefab" (SANS "validation") +- [ ] UN SEUL composant de démo est créé (pas 3) +- [ ] Le composant de démo utilise `@triptyk/ember-ui` +- [ ] Le template principal est créé et importe le bon composant +- [ ] Tous les noms sont adaptés à la nouvelle ressource +- [ ] Aucun nom d'exemple (confirm-modal) n'apparaît dans les nouveaux fichiers +- [ ] Les clés i18n suivent le pattern `ember-ui.prefabs.[resource]` +- [ ] Les fichiers de traduction principaux (en-us.yaml et fr-fr.yaml) sont mis à jour +- [ ] Les fichiers de traduction de propriétés sont créés (EN et FR) +- [ ] Les traductions correspondent aux propriétés définies dans la route +- [ ] L'indentation est cohérente avec le reste du projet + +--- + +## 🔍 Différences récapitulatives ember-input-validation vs ember-ui + +### Structure des composants de démo + +**ember-input-validation :** +``` +components/docs/ember-input-validation/prefabs/ +├── basic-input.gts +├── disabled-input.gts +└── error-input.gts +``` + +**ember-ui :** +``` +components/docs/ember-ui/prefabs/ +└── confirm-modal.gts +``` + +### Labels de la sidebar + +**ember-input-validation :** +```typescript +{ + label: 'Input validation prefab', + route: 'dashboard.docs.ember-input-validation.prefabs.input', +} +``` + +**ember-ui :** +```typescript +{ + label: 'Confirm modal prefab', + route: 'dashboard.docs.ember-ui.prefabs.confirm-modal', +} +``` + +### Clés de traduction + +**ember-input-validation :** +```yaml +emberInputValidation: + prefabs: + input: + title: 'Input' +``` + +**ember-ui :** +```yaml +ember-ui: + prefabs: + confirm-modal: + title: 'Confirm Modal' +``` + +### Import des packages + +**ember-input-validation :** +```typescript +import TpkInputPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-input'; +``` + +**ember-ui :** +```typescript +import TpkConfirmModalPrefab from '@triptyk/ember-ui/components/prefabs/tpk-confirm-modal-prefab'; +``` + +--- + +## ✨ Conclusion + +Ce guide est spécifique aux composants **ember-ui**. Pour les composants **ember-input-validation**, référez-vous au guide "creation doc ressources.instructions.md". + +La principale différence réside dans : +1. Le nombre de composants de démo (1 au lieu de 3) +2. Les labels (sans "validation") +3. Les clés i18n (`ember-ui` au lieu de `emberInputValidation`) +4. Le package importé (`@triptyk/ember-ui`) diff --git a/.github/instructions/creation doc ressources.instructions.md b/.github/instructions/creation doc ressources.instructions.md new file mode 100644 index 00000000..295f9da0 --- /dev/null +++ b/.github/instructions/creation doc ressources.instructions.md @@ -0,0 +1,542 @@ + +# 🧠 GUIDE DE CRÉATION D'UNE NOUVELLE RESSOURCE DE DOCUMENTATION + +## Rôle de l'agent + +Vous êtes un agent IA responsable de la création d'une nouvelle ressource de documentation dans le projet doc-app. + +Vous devez strictement suivre les instructions écrites, sans interprétation, sans déduction implicite et sans extrapolation. + +Si une information manque, est ambiguë ou contradictoire, vous devez vous arrêter et demander des clarifications. + +## Principe fondamental + +Le prompt utilisateur suivra toujours ce format : + +**"créer la ressource RESOURCE_NAME dans la section SECTION_NAME"** + +Par exemple : "A partir de ce context #context créer la ressource checkbox dans la section ember-input-validation/prefabs a partir de #checkbox" + +Conséquences obligatoires : +- Le nom de la ressource est fourni par le prompt (RESOURCE_NAME) +- La section cible est fournie par le prompt (SECTION_NAME) +- Ce fichier fournit la structure attendue, les patterns de fichiers, les conventions de routage et les types de composants + +⚠️ **Les exemples fournis ci-dessous sont des MODÈLES DE STRUCTURE, pas des définitions fonctionnelles finales** + +--- + +## 📁 Structure du projet doc-app + +\`\`\` +doc-app/ +├── app/ +│ ├── router.ts # Fichier de routage principal +│ ├── templates/ +│ │ └── dashboard.gts # Template principal avec sidebar +│ ├── routes/ +│ │ └── dashboard/ +│ │ └── docs/ +│ │ └── [section]/ +│ │ └── prefabs/ +│ │ └── [resource].ts # Fichier de route +│ ├── templates/ +│ │ └── dashboard/ +│ │ └── docs/ +│ │ └── [section]/ +│ │ └── prefabs/ +│ │ └── [resource].gts # Template de la page +│ └── components/ +│ └── docs/ +│ └── [section]/ +│ └── prefabs/ +│ ├── basic-[resource].gts +│ ├── disabled-[resource].gts +│ └── error-[resource].gts +│ +└── translations/ +│ ├── en-us.yaml +│ └── [section]/ +│ └── prefabs/ +| └── [resource]/en-us.yaml +\`\`\` + +--- + +## Tâches à effectuer (ordre obligatoire) + +### 1️⃣ Création de la route + +**Fichier à créer :** +\`\`\` +doc-app/app/routes/dashboard/docs/[SECTION_NAME]/prefabs/[RESOURCE_NAME].ts +\`\`\` + +**Structure exacte :** +\`\`\`typescript +// doc-app/app/routes/docs/[section-name]/prefabs/[resource-name].ts +import Route from '@ember/routing/route'; + +export default class Docs[SectionName]Prefabs[ResourceName]Route extends Route { + model() { + return { + properties: [ + { + name: '@validationField', + type: 'string', + required: true, + description: '[section-key].prefabs.[resource-name].properties.validationField.description', + }, + { + name: '@changeset', + type: 'ImmerChangeset', + required: true, + description: '[section-key].prefabs.[resource-name].properties.changeset.description', + }, + { + name: '@label', + type: 'string', + required: false, + description: '[section-key].prefabs.[resource-name].properties.label.description', + }, + { + name: '@placeholder', + type: 'string', + required: false, + description: '[section-key].prefabs.[resource-name].properties.placeholder.description', + }, + // Ajouter les autres propriétés spécifiques à la ressource + ], + }; + } +} +\`\`\` + +**Règles de nommage :** +- Classe : \`Docs\` + PascalCase(section) + \`Prefabs\` + PascalCase(resource) + \`Route\` +- Clés i18n : \`[section-kebab-case].prefabs.[resource-kebab-case].properties.[property-name].description\` + +--- + +### 2️⃣ Modification du router.ts + +**Fichier à modifier :** \`doc-app/app/router.ts\` + +**Localisation exacte :** Dans la fonction \`Router.map()\`, sous la section correspondante + +**Exemple avant :** +\`\`\`typescript +Router.map(function () { + this.route('dashboard', { path: '/' }, function () { + this.route('docs', function () { + this.route('ember-input-validation', function () { + this.route('prefabs', function () { + this.route('input'); + this.route('number'); + }); + }); + }); + }); +}); +\`\`\` + +**Exemple après (ajout de 'checkbox') :** +\`\`\`typescript +Router.map(function () { + this.route('dashboard', { path: '/' }, function () { + this.route('docs', function () { + this.route('ember-input-validation', function () { + this.route('prefabs', function () { + this.route('input'); + this.route('number'); + this.route('checkbox'); // ← NOUVELLE ROUTE + }); + }); + }); + }); +}); +\`\`\` + +**Contraintes strictes :** +- Respecter l'indentation existante +- Ne modifier aucune autre route +- Ajouter la nouvelle route à la fin de la section concernée + +--- + +### 3️⃣ Ajout dans la Sidebar + +**Fichier à modifier :** \`doc-app/app/templates/dashboard.gts\` + +**Structure de l'entrée :** +\`\`\`typescript +menuItems = [ + // ... entrées existantes + { + label: '[Resource Name] validation prefab', + route: 'dashboard.docs.[section-name].prefabs.[resource-name]', + tooltip: '[Resource Name] validation prefab', + }, +]; +\`\`\` + +**Exemple concret pour 'checkbox' dans 'ember-input-validation' :** +\`\`\`typescript +menuItems = [ + { + label: 'Input validation prefab', + route: 'dashboard.docs.ember-input-validation.prefabs.input', + tooltip: 'Input validation prefab', + }, + { + label: 'Number validation prefab', + route: 'dashboard.docs.ember-input-validation.prefabs.number', + tooltip: 'Number validation prefab', + }, + { + label: 'Checkbox validation prefab', // ← NOUVELLE ENTRÉE + route: 'dashboard.docs.ember-input-validation.prefabs.checkbox', + tooltip: 'Checkbox validation prefab', + }, +]; +\`\`\` + +--- + +### 4️⃣ Création des composants de démonstration + +**Dossier de création :** +\`\`\` +doc-app/app/components/docs/[section-name]/prefabs/ +\`\`\` + +**Composants obligatoires à créer :** + +#### a) basic-[resource-name].gts +\`\`\`typescript +// doc-app/app/components/docs/[section-name]/prefabs/basic-[resource-name].gts +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import Tpk[ResourceName]Prefab from '@triptyk/[package-name]/components/prefabs/tpk-validation-[resource-name]'; + +export default class Basic[ResourceName]Example extends Component { + @tracked changeset = new ImmerChangeset({ + something: '', // Adapter selon le type de donnée + }); + + +} +\`\`\` + +#### b) disabled-[resource-name].gts +\`\`\`typescript +// doc-app/app/components/docs/[section-name]/prefabs/disabled-[resource-name].gts +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import Tpk[ResourceName]Prefab from '@triptyk/[package-name]/components/prefabs/tpk-validation-[resource-name]'; + +export default class Disabled[ResourceName]Example extends Component { + @tracked changeset = new ImmerChangeset({ + disabled: 'This is disabled', // Adapter selon le type + }); + + +} +\`\`\` + +#### c) error-[resource-name].gts +\`\`\`typescript +// doc-app/app/components/docs/[section-name]/prefabs/error-[resource-name].gts +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import Tpk[ResourceName]Prefab from '@triptyk/[package-name]/components/prefabs/tpk-validation-[resource-name]'; +import type Owner from '@ember/owner'; +import { action } from '@ember/object'; + +export default class Error[ResourceName]Example extends Component { + @tracked changeset = new ImmerChangeset({ + something: '', // Adapter selon le type + }); + + @action + onChange(value: string | number | Date | null) { + // Logique de validation d'exemple + // Adapter selon les règles métier de la ressource + + if (typeof value !== 'string') { + this.changeset.addError({ + message: 'should be a string value', + value: 'err', + originalValue: '', + key: 'something', + }); + } + if ((value as string)?.length >= 5) { + this.changeset.removeErrors(); + } else { + this.changeset.addError({ + message: 'Minimum 5 characters', + value: 'err', + originalValue: '', + key: 'something', + }); + } + } + + constructor(owner: Owner, args: never) { + super(owner, args); + setTimeout(() => { + this.changeset.addError({ + message: 'Minimum 5 characters', + value: 'err', + originalValue: '', + key: 'something', + }); + }, 0); + } + + +} +\`\`\` + +**Conventions de nommage des composants :** +- Fichiers : kebab-case (ex: \`basic-input.gts\`, \`error-checkbox.gts\`) +- Classes : PascalCase (ex: \`BasicInputExample\`, \`ErrorCheckboxExample\`) +- Pattern : \`[Type][ResourceName]Example\` + +--- + +### 5️⃣ Création du template de route principal + +**Fichier à créer :** +\`\`\` +doc-app/app/templates/dashboard/docs/[section-name]/prefabs/[resource-name].gts +\`\`\` + +**Structure exacte :** +\`\`\`typescript +import Component from '@glimmer/component'; +import DocPage from 'doc-app/components/doc/page'; +import DocSection from 'doc-app/components/doc/section'; +import DocPropertyTable from 'doc-app/components/doc/property-table'; +import { t, type IntlService } from 'ember-intl'; +import Basic[ResourceName]Example from 'doc-app/components/docs/[section-name]/prefabs/basic-[resource-name].gts'; +import Disabled[ResourceName]Example from 'doc-app/components/docs/[section-name]/prefabs/disabled-[resource-name].gts'; +import Error[ResourceName]Example from 'doc-app/components/docs/[section-name]/prefabs/error-[resource-name].gts'; +import { service } from '@ember/service'; +import CodeExampleComponent from 'doc-app/components/doc/code-example.gts'; +import CodeBlock from 'doc-app/components/doc/code-block.gts'; + +interface Property { + name: string; + type: string; + required: boolean; + description: string; +} + +interface [ResourceName]PrefabDocsSignature { + Args: { + model: { + properties: Property[]; + }; + }; +} + +export default class [ResourceName]PrefabDocs extends Component<[ResourceName]PrefabDocsSignature> { + @service declare intl: IntlService; + + [resourceName] = \` + + \`; + + +} +\`\`\` + +**Règles pour le template :** +- Classe : PascalCase de la ressource + \`PrefabDocs\` +- Signature : Interface nommée \`[ResourceName]PrefabDocsSignature\` +- Importer UNIQUEMENT les composants créés (basic, disabled, error) +- Variable de code : nom de la ressource en camelCase +- Clés i18n : \`[sectionKey].prefabs.[resourceName].[sous-section]\` + +--- + +### 6️⃣ Ajout des traductions + +**Fichier à modifier :** \`doc-app/translations/en-us.yaml\` + +**Structure à ajouter :** +\`\`\`yaml +[sectionKey]: + prefabs: + [resourceName]: + title: '[Resource Name]' + description: 'Description courte et claire du composant de validation' + examples: + title: 'Examples' + basic: 'Basic usage' +\`\`\` + +**Exemple concret pour 'checkbox' dans 'ember-input-validation' :** +\`\`\`yaml +emberInputValidation: + prefabs: + checkbox: + title: 'Checkbox' + description: 'A reusable validation component for checkboxes with integrated error handling' + examples: + title: 'Examples' + basic: 'Basic usage' +\`\`\` + +**Règles pour les traductions :** +- Clé de section : camelCase du nom de la section (ex: \`emberInputValidation\`) +- Clé de ressource : camelCase du nom de la ressource (ex: \`checkbox\`) +- Structure obligatoire : \`title\`, \`description\`, \`examples.title\`, \`examples.basic\` +- **NE PAS ajouter de section \`properties\`** - les descriptions des propriétés sont dans le fichier de route +- Le \`title\` est juste le nom de la ressource (sans "validation prefab") +- La \`description\` explique brièvement l'utilité du composant +- \`examples.title\` doit toujours être "Examples" +- \`examples.basic\` doit toujours être "Basic usage" +- Format : Respecter l'indentation YAML (2 espaces) + +**Placement dans le fichier :** +- Localiser la section correspondante (ex: \`emberInputValidation\`) +- Si la section n'existe pas, la créer en respectant l'ordre alphabétique +- Ajouter \`prefabs\` si non existant +- Ajouter la ressource en ordre alphabétique sous \`prefabs\` + +**⚠️ IMPORTANT :** Les descriptions des propriétés (@validationField, @changeset, etc.) sont définies dans le fichier de route (routes/dashboard/docs/[section]/prefabs/[resource].ts) et NON dans le fichier YAML + +--- + +## 🔄 Tableau de correspondance des transformations + +| Type | Exemple Input | Transformation | Exemple Output | +|------|---------------|----------------|----------------| +| Route name | checkbox | kebab-case | \`this.route('checkbox')\` | +| Route file | checkbox | kebab-case | \`prefabs/checkbox.ts\` | +| Route class | checkbox | PascalCase | \`DocsEmberInputValidationPrefabsCheckboxRoute\` | +| Template file | checkbox | kebab-case | \`prefabs/checkbox.gts\` | +| Component file | checkbox | kebab-case + prefix | \`basic-checkbox.gts\` | +| Component class | checkbox | PascalCase + suffix | \`BasicCheckboxExample\` | +| Import name | checkbox | PascalCase | \`BasicCheckboxExample\` | +| Menu label | checkbox | Title Case + suffix | \`Checkbox validation prefab\` | +| Route path | checkbox | kebab-case | \`dashboard.docs.ember-input-validation.prefabs.checkbox\` | +| Section i18n key | ember-input-validation | camelCase | \`emberInputValidation\` | +| Resource i18n key | checkbox | camelCase | \`checkbox\` | +| Translation key | checkbox | camelCase with dots | \`emberInputValidation.prefabs.checkbox.title\` | + +--- + +## ⚠️ Contraintes strictes + +### ❌ INTERDIT +- Réutiliser les noms de ressources des exemples (input, number) +- Copier les données métier des exemples +- Inventer une logique en dehors du contexte +- Créer des composants supplémentaires non mentionnés +- Modifier d'autres routes que celle créée + +### ✅ OBLIGATOIRE +- Remplacer TOUS les éléments dépendants de la ressource +- Respecter l'indentation et la structure existantes +- Suivre les conventions de nommage décrites +- Créer exactement 3 composants de démonstration (basic, disabled, error) +- Importer uniquement les composants créés + +### 🛑 En cas de doute +**STOP et demander des clarifications** + +--- + +## 📝 Exemple complet : Création de la ressource "select" + +**Prompt utilisateur :** "créer la ressource select dans la section ember-input-validation/prefabs" + +### Fichiers à créer : + +1. \`doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/select.ts\` +2. \`doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/select.gts\` +3. \`doc-app/app/components/docs/ember-input-validation/prefabs/basic-select.gts\` +4. \`doc-app/app/components/docs/ember-input-validation/prefabs/disabled-select.gts\` +5. \`doc-app/app/components/docs/ember-input-validation/prefabs/error-select.gts\` + +### Fichiers à modifier : + +1. \`doc-app/app/router.ts\` - Ajouter \`this.route('select');\` +2. \`doc-app/app/templates/dashboard.gts\` - Ajouter l'entrée menu pour select +3. \`doc-app/translations/en-us.yaml\` - Ajouter les traductions pour select + +--- + +## 🎯 Checklist de validation + +Avant de considérer la tâche terminée, vérifier : + +- [ ] La route est ajoutée dans \`router.ts\` +- [ ] Le fichier de route existe avec le bon nom de classe +- [ ] L'entrée de menu est ajoutée dans \`dashboard.gts\` +- [ ] Les 3 composants de démo sont créés (basic, disabled, error) +- [ ] Le template principal est créé et importe les bons composants +- [ ] Tous les noms sont adaptés à la nouvelle ressource +- [ ] Aucun nom d'exemple (input, number) n'apparaît dans les nouveaux fichiers +- [ ] Les clés i18n suivent le pattern correct +- [ ] Le fichier de traduction \`en-us.yaml\` est mis à jour avec toutes les clés nécessaires +- [ ] Les traductions correspondent exactement aux propriétés définies dans la route +- [ ] L'indentation est cohérente avec le reste du projet \ No newline at end of file diff --git a/.github/workflows/publish-dist.yaml b/.github/workflows/publish-dist.yaml index 87d6b845..4e5f1989 100644 --- a/.github/workflows/publish-dist.yaml +++ b/.github/workflows/publish-dist.yaml @@ -5,6 +5,7 @@ on: branches: - main - develop + - upgrade-ember jobs: push-dist: diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 018e453c..6596d39b 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -13,7 +13,7 @@ jobs: - uses: actions/checkout@v4 - uses: wyvox/action-setup-pnpm@v3 - name: Build - run: pnpm turbo build + run: pnpm turbo build --filter='@triptyk/ember-*' - name: Run tests run: pnpm turbo lint test deploy: @@ -25,12 +25,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v2 with: - node-version: 20 + node-version: 22 registry-url: https://registry.npmjs.org/ scope: "@triptyk" - uses: wyvox/action-setup-pnpm@v3 with: - node-version: 20 + node-version: 22 - run: pnpm recursive publish --access=public --tag=beta env: NODE_AUTH_TOKEN: ${{secrets.npm_token}} diff --git a/.gitignore b/.gitignore index 01315312..1561d525 100644 --- a/.gitignore +++ b/.gitignore @@ -107,4 +107,7 @@ dist # Sorry Triptyk, i'm a vim guy :c *.swo -*.swp +*.swp + +# macOS system files +.DS_Store diff --git a/.vscode/mcp.json b/.vscode/mcp.json new file mode 100644 index 00000000..6df9c17c --- /dev/null +++ b/.vscode/mcp.json @@ -0,0 +1,3 @@ +{ + "servers": {} +} diff --git a/.vscode/settings.json b/.vscode/settings.json index 983d9911..cdf0fd12 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,7 +4,7 @@ "editor.formatOnSave": true }, "[glimmer-ts]": { - "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.defaultFormatter": "dbaeumer.vscode-eslint", "editor.formatOnSave": true }, "editor.formatOnSave": true, @@ -24,6 +24,5 @@ }, "[typescript]": { "editor.defaultFormatter": "dbaeumer.vscode-eslint" - }, - "eslint.validate": ["glimmer-ts", "glimmer-js"] + } } diff --git a/README.md b/README.md index 588f3c7c..899c9a0f 100644 --- a/README.md +++ b/README.md @@ -20,4 +20,30 @@ All the tests are in the `doc-app`. ## Disclaimer -Versions *0.X.X* does not follow SemVer. \ No newline at end of file +Versions *0.X.X* does not follow SemVer. + + +## Architecture + +``` +doc-app/ + app/ + routes/ + docs/ + ember-input-validation/ + prefabs/ + input.ts # Route qui charge les données + templates/ + docs/ + ember-input-validation/ + prefabs/ + input.hbs # Template de la page + components/ + doc-page.gts # Layout principal de page doc + code-example.gts # Composant avec onglets Template/Result/Code + usage-example.gts # Wrapper pour les exemples + markdown-content.gts # Pour le contenu texte (optionnel) + translations/ + en-us.yaml + fr-fr.yaml +``` diff --git a/doc-app/.ember-cli b/doc-app/.ember-cli index 4defd284..a37e45fa 100644 --- a/doc-app/.ember-cli +++ b/doc-app/.ember-cli @@ -3,5 +3,17 @@ Setting `isTypeScriptProject` to true will force the blueprint generators to generate TypeScript rather than JavaScript by default, when a TypeScript version of a given blueprint is available. */ - "isTypeScriptProject": true + "isTypeScriptProject": true, + + /** + Setting `componentAuthoringFormat` to "strict" will force the blueprint generators to generate GJS + or GTS files for the component and the component rendering test. "loose" is the default. + */ + "componentAuthoringFormat": "strict", + + /** + Setting `routeAuthoringFormat` to "strict" will force the blueprint generators to generate GJS + or GTS templates for routes. "loose" is the default + */ + "routeAuthoringFormat": "strict" } diff --git a/doc-app/.env.development b/doc-app/.env.development new file mode 100644 index 00000000..f3289142 --- /dev/null +++ b/doc-app/.env.development @@ -0,0 +1,8 @@ +# This file is committed to git and should not contain any secrets. +# +# Vite recommends using .env.local or .env.[mode].local if you need to manage secrets +# SEE: https://vite.dev/guide/env-and-mode.html#env-files for more information. + + +# Default NODE_ENV with vite build --mode=test is production +NODE_ENV=development diff --git a/doc-app/.eslintignore b/doc-app/.eslintignore deleted file mode 100644 index 768fab33..00000000 --- a/doc-app/.eslintignore +++ /dev/null @@ -1,14 +0,0 @@ -# unconventional js -/blueprints/*/files/ - -# compiled output -/declarations/ -/dist/ - -# misc -/coverage/ -!.* -.*/ - -# ember-try -/.node_modules.ember-try/ diff --git a/doc-app/.eslintrc.js b/doc-app/.eslintrc.js deleted file mode 100644 index ba178f1e..00000000 --- a/doc-app/.eslintrc.js +++ /dev/null @@ -1,63 +0,0 @@ -// .eslintrc.js -module.exports = { - overrides: [ - { - files: ['**/*.{js,ts}'], - plugins: ['ember'], - parser: '@typescript-eslint/parser', - extends: [ - 'eslint:recommended', - 'plugin:ember/recommended', // or other configuration - ], - rules: { - // override / enable optional rules - 'ember/no-replace-test-comments': 'error', - 'no-unused-vars': 'off', - 'no-undef': 'off', - } - }, - { - files: ['**/*.gts'], - parser: 'ember-eslint-parser', - plugins: ['ember'], - extends: [ - 'eslint:recommended', - 'plugin:@typescript-eslint/recommended', - 'plugin:ember/recommended', - 'plugin:ember/recommended-gts', - ], - }, - { - files: ['**/*.gjs'], - parser: 'ember-eslint-parser', - plugins: ['ember'], - extends: [ - 'eslint:recommended', - 'plugin:ember/recommended', - 'plugin:ember/recommended-gjs', - ], - }, - { - files: ['tests/**/*.{js,ts,gjs,gts}'], - rules: { - // override / enable optional rules - 'ember/no-replace-test-comments': 'error', - 'no-unused-vars': 'off', - 'no-undef': 'off', - } - }, - { - files: [ - '*.js' - ], - env: { - node: true - }, - rules: { - // rules specific to nodejs files - 'no-console': 'off', - 'strict': ['error', 'global'] - } - } - ], -}; diff --git a/doc-app/.github/workflows/ci.yml b/doc-app/.github/workflows/ci.yml new file mode 100644 index 00000000..5494bdcf --- /dev/null +++ b/doc-app/.github/workflows/ci.yml @@ -0,0 +1,53 @@ +name: CI + +on: + push: + branches: + - main + - master + pull_request: {} + +concurrency: + group: ci-${{ github.head_ref || github.ref }} + cancel-in-progress: true + +jobs: + lint: + name: "Lint" + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - uses: actions/checkout@v3 + - uses: pnpm/action-setup@v4 + with: + version: 9 + - name: Install Node + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: pnpm + - name: Install Dependencies + run: pnpm install --frozen-lockfile + - name: Lint + run: pnpm lint + + test: + name: "Test" + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - uses: actions/checkout@v3 + - uses: pnpm/action-setup@v4 + with: + version: 9 + - name: Install Node + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: pnpm + - name: Install Dependencies + run: pnpm install --frozen-lockfile + - name: Run Tests + run: pnpm test diff --git a/doc-app/.gitignore b/doc-app/.gitignore index 71ad79d0..b4554042 100644 --- a/doc-app/.gitignore +++ b/doc-app/.gitignore @@ -1,12 +1,13 @@ # compiled output /dist/ /declarations/ +/tmp/ # dependencies /node_modules/ # misc -/.env* +*.local /.pnp* /.eslintcache /coverage/ diff --git a/doc-app/.prettierignore b/doc-app/.prettierignore index 9385391f..c2a4e423 100644 --- a/doc-app/.prettierignore +++ b/doc-app/.prettierignore @@ -4,10 +4,13 @@ # compiled output /dist/ +# generated +public/mockServiceWorker.js + # misc /coverage/ !.* .*/ - -# ember-try -/.node_modules.ember-try/ +/pnpm-lock.yaml +ember-cli-update.json +*.html diff --git a/doc-app/.prettierrc.js b/doc-app/.prettierrc.js deleted file mode 100644 index 21dbe8b4..00000000 --- a/doc-app/.prettierrc.js +++ /dev/null @@ -1,12 +0,0 @@ - - -module.exports = { - overrides: [ - { - files: '*.{js,ts}', - options: { - singleQuote: true, - }, - }, - ], -}; diff --git a/doc-app/.prettierrc.mjs b/doc-app/.prettierrc.mjs new file mode 100644 index 00000000..de1d43fb --- /dev/null +++ b/doc-app/.prettierrc.mjs @@ -0,0 +1,37 @@ +export default { + plugins: ['prettier-plugin-ember-template-tag'], + singleQuote: true, + overrides: [ + { + files: ['*.js', '*.ts', '*.cjs', '.mjs', '.cts', '.mts', '.cts'], + options: { + trailingComma: 'es5', + }, + }, + { + files: ['*.html'], + options: { + singleQuote: false, + }, + }, + { + files: ['*.json'], + options: { + singleQuote: false, + }, + }, + { + files: ['*.hbs'], + options: { + singleQuote: false, + }, + }, + { + files: ['*.gjs', '*.gts'], + options: { + templateSingleQuote: false, + trailingComma: 'es5', + }, + }, + ], +}; diff --git a/doc-app/.stylelintignore b/doc-app/.stylelintignore deleted file mode 100644 index a0cf71cb..00000000 --- a/doc-app/.stylelintignore +++ /dev/null @@ -1,8 +0,0 @@ -# unconventional files -/blueprints/*/files/ - -# compiled output -/dist/ - -# addons -/.node_modules.ember-try/ diff --git a/doc-app/.stylelintrc.js b/doc-app/.stylelintrc.js deleted file mode 100644 index 0f9632c4..00000000 --- a/doc-app/.stylelintrc.js +++ /dev/null @@ -1,5 +0,0 @@ - - -module.exports = { - extends: ['stylelint-config-standard', 'stylelint-prettier/recommended'], -}; diff --git a/doc-app/.template-lintrc.js b/doc-app/.template-lintrc.mjs similarity index 58% rename from doc-app/.template-lintrc.js rename to doc-app/.template-lintrc.mjs index cedfc014..589ce8f7 100644 --- a/doc-app/.template-lintrc.js +++ b/doc-app/.template-lintrc.mjs @@ -1,5 +1,3 @@ - - -module.exports = { +export default { extends: 'recommended', }; diff --git a/doc-app/CHANGELOG.md b/doc-app/CHANGELOG.md deleted file mode 100644 index 1c4b1648..00000000 --- a/doc-app/CHANGELOG.md +++ /dev/null @@ -1,165 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -## [3.0.1](https://github.com/TRIPTYK/ember-common-ui/compare/v3.0.0...v3.0.1) (2026-01-14) - - -### Features - -* add index as param for yield and give info if stack is open for button delete ([c25dda6](https://github.com/TRIPTYK/ember-common-ui/commit/c25dda67800d515d7b5208e421d90e7a95aa619c)) - - - - - -# [3.0.0](https://github.com/TRIPTYK/ember-common-ui/compare/v3.0.0-alpha.13...v3.0.0) (2025-04-18) - -**Note:** Version bump only for package doc-app - - - - - -# [3.0.0-alpha.13](https://github.com/TRIPTYK/ember-common-ui/compare/v3.0.0-alpha.12...v3.0.0-alpha.13) (2025-02-03) - - -### Bug Fixes - -* element pass by function ([9baa96d](https://github.com/TRIPTYK/ember-common-ui/commit/9baa96d1e64e38c9b74974c613264f272bb0fb83)) -* review ([2b3125b](https://github.com/TRIPTYK/ember-common-ui/commit/2b3125b8972474f87ce1ac959a312e9f154cb86b)) - - - - - -# [3.0.0-alpha.12](https://github.com/TRIPTYK/ember-common-ui/compare/v3.0.0-alpha.11...v3.0.0-alpha.12) (2025-01-27) - - -### Bug Fixes - -* debug table generic prefab ([7364795](https://github.com/TRIPTYK/ember-common-ui/commit/7364795ca2edd05bafc51c8e80e048f87710bbd9)) - - - - - -# [3.0.0-alpha.11](https://github.com/TRIPTYK/ember-common-ui/compare/v3.0.0-alpha.10...v3.0.0-alpha.11) (2025-01-24) - - -### Features - -* add prefab file list with dropzone ([d9b682c](https://github.com/TRIPTYK/ember-common-ui/commit/d9b682cc725b5c536513795f5abf5dcf039a0000)) -* add tpk-search input ([0c56a9d](https://github.com/TRIPTYK/ember-common-ui/commit/0c56a9d80273a8cd0b2b8dc5a4802ac39302527d)) -* button prefab ([b5391df](https://github.com/TRIPTYK/ember-common-ui/commit/b5391df3a08f4eea3c9972d991d81a2598b69cfc)) -* confirm modal prefab ([0a01c33](https://github.com/TRIPTYK/ember-common-ui/commit/0a01c3341e1ab7bfb025fcb80f5b69ad4c037847)) -* confirm modal prefab ([918a38a](https://github.com/TRIPTYK/ember-common-ui/commit/918a38a6938d70e1ae5a329a57f5342be51dbe84)) -* remove tpk-stepper ([ea85b32](https://github.com/TRIPTYK/ember-common-ui/commit/ea85b32199f8459089989910aeb8f82ceb8161bc)) -* review ([149121f](https://github.com/TRIPTYK/ember-common-ui/commit/149121fe856b11809784d0ac69fb021c05dabd0c)) -* toggle switch ([6206fd4](https://github.com/TRIPTYK/ember-common-ui/commit/6206fd4035caa13ea83ffb864f37a983c9b6fe38)) - - - - - -# [3.0.0-alpha.10](https://github.com/TRIPTYK/ember-common-ui/compare/v3.0.0-alpha.9...v3.0.0-alpha.10) (2024-12-06) - -**Note:** Version bump only for package doc-app - - - - - -# [3.0.0-alpha.9](https://github.com/TRIPTYK/ember-common-ui/compare/v3.0.0-alpha.8...v3.0.0-alpha.9) (2024-12-06) - -**Note:** Version bump only for package doc-app - - - - - -# [3.0.0-alpha.8](https://github.com/TRIPTYK/ember-common-ui/compare/v3.0.0-alpha.7...v3.0.0-alpha.8) (2024-12-06) - - -### Bug Fixes - -* css file for datepicker icon ([909c051](https://github.com/TRIPTYK/ember-common-ui/commit/909c05139f7966f799b800a7db6c70e8df858e69)) - - - - - -# [3.0.0-alpha.7](https://github.com/TRIPTYK/ember-common-ui/compare/v3.0.0-alpha.6...v3.0.0-alpha.7) (2024-12-05) - -**Note:** Version bump only for package doc-app - - - - - -# [3.0.0-alpha.6](https://github.com/TRIPTYK/ember-common-ui/compare/v3.0.0-alpha.5...v3.0.0-alpha.6) (2024-12-05) - - -### Bug Fixes - -* bic, iban & vat return uppercase automaticly ([8c8cd3b](https://github.com/TRIPTYK/ember-common-ui/commit/8c8cd3b080dd5126c7fb55a0f5c5d62976867a0d)) - - - - - -# [3.0.0-alpha.5](https://github.com/TRIPTYK/ember-common-ui/compare/v3.0.0-alpha.3...v3.0.0-alpha.5) (2024-12-03) - -**Note:** Version bump only for package doc-app - - - - - -# [3.0.0-alpha.4](https://github.com/TRIPTYK/ember-common-ui/compare/v3.0.0-alpha.3...v3.0.0-alpha.4) (2024-12-03) - -**Note:** Version bump only for package doc-app - - - - - -# [3.0.0-alpha.3](https://github.com/TRIPTYK/ember-common-ui/compare/v3.0.0-alpha.2...v3.0.0-alpha.3) (2024-12-03) - - -### Bug Fixes - -* make good for a11y and let just one theme to build faster daisy ([9de5e05](https://github.com/TRIPTYK/ember-common-ui/commit/9de5e05b1adcef966658d53527e77b9b85b34854)) -* missing disabled ([ef7bb35](https://github.com/TRIPTYK/ember-common-ui/commit/ef7bb35c6722fe2c6bf5dd95a86b0f6a5e8e5509)) -* mobile number is not reset when change other input in form ([23566a4](https://github.com/TRIPTYK/ember-common-ui/commit/23566a496b8a68961947d33cebd8eaf115d4c6d3)) -* remove question mark in parameter ([127f0b2](https://github.com/TRIPTYK/ember-common-ui/commit/127f0b214bc415e66dabbf783d5eb8861061bd36)) -* test for tpk-validation-mobile ([16bfb19](https://github.com/TRIPTYK/ember-common-ui/commit/16bfb19959cbaa4b047a4d278af8daf86efabab8)) -* updated not update ([a59cf21](https://github.com/TRIPTYK/ember-common-ui/commit/a59cf211e2441393f2ebbe7a79f3a5e70ba696f6)) - - -### Features - -* add a11y on prefb number ([f27cc9e](https://github.com/TRIPTYK/ember-common-ui/commit/f27cc9e55536d237cc332072cef44b532e9e5472)) -* add a11y on prefb radio ([cf5d47e](https://github.com/TRIPTYK/ember-common-ui/commit/cf5d47e0a4f7fb899747af02174c1006c71763ac)) -* add daisyui ([fce98a6](https://github.com/TRIPTYK/ember-common-ui/commit/fce98a6d2d3aee0f864088193a3f21dcdafa0d88)) -* add default design with daisy for mobile prefab and add right class on prefab mobile ([a7f3a7b](https://github.com/TRIPTYK/ember-common-ui/commit/a7f3a7bc5bf5deb7cff451c3d9e8843b86828f7e)) -* add default design with daisy for select create prefab ([68bd7a4](https://github.com/TRIPTYK/ember-common-ui/commit/68bd7a4a5dc61edc34a7fba7ca6f534a6ddd44c6)) -* add default design with daisy for select prefab ([dc5d513](https://github.com/TRIPTYK/ember-common-ui/commit/dc5d513e3603deecaf549986b1bdb1af54b159c5)) -* add default design with daisy for select search prefab ([041eb36](https://github.com/TRIPTYK/ember-common-ui/commit/041eb36afc138fda0d8bc9f40052b78d56c2cb46)) -* add prefab for datepicker ([bb4875c](https://github.com/TRIPTYK/ember-common-ui/commit/bb4875c53b6e82ad5890f99b851ed4c5d7d336c7)) -* daisy on bic ([619f069](https://github.com/TRIPTYK/ember-common-ui/commit/619f0698e414eeeb1399f4fd8e6e9be2c30a9e9b)) -* daisy on date picker range and currency ([654a5ac](https://github.com/TRIPTYK/ember-common-ui/commit/654a5ac31f8a566bd88de9a8d84295b5413fcaea)) -* daisy on email, file and iban prefab ([7daea16](https://github.com/TRIPTYK/ember-common-ui/commit/7daea16d8ac59fed1af944ca3890c9ded5ebd924)) -* daisyUI checkbox and input ([9d47dc1](https://github.com/TRIPTYK/ember-common-ui/commit/9d47dc1a8b48df7fedcf2706a3f6d5569d83a009)) -* daisyUI checkbox and input ([f095aa4](https://github.com/TRIPTYK/ember-common-ui/commit/f095aa4fe4520d5c5ccb5224b05e84345ab1f5d3)) -* daisyui for integer input ([57de733](https://github.com/TRIPTYK/ember-common-ui/commit/57de733126c6802a87df375d2d8f3a3415d979d2)) -* daisyui input number ([65b37ad](https://github.com/TRIPTYK/ember-common-ui/commit/65b37ade0ba9ec06408e3d0d00f2d31f583559a7)) -* daisyui national number prefab ([1b3df89](https://github.com/TRIPTYK/ember-common-ui/commit/1b3df895c231e01c33568dbeb126234dd6e58bb1)) -* daisyUI on prefab bic ([4e26577](https://github.com/TRIPTYK/ember-common-ui/commit/4e265774f9cad0bad5ea5902b6085ebe02e7f8c0)) -* daisyui radio-group prefab ([dae07b6](https://github.com/TRIPTYK/ember-common-ui/commit/dae07b60948852da9770d37de13a1086dc06d289)) -* input vat ([d1b1c38](https://github.com/TRIPTYK/ember-common-ui/commit/d1b1c3810fda38b106721d8fa984bdfa5da16fe4)) -* prefab password daisyui ([61e0be5](https://github.com/TRIPTYK/ember-common-ui/commit/61e0be57c55170d72210ba44e928d6d6616f598b)) -* remove classless feature ([dfed3d7](https://github.com/TRIPTYK/ember-common-ui/commit/dfed3d7226288bc84824f72f8f69174380604d97)) -* review ([1eea468](https://github.com/TRIPTYK/ember-common-ui/commit/1eea468820144f45eb0015b3635bbfffceb15968)) -* textarea prefab daisyui ([6bb6a22](https://github.com/TRIPTYK/ember-common-ui/commit/6bb6a222873142584439dcd5aa6e5cebfd2c86e5)) diff --git a/doc-app/README.md b/doc-app/README.md index 4248b3a4..4bc1caf3 100644 --- a/doc-app/README.md +++ b/doc-app/README.md @@ -8,40 +8,39 @@ A short introduction of this app could easily go here. You will need the following things properly installed on your computer. - [Git](https://git-scm.com/) -- [Node.js](https://nodejs.org/) (with npm) -- [Ember CLI](https://cli.emberjs.com/release/) +- [Node.js](https://nodejs.org/) +- [pnpm](https://pnpm.io/) - [Google Chrome](https://google.com/chrome/) ## Installation - `git clone ` this repository - `cd doc-app` -- `npm install` +- `pnpm install` ## Running / Development -- `npm run start` +- `pnpm start` - Visit your app at [http://localhost:4200](http://localhost:4200). - Visit your tests at [http://localhost:4200/tests](http://localhost:4200/tests). ### Code Generators -Make use of the many generators for code, try `ember help generate` for more details +Make use of the many generators for code, try `pnpm ember help generate` for more details ### Running Tests -- `npm run test` -- `npm run test:ember -- --server` +- `pnpm test` ### Linting -- `npm run lint` -- `npm run lint:fix` +- `pnpm lint` +- `pnpm lint:fix` ### Building -- `npm exec ember build` (development) -- `npm run build` (production) +- `pnpm vite build --mode development` (development) +- `pnpm build` (production) ### Deploying @@ -50,7 +49,7 @@ Specify what it takes to deploy your app. ## Further Reading / Useful Links - [ember.js](https://emberjs.com/) -- [ember-cli](https://cli.emberjs.com/release/) +- [Vite](https://vite.dev) - Development Browser Extensions - [ember inspector for chrome](https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi) - [ember inspector for firefox](https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/) diff --git a/doc-app/app/adapters/application.js b/doc-app/app/adapters/application.js deleted file mode 100644 index 1376f981..00000000 --- a/doc-app/app/adapters/application.js +++ /dev/null @@ -1,5 +0,0 @@ -import JSONAPIAdapter from '@ember-data/adapter/json-api'; - -export default class ApplicationAdapter extends JSONAPIAdapter { - host = 'http://localhost:4200'; -} diff --git a/doc-app/app/app.ts b/doc-app/app/app.ts index 59066108..02589193 100644 --- a/doc-app/app/app.ts +++ b/doc-app/app/app.ts @@ -1,12 +1,21 @@ import Application from '@ember/application'; +import compatModules from '@embroider/virtual/compat-modules'; import Resolver from 'ember-resolver'; import loadInitializers from 'ember-load-initializers'; import config from 'doc-app/config/environment'; +import { importSync, isDevelopingApp, macroCondition } from '@embroider/macros'; +import setupInspector from '@embroider/legacy-inspector-support/ember-source-4.12'; +import './styles/app.css'; + +if (macroCondition(isDevelopingApp())) { + importSync('./deprecation-workflow'); +} export default class App extends Application { modulePrefix = config.modulePrefix; podModulePrefix = config.podModulePrefix; - Resolver = Resolver; + Resolver = Resolver.withModules(compatModules); + inspector = setupInspector(this); } -loadInitializers(App, config.modulePrefix); +loadInitializers(App, config.modulePrefix, compatModules); diff --git a/doc-app/app/components/auth-layout.gts b/doc-app/app/components/auth-layout.gts new file mode 100644 index 00000000..def5731b --- /dev/null +++ b/doc-app/app/components/auth-layout.gts @@ -0,0 +1,16 @@ +import type { TOC } from '@ember/component/template-only'; + +interface AuthLayoutSignature { + Element: HTMLDivElement; + Blocks: { + default: []; + }; +} + + satisfies TOC; diff --git a/doc-app/app/components/doc/code-block.gts b/doc-app/app/components/doc/code-block.gts new file mode 100644 index 00000000..b57a042d --- /dev/null +++ b/doc-app/app/components/doc/code-block.gts @@ -0,0 +1,111 @@ +// doc-app/app/components/doc/code-block.gts +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { action } from '@ember/object'; +import { on } from '@ember/modifier'; +import { codeToHtml } from 'shiki'; +import { htmlSafe } from '@ember/template'; +import type Owner from '@ember/owner'; + +interface CodeBlockSignature { + Args: { + code: string; + language?: string; + }; +} + +export default class CodeBlockComponent extends Component { + @tracked copied = false; + @tracked highlightedHtml = ''; + + constructor(owner: Owner, args: CodeBlockSignature['Args']) { + super(owner, args); + void this.generateHighlightedCode(); + } + + async generateHighlightedCode() { + try { + const html = await codeToHtml(this.args.code, { + lang: this.language, + theme: 'catppuccin-frappe', + }); + this.highlightedHtml = html; + } catch (error) { + console.error('Failed to highlight code:', error); + this.highlightedHtml = `
${this.args.code}
`; + } + } + + @action + async copyCode() { + try { + await navigator.clipboard.writeText(this.args.code); + this.copied = true; + setTimeout(() => { + this.copied = false; + }, 2000); + } catch (err) { + console.error('Failed to copy:', err); + } + } + + get language() { + const lang = this.args.language || 'typescript'; + const languageMap: Record = { + ts: 'typescript', + gts: 'glimmer-ts', + js: 'javascript', + }; + return languageMap[lang] || lang; + } + + get safeHtml() { + return htmlSafe(this.highlightedHtml); + } + + +} diff --git a/doc-app/app/components/doc/code-example.gts b/doc-app/app/components/doc/code-example.gts new file mode 100644 index 00000000..dad2d883 --- /dev/null +++ b/doc-app/app/components/doc/code-example.gts @@ -0,0 +1,108 @@ +// doc-app/app/components/doc/code-example.gts +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { action } from '@ember/object'; +import { service } from '@ember/service'; +import type IntlService from 'ember-intl/services/intl'; +import { on } from '@ember/modifier'; +import { fn } from '@ember/helper'; + +interface CodeExampleSignature { + Args: { + title?: string; + }; + Blocks: { + default: []; + }; +} + +export default class CodeExampleComponent extends Component { + @service declare intl: IntlService; + @tracked activeYield = 'demo'; + + @action + selectYield(yieldName: string) { + this.activeYield = yieldName; + } + + get isDemo() { + return this.activeYield === 'demo'; + } + + get isTemplate() { + return this.activeYield === 'template'; + } + + get isJavascript() { + return this.activeYield === 'javascript'; + } + + get isTypescript() { + return this.activeYield === 'typescript'; + } + + getTabClass(isActive: boolean): string { + return isActive ? 'tab tab-active' : 'tab'; + } + + +} diff --git a/doc-app/app/components/doc/page.gts b/doc-app/app/components/doc/page.gts new file mode 100644 index 00000000..e6f63f23 --- /dev/null +++ b/doc-app/app/components/doc/page.gts @@ -0,0 +1,33 @@ +// doc-app/app/components/doc/page.gts +import Component from '@glimmer/component'; +import { service } from '@ember/service'; +import type IntlService from 'ember-intl/services/intl'; + +interface DocPageSignature { + Args: { + title: string; + description?: string; + }; + Blocks: { + default: []; + }; +} + +export default class DocPageComponent extends Component { + @service declare intl: IntlService; + + +} diff --git a/doc-app/app/components/doc/property-table.gts b/doc-app/app/components/doc/property-table.gts new file mode 100644 index 00000000..8035f1d3 --- /dev/null +++ b/doc-app/app/components/doc/property-table.gts @@ -0,0 +1,75 @@ +// doc-app/app/components/doc/property-table.gts +import type { TOC } from '@ember/component/template-only'; +import t from 'ember-intl/helpers/t'; + +interface Property { + name: string; + type: string; + required: boolean; + description: string; +} + +interface PropertyTableSignature { + Args: { + properties: Property[]; + }; +} + +const PropertyTable: TOC = ; + +export default PropertyTable; diff --git a/doc-app/app/components/doc/section.gts b/doc-app/app/components/doc/section.gts new file mode 100644 index 00000000..d365d901 --- /dev/null +++ b/doc-app/app/components/doc/section.gts @@ -0,0 +1,26 @@ +import { service } from '@ember/service'; +import Component from '@glimmer/component'; +import type { IntlService } from 'ember-intl'; + +interface DocSectionSignature { + Args: { + title: string; + id?: string; + }; + Blocks: { + default: []; + }; +} + +export default class DocSectionComponent extends Component { + @service declare intl: IntlService; + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/basic-bic.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-bic.gts new file mode 100644 index 00000000..fb84c679 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-bic.gts @@ -0,0 +1,19 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkBicPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-bic'; + +export default class BasicBicExample extends Component { + @tracked changeset = new ImmerChangeset({ + bic: '', + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/basic-currency.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-currency.gts new file mode 100644 index 00000000..f40b20bd --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-currency.gts @@ -0,0 +1,19 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkCurrencyPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-currency'; + +export default class BasicCurrencyExample extends Component { + @tracked changeset = new ImmerChangeset({ + value: '', + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/basic-datepicker-range.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-datepicker-range.gts new file mode 100644 index 00000000..20cc826e --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-datepicker-range.gts @@ -0,0 +1,18 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkDatepickerRangePrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-datepicker-range'; + +export default class BasicDatepickerRangeExample extends Component { + @tracked changeset = new ImmerChangeset({ + range: null, + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/basic-datepicker.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-datepicker.gts new file mode 100644 index 00000000..6d12991e --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-datepicker.gts @@ -0,0 +1,19 @@ +// doc-app/app/components/docs/ember-input-validation/prefabs/basic-datepicker.gts +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkDatepickerPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-datepicker'; + +export default class BasicDatepickerExample extends Component { + @tracked changeset = new ImmerChangeset({ + birthday: null, + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/basic-email.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-email.gts new file mode 100644 index 00000000..dd04bd9e --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-email.gts @@ -0,0 +1,20 @@ +// doc-app/app/components/docs/ember-input-validation/prefabs/basic-email.gts +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkEmailPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-email'; + +export default class BasicEmailExample extends Component { + @tracked changeset = new ImmerChangeset({ + email: '', + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/basic-file-list.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-file-list.gts new file mode 100644 index 00000000..fd96ff8e --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-file-list.gts @@ -0,0 +1,20 @@ +// doc-app/app/components/docs/ember-input-validation/prefabs/basic-file-list.gts +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkFileListPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-file-list'; + +export default class BasicFileListExample extends Component { + @tracked changeset = new ImmerChangeset({ + files: [], + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/basic-file.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-file.gts new file mode 100644 index 00000000..6b61e78f --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-file.gts @@ -0,0 +1,19 @@ +// doc-app/app/components/docs/ember-input-validation/prefabs/basic-file.gts +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkFilePrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-file'; + +export default class BasicFileExample extends Component { + @tracked changeset = new ImmerChangeset({ + file: null, + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/basic-iban.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-iban.gts new file mode 100644 index 00000000..668763d1 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-iban.gts @@ -0,0 +1,20 @@ +// doc-app/app/components/docs/ember-input-validation/prefabs/basic-iban.gts +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkIbanPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-iban'; + +export default class BasicIbanExample extends Component { + @tracked changeset = new ImmerChangeset({ + iban: '', + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/basic-input.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-input.gts new file mode 100644 index 00000000..ec45804e --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-input.gts @@ -0,0 +1,19 @@ +// doc-app/app/components/docs/ember-input-validation/prefabs/basic-input.gts +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkInputPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-input'; + +export default class BasicInputExample extends Component { + @tracked changeset = new ImmerChangeset({ + something: '', + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/basic-integer.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-integer.gts new file mode 100644 index 00000000..3ad71a89 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-integer.gts @@ -0,0 +1,21 @@ +// doc-app/app/components/docs/ember-input-validation/prefabs/basic-integer.gts +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkIntegerPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-integer'; + +export default class BasicIntegerExample extends Component { + @tracked changeset = new ImmerChangeset({ + integer: 0, + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/basic-mobile.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-mobile.gts new file mode 100644 index 00000000..ab37dd7e --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-mobile.gts @@ -0,0 +1,18 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkMobilePrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-mobile'; + +export default class BasicMobileExample extends Component { + @tracked changeset = new ImmerChangeset({ + phone: '', + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/basic-national-number.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-national-number.gts new file mode 100644 index 00000000..6fdde5db --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-national-number.gts @@ -0,0 +1,19 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkNationalNumberPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-national-number'; + +export default class BasicNationalNumberExample extends Component { + @tracked changeset = new ImmerChangeset({ + nationalNumber: '', + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/basic-number.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-number.gts new file mode 100644 index 00000000..431cf807 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-number.gts @@ -0,0 +1,20 @@ +// doc-app/app/components/docs/ember-input-validation/prefabs/basic-number.gts +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkValidationNumber from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-number'; + +export default class BasicNumberExample extends Component { + @tracked changeset = new ImmerChangeset({ + number: 0, + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/basic-password.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-password.gts new file mode 100644 index 00000000..4f07cac4 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-password.gts @@ -0,0 +1,19 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkPasswordPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-password'; + +export default class BasicPasswordExample extends Component { + @tracked changeset = new ImmerChangeset({ + password: '', + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/basic-radio-group.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-radio-group.gts new file mode 100644 index 00000000..22a105cb --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-radio-group.gts @@ -0,0 +1,22 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkRadioGroupPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-radio-group'; + +export default class BasicRadioGroupExample extends Component { + @tracked changeset = new ImmerChangeset({ + radio: '', + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/basic-radio.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-radio.gts new file mode 100644 index 00000000..5dcf68e1 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-radio.gts @@ -0,0 +1,19 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkRadioPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-radio'; + +export default class BasicRadioExample extends Component { + @tracked changeset = new ImmerChangeset({ + radio: '', + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/basic-select-create.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-select-create.gts new file mode 100644 index 00000000..a0027f22 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-select-create.gts @@ -0,0 +1,51 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkSelectCreatePrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-select-create'; +import { action } from '@ember/object'; + +export default class BasicSelectCreateExample extends Component { + @tracked changeset = new ImmerChangeset({ + addon: null, + }); + + options = [ + { + label: 'ember-power-select', + value: 'ember-power-select', + toString() { + return `${this.label}`; + }, + }, + { + label: 'ember-concurrency', + value: 'ember-concurrency', + toString() { + return `${this.label}`; + }, + }, + ]; + + @action + onCreate(selection: unknown) { + const value = selection as string; + const newOption = { + label: value, + value: value.toLowerCase().replace(/\s+/g, '-'), + toString() { + return `${this.label}`; + }, + }; + this.options = [...this.options, newOption]; + } + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/basic-select-search.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-select-search.gts new file mode 100644 index 00000000..9b27a6b0 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-select-search.gts @@ -0,0 +1,47 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkSelectSearchPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-select-search'; +import { task } from 'ember-concurrency'; +import perform from 'ember-concurrency/helpers/perform'; + +export default class BasicSelectSearchExample extends Component { + @tracked changeset = new ImmerChangeset({ + repository: null, + }); + + @tracked options: unknown[] = []; + + onSearch = task(async (searchTerm: string) => { + // Simulate API call + await new Promise((resolve) => setTimeout(resolve, 300)); + + const mockRepos = [ + { label: 'ember-common-ui', value: 'ember-common-ui' }, + { label: 'ember-power-select', value: 'ember-power-select' }, + { label: 'ember-concurrency', value: 'ember-concurrency' }, + { label: 'ember-cli', value: 'ember-cli' }, + ]; + + this.options = mockRepos + .filter((repo) => + repo.label.toLowerCase().includes(searchTerm.toLowerCase()) + ) + .map((repo) => ({ + ...repo, + toString() { + return `${this.label}`; + }, + })); + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/basic-select.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-select.gts new file mode 100644 index 00000000..4641aeb1 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-select.gts @@ -0,0 +1,43 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkSelectPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-select'; + +export default class BasicSelectExample extends Component { + @tracked changeset = new ImmerChangeset({ + addon: null, + }); + + options = [ + { + label: 'ember-power-select', + value: 'ember-power-select', + toString() { + return `${this.label}`; + }, + }, + { + label: 'ember-concurrency', + value: 'ember-concurrency', + toString() { + return `${this.label}`; + }, + }, + { + label: 'ember-composable-helpers', + value: 'ember-composable-helpers', + toString() { + return `${this.label}`; + }, + }, + ]; + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/basic-textarea.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-textarea.gts new file mode 100644 index 00000000..dcfba778 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-textarea.gts @@ -0,0 +1,19 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkTextareaPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-textarea'; + +export default class BasicTextareaExample extends Component { + @tracked changeset = new ImmerChangeset({ + ember: '', + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/basic-timepicker.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-timepicker.gts new file mode 100644 index 00000000..7b278020 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-timepicker.gts @@ -0,0 +1,18 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkTimepickerPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-timepicker'; + +export default class BasicTimepickerExample extends Component { + @tracked changeset = new ImmerChangeset({ + time: null, + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/basic-vat.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-vat.gts new file mode 100644 index 00000000..8796b336 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/basic-vat.gts @@ -0,0 +1,19 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkVatPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-vat'; + +export default class BasicVatExample extends Component { + @tracked changeset = new ImmerChangeset({ + vat: '', + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-bic.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-bic.gts new file mode 100644 index 00000000..08f8a712 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-bic.gts @@ -0,0 +1,19 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkBicPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-bic'; + +export default class DisabledBicExample extends Component { + @tracked changeset = new ImmerChangeset({ + disabled: 'ABNANL2AXXX', + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-currency.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-currency.gts new file mode 100644 index 00000000..f80e67c9 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-currency.gts @@ -0,0 +1,19 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkCurrencyPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-currency'; + +export default class DisabledCurrencyExample extends Component { + @tracked changeset = new ImmerChangeset({ + disabled: '1234.56', + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-datepicker-range.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-datepicker-range.gts new file mode 100644 index 00000000..994c7bdb --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-datepicker-range.gts @@ -0,0 +1,19 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkDatepickerRangePrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-datepicker-range'; + +export default class DisabledDatepickerRangeExample extends Component { + @tracked changeset = new ImmerChangeset({ + disabled: null, + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-datepicker.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-datepicker.gts new file mode 100644 index 00000000..f24958a7 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-datepicker.gts @@ -0,0 +1,20 @@ +// doc-app/app/components/docs/ember-input-validation/prefabs/disabled-datepicker.gts +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkDatepickerPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-datepicker'; + +export default class DisabledDatepickerExample extends Component { + @tracked changeset = new ImmerChangeset({ + disabled: new Date(), + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-email.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-email.gts new file mode 100644 index 00000000..c015b9c4 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-email.gts @@ -0,0 +1,20 @@ +// doc-app/app/components/docs/ember-input-validation/prefabs/disabled-email.gts +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkEmailPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-email'; + +export default class DisabledEmailExample extends Component { + @tracked changeset = new ImmerChangeset({ + disabled: 'disabled@example.com', + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-file-list.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-file-list.gts new file mode 100644 index 00000000..f9433064 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-file-list.gts @@ -0,0 +1,21 @@ +// doc-app/app/components/docs/ember-input-validation/prefabs/disabled-file-list.gts +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkFileListPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-file-list'; + +export default class DisabledFileListExample extends Component { + @tracked changeset = new ImmerChangeset({ + disabled: [], + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-file.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-file.gts new file mode 100644 index 00000000..b70d3948 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-file.gts @@ -0,0 +1,20 @@ +// doc-app/app/components/docs/ember-input-validation/prefabs/disabled-file.gts +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkFilePrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-file'; + +export default class DisabledFileExample extends Component { + @tracked changeset = new ImmerChangeset({ + disabled: null, + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-iban.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-iban.gts new file mode 100644 index 00000000..9525b7be --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-iban.gts @@ -0,0 +1,21 @@ +// doc-app/app/components/docs/ember-input-validation/prefabs/disabled-iban.gts +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkIbanPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-iban'; + +export default class DisabledIbanExample extends Component { + @tracked changeset = new ImmerChangeset({ + disabled: 'BE68 5390 0754 7034', + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-input.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-input.gts new file mode 100644 index 00000000..011437f0 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-input.gts @@ -0,0 +1,25 @@ +// doc-app/app/components/examples/input-validation/disabled-input.gts +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import { object, string } from 'zod'; +import TpkInputPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-input'; + +export default class DisabledInputExample extends Component { + @tracked changeset = new ImmerChangeset({ + disabled: 'This is disabled', + }); + + validationSchema = object({ + disabled: string(), + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-integer.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-integer.gts new file mode 100644 index 00000000..646a2baa --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-integer.gts @@ -0,0 +1,21 @@ +// doc-app/app/components/docs/ember-input-validation/prefabs/disabled-integer.gts +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkIntegerPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-integer'; + +export default class DisabledIntegerExample extends Component { + @tracked changeset = new ImmerChangeset({ + disabled: 42, + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-mobile.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-mobile.gts new file mode 100644 index 00000000..85da8921 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-mobile.gts @@ -0,0 +1,19 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkMobilePrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-mobile'; + +export default class DisabledMobileExample extends Component { + @tracked changeset = new ImmerChangeset({ + disabled: '+352 621 123 456', + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-national-number.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-national-number.gts new file mode 100644 index 00000000..f5c07dd5 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-national-number.gts @@ -0,0 +1,20 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkNationalNumberPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-national-number'; + +export default class DisabledNationalNumberExample extends Component { + @tracked changeset = new ImmerChangeset({ + disabled: '12.34.56-789.01', + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-number.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-number.gts new file mode 100644 index 00000000..9bfbf260 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-number.gts @@ -0,0 +1,21 @@ +// doc-app/app/components/docs/ember-input-validation/prefabs/disabled-number.gts +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkValidationNumber from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-number'; + +export default class DisabledNumberExample extends Component { + @tracked changeset = new ImmerChangeset({ + number: 42, + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-password.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-password.gts new file mode 100644 index 00000000..b982b511 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-password.gts @@ -0,0 +1,20 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkPasswordPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-password'; + +export default class DisabledPasswordExample extends Component { + @tracked changeset = new ImmerChangeset({ + disabled: 'DisabledPassword123', + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-radio-group.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-radio-group.gts new file mode 100644 index 00000000..2676b01c --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-radio-group.gts @@ -0,0 +1,23 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkRadioGroupPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-radio-group'; + +export default class DisabledRadioGroupExample extends Component { + @tracked changeset = new ImmerChangeset({ + disabled: 'applati', + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-radio.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-radio.gts new file mode 100644 index 00000000..ad4233c9 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-radio.gts @@ -0,0 +1,20 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkRadioPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-radio'; + +export default class DisabledRadioExample extends Component { + @tracked changeset = new ImmerChangeset({ + disabled: 'selected one', + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-select-create.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-select-create.gts new file mode 100644 index 00000000..36b2ccfe --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-select-create.gts @@ -0,0 +1,58 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkSelectCreatePrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-select-create'; +import { action } from '@ember/object'; + +export default class DisabledSelectCreateExample extends Component { + @tracked changeset = new ImmerChangeset({ + disabled: { + label: 'ember-power-select', + value: 'ember-power-select', + toString() { + return `${this.label}`; + }, + }, + }); + + options = [ + { + label: 'ember-power-select', + value: 'ember-power-select', + toString() { + return `${this.label}`; + }, + }, + { + label: 'ember-concurrency', + value: 'ember-concurrency', + toString() { + return `${this.label}`; + }, + }, + ]; + + @action + onCreate(selection: unknown) { + const value = selection as string; + const newOption = { + label: value, + value: value.toLowerCase().replace(/\s+/g, '-'), + toString() { + return `${this.label}`; + }, + }; + this.options = [...this.options, newOption]; + } + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-select-search.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-select-search.gts new file mode 100644 index 00000000..745c5442 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-select-search.gts @@ -0,0 +1,51 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkSelectSearchPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-select-search'; +import { task } from 'ember-concurrency'; +import perform from 'ember-concurrency/helpers/perform'; + +export default class DisabledSelectSearchExample extends Component { + @tracked changeset = new ImmerChangeset({ + disabled: { + label: 'ember-common-ui', + value: 'ember-common-ui', + toString() { + return `${this.label}`; + }, + }, + }); + + @tracked options: unknown[] = []; + + onSearch = task(async (searchTerm: string) => { + await new Promise((resolve) => setTimeout(resolve, 300)); + + const mockRepos = [ + { label: 'ember-common-ui', value: 'ember-common-ui' }, + { label: 'ember-power-select', value: 'ember-power-select' }, + ]; + + this.options = mockRepos + .filter((repo) => + repo.label.toLowerCase().includes(searchTerm.toLowerCase()) + ) + .map((repo) => ({ + ...repo, + toString() { + return `${this.label}`; + }, + })); + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-select.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-select.gts new file mode 100644 index 00000000..6a55d085 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-select.gts @@ -0,0 +1,43 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkSelectPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-select'; + +export default class DisabledSelectExample extends Component { + @tracked changeset = new ImmerChangeset({ + disabled: { + label: 'ember-power-select', + value: 'ember-power-select', + toString() { + return `${this.label}`; + }, + }, + }); + + options = [ + { + label: 'ember-power-select', + value: 'ember-power-select', + toString() { + return `${this.label}`; + }, + }, + { + label: 'ember-concurrency', + value: 'ember-concurrency', + toString() { + return `${this.label}`; + }, + }, + ]; + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-textarea.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-textarea.gts new file mode 100644 index 00000000..d3e00d8b --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-textarea.gts @@ -0,0 +1,19 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkTextareaPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-textarea'; + +export default class DisabledTextareaExample extends Component { + @tracked changeset = new ImmerChangeset({ + disabled: 'This textarea is disabled', + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-timepicker.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-timepicker.gts new file mode 100644 index 00000000..11e71bd7 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-timepicker.gts @@ -0,0 +1,19 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkTimepickerPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-timepicker'; + +export default class DisabledTimepickerExample extends Component { + @tracked changeset = new ImmerChangeset({ + disabled: '14:30', + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-vat.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-vat.gts new file mode 100644 index 00000000..4871949c --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/disabled-vat.gts @@ -0,0 +1,20 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkVatPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-vat'; + +export default class DisabledVatExample extends Component { + @tracked changeset = new ImmerChangeset({ + disabled: 'BE0123456789', + }); + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/error-bic.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/error-bic.gts new file mode 100644 index 00000000..ce9e09f7 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/error-bic.gts @@ -0,0 +1,56 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkBicPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-bic'; +import type Owner from '@ember/owner'; +import { action } from '@ember/object'; + +export default class ErrorBicExample extends Component { + @tracked changeset = new ImmerChangeset({ + bic: '', + }); + + @action + onChange(value: string | number | Date | null) { + if (typeof value !== 'string') { + this.changeset.addError({ + message: 'should be a string value', + value: 'err', + originalValue: '', + key: 'bic', + }); + } + if ((value as string).length >= 8) { + this.changeset.removeErrors(); + } else { + this.changeset.addError({ + message: 'BIC must be at least 8 characters', + value: 'err', + originalValue: '', + key: 'bic', + }); + } + } + + constructor(owner: Owner, args: never) { + super(owner, args); + setTimeout(() => { + this.changeset.addError({ + message: 'BIC must be at least 8 characters', + value: 'err', + originalValue: '', + key: 'bic', + }); + }, 0); + } + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/error-currency.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/error-currency.gts new file mode 100644 index 00000000..76412b40 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/error-currency.gts @@ -0,0 +1,56 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkCurrencyPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-currency'; +import type Owner from '@ember/owner'; +import { action } from '@ember/object'; + +export default class ErrorCurrencyExample extends Component { + @tracked changeset = new ImmerChangeset({ + error: '', + }); + + @action + onChange(value: string | number | Date | null) { + if (typeof value !== 'number') { + this.changeset.addError({ + message: 'should be a number value', + value: 'err', + originalValue: 0, + key: 'number', + }); + return; + } + if (value !== null && value > 0) { + this.changeset.removeErrors(); + } else { + this.changeset.addError({ + message: 'Amount must be greater than 0', + value: 'err', + originalValue: '', + key: 'error', + }); + } + } + + constructor(owner: Owner, args: never) { + super(owner, args); + setTimeout(() => { + this.changeset.addError({ + message: 'Amount must be greater than 0', + value: 'err', + originalValue: '', + key: 'error', + }); + }, 0); + } + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/error-datepicker-range.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/error-datepicker-range.gts new file mode 100644 index 00000000..05b55e08 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/error-datepicker-range.gts @@ -0,0 +1,65 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkDatepickerRangePrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-datepicker-range'; +import type Owner from '@ember/owner'; +import { action } from '@ember/object'; + +export default class ErrorDatepickerRangeExample extends Component { + @tracked changeset = new ImmerChangeset({ + error: null, + }); + + @action + onChange(value: Date[] | null) { + if (value && value.length === 2) { + const [startDate, endDate] = value; + if (!endDate || !startDate) { + this.changeset.addError({ + message: 'need a start and end date', + value: 'err', + originalValue: null, + key: 'error', + }); + return; + } + + const daysDiff = Math.floor( + (endDate.getTime() - startDate.getTime()) / (1000 * 60 * 60 * 24) + ); + if (daysDiff > 30) { + this.changeset.addError({ + message: 'Date range cannot exceed 30 days', + value: 'err', + originalValue: null, + key: 'error', + }); + } else { + this.changeset.removeErrors(); + } + } else { + this.changeset.removeErrors(); + } + } + + constructor(owner: Owner, args: never) { + super(owner, args); + setTimeout(() => { + this.changeset.addError({ + message: 'Please select a valid date range', + value: 'err', + originalValue: null, + key: 'error', + }); + }, 0); + } + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/error-datepicker.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/error-datepicker.gts new file mode 100644 index 00000000..4cfd2019 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/error-datepicker.gts @@ -0,0 +1,58 @@ +// doc-app/app/components/docs/ember-input-validation/prefabs/error-datepicker.gts +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkDatepickerPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-datepicker'; +import type Owner from '@ember/owner'; +import { action } from '@ember/object'; + +export default class ErrorDatepickerExample extends Component { + @tracked changeset = new ImmerChangeset({ + birthday: null, + }); + + @action + onChange(value: Date[]) { + if (!Array.isArray(value) || value.length === 0) { + this.changeset.addError({ + message: 'need a start and end date', + value: 'err', + originalValue: null, + key: 'error', + }); + return; + } + const dateValue = value[0]; + if (dateValue && dateValue > new Date()) { + this.changeset.addError({ + message: 'Date must be in the past', + value: 'err', + originalValue: null, + key: 'birthday', + }); + } else if (dateValue) { + this.changeset.removeErrors(); + } + } + + constructor(owner: Owner, args: never) { + super(owner, args); + setTimeout(() => { + this.changeset.addError({ + message: 'Please select a date', + value: 'err', + originalValue: null, + key: 'birthday', + }); + }, 0); + } + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/error-email.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/error-email.gts new file mode 100644 index 00000000..013b09e1 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/error-email.gts @@ -0,0 +1,69 @@ +// doc-app/app/components/docs/ember-input-validation/prefabs/error-email.gts +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkEmailPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-email'; +import type Owner from '@ember/owner'; +import { action } from '@ember/object'; + +export default class ErrorEmailExample extends Component { + @tracked changeset = new ImmerChangeset({ + email: '', + }); + + @action + onChange(value: string | number | Date | null) { + // Email validation logic + const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; + + if (typeof value !== 'string') { + this.changeset.addError({ + message: 'Email should be a string value', + value: 'err', + originalValue: '', + key: 'email', + }); + return; + } + + if (!value || value.trim() === '') { + this.changeset.addError({ + message: 'Email is required', + value: 'err', + originalValue: '', + key: 'email', + }); + } else if (!emailRegex.test(value)) { + this.changeset.addError({ + message: 'Please enter a valid email address', + value: 'err', + originalValue: '', + key: 'email', + }); + } else { + this.changeset.removeErrors(); + } + } + + constructor(owner: Owner, args: never) { + super(owner, args); + setTimeout(() => { + this.changeset.addError({ + message: 'Email is required', + value: 'err', + originalValue: '', + key: 'email', + }); + }, 0); + } + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/error-file-list.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/error-file-list.gts new file mode 100644 index 00000000..843e6d8c --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/error-file-list.gts @@ -0,0 +1,61 @@ +// doc-app/app/components/docs/ember-input-validation/prefabs/error-file-list.gts +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkFileListPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-file-list'; +import type Owner from '@ember/owner'; +import { action } from '@ember/object'; + +export default class ErrorFileListExample extends Component { + @tracked changeset = new ImmerChangeset({ + files: [], + }); + + @action + onChange(value: unknown) { + // File validation logic + if (!Array.isArray(value)) { + this.changeset.addError({ + message: 'Value should be an array', + value: 'err', + originalValue: [], + key: 'files', + }); + return; + } + + if (value.length === 0) { + this.changeset.addError({ + message: 'At least one file is required', + value: 'err', + originalValue: [], + key: 'files', + }); + } else { + this.changeset.removeErrors(); + } + } + + constructor(owner: Owner, args: never) { + super(owner, args); + setTimeout(() => { + this.changeset.addError({ + message: 'At least one file is required', + value: 'err', + originalValue: [], + key: 'files', + }); + }, 0); + } + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/error-file.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/error-file.gts new file mode 100644 index 00000000..42c9ff8e --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/error-file.gts @@ -0,0 +1,50 @@ +// doc-app/app/components/docs/ember-input-validation/prefabs/error-file.gts +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkFilePrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-file'; +import type Owner from '@ember/owner'; +import { action } from '@ember/object'; + +export default class ErrorFileExample extends Component { + @tracked changeset = new ImmerChangeset({ + file: null, + }); + + @action + onChange(value: unknown) { + // File validation logic + if (!value) { + this.changeset.addError({ + message: 'File is required', + value: 'err', + originalValue: null, + key: 'file', + }); + } else { + this.changeset.removeErrors(); + } + } + + constructor(owner: Owner, args: never) { + super(owner, args); + setTimeout(() => { + this.changeset.addError({ + message: 'File is required', + value: 'err', + originalValue: null, + key: 'file', + }); + }, 0); + } + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/error-iban.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/error-iban.gts new file mode 100644 index 00000000..9ed6c266 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/error-iban.gts @@ -0,0 +1,69 @@ +// doc-app/app/components/docs/ember-input-validation/prefabs/error-iban.gts +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkIbanPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-iban'; +import type Owner from '@ember/owner'; +import { action } from '@ember/object'; + +export default class ErrorIbanExample extends Component { + @tracked changeset = new ImmerChangeset({ + iban: '', + }); + + @action + onChange(value: string | number | Date | null) { + // IBAN validation logic + if (typeof value !== 'string') { + this.changeset.addError({ + message: 'IBAN should be a string value', + value: 'err', + originalValue: '', + key: 'iban', + }); + return; + } + + const ibanWithoutSpaces = value.replace(/\s/g, ''); + + if (!ibanWithoutSpaces) { + this.changeset.addError({ + message: 'IBAN is required', + value: 'err', + originalValue: '', + key: 'iban', + }); + } else if (ibanWithoutSpaces.length < 15) { + this.changeset.addError({ + message: 'IBAN must be at least 15 characters', + value: 'err', + originalValue: '', + key: 'iban', + }); + } else { + this.changeset.removeErrors(); + } + } + + constructor(owner: Owner, args: never) { + super(owner, args); + setTimeout(() => { + this.changeset.addError({ + message: 'IBAN is required', + value: 'err', + originalValue: '', + key: 'iban', + }); + }, 0); + } + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/error-input.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/error-input.gts new file mode 100644 index 00000000..ec410126 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/error-input.gts @@ -0,0 +1,58 @@ +// doc-app/app/components/examples/input-validation/error-input.gts +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkInputPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-input'; +import type Owner from '@ember/owner'; +import { action } from '@ember/object'; + +export default class ErrorInputExample extends Component { + @tracked changeset = new ImmerChangeset({ + something: '', + }); + + @action + onChange(value: string | number | Date | null) { + // Type guard to ensure we only work with strings + if (typeof value !== 'string') { + this.changeset.addError({ + message: 'should be a string value', + value: 'err', + originalValue: '', + key: 'something', + }); + } + + if ((value as string)?.length >= 5) { + this.changeset.removeErrors(); + } else { + this.changeset.addError({ + message: 'Minimum 5 characters', + value: 'err', + originalValue: '', + key: 'something', + }); + } + } + + constructor(owner: Owner, args: never) { + super(owner, args); + setTimeout(() => { + this.changeset.addError({ + message: 'Minimum 5 characters', + value: 'err', + originalValue: '', + key: 'something', + }); + }, 0); + } + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/error-integer.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/error-integer.gts new file mode 100644 index 00000000..eab5e059 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/error-integer.gts @@ -0,0 +1,71 @@ +// doc-app/app/components/docs/ember-input-validation/prefabs/error-integer.gts +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkIntegerPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-integer'; +import type Owner from '@ember/owner'; +import { action } from '@ember/object'; + +export default class ErrorIntegerExample extends Component { + @tracked changeset = new ImmerChangeset({ + integer: null, + }); + + @action + onChange(value: string | number | Date | null) { + // Integer validation logic + if (value === null || value === undefined || value === '') { + this.changeset.addError({ + message: 'Integer is required', + value: 'err', + originalValue: null, + key: 'integer', + }); + return; + } + + const numValue = + typeof value === 'number' ? value : parseFloat(value as string); + + if (isNaN(numValue)) { + this.changeset.addError({ + message: 'Must be a valid number', + value: 'err', + originalValue: null, + key: 'integer', + }); + } else if (!Number.isInteger(numValue)) { + this.changeset.addError({ + message: 'Must be an integer (no decimal)', + value: 'err', + originalValue: null, + key: 'integer', + }); + } else { + this.changeset.removeErrors(); + } + } + + constructor(owner: Owner, args: never) { + super(owner, args); + setTimeout(() => { + this.changeset.addError({ + message: 'Integer is required', + value: 'err', + originalValue: null, + key: 'integer', + }); + }, 0); + } + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/error-mobile.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/error-mobile.gts new file mode 100644 index 00000000..4e61001b --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/error-mobile.gts @@ -0,0 +1,56 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkMobilePrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-mobile'; +import type Owner from '@ember/owner'; +import { action } from '@ember/object'; + +export default class ErrorMobileExample extends Component { + @tracked changeset = new ImmerChangeset({ + phone: '', + }); + + @action + onChange(value: string | number | Date | null) { + if (typeof value !== 'number') { + this.changeset.addError({ + message: 'should be a string value', + value: 'err', + originalValue: '', + key: 'phone', + }); + } + if ((value as string)?.length >= 10) { + this.changeset.removeErrors(); + } else { + this.changeset.addError({ + message: 'Minimum 10 characters', + value: 'err', + originalValue: '', + key: 'phone', + }); + } + } + + constructor(owner: Owner, args: never) { + super(owner, args); + setTimeout(() => { + this.changeset.addError({ + message: 'Minimum 10 characters', + value: 'err', + originalValue: '', + key: 'phone', + }); + }, 0); + } + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/error-national-number.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/error-national-number.gts new file mode 100644 index 00000000..f3ed820a --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/error-national-number.gts @@ -0,0 +1,56 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkNationalNumberPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-national-number'; +import type Owner from '@ember/owner'; +import { action } from '@ember/object'; + +export default class ErrorNationalNumberExample extends Component { + @tracked changeset = new ImmerChangeset({ + nationalNumber: '', + }); + + @action + onChange(value: string | number | Date | null) { + if (typeof value !== 'string') { + this.changeset.addError({ + message: 'should be a string value', + value: 'err', + originalValue: '', + key: 'nationalNumber', + }); + } + if ((value as string)?.length >= 11) { + this.changeset.removeErrors(); + } else { + this.changeset.addError({ + message: 'Invalid national number format', + value: 'err', + originalValue: '', + key: 'nationalNumber', + }); + } + } + + constructor(owner: Owner, args: never) { + super(owner, args); + setTimeout(() => { + this.changeset.addError({ + message: 'Invalid national number format', + value: 'err', + originalValue: '', + key: 'nationalNumber', + }); + }, 0); + } + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/error-number.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/error-number.gts new file mode 100644 index 00000000..0705fd6d --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/error-number.gts @@ -0,0 +1,59 @@ +// doc-app/app/components/docs/ember-input-validation/prefabs/error-number.gts +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkValidationNumber from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-number'; +import type Owner from '@ember/owner'; +import { action } from '@ember/object'; + +export default class ErrorNumberExample extends Component { + @tracked changeset = new ImmerChangeset({ + number: 0, + }); + + @action + onChange(value: string | number | Date | null) { + if (typeof value !== 'number') { + this.changeset.addError({ + message: 'should be a number value', + value: 'err', + originalValue: 0, + key: 'number', + }); + return; + } + + if (value >= 10) { + this.changeset.removeErrors(); + } else { + this.changeset.addError({ + message: 'Minimum value is 10', + value: 'err', + originalValue: 0, + key: 'number', + }); + } + } + + constructor(owner: Owner, args: never) { + super(owner, args); + setTimeout(() => { + this.changeset.addError({ + message: 'Minimum value is 10', + value: 'err', + originalValue: 0, + key: 'number', + }); + }, 0); + } + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/error-password.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/error-password.gts new file mode 100644 index 00000000..03bf0e4d --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/error-password.gts @@ -0,0 +1,56 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkPasswordPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-password'; +import type Owner from '@ember/owner'; +import { action } from '@ember/object'; + +export default class ErrorPasswordExample extends Component { + @tracked changeset = new ImmerChangeset({ + password: '', + }); + + @action + onChange(value: string | number | Date | null) { + if (typeof value !== 'string') { + this.changeset.addError({ + message: 'should be a string value', + value: 'err', + originalValue: '', + key: 'password', + }); + } + if ((value as string)?.length >= 8) { + this.changeset.removeErrors(); + } else { + this.changeset.addError({ + message: 'Minimum 8 characters', + value: 'err', + originalValue: '', + key: 'password', + }); + } + } + + constructor(owner: Owner, args: never) { + super(owner, args); + setTimeout(() => { + this.changeset.addError({ + message: 'Minimum 8 characters', + value: 'err', + originalValue: '', + key: 'password', + }); + }, 0); + } + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/error-radio-group.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/error-radio-group.gts new file mode 100644 index 00000000..7e44e020 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/error-radio-group.gts @@ -0,0 +1,51 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkRadioGroupPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-radio-group'; +import type Owner from '@ember/owner'; +import { action } from '@ember/object'; + +export default class ErrorRadioGroupExample extends Component { + @tracked changeset = new ImmerChangeset({ + radio: '', + }); + + @action + onChange(value: string | number | Date | null) { + if (!value) { + this.changeset.addError({ + message: 'should be a string value', + value: 'err', + originalValue: '', + key: 'radio', + }); + } else { + this.changeset.removeErrors(); + } + } + + constructor(owner: Owner, args: never) { + super(owner, args); + setTimeout(() => { + this.changeset.addError({ + message: 'A selection is mandatory', + value: 'err', + originalValue: '', + key: 'radio', + }); + }, 0); + } + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/error-radio.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/error-radio.gts new file mode 100644 index 00000000..2734ea9b --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/error-radio.gts @@ -0,0 +1,48 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkRadioPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-radio'; +import type Owner from '@ember/owner'; +import { action } from '@ember/object'; + +export default class ErrorRadioExample extends Component { + @tracked changeset = new ImmerChangeset({ + radio: '', + }); + + @action + onChange(value: string | number | Date | null) { + if (!value) { + this.changeset.addError({ + message: 'Please select an option', + value: 'err', + originalValue: '', + key: 'radio', + }); + } else { + this.changeset.removeErrors(); + } + } + + constructor(owner: Owner, args: never) { + super(owner, args); + setTimeout(() => { + this.changeset.addError({ + message: 'Please select an option', + value: 'err', + originalValue: '', + key: 'radio', + }); + }, 0); + } + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/error-select-create.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/error-select-create.gts new file mode 100644 index 00000000..68514d6e --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/error-select-create.gts @@ -0,0 +1,79 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkSelectCreatePrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-select-create'; +import type Owner from '@ember/owner'; +import { action } from '@ember/object'; + +export default class ErrorSelectCreateExample extends Component { + @tracked changeset = new ImmerChangeset({ + addon: null, + }); + + options = [ + { + label: 'ember-power-select', + value: 'ember-power-select', + toString() { + return `${this.label}`; + }, + }, + { + label: 'ember-concurrency', + value: 'ember-concurrency', + toString() { + return `${this.label}`; + }, + }, + ]; + + @action + onCreate(selection: unknown) { + const value = selection as string; + const newOption = { + label: value, + value: value.toLowerCase().replace(/\s+/g, '-'), + toString() { + return `${this.label}`; + }, + }; + this.options = [...this.options, newOption]; + } + + @action + onChange(value: unknown) { + if (!value) { + this.changeset.addError({ + message: 'Please select or create an addon', + value: 'err', + originalValue: '', + key: 'addon', + }); + } else { + this.changeset.removeErrors(); + } + } + + constructor(owner: Owner, args: never) { + super(owner, args); + setTimeout(() => { + this.changeset.addError({ + message: 'Please select or create an addon', + value: 'err', + originalValue: '', + key: 'addon', + }); + }, 0); + } + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/error-select-search.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/error-select-search.gts new file mode 100644 index 00000000..fc4ce01d --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/error-select-search.gts @@ -0,0 +1,74 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkSelectSearchPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-select-search'; +import type Owner from '@ember/owner'; +import { action } from '@ember/object'; +import { task } from 'ember-concurrency'; +import perform from 'ember-concurrency/helpers/perform'; + +export default class ErrorSelectSearchExample extends Component { + @tracked changeset = new ImmerChangeset({ + repository: null, + }); + + @tracked options: unknown[] = []; + + onSearch = task(async (searchTerm: string) => { + await new Promise((resolve) => setTimeout(resolve, 300)); + + const mockRepos = [ + { label: 'ember-common-ui', value: 'ember-common-ui' }, + { label: 'ember-power-select', value: 'ember-power-select' }, + { label: 'ember-concurrency', value: 'ember-concurrency' }, + ]; + + this.options = mockRepos + .filter((repo) => + repo.label.toLowerCase().includes(searchTerm.toLowerCase()) + ) + .map((repo) => ({ + ...repo, + toString() { + return `${this.label}`; + }, + })); + }); + + @action + onChange(value: unknown) { + if (!value) { + this.changeset.addError({ + message: 'Please select a repository', + value: 'err', + originalValue: '', + key: 'repository', + }); + } else { + this.changeset.removeErrors(); + } + } + + constructor(owner: Owner, args: never) { + super(owner, args); + setTimeout(() => { + this.changeset.addError({ + message: 'Please select a repository', + value: 'err', + originalValue: '', + key: 'repository', + }); + }, 0); + } + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/error-select.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/error-select.gts new file mode 100644 index 00000000..de5d71b7 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/error-select.gts @@ -0,0 +1,72 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkSelectPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-select'; +import type Owner from '@ember/owner'; +import { action } from '@ember/object'; + +export default class ErrorSelectExample extends Component { + @tracked changeset = new ImmerChangeset({ + addon: null, + }); + + options = [ + { + label: 'ember-power-select', + value: 'ember-power-select', + toString() { + return `${this.label}`; + }, + }, + { + label: 'ember-concurrency', + value: 'ember-concurrency', + toString() { + return `${this.label}`; + }, + }, + { + label: 'ember-composable-helpers', + value: 'ember-composable-helpers', + toString() { + return `${this.label}`; + }, + }, + ]; + + @action + onChange(value: unknown) { + if (!value) { + this.changeset.addError({ + message: 'Please select an addon', + value: 'err', + originalValue: '', + key: 'addon', + }); + } else { + this.changeset.removeErrors(); + } + } + + constructor(owner: Owner, args: never) { + super(owner, args); + setTimeout(() => { + this.changeset.addError({ + message: 'Please select an addon', + value: 'err', + originalValue: '', + key: 'addon', + }); + }, 0); + } + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/error-textarea.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/error-textarea.gts new file mode 100644 index 00000000..51cd946e --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/error-textarea.gts @@ -0,0 +1,48 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkTextareaPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-textarea'; +import type Owner from '@ember/owner'; +import { action } from '@ember/object'; + +export default class ErrorTextareaExample extends Component { + @tracked changeset = new ImmerChangeset({ + ember: '', + }); + + @action + onChange(value: string) { + if (!value || value.length < 10) { + this.changeset.addError({ + message: 'Minimum 10 characters', + value: 'err', + originalValue: '', + key: 'ember', + }); + } else { + this.changeset.removeErrors(); + } + } + + constructor(owner: Owner, args: never) { + super(owner, args); + setTimeout(() => { + this.changeset.addError({ + message: 'Minimum 10 characters', + value: 'err', + originalValue: '', + key: 'ember', + }); + }, 0); + } + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/error-timepicker.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/error-timepicker.gts new file mode 100644 index 00000000..f671ef9a --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/error-timepicker.gts @@ -0,0 +1,47 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkTimepickerPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-timepicker'; +import type Owner from '@ember/owner'; +import { action } from '@ember/object'; + +export default class ErrorTimepickerExample extends Component { + @tracked changeset = new ImmerChangeset({ + time: null, + }); + + @action + onChange(value: Date[]) { + if (!value) { + this.changeset.addError({ + message: 'Please select a time', + value: 'err', + originalValue: '', + key: 'time', + }); + } else { + this.changeset.removeErrors(); + } + } + + constructor(owner: Owner, args: never) { + super(owner, args); + setTimeout(() => { + this.changeset.addError({ + message: 'Please select a time', + value: 'err', + originalValue: '', + key: 'time', + }); + }, 0); + } + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/error-vat.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/error-vat.gts new file mode 100644 index 00000000..ee544763 --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/error-vat.gts @@ -0,0 +1,56 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkVatPrefab from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-vat'; +import type Owner from '@ember/owner'; +import { action } from '@ember/object'; + +export default class ErrorVatExample extends Component { + @tracked changeset = new ImmerChangeset({ + vat: '', + }); + + @action + onChange(value: string | number | Date | null) { + if (typeof value !== 'string') { + this.changeset.addError({ + message: 'should be a string value', + value: 'err', + originalValue: '', + key: 'password', + }); + } + if (!value || (value as string).length < 5) { + this.changeset.addError({ + message: 'Please enter a valid VAT number', + value: 'err', + originalValue: '', + key: 'vat', + }); + } else { + this.changeset.removeErrors(); + } + } + + constructor(owner: Owner, args: never) { + super(owner, args); + setTimeout(() => { + this.changeset.addError({ + message: 'Please enter a valid VAT number', + value: 'err', + originalValue: '', + key: 'vat', + }); + }, 0); + } + + +} diff --git a/doc-app/app/components/docs/ember-input-validation/prefabs/unsigned-number.gts b/doc-app/app/components/docs/ember-input-validation/prefabs/unsigned-number.gts new file mode 100644 index 00000000..7432d08e --- /dev/null +++ b/doc-app/app/components/docs/ember-input-validation/prefabs/unsigned-number.gts @@ -0,0 +1,21 @@ +// doc-app/app/components/docs/ember-input-validation/prefabs/unsigned-number.gts +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import TpkValidationNumber from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-number'; + +export default class UnsignedNumberExample extends Component { + @tracked changeset = new ImmerChangeset({ + uNumber: 0, + }); + + +} diff --git a/doc-app/app/components/docs/ember-input/prefabs/button.gts b/doc-app/app/components/docs/ember-input/prefabs/button.gts new file mode 100644 index 00000000..a6a9adae --- /dev/null +++ b/doc-app/app/components/docs/ember-input/prefabs/button.gts @@ -0,0 +1,25 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { action } from '@ember/object'; +import TpkPrefabButton from '@triptyk/ember-input/components/prefabs/tpk-prefab-button'; + +export default class ButtonExample extends Component { + @tracked counter = 0; + + @action + incrementCounter() { + this.counter++; + } + + +} diff --git a/doc-app/app/components/docs/ember-input/prefabs/disabled-button.gts b/doc-app/app/components/docs/ember-input/prefabs/disabled-button.gts new file mode 100644 index 00000000..39aa1abf --- /dev/null +++ b/doc-app/app/components/docs/ember-input/prefabs/disabled-button.gts @@ -0,0 +1,23 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { action } from '@ember/object'; +import TpkPrefabButton from '@triptyk/ember-input/components/prefabs/tpk-prefab-button'; + +export default class DisabledButtonExample extends Component { + @tracked counter = 0; + + @action + incrementCounter() { + this.counter++; + } + + +} diff --git a/doc-app/app/components/docs/ember-input/prefabs/disabled-toggle.gts b/doc-app/app/components/docs/ember-input/prefabs/disabled-toggle.gts new file mode 100644 index 00000000..6f4ded71 --- /dev/null +++ b/doc-app/app/components/docs/ember-input/prefabs/disabled-toggle.gts @@ -0,0 +1,13 @@ +import Component from '@glimmer/component'; +import TpkTogglePrefabComponent from '@triptyk/ember-input/components/prefabs/tpk-toggle'; + +// eslint-disable-next-line ember/no-empty-glimmer-component-classes +export default class DisabledToggleExample extends Component { + +} diff --git a/doc-app/app/components/docs/ember-input/prefabs/toggle.gts b/doc-app/app/components/docs/ember-input/prefabs/toggle.gts new file mode 100644 index 00000000..ea2e9a3f --- /dev/null +++ b/doc-app/app/components/docs/ember-input/prefabs/toggle.gts @@ -0,0 +1,9 @@ +import Component from '@glimmer/component'; +import TpkTogglePrefab from '@triptyk/ember-input/components/prefabs/tpk-toggle'; + +// eslint-disable-next-line ember/no-empty-glimmer-component-classes +export default class ToggleExample extends Component { + +} diff --git a/doc-app/app/components/docs/ember-ui/prefabs/confirm-modal.gts b/doc-app/app/components/docs/ember-ui/prefabs/confirm-modal.gts new file mode 100644 index 00000000..45ac3da0 --- /dev/null +++ b/doc-app/app/components/docs/ember-ui/prefabs/confirm-modal.gts @@ -0,0 +1,39 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import TpkConfirmModalPrefab from '@triptyk/ember-ui/components/prefabs/tpk-confirm-modal-prefab'; +import { action } from '@ember/object'; +import TpkButtonPrefabComponent from '@triptyk/ember-input/components/prefabs/tpk-prefab-button'; + +export default class ConfirmModalExample extends Component { + @tracked isOpen = false; + confirmQuestion = 'Are you sure?'; + + @action + open() { + this.isOpen = true; + } + + @action + onClose() { + this.isOpen = false; + } + + @action + onConfirm() { + this.isOpen = false; + alert('Confirmed'); + } + + +} diff --git a/doc-app/app/components/docs/ember-ui/prefabs/table-generic.gts b/doc-app/app/components/docs/ember-ui/prefabs/table-generic.gts new file mode 100644 index 00000000..ec2f43b5 --- /dev/null +++ b/doc-app/app/components/docs/ember-ui/prefabs/table-generic.gts @@ -0,0 +1,97 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { action } from '@ember/object'; +import TpkTableGenericPrefab from '@triptyk/ember-ui/components/prefabs/tpk-table-generic-prefab'; +import type { TableParams } from '@triptyk/ember-ui/components/prefabs/tpk-table-generic-prefab'; +import TpkSelect from '@triptyk/ember-input/components/tpk-select'; +import type { TOC } from '@ember/component/template-only'; +import type { TpkSelectSignature } from '@triptyk/ember-input/components/tpk-select'; +import { hash } from '@ember/helper'; +import stringify from 'doc-app/helpers/to-string'; + +const TpkSelectElement: TOC< + TpkSelectSignature & { + Args: { + cellValue: string; + }; + } +> = ; + +export default class TpkTableGenericPrefabExample extends Component { + @tracked tableParams: TableParams = { + entity: 'user', + pageSizes: [10, 30, 50, 75], + defaultSortColumn: 'firstName', + columns: [ + { + field: 'lastName', + headerName: 'Nom', + sortable: true, + }, + { + field: 'firstName', + headerName: 'Prénom', + sortable: true, + }, + { + field: 'email', + headerName: 'Email', + sortable: false, + component: 'selectEmail', + }, + ], + actionMenu: [ + { + icon: 'edit', + action: (element: unknown) => { + console.log('Edit clicked', element); + }, + name: 'Edit', + }, + { + icon: 'delete', + action: (element: unknown) => { + console.log('Delete clicked', element); + }, + name: 'Delete', + }, + ], + }; + + emailOptions = ['info@triptyk.eu', 'loempia@triptyk.eu']; + + @action + onEmailChange(selection: unknown) { + console.log('Email changed:', selection); + } + + @action + onRowClick(element: unknown, e?: Event) { + console.log('Row clicked:', element, e); + } + + +} diff --git a/doc-app/app/components/docs/ember-ui/prefabs/tpk-form.gts b/doc-app/app/components/docs/ember-ui/prefabs/tpk-form.gts new file mode 100644 index 00000000..eec8fae4 --- /dev/null +++ b/doc-app/app/components/docs/ember-ui/prefabs/tpk-form.gts @@ -0,0 +1,57 @@ +import Component from '@glimmer/component'; +import { action } from '@ember/object'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import { object, string } from 'zod'; +import TpkForm from '@triptyk/ember-input-validation/components/tpk-form'; + +export default class TpkFormExample extends Component { + // Initialize an empty changeset + changeset = new ImmerChangeset({ + firstName: '', + lastName: '', + email: '', + }); + + // Define validation rules with Zod + validationSchema = object({ + firstName: string().min(2, 'First name must be at least 2 characters'), + lastName: string().min(2, 'Last name must be at least 2 characters'), + email: string().email('Must be a valid email address'), + }); + + @action + handleSubmit( + validatedData: { + firstName: string; + lastName: string; + email: string; + }, + changeset: ImmerChangeset<{ + firstName: string; + lastName: string; + email: string; + }> + ) { + // validatedData contains the validated form data + // changeset is the ImmerChangeset instance + console.log('Form submitted with:', validatedData, changeset); + alert('Form submitted successfully!'); + } + + +} diff --git a/doc-app/app/components/docs/ember-ui/prefabs/tpk-form/base-components.gts b/doc-app/app/components/docs/ember-ui/prefabs/tpk-form/base-components.gts new file mode 100644 index 00000000..08a9df92 --- /dev/null +++ b/doc-app/app/components/docs/ember-ui/prefabs/tpk-form/base-components.gts @@ -0,0 +1,49 @@ +import Component from '@glimmer/component'; +import { action } from '@ember/object'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import { object, string } from 'zod'; +import TpkForm from '@triptyk/ember-input-validation/components/tpk-form'; + +export default class TpkFormBaseComponentsExample extends Component { + changeset = new ImmerChangeset({ + username: '', + }); + + validationSchema = object({ + username: string().min(3, 'Username must be at least 3 characters'), + }); + + @action + handleSubmit(validatedData: { username: string }) { + console.log('Form submitted with:', validatedData); + alert('Form submitted successfully!'); + } + + errorMessage(error: Record): string { + const message = error['message']; + return typeof message === 'string' ? message : ''; + } + + +} diff --git a/doc-app/app/components/docs/ember-ui/prefabs/tpk-form/changeset-get.gts b/doc-app/app/components/docs/ember-ui/prefabs/tpk-form/changeset-get.gts new file mode 100644 index 00000000..ccf9b263 --- /dev/null +++ b/doc-app/app/components/docs/ember-ui/prefabs/tpk-form/changeset-get.gts @@ -0,0 +1,43 @@ +import Component from '@glimmer/component'; +import { action } from '@ember/object'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import { object, string } from 'zod'; +import TpkForm from '@triptyk/ember-input-validation/components/tpk-form'; + +export default class TpkFormChangesetGetExample extends Component { + changeset = new ImmerChangeset({ + firstName: '', + lastName: '', + }); + + validationSchema = object({ + firstName: string().min(2, 'First name must be at least 2 characters'), + lastName: string().min(2, 'Last name must be at least 2 characters'), + }); + + @action + handleSubmit(validatedData: { firstName: string; lastName: string }) { + console.log('Form submitted with:', validatedData); + alert('Form submitted successfully!'); + } + + +} diff --git a/doc-app/app/components/docs/ember-ui/prefabs/tpk-form/disabled-state.gts b/doc-app/app/components/docs/ember-ui/prefabs/tpk-form/disabled-state.gts new file mode 100644 index 00000000..cafd34f5 --- /dev/null +++ b/doc-app/app/components/docs/ember-ui/prefabs/tpk-form/disabled-state.gts @@ -0,0 +1,53 @@ +import Component from '@glimmer/component'; +import { action } from '@ember/object'; +import { tracked } from '@glimmer/tracking'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import { object, string } from 'zod'; +import TpkForm from '@triptyk/ember-input-validation/components/tpk-form'; +import { on } from '@ember/modifier'; + +export default class TpkFormDisabledStateExample extends Component { + @tracked isLoading = false; + + changeset = new ImmerChangeset({ + name: '', + }); + + validationSchema = object({ + name: string().min(2, 'Name must be at least 2 characters'), + }); + + @action + handleSubmit(validatedData: { name: string }) { + this.isLoading = true; + setTimeout(() => { + console.log('Form submitted with:', validatedData); + alert('Form submitted successfully!'); + this.isLoading = false; + }, 1000); + } + + @action + toggleLoading() { + this.isLoading = !this.isLoading; + } + + +} diff --git a/doc-app/app/components/docs/ember-ui/prefabs/tpk-form/error-handling.gts b/doc-app/app/components/docs/ember-ui/prefabs/tpk-form/error-handling.gts new file mode 100644 index 00000000..9e5ae1bb --- /dev/null +++ b/doc-app/app/components/docs/ember-ui/prefabs/tpk-form/error-handling.gts @@ -0,0 +1,38 @@ +import Component from '@glimmer/component'; +import { action } from '@ember/object'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import { object, string } from 'zod'; +import TpkForm from '@triptyk/ember-input-validation/components/tpk-form'; + +export default class TpkFormErrorHandlingExample extends Component { + changeset = new ImmerChangeset({ + field1: '', + field2: '', + }); + + validationSchema = object({ + field1: string().min(3, 'Field 1 must be at least 3 characters'), + field2: string().min(3, 'Field 2 must be at least 3 characters'), + }); + + @action + handleSubmit(validatedData: { field1: string; field2: string }) { + console.log('Form submitted with:', validatedData); + alert('Form submitted successfully!'); + } + + +} diff --git a/doc-app/app/components/docs/ember-ui/prefabs/tpk-form/reactive-validation.gts b/doc-app/app/components/docs/ember-ui/prefabs/tpk-form/reactive-validation.gts new file mode 100644 index 00000000..1e0b222e --- /dev/null +++ b/doc-app/app/components/docs/ember-ui/prefabs/tpk-form/reactive-validation.gts @@ -0,0 +1,34 @@ +import Component from '@glimmer/component'; +import { action } from '@ember/object'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import { object, string } from 'zod'; +import TpkForm from '@triptyk/ember-input-validation/components/tpk-form'; + +export default class TpkFormReactiveValidationExample extends Component { + changeset = new ImmerChangeset({ + email: '', + }); + + validationSchema = object({ + email: string().email('Must be a valid email address'), + }); + + @action + handleSubmit(validatedData: { email: string }) { + console.log('Form submitted with:', validatedData); + alert('Form submitted successfully!'); + } + + +} diff --git a/doc-app/app/components/docs/ember-ui/prefabs/tpk-form/required-fields.gts b/doc-app/app/components/docs/ember-ui/prefabs/tpk-form/required-fields.gts new file mode 100644 index 00000000..d544dc89 --- /dev/null +++ b/doc-app/app/components/docs/ember-ui/prefabs/tpk-form/required-fields.gts @@ -0,0 +1,46 @@ +import Component from '@glimmer/component'; +import { action } from '@ember/object'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import { object, string } from 'zod'; +import TpkForm from '@triptyk/ember-input-validation/components/tpk-form'; + +export default class TpkFormRequiredFieldsExample extends Component { + changeset = new ImmerChangeset({ + name: '', + email: '', + }); + + validationSchema = object({ + name: string().min(2, 'Name must be at least 2 characters'), + email: string().email('Must be a valid email address'), + }); + + @action + handleSubmit(validatedData: { name: string; email: string }) { + console.log('Form submitted with:', validatedData); + alert('Form submitted successfully!'); + } + + includes = (array: string[], value: string) => array.includes(value); + + +} diff --git a/doc-app/app/components/docs/ember-ui/prefabs/tpk-form/submit-only-validation.gts b/doc-app/app/components/docs/ember-ui/prefabs/tpk-form/submit-only-validation.gts new file mode 100644 index 00000000..972053b4 --- /dev/null +++ b/doc-app/app/components/docs/ember-ui/prefabs/tpk-form/submit-only-validation.gts @@ -0,0 +1,34 @@ +import Component from '@glimmer/component'; +import { action } from '@ember/object'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import { object, string } from 'zod'; +import TpkForm from '@triptyk/ember-input-validation/components/tpk-form'; + +export default class TpkFormSubmitOnlyValidationExample extends Component { + changeset = new ImmerChangeset({ + email: '', + }); + + validationSchema = object({ + email: string().email('Must be a valid email address'), + }); + + @action + handleSubmit(validatedData: { email: string }) { + console.log('Form submitted with:', validatedData); + alert('Form submitted successfully!'); + } + + +} diff --git a/doc-app/app/components/dummy-form.gts b/doc-app/app/components/dummy-form.gts new file mode 100644 index 00000000..ce91bea8 --- /dev/null +++ b/doc-app/app/components/dummy-form.gts @@ -0,0 +1,118 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { action } from '@ember/object'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import { + object, + string, + date, + boolean, + array, + email, + union, + literal, +} from 'zod'; +import TpkForm from '@triptyk/ember-input-validation/components/tpk-form'; + +export default class DummyFormComponent extends Component { + @tracked changeset = new ImmerChangeset({ + firstName: '', + lastName: '', + email: '', + phone: '', + birthday: null, + languages: [], + password: '', + agreed: false, + description: '', + }); + + validationSchema = object({ + firstName: string(), + lastName: string().min(2, 'At least 2 characters'), + email: union([literal(''), email()]), // allow empty string or email + phone: string(), + birthday: date().max(new Date(), 'Cannot be in the future'), + languages: array(string()).min(1, 'Select at least one language'), + password: string().min(8, 'At least 8 characters'), + agreed: boolean().refine((value) => value === true, 'You must agree'), + description: string().max(500, 'Maximum 500 characters'), + }); + + languageOptions = [ + { + value: 'fr', + label: 'French', + toString: function () { + return this.label; + }, + }, + { + value: 'en', + label: 'English', + toString: function () { + return this.label; + }, + }, + { + value: 'es', + label: 'Spanish', + toString: function () { + return this.label; + }, + }, + { + value: 'de', + label: 'German', + toString: function () { + return this.label; + }, + }, + ]; + + @action + onSubmit() { + alert('Form submitted successfully!'); + } + + @action + onChange(value: unknown) { + console.log('Value changed:', value); + } + + +} diff --git a/doc-app/app/components/dummy-label-select.gts b/doc-app/app/components/dummy-label-select.gts index fbc9c986..bde481fd 100644 --- a/doc-app/app/components/dummy-label-select.gts +++ b/doc-app/app/components/dummy-label-select.gts @@ -1,4 +1,4 @@ -import type { TOC } from "@ember/component/template-only"; +import type { TOC } from '@ember/component/template-only'; interface Args { labelText: string; diff --git a/doc-app/app/components/theme-selector.gts b/doc-app/app/components/theme-selector.gts new file mode 100644 index 00000000..664c691c --- /dev/null +++ b/doc-app/app/components/theme-selector.gts @@ -0,0 +1,125 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { action } from '@ember/object'; +import { fn } from '@ember/helper'; +import { on } from '@ember/modifier'; +import type Owner from '@ember/owner'; + +const THEMES = ['nord', 'dracula', 'cupcake', 'corporate', 'lemonade'] as const; + +interface ThemeSelectorSignature { + Args: { + sidebarCollapsed?: boolean; + }; +} + +export default class ThemeSelector extends Component { + @tracked currentTheme = 'nord'; + @tracked themeDropdownOpen = false; + + constructor(owner: Owner, args: ThemeSelectorSignature['Args']) { + super(owner, args); + let theme = 'nord'; + if (typeof localStorage !== 'undefined') { + theme = localStorage.getItem('doc-app-theme') ?? 'nord'; + } + this.currentTheme = theme; + if (typeof document !== 'undefined') { + document.documentElement.setAttribute('data-theme', theme); + } + } + + THEMES = THEMES; + + @action + setTheme(themeName: string) { + this.currentTheme = themeName; + this.themeDropdownOpen = false; + if (typeof document !== 'undefined') { + document.documentElement.setAttribute('data-theme', themeName); + } + if (typeof localStorage !== 'undefined') { + localStorage.setItem('doc-app-theme', themeName); + } + } + + @action + toggleThemeDropdown() { + this.themeDropdownOpen = !this.themeDropdownOpen; + } + + @action + isCurrentTheme(themeName: string): boolean { + return this.currentTheme === themeName; + } + + +} diff --git a/doc-app/app/config/environment.d.ts b/doc-app/app/config/environment.d.ts deleted file mode 100644 index 3dffaa8b..00000000 --- a/doc-app/app/config/environment.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Type declarations for - * import config from 'doc-app/config/environment' - */ -declare const config: { - environment: string; - modulePrefix: string; - podModulePrefix: string; - locationType: 'history' | 'hash' | 'none'; - rootURL: string; - APP: Record; -}; - -export default config; diff --git a/doc-app/app/config/environment.ts b/doc-app/app/config/environment.ts new file mode 100644 index 00000000..53c0e21e --- /dev/null +++ b/doc-app/app/config/environment.ts @@ -0,0 +1,33 @@ +import loadConfigFromMeta from '@embroider/config-meta-loader'; +import { assert } from '@ember/debug'; + +const config = loadConfigFromMeta('doc-app') as unknown; + +assert( + 'config is not an object', + typeof config === 'object' && config !== null +); +assert( + 'modulePrefix was not detected on your config', + 'modulePrefix' in config && typeof config.modulePrefix === 'string' +); +assert( + 'locationType was not detected on your config', + 'locationType' in config && typeof config.locationType === 'string' +); +assert( + 'rootURL was not detected on your config', + 'rootURL' in config && typeof config.rootURL === 'string' +); +assert( + 'APP was not detected on your config', + 'APP' in config && typeof config.APP === 'object' +); + +export default config as { + modulePrefix: string; + podModulePrefix?: string; + locationType: string; + rootURL: string; + APP: Record; +} & Record; diff --git a/doc-app/app/controllers/docs/.DS_Store b/doc-app/app/controllers/docs/.DS_Store deleted file mode 100644 index 21edadea..00000000 Binary files a/doc-app/app/controllers/docs/.DS_Store and /dev/null differ diff --git a/doc-app/app/controllers/docs/ember-input-validation/checkbox.ts b/doc-app/app/controllers/docs/ember-input-validation/checkbox.ts deleted file mode 100644 index e784734c..00000000 --- a/doc-app/app/controllers/docs/ember-input-validation/checkbox.ts +++ /dev/null @@ -1,27 +0,0 @@ -import Controller from '@ember/controller'; -import { action } from '@ember/object'; -import { tracked } from 'tracked-built-ins'; -import { ImmerChangeset } from 'ember-immer-changeset'; - -export default class DocsCheckboxValidationController extends Controller { - label = "I'm a beast"; - changeset = new ImmerChangeset({ - checked: true, - }); - - @action - onChange(value: boolean) { - this.changeset.set('checked', value); - this.changeset.save(); - if (!this.changeset.get('checked')) { - this.changeset.addError({ - message: 'Check to be a beast', - value: true, - originalValue: true, - key: 'checked', - }); - } else { - this.changeset.removeError('checked'); - } - } -} diff --git a/doc-app/app/controllers/docs/ember-input-validation/input.ts b/doc-app/app/controllers/docs/ember-input-validation/input.ts deleted file mode 100644 index ce66ba62..00000000 --- a/doc-app/app/controllers/docs/ember-input-validation/input.ts +++ /dev/null @@ -1,27 +0,0 @@ -import Controller from '@ember/controller'; -import { action } from '@ember/object'; -import { tracked } from 'tracked-built-ins'; -import { ImmerChangeset } from 'ember-immer-changeset'; - -export default class DocsInputValidationController extends Controller { - label = 'Clear it'; - changeset = new ImmerChangeset({ - delete_text: 'Delete my text', - }); - - @action - onChange(value: string) { - this.changeset.set('delete_text', value); - this.changeset.save(); - if (this.changeset.get('delete_text') === '') { - this.changeset.addError({ - message: 'Why did you do that? Why??', - value: '', - originalValue: '', - key: 'delete_text', - }); - } else { - this.changeset.removeError('delete_text'); - } - } -} diff --git a/doc-app/app/controllers/docs/ember-input-validation/prefabs/bic.ts b/doc-app/app/controllers/docs/ember-input-validation/prefabs/bic.ts deleted file mode 100644 index 36c6b23e..00000000 --- a/doc-app/app/controllers/docs/ember-input-validation/prefabs/bic.ts +++ /dev/null @@ -1,25 +0,0 @@ -import Controller from '@ember/controller'; -import { ImmerChangeset } from 'ember-immer-changeset'; -import { tracked } from '@glimmer/tracking'; -import type { Owner } from '@ember/test-helpers/build-owner'; - -export default class DocsEmberInputValidationPrefabsIBANController extends Controller { - changeset = new ImmerChangeset({ - bic: '', - disabled: 'UKIO0000', - }); - - changesetWithErrors = new ImmerChangeset({ - bic: 'UKIO0000', - }); - - constructor(owner: Owner) { - super(owner); - this.changesetWithErrors.addError({ - message: 'This bic is invalid', - value: '', - originalValue: '', - key: 'bic', - }); - } -} diff --git a/doc-app/app/controllers/docs/ember-input-validation/prefabs/checkbox.ts b/doc-app/app/controllers/docs/ember-input-validation/prefabs/checkbox.ts deleted file mode 100644 index 1414f9a8..00000000 --- a/doc-app/app/controllers/docs/ember-input-validation/prefabs/checkbox.ts +++ /dev/null @@ -1,23 +0,0 @@ -import Controller from '@ember/controller'; -import { ImmerChangeset } from 'ember-immer-changeset'; -import { tracked } from '@glimmer/tracking'; -import type { Owner } from '@ember/test-helpers/build-owner'; - -export default class DocsEmberInputValidationPrefabsCheckboxController extends Controller { - changeset = new ImmerChangeset({ - disabled: true, - unchecked: false, - checked: true, - error: true, - }); - - constructor(owner: Owner) { - super(owner); - this.changeset.addError({ - message: 'This is an error message', - value: '', - originalValue: '', - key: 'error', - }); - } -} diff --git a/doc-app/app/controllers/docs/ember-input-validation/prefabs/currency.ts b/doc-app/app/controllers/docs/ember-input-validation/prefabs/currency.ts deleted file mode 100644 index bb5c7ec5..00000000 --- a/doc-app/app/controllers/docs/ember-input-validation/prefabs/currency.ts +++ /dev/null @@ -1,22 +0,0 @@ -import Controller from '@ember/controller'; -import { ImmerChangeset } from 'ember-immer-changeset'; -import { tracked } from '@glimmer/tracking'; -import type { Owner } from '@ember/test-helpers/build-owner'; - -export default class DocsEmberInputValidationPrefabsCurrencyController extends Controller { - changeset = new ImmerChangeset({ - value: undefined, - disabled: 0.03, - error: 34020.03, - }); - - constructor(owner: Owner) { - super(owner); - this.changeset.addError({ - message: 'This is an error message', - value: '', - originalValue: '', - key: 'error', - }); - } -} diff --git a/doc-app/app/controllers/docs/ember-input-validation/prefabs/datepicker-range.ts b/doc-app/app/controllers/docs/ember-input-validation/prefabs/datepicker-range.ts deleted file mode 100644 index 31fa5e82..00000000 --- a/doc-app/app/controllers/docs/ember-input-validation/prefabs/datepicker-range.ts +++ /dev/null @@ -1,22 +0,0 @@ -import Controller from '@ember/controller'; -import { ImmerChangeset } from 'ember-immer-changeset'; -import { tracked } from '@glimmer/tracking'; -import type { Owner } from '@ember/test-helpers/build-owner'; - -export default class DocsEmberInputValidationPrefabsDatepickerRangeController extends Controller { - changeset = new ImmerChangeset({ - range: null, - disabled: null, - error: null, - }); - - constructor(owner: Owner) { - super(owner); - this.changeset.addError({ - message: 'This is an error message', - value: '', - originalValue: '', - key: 'error', - }); - } -} diff --git a/doc-app/app/controllers/docs/ember-input-validation/prefabs/datepicker.ts b/doc-app/app/controllers/docs/ember-input-validation/prefabs/datepicker.ts deleted file mode 100644 index 08eaa8b9..00000000 --- a/doc-app/app/controllers/docs/ember-input-validation/prefabs/datepicker.ts +++ /dev/null @@ -1,22 +0,0 @@ -import Controller from '@ember/controller'; -import { ImmerChangeset } from 'ember-immer-changeset'; -import { tracked } from '@glimmer/tracking'; -import type { Owner } from '@ember/test-helpers/build-owner'; - -export default class DocsEmberInputValidationPrefabsDatepickerController extends Controller { - changeset = new ImmerChangeset({ - birthday: null, - disabled: null, - error: null, - }); - - constructor(owner: Owner) { - super(owner); - this.changeset.addError({ - message: 'This is an error message', - value: '', - originalValue: '', - key: 'error', - }); - } -} diff --git a/doc-app/app/controllers/docs/ember-input-validation/prefabs/email.ts b/doc-app/app/controllers/docs/ember-input-validation/prefabs/email.ts deleted file mode 100644 index ae603148..00000000 --- a/doc-app/app/controllers/docs/ember-input-validation/prefabs/email.ts +++ /dev/null @@ -1,24 +0,0 @@ -import Controller from '@ember/controller'; -import { action } from '@ember/object'; -import { ImmerChangeset } from 'ember-immer-changeset'; -import { tracked } from '@glimmer/tracking'; -import type { Owner } from '@ember/test-helpers/build-owner'; - -export default class DocsEmberInputValidationPrefabsEmailController extends Controller { - changeset = new ImmerChangeset({ - email: undefined, - disabled: 'email@disabled.true', - error: 'hyperloop.com', - }); - - constructor(owner: Owner) { - super(owner); - this.changeset.addError({ - message: 'This is an error message', - value: '', - originalValue: '', - key: 'error', - }); - } - -} diff --git a/doc-app/app/controllers/docs/ember-input-validation/prefabs/file-list.ts b/doc-app/app/controllers/docs/ember-input-validation/prefabs/file-list.ts deleted file mode 100644 index f517cec2..00000000 --- a/doc-app/app/controllers/docs/ember-input-validation/prefabs/file-list.ts +++ /dev/null @@ -1,22 +0,0 @@ -import Controller from '@ember/controller'; -import { action } from '@ember/object'; -import { ImmerChangeset } from 'ember-immer-changeset'; -import type { Owner } from '@ember/test-helpers/build-owner'; - -export default class DocsEmberInputValidationPrefabsFileListController extends Controller { - changeset = new ImmerChangeset({ - files: [new File([], 'file.txt')], - disabled: [new File([], 'file.txt')], - error: '', - }); - - constructor(owner: Owner) { - super(owner); - this.changeset.addError({ - message: 'This is an error message', - value: '', - originalValue: '', - key: 'error', - }); - } -} diff --git a/doc-app/app/controllers/docs/ember-input-validation/prefabs/file.ts b/doc-app/app/controllers/docs/ember-input-validation/prefabs/file.ts deleted file mode 100644 index 94d1d1ec..00000000 --- a/doc-app/app/controllers/docs/ember-input-validation/prefabs/file.ts +++ /dev/null @@ -1,23 +0,0 @@ -import Controller from '@ember/controller'; -import { action } from '@ember/object'; -import { ImmerChangeset } from 'ember-immer-changeset'; -import { tracked } from '@glimmer/tracking'; -import type { Owner } from '@ember/test-helpers/build-owner'; - -export default class DocsEmberInputValidationPrefabsFileController extends Controller { - changeset = new ImmerChangeset({ - file: new File([], 'file.txt'), - disabled: '', - error: '', - }); - - constructor(owner: Owner) { - super(owner); - this.changeset.addError({ - message: 'This is an error message', - value: '', - originalValue: '', - key: 'error', - }); - } -} diff --git a/doc-app/app/controllers/docs/ember-input-validation/prefabs/iban.ts b/doc-app/app/controllers/docs/ember-input-validation/prefabs/iban.ts deleted file mode 100644 index 9c3dabf4..00000000 --- a/doc-app/app/controllers/docs/ember-input-validation/prefabs/iban.ts +++ /dev/null @@ -1,22 +0,0 @@ -import Controller from '@ember/controller'; -import { ImmerChangeset } from 'ember-immer-changeset'; -import { tracked } from '@glimmer/tracking'; -import type { Owner } from '@ember/test-helpers/build-owner'; - -export default class DocsEmberInputValidationPrefabsIBANController extends Controller { - changeset = new ImmerChangeset({ - iban: '', - error: 'bad iban', - disabled: 'disabled', - }); - - constructor(owner: Owner) { - super(owner); - this.changeset.addError({ - message: 'This is an error message', - value: '', - originalValue: '', - key: 'error', - }); - } -} diff --git a/doc-app/app/controllers/docs/ember-input-validation/prefabs/input.ts b/doc-app/app/controllers/docs/ember-input-validation/prefabs/input.ts deleted file mode 100644 index 0af0e429..00000000 --- a/doc-app/app/controllers/docs/ember-input-validation/prefabs/input.ts +++ /dev/null @@ -1,25 +0,0 @@ -import Controller from '@ember/controller'; -import { ImmerChangeset } from 'ember-immer-changeset'; -import { tracked } from '@glimmer/tracking'; -import type { Owner } from '@ember/test-helpers/build-owner'; - -export default class DocsEmberInputValidationPrefabsInputController extends Controller { - changeset = new ImmerChangeset({ - something: '', - disabled: 'text', - }); - - changesetWithErrors = new ImmerChangeset({ - something: '', - }); - - constructor(owner: Owner) { - super(owner); - this.changesetWithErrors.addError({ - message: 'This is an error message', - value: '', - originalValue: '', - key: 'something', - }); - } -} diff --git a/doc-app/app/controllers/docs/ember-input-validation/prefabs/integer.ts b/doc-app/app/controllers/docs/ember-input-validation/prefabs/integer.ts deleted file mode 100644 index d0cc4b90..00000000 --- a/doc-app/app/controllers/docs/ember-input-validation/prefabs/integer.ts +++ /dev/null @@ -1,37 +0,0 @@ -import Controller from '@ember/controller'; -import { action } from '@ember/object'; -import { tracked } from 'tracked-built-ins'; -import { ImmerChangeset } from 'ember-immer-changeset'; -import type { Owner } from '@ember/test-helpers/build-owner'; - -export default class DocsEmberInputValidationPrefabsIntegerController extends Controller { - changeset = new ImmerChangeset({ - integer: 0, - uInteger: 0, - }); - - changesetWithErrors = new ImmerChangeset({ - integer: 0, - uInteger: 0, - }); - - public constructor(owner: Owner) { - super(owner); - this.changesetWithErrors.addError({ - message: 'This integer is invalid', - value: '', - originalValue: '', - key: 'integer', - }); - } - - @action - onChangeInteger(value: number) { - this.changeset.set('integer', value); - } - - @action - onChangeUInteger(value: number) { - this.changeset.set('uInteger', value); - } -} diff --git a/doc-app/app/controllers/docs/ember-input-validation/prefabs/mobile.ts b/doc-app/app/controllers/docs/ember-input-validation/prefabs/mobile.ts deleted file mode 100644 index 4a2eb4d2..00000000 --- a/doc-app/app/controllers/docs/ember-input-validation/prefabs/mobile.ts +++ /dev/null @@ -1,21 +0,0 @@ -import Controller from '@ember/controller'; -import { ImmerChangeset } from 'ember-immer-changeset'; -import { tracked } from '@glimmer/tracking'; -import type { Owner } from '@ember/test-helpers/build-owner'; - -export default class DocsEmberInputValidationPrefabsPhoneController extends Controller { - changeset = new ImmerChangeset({ - phone: '', - error: '', - disabled: '', - }); - constructor(owner: Owner) { - super(owner); - this.changeset.addError({ - message: 'This is an error message', - value: '', - originalValue: '', - key: 'error', - }); - } -} diff --git a/doc-app/app/controllers/docs/ember-input-validation/prefabs/national-number.ts b/doc-app/app/controllers/docs/ember-input-validation/prefabs/national-number.ts deleted file mode 100644 index e69cfb9e..00000000 --- a/doc-app/app/controllers/docs/ember-input-validation/prefabs/national-number.ts +++ /dev/null @@ -1,25 +0,0 @@ -import Controller from '@ember/controller'; -import { ImmerChangeset } from 'ember-immer-changeset'; -import { tracked } from '@glimmer/tracking'; -import type Owner from '@ember/owner'; - -export default class DocsEmberInputValidationPrefabsNationalNumberController extends Controller { - changeset = new ImmerChangeset({ - nationalNumber: '', - }); - - changesetWithErrors = new ImmerChangeset({ - nationalNumber: '', - }); - - public constructor(owner: Owner) { - super(owner); - this.changesetWithErrors.addError({ - key: 'nationalNumber', - value: '', - originalValue: '', - - message: 'This is not a valid national number', - }) - } -} diff --git a/doc-app/app/controllers/docs/ember-input-validation/prefabs/number.ts b/doc-app/app/controllers/docs/ember-input-validation/prefabs/number.ts deleted file mode 100644 index b51b4040..00000000 --- a/doc-app/app/controllers/docs/ember-input-validation/prefabs/number.ts +++ /dev/null @@ -1,36 +0,0 @@ -import Controller from '@ember/controller'; -import { action } from '@ember/object'; -import { tracked } from 'tracked-built-ins'; -import { ImmerChangeset } from 'ember-immer-changeset'; -import type { Owner } from '@ember/test-helpers/build-owner'; - -export default class DocsEmberInputValidationPrefabsNumberController extends Controller { - changeset = new ImmerChangeset({ - number: 0, - uNumber: 0, - }); - - changesetWithErrors = new ImmerChangeset({ - number: 0, - }); - - public constructor(owner: Owner) { - super(owner); - - this.changesetWithErrors.addError({ - value: '0', - originalValue: 0, - key: 'number', - message: 'This is an error message', - }); - } - - @action - onChangeNumber(value: number) { - this.changeset.set('number', value); - } - - onChangeUNumber(value: number) { - this.changeset.set('uNumber', value); - } -} diff --git a/doc-app/app/controllers/docs/ember-input-validation/prefabs/password.ts b/doc-app/app/controllers/docs/ember-input-validation/prefabs/password.ts deleted file mode 100644 index f7d0a413..00000000 --- a/doc-app/app/controllers/docs/ember-input-validation/prefabs/password.ts +++ /dev/null @@ -1,25 +0,0 @@ -import Controller from '@ember/controller'; -import { ImmerChangeset } from 'ember-immer-changeset'; -import { tracked } from '@glimmer/tracking'; -import type Owner from '@ember/owner'; - -export default class DocsEmberInputValidationPrefabsPasswordController extends Controller { - changeset = new ImmerChangeset({ - name: '', - }); - - changesetWithErrors = new ImmerChangeset({ - name: '', - }); - - public constructor(owner: Owner) { - super(owner); - - this.changesetWithErrors.addError({ - value: '0', - originalValue: 0, - key: 'name', - message: 'This is an error message', - }); - } -} diff --git a/doc-app/app/controllers/docs/ember-input-validation/prefabs/radio-group.ts b/doc-app/app/controllers/docs/ember-input-validation/prefabs/radio-group.ts deleted file mode 100644 index bafd9b26..00000000 --- a/doc-app/app/controllers/docs/ember-input-validation/prefabs/radio-group.ts +++ /dev/null @@ -1,30 +0,0 @@ -import Controller from '@ember/controller'; -import { action } from '@ember/object'; -import { tracked } from 'tracked-built-ins'; -import { ImmerChangeset } from 'ember-immer-changeset'; -import type Owner from '@ember/owner'; - -export default class DocsEmberInputValidationPrefabsRadioGroupController extends Controller { - changeset = new ImmerChangeset({ - radio: undefined, - }); - - changesetWithErrors = new ImmerChangeset({ - radio: undefined, - }); - - public constructor(owner: Owner) { - super(owner); - this.changesetWithErrors.addError({ - key: 'radio', - message: 'Invalid value', - value: 'Invalid value', - originalValue : '' - }); - } - - @action - onChange() { - - } -} diff --git a/doc-app/app/controllers/docs/ember-input-validation/prefabs/radio.ts b/doc-app/app/controllers/docs/ember-input-validation/prefabs/radio.ts deleted file mode 100644 index d3cf9c78..00000000 --- a/doc-app/app/controllers/docs/ember-input-validation/prefabs/radio.ts +++ /dev/null @@ -1,29 +0,0 @@ -import Controller from '@ember/controller'; -import { ImmerChangeset } from 'ember-immer-changeset'; -import { action } from '@ember/object'; -import type Owner from '@ember/owner'; - -export default class DocsEmberInputValidationPrefabsRadioController extends Controller { - changeset = new ImmerChangeset({ - radio: '', - }); - - changesetWithErrors = new ImmerChangeset({ - radio: '', - }); - - public constructor(owner: Owner) { - super(owner); - this.changesetWithErrors.addError({ - key: 'radio', - message: 'Invalid value', - value: 'Invalid value', - originalValue : '' - }); - } - - @action - onChange(e: Event) { - console.log('onChange', e); - } -} diff --git a/doc-app/app/controllers/docs/ember-input-validation/prefabs/select-create.ts b/doc-app/app/controllers/docs/ember-input-validation/prefabs/select-create.ts deleted file mode 100644 index edb2500e..00000000 --- a/doc-app/app/controllers/docs/ember-input-validation/prefabs/select-create.ts +++ /dev/null @@ -1,84 +0,0 @@ -import Controller from '@ember/controller'; -import { ImmerChangeset } from 'ember-immer-changeset'; -import { tracked } from '@glimmer/tracking'; -import { action } from '@ember/object'; -import type Owner from '@ember/owner'; - -function configureDisplay(obj: T, format: (obj: T) => string) { - return { - ...obj, - toString() { - return format(this); - }, - }; -} - -interface ChangesetType { - ceo?: { firstname: string }; - disabled?: { firstname: string }; - error?: { firstname: string }; -} - -interface ChangesetBisType { - ceo: { firstname: string }[]; -} - -export default class DocsEmberInputValidationPrefabsSelectCreateController extends Controller { - constructor(owner: Owner) { - super(owner); - this.changeset.addError({ - message: 'This is an error message', - value: '', - originalValue: '', - key: 'error', - }); - } - - changeset = new ImmerChangeset({ - ceo: undefined, - disabled: undefined, - error: undefined, - }); - - changesetBis = new ImmerChangeset({ - ceo: [], - }); - - @tracked options = [ - { firstname: 'Patrick' }, - { firstname: 'Romain' }, - { firstname: 'Gilles' }, - ].map((o) => configureDisplay(o, (option) => option.firstname)); - - @action - onCreate(value: string) { - const newValue = configureDisplay( - { firstname: value }, - (option) => option.firstname, - ); - this.options = [...this.options, newValue]; - this.changeset.set('ceo', newValue); - } - - @action - onCreateBis(value: string) { - console.log(value); - const newValue = configureDisplay( - { firstname: value }, - (option) => option.firstname, - ); - this.options = [...this.options, newValue]; - this.changesetBis.set('ceo', [...this.changesetBis.get('ceo'), newValue]); - } - - @action - buildSuggestion(term: string) { - return `Créer "${term}"...`; - } - - @action - showCreateWhen(term: string) { - const existingOption = this.options.find((name) => name.firstname === term); - return !existingOption; - } -} diff --git a/doc-app/app/controllers/docs/ember-input-validation/prefabs/select-search.ts b/doc-app/app/controllers/docs/ember-input-validation/prefabs/select-search.ts deleted file mode 100644 index d63cfd81..00000000 --- a/doc-app/app/controllers/docs/ember-input-validation/prefabs/select-search.ts +++ /dev/null @@ -1,57 +0,0 @@ -import Controller from '@ember/controller'; -import { ImmerChangeset } from 'ember-immer-changeset'; -import { tracked } from '@glimmer/tracking'; -import { action } from '@ember/object'; -import { restartableTask, timeout } from 'ember-concurrency'; -import type Owner from '@ember/owner'; - -interface Option { - name: string; - toString(): string; -} - -interface Changeset { - repository: Option | undefined; - disabled: Option | undefined; - error: Option | undefined; -} - -export default class DocsEmberInputValidationPrefabsSelectSearchController extends Controller { - constructor(owner: Owner) { - super(owner); - this.changeset.addError({ - message: 'This is an error message', - value: '', - originalValue: '', - key: 'error', - }); - } - - changeset = new ImmerChangeset({ - repository: undefined, - disabled: undefined, - error: undefined, - }); - @tracked options: Option[] = []; - - @restartableTask - // eslint-disable-next-line @typescript-eslint/no-explicit-any - *onSearch(value: string): any { - yield timeout(300); - const response = yield fetch( - `https://api.github.com/search/repositories?q=${value}`, - ); - const json: { items: { full_name: string }[] } = yield response.json(); - this.options = json.items.map((item) => ({ - name: item.full_name, - toString() { - return this.name; - }, - })); - } - - @action - onChange(value: Option) { - this.changeset.set('repository', value); - } -} diff --git a/doc-app/app/controllers/docs/ember-input-validation/prefabs/select.ts b/doc-app/app/controllers/docs/ember-input-validation/prefabs/select.ts deleted file mode 100644 index 63e68a2e..00000000 --- a/doc-app/app/controllers/docs/ember-input-validation/prefabs/select.ts +++ /dev/null @@ -1,55 +0,0 @@ -import Controller from '@ember/controller'; -import { ImmerChangeset } from 'ember-immer-changeset'; -import { tracked } from '@glimmer/tracking'; -import type { Owner } from '@ember/test-helpers/build-owner'; - -function configureDisplay(obj: T, format: (obj: T) => string) { - return { - ...obj, - toString() { - return format(this); - }, - }; -} - -export default class DocsEmberInputValidationPrefabsSelectController extends Controller { - constructor(owner: Owner) { - super(owner); - this.changeset.addError({ - message: 'This is an error message', - value: '', - originalValue: '', - key: 'error', - }); - } - changeset = new ImmerChangeset({ - ceo: configureDisplay( - { firstname: 'Patrick', lastname: 'Pagnoulle' }, - (option) => `${option.firstname} ${option.lastname}`, - ), - disabled: configureDisplay( - { firstname: 'Tils', lastname: 'Abled' }, - (option) => `${option.firstname} ${option.lastname}`, - ), - error: configureDisplay( - { firstname: 'Err', lastname: 'Aur' }, - (option) => `${option.firstname} ${option.lastname}`, - ), - }); - - changesetBis = new ImmerChangeset({ - ceo: undefined, - }); - - changesetTris = new ImmerChangeset({ - ceo: [], - }); - - @tracked options = [ - { firstname: 'Patrick', lastname: 'Pagnoulle' }, - { firstname: 'Romain', lastname: 'Verliefden' }, - { firstname: 'Gilles', lastname: 'Bertrand' }, - ].map((o) => - configureDisplay(o, (option) => `${option.firstname} ${option.lastname}`), - ); -} diff --git a/doc-app/app/controllers/docs/ember-input-validation/prefabs/textarea.ts b/doc-app/app/controllers/docs/ember-input-validation/prefabs/textarea.ts deleted file mode 100644 index 9e96dee3..00000000 --- a/doc-app/app/controllers/docs/ember-input-validation/prefabs/textarea.ts +++ /dev/null @@ -1,25 +0,0 @@ -import Controller from '@ember/controller'; -import { ImmerChangeset } from 'ember-immer-changeset'; -import { tracked } from '@glimmer/tracking'; -import type Owner from '@ember/owner'; - -export default class DocsEmberInputValidationPrefabsTextareaController extends Controller { - changeset = new ImmerChangeset({ - ember: '', - }); - - changesetWithErrors = new ImmerChangeset({ - ember: '', - }); - - public constructor(owner: Owner) { - super(owner); - - this.changesetWithErrors.addError({ - key: 'ember', - message: 'required', - value: '', - originalValue: '', - }) - } -} diff --git a/doc-app/app/controllers/docs/ember-input-validation/prefabs/timepicker.ts b/doc-app/app/controllers/docs/ember-input-validation/prefabs/timepicker.ts deleted file mode 100644 index e08dc5f0..00000000 --- a/doc-app/app/controllers/docs/ember-input-validation/prefabs/timepicker.ts +++ /dev/null @@ -1,21 +0,0 @@ -import Controller from '@ember/controller'; -import { ImmerChangeset } from 'ember-immer-changeset'; -import { tracked } from '@glimmer/tracking'; -import type Owner from '@ember/owner'; - -export default class DocsEmberInputValidationPrefabsTimepickerController extends Controller { - constructor(owner: Owner) { - super(owner); - this.changeset.addError({ - message: 'This is an error message', - value: '', - originalValue: '', - key: 'error', - }); - } - changeset = new ImmerChangeset({ - time: null, - disabled: null, - error: null, - }); -} diff --git a/doc-app/app/controllers/docs/ember-input-validation/prefabs/vat.ts b/doc-app/app/controllers/docs/ember-input-validation/prefabs/vat.ts deleted file mode 100644 index 8405a511..00000000 --- a/doc-app/app/controllers/docs/ember-input-validation/prefabs/vat.ts +++ /dev/null @@ -1,22 +0,0 @@ -import Controller from '@ember/controller'; -import { ImmerChangeset } from 'ember-immer-changeset'; -import { tracked } from '@glimmer/tracking'; -import type Owner from '@ember/owner'; - -export default class DocsEmberInputValidationPrefabsVATController extends Controller { - constructor(owner: Owner) { - super(owner); - this.changeset.addError({ - message: 'This is an error message', - value: '', - originalValue: '', - key: 'error', - }); - } - - changeset = new ImmerChangeset({ - vat: '', - disabled: '', - error: '', - }); -} diff --git a/doc-app/app/controllers/docs/ember-input-validation/radio-group.js b/doc-app/app/controllers/docs/ember-input-validation/radio-group.js deleted file mode 100644 index cf987c17..00000000 --- a/doc-app/app/controllers/docs/ember-input-validation/radio-group.js +++ /dev/null @@ -1,16 +0,0 @@ -import Controller from '@ember/controller'; -import { action } from '@ember/object'; -import { tracked } from 'tracked-built-ins'; -import { ImmerChangeset } from 'ember-immer-changeset'; - -export default class DocsRadioGroupValidationController extends Controller { - changeset = new ImmerChangeset({ - radio: undefined, - }); - - @action - onChange(value) { - this.changeset.set('radio', value); - this.changeset.save(); - } -} diff --git a/doc-app/app/controllers/docs/ember-input-validation/radio.js b/doc-app/app/controllers/docs/ember-input-validation/radio.js deleted file mode 100644 index 80d9d72e..00000000 --- a/doc-app/app/controllers/docs/ember-input-validation/radio.js +++ /dev/null @@ -1,30 +0,0 @@ -import Controller from '@ember/controller'; -import { action } from '@ember/object'; -import { tracked } from 'tracked-built-ins'; -import { ImmerChangeset } from 'ember-immer-changeset'; - -export default class DocsRadioValidationController extends Controller { - first = 'Ho yes!'; - second = 'It the good choice!'; - third = 'You don t regret it!'; - - changeset = new ImmerChangeset({ - radio: undefined, - }); - - @action - onChange(value) { - this.changeset.set('radio', value); - this.changeset.save(); - if (!this.changeset.get('radio')) { - this.changeset.addError({ - message: 'Select a radio', - value: true, - originalValue: true, - key: 'radio', - }); - } else { - this.changeset.removeError('radio'); - } - } -} diff --git a/doc-app/app/controllers/docs/ember-input-validation/tpk-form.ts b/doc-app/app/controllers/docs/ember-input-validation/tpk-form.ts deleted file mode 100644 index 532de48a..00000000 --- a/doc-app/app/controllers/docs/ember-input-validation/tpk-form.ts +++ /dev/null @@ -1,48 +0,0 @@ -import Controller from '@ember/controller'; -import ImmerChangeset from 'ember-immer-changeset'; -import { object, string, array, date, boolean, number } from 'yup'; -import { action } from '@ember/object'; - -// BEGIN-SNIPPET tpk-form-controller.js -export default class TpkFormController extends Controller { - changeset = new ImmerChangeset({ - firstName: '', - lastName: '', - languages: ['French', 'English'], - birthday: null, - email: '', - phone: '', - nationalNumber: '', - vat: '', - bic: '', - iban: '', - status: '', - isFree: false, - time: null, - availableMoney: 0, - }); - options = ['French', 'English', 'Spanish', 'German', 'Italian']; - validationSchema = object().shape({ - firstName: string().required().min(3), - lastName: string().required().min(3), - languages: array().min(2), - birthday: date().required(), - email: string().email().required(), - phone: string().required(), - nationalNumber: string().optional(), - vat: string().optional(), - bic: string().optional(), - iban: string().optional(), - status: string().optional(), - isFree: boolean().required(), - time: date().required(), - password: string().required(), - availableMoney: number().required(), - }); - - @action - success() { - alert('success'); - } -} -// END-SNIPPET diff --git a/doc-app/app/controllers/docs/ember-input/button.ts b/doc-app/app/controllers/docs/ember-input/button.ts deleted file mode 100644 index 554f7ab9..00000000 --- a/doc-app/app/controllers/docs/ember-input/button.ts +++ /dev/null @@ -1,13 +0,0 @@ -import Controller from '@ember/controller'; -import { action } from '@ember/object'; -import { tracked } from 'tracked-built-ins'; - -export default class DocsTpkButtonController extends Controller { - @tracked counter = 0; - - @action - async incrementCounter() { - await new Promise((resolve) => setTimeout(resolve, 1000)); - this.counter++; - } -} diff --git a/doc-app/app/controllers/docs/ember-input/checkbox.ts b/doc-app/app/controllers/docs/ember-input/checkbox.ts deleted file mode 100644 index 56132287..00000000 --- a/doc-app/app/controllers/docs/ember-input/checkbox.ts +++ /dev/null @@ -1,12 +0,0 @@ -import Controller from '@ember/controller'; -import { action } from '@ember/object'; -import { tracked } from 'tracked-built-ins'; - -export default class DocsTpkCheckboxController extends Controller { - @tracked checked = false; - - @action - onChange(checked: boolean) { - this.checked = checked; - } -} diff --git a/doc-app/app/controllers/docs/ember-input/datepicker.ts b/doc-app/app/controllers/docs/ember-input/datepicker.ts deleted file mode 100644 index 328e802e..00000000 --- a/doc-app/app/controllers/docs/ember-input/datepicker.ts +++ /dev/null @@ -1,21 +0,0 @@ -import Controller from '@ember/controller'; -import { action } from '@ember/object'; -import { tracked } from 'tracked-built-ins'; - -export default class DocsTpkDatepickerController extends Controller { - @tracked selectedDate?: Date; - @tracked selectedDates?: Date[]; - @tracked date = new Date(2022, 10, 15); - @tracked minDate = new Date(2022, 10, 13); - @tracked maxDate = new Date(2022, 10, 16); - - @action - onChange(dates: [Date, Date]) { - this.selectedDate = dates[0]; - } - - @action - onChangeRange(dates: [Date, Date]) { - this.selectedDates = dates; - } -} diff --git a/doc-app/app/controllers/docs/ember-input/file.ts b/doc-app/app/controllers/docs/ember-input/file.ts deleted file mode 100644 index caa77d9d..00000000 --- a/doc-app/app/controllers/docs/ember-input/file.ts +++ /dev/null @@ -1,12 +0,0 @@ -import Controller from '@ember/controller'; -import { action } from '@ember/object'; -import { tracked } from 'tracked-built-ins'; - -export default class DocsTpkFileController extends Controller { - @tracked value?: File; - - @action - onChange(value: File) { - this.value = value; - } -} diff --git a/doc-app/app/controllers/docs/ember-input/input.ts b/doc-app/app/controllers/docs/ember-input/input.ts deleted file mode 100644 index 819459e5..00000000 --- a/doc-app/app/controllers/docs/ember-input/input.ts +++ /dev/null @@ -1,12 +0,0 @@ -import Controller from '@ember/controller'; -import { action } from '@ember/object'; -import { tracked } from 'tracked-built-ins'; - -export default class DocsTpkInputController extends Controller { - @tracked value: string | undefined = undefined; - - @action - onChange(value: string) { - this.value = value; - } -} diff --git a/doc-app/app/controllers/docs/ember-input/prefabs/button.ts b/doc-app/app/controllers/docs/ember-input/prefabs/button.ts deleted file mode 100644 index cb640c9b..00000000 --- a/doc-app/app/controllers/docs/ember-input/prefabs/button.ts +++ /dev/null @@ -1,12 +0,0 @@ -import Controller from '@ember/controller'; -import { action } from '@ember/object'; -import { tracked } from 'tracked-built-ins'; - -export default class DocsTpkPrefabButtonController extends Controller { - @tracked counter = 0; - - @action - async incrementCounter() { - this.counter++; - } -} \ No newline at end of file diff --git a/doc-app/app/controllers/docs/ember-input/prefabs/toggle.ts b/doc-app/app/controllers/docs/ember-input/prefabs/toggle.ts deleted file mode 100644 index e6c2655f..00000000 --- a/doc-app/app/controllers/docs/ember-input/prefabs/toggle.ts +++ /dev/null @@ -1,3 +0,0 @@ -import Controller from "@ember/controller"; - -export default class extends Controller {} diff --git a/doc-app/app/controllers/docs/ember-input/radio.ts b/doc-app/app/controllers/docs/ember-input/radio.ts deleted file mode 100644 index 4414adcc..00000000 --- a/doc-app/app/controllers/docs/ember-input/radio.ts +++ /dev/null @@ -1,12 +0,0 @@ -import Controller from '@ember/controller'; -import { action } from '@ember/object'; -import { tracked } from 'tracked-built-ins'; - -export default class DocsTpkInputController extends Controller { - @tracked value = ''; - - @action - setRadio(value: string) { - this.value = value; - } -} diff --git a/doc-app/app/controllers/docs/ember-input/select.ts b/doc-app/app/controllers/docs/ember-input/select.ts deleted file mode 100644 index bc2bba0f..00000000 --- a/doc-app/app/controllers/docs/ember-input/select.ts +++ /dev/null @@ -1,27 +0,0 @@ -import Controller from '@ember/controller'; -import { action } from '@ember/object'; -import { tracked } from 'tracked-built-ins'; - -export default class DocsTpkSelectController extends Controller { - @tracked selection = ''; - @tracked valueCar: string[] = []; - @tracked multiple = true; - @tracked sauceOptions = ['BBQ', 'Ketchup', 'Dallas']; - @tracked carOptions = ['BMW', 'Mercedes', 'Audi', 'Tesla']; - - @action - onChange(value: string) { - this.selection = value; - } - - @action - onChangeCar(car: string) { - if (this.valueCar.includes(car)) { - this.valueCar = this.valueCar.filter( - (existingCar) => existingCar !== car, - ); - } else { - this.valueCar = [...this.valueCar, car]; - } - } -} diff --git a/doc-app/app/controllers/docs/ember-input/textarea.ts b/doc-app/app/controllers/docs/ember-input/textarea.ts deleted file mode 100644 index d68b49dc..00000000 --- a/doc-app/app/controllers/docs/ember-input/textarea.ts +++ /dev/null @@ -1,13 +0,0 @@ -import Controller from '@ember/controller'; -import { action } from '@ember/object'; -import { tracked } from 'tracked-built-ins'; - -export default class DocsTpkCheckboxController extends Controller { - @tracked value = - `Tomster was the first of many friendly faces of the Ember project and community... Read more at https://emberjs.com/mascots/`; - - @action - onChange(value: string) { - this.value = value; - } -} diff --git a/doc-app/app/controllers/docs/ember-ui/actions-menu.ts b/doc-app/app/controllers/docs/ember-ui/actions-menu.ts deleted file mode 100644 index a8b12ce1..00000000 --- a/doc-app/app/controllers/docs/ember-ui/actions-menu.ts +++ /dev/null @@ -1,9 +0,0 @@ -import Controller from '@ember/controller'; -import { action } from '@ember/object'; - -export default class DocsActionsMenuController extends Controller { - @action - showEditPopup() { - window.alert('Edit'); - } -} diff --git a/doc-app/app/controllers/docs/ember-ui/modal.ts b/doc-app/app/controllers/docs/ember-ui/modal.ts deleted file mode 100644 index dc143aeb..00000000 --- a/doc-app/app/controllers/docs/ember-ui/modal.ts +++ /dev/null @@ -1,18 +0,0 @@ -import Controller from '@ember/controller'; -import { action } from '@ember/object'; -import { tracked } from 'tracked-built-ins'; - -export default class DocsModalController extends Controller { - @tracked isOpen = false; - @tracked title = 'Modal title'; - - @action - open() { - this.isOpen = true; - } - - @action - onClose() { - this.isOpen = false; - } -} diff --git a/doc-app/app/controllers/docs/ember-ui/prefabs/confirm-modal.ts b/doc-app/app/controllers/docs/ember-ui/prefabs/confirm-modal.ts deleted file mode 100644 index a8185b95..00000000 --- a/doc-app/app/controllers/docs/ember-ui/prefabs/confirm-modal.ts +++ /dev/null @@ -1,27 +0,0 @@ -import Controller from '@ember/controller'; -import { action } from '@ember/object'; -import { tracked } from 'tracked-built-ins'; - -export default class DocsTpkConfirmModalPrefabController extends Controller { - @tracked isOpen = false; - confirmQuestion = 'Are you sure?'; - confirmText = 'Yes'; - cancelText = 'No'; - - @action - open() { - this.isOpen = true; - } - - @action - onClose() { - this.isOpen = false; - } - - @action - onConfirm() { - this.isOpen = false; - alert('Confirmed'); - } - -} \ No newline at end of file diff --git a/doc-app/app/controllers/docs/ember-ui/prefabs/table-generic.ts b/doc-app/app/controllers/docs/ember-ui/prefabs/table-generic.ts deleted file mode 100644 index 5ee52c53..00000000 --- a/doc-app/app/controllers/docs/ember-ui/prefabs/table-generic.ts +++ /dev/null @@ -1,46 +0,0 @@ -import Controller from "@ember/controller"; -import { action } from "@ember/object"; - - - -export default class DocsTpkTableGenericPrefabController extends Controller { - -// BEGIN-SNIPPET tpk-table-generic-prefab.js - tableParams:any = { - entity: 'user', - pageSizes: [10,30,50,75], - defaultSortColumn: 'firstName', - rowClick(element: any){ - alert(`row clicked ${element.id}`); - }, - columns:[ - { - field: 'lastName', - headerName: 'Nom', - sortable: true, - }, - { - field: 'firstName', - headerName: 'Prénom', - sortable: true, - }, - { - field: 'email', - headerName: 'Email', - sortable: false, - }], - actionMenu: [{ - icon: 'edit', - action: (element:any) => {alert(`edit action ${element.id}`); - }, - name: 'Edit', - }, - { - icon: 'delete', - action: () => {alert('delete action')}, - name: 'Delete', - }], - }; - -// END-SNIPPET -} \ No newline at end of file diff --git a/doc-app/app/controllers/docs/ember-ui/stack-list.ts b/doc-app/app/controllers/docs/ember-ui/stack-list.ts deleted file mode 100644 index 6d59e792..00000000 --- a/doc-app/app/controllers/docs/ember-ui/stack-list.ts +++ /dev/null @@ -1,22 +0,0 @@ -import Controller from '@ember/controller'; -import { action } from '@ember/object'; -import { tracked } from 'tracked-built-ins'; - -export default class DocsStackListController extends Controller { - @tracked data: string[] = []; - titleForAdd = 'add element to list'; - contentData = 'element added'; - - @action - onAddData() { - const newData = [...this.data, this.contentData]; - this.data = newData; - } - - @action - onRemoveData(index: number) { - const newData = [...this.data]; - newData.splice(index, 1); - this.data = newData; - } -} diff --git a/doc-app/app/controllers/docs/ember-ui/table-generic.ts b/doc-app/app/controllers/docs/ember-ui/table-generic.ts deleted file mode 100644 index 037a8388..00000000 --- a/doc-app/app/controllers/docs/ember-ui/table-generic.ts +++ /dev/null @@ -1,18 +0,0 @@ -import Controller from '@ember/controller'; -import { action } from '@ember/object'; -import { tracked } from 'tracked-built-ins'; - -export default class DocsTableGenericController extends Controller { - @action - rowClick() { - alert('row click'); - } - - @tracked pageSizes = [10, 25, 50, 100]; - @tracked pageSize = 10; - - @action - deleteAction() { - alert('delete click'); - } -} diff --git a/doc-app/app/deprecation-workflow.ts b/doc-app/app/deprecation-workflow.ts new file mode 100644 index 00000000..274a689d --- /dev/null +++ b/doc-app/app/deprecation-workflow.ts @@ -0,0 +1,24 @@ +import setupDeprecationWorkflow from 'ember-cli-deprecation-workflow'; + +/** + * Docs: https://github.com/ember-cli/ember-cli-deprecation-workflow + */ +setupDeprecationWorkflow({ + /** + false by default, but if a developer / team wants to be more aggressive about being proactive with + handling their deprecations, this should be set to "true" + */ + throwOnUnhandled: false, + workflow: [ + /* ... handlers ... */ + /* to generate this list, run your app for a while (or run the test suite), + * and then run in the browser console: + * + * deprecationWorkflow.flushDeprecations() + * + * And copy the handlers here + */ + /* example: */ + /* { handler: 'silence', matchId: 'template-action' }, */ + ], +}); diff --git a/doc-app/app/formats.js b/doc-app/app/formats.js deleted file mode 100644 index 098504a0..00000000 --- a/doc-app/app/formats.js +++ /dev/null @@ -1,29 +0,0 @@ -export default { - time: { - hhmmss: { - hour: 'numeric', - minute: 'numeric', - second: 'numeric', - }, - }, - date: { - hhmmss: { - hour: 'numeric', - minute: 'numeric', - second: 'numeric', - }, - }, - number: { - compact: { - notation: 'compact', - }, - EUR: { - style: 'currency', - currency: 'EUR', - }, - USD: { - style: 'currency', - currency: 'USD', - }, - }, -}; diff --git a/doc-app/app/helpers/catch-state.ts b/doc-app/app/helpers/catch-state.ts index bf7cc7b9..cd63d923 100644 --- a/doc-app/app/helpers/catch-state.ts +++ b/doc-app/app/helpers/catch-state.ts @@ -2,10 +2,14 @@ import Helper from '@ember/component/helper'; import { service } from '@ember/service'; import CatchState from '../services/catch-state'; -export default class Substring extends Helper { +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export default class CatchStateHelper extends Helper { @service declare catchState: CatchState; + // eslint-disable-next-line @typescript-eslint/no-explicit-any compute([state]: [any]) { this.catchState.state = state; + // eslint-disable-next-line @typescript-eslint/no-unsafe-return + return state; } } diff --git a/doc-app/app/helpers/to-string.ts b/doc-app/app/helpers/to-string.ts new file mode 100644 index 00000000..3875b1de --- /dev/null +++ b/doc-app/app/helpers/to-string.ts @@ -0,0 +1,3 @@ +export default function stringify(value: unknown) { + return String(value); +} diff --git a/doc-app/app/models/user.ts b/doc-app/app/models/user.ts index 7860c78a..3b4b064d 100644 --- a/doc-app/app/models/user.ts +++ b/doc-app/app/models/user.ts @@ -1,10 +1,28 @@ -import Model, { attr } from '@ember-data/model'; +import { + withDefaults, + type WithLegacy, +} from '@warp-drive/legacy/model/migration-support'; +import { Type } from '@warp-drive/core/types/symbols'; -export default class UserModel extends Model { - @attr('string') email!: string; - @attr('string') firstName!: string; - @attr('string') lastName!: string; - @attr('string') phone!: string; - @attr('string') job!: string; - @attr('string') country!: string; -} +export const UserSchema = withDefaults({ + type: 'user', + fields: [ + { name: 'email', kind: 'attribute' }, + { name: 'firstName', kind: 'attribute' }, + { name: 'lastName', kind: 'attribute' }, + { name: 'phone', kind: 'attribute' }, + { name: 'job', kind: 'attribute' }, + { name: 'country', kind: 'attribute' }, + ], +}); + +export type User = WithLegacy<{ + firstName: string; + lastName: string; + age: number; + email: string; + phone: string; + job: string; + country: string; + [Type]: 'user'; +}>; diff --git a/doc-app/app/router.ts b/doc-app/app/router.ts index afbdbdd4..5febaa86 100644 --- a/doc-app/app/router.ts +++ b/doc-app/app/router.ts @@ -1,80 +1,60 @@ -// @ts-expect-error no types -import AddonDocsRouter, { docsRoute } from 'ember-cli-addon-docs/router'; -import config from './config/environment'; -import RouterDSL from '@ember/routing/-private/router-dsl'; +import EmberRouter from '@embroider/router'; +import config from 'doc-app/config/environment'; +import '@warp-drive/ember/install'; -const Router = AddonDocsRouter.extend({ - location: config.locationType, - rootURL: config.rootURL, -}); +export default class Router extends EmberRouter { + location = config.locationType; + rootURL = config.rootURL; +} -Router.map(function (this: RouterDSL) { - docsRoute(this, function (this: RouterDSL) { - this.route('ember-ui', function (this: RouterDSL) { - this.route('prefabs', function () { - this.route('confirm-modal') - this.route('table-generic') - }) - this.route('installation'); - this.route('actions-menu'); - this.route('modal'); - this.route('table-generic'); - this.route('file-list'); - this.route('stack-list'); - }); - this.route('ember-input', function () { - this.route('installation'); - this.route('prefabs', function () { - this.route('button') - this.route('toggle'); +Router.map(function () { + this.route('dashboard', { path: '/' }, function () { + this.route('docs', function () { + this.route('ember-input-validation', function () { + this.route('prefabs', function () { + this.route('input'); + this.route('number'); + this.route('bic'); + this.route('currency'); + this.route('datepicker-range'); + this.route('datepicker'); + this.route('email'); + this.route('file'); + this.route('file-list'); + this.route('iban'); + this.route('integer'); + this.route('mobile'); + this.route('national-number'); + this.route('password'); + this.route('radio'); + this.route('radio-group'); + this.route('select'); + this.route('select-create'); + this.route('select-search'); + this.route('textarea'); + this.route('timepicker'); + this.route('vat'); + }); }); - this.route('input'); - this.route('button'); - this.route('checkbox'); - this.route('datepicker'); - this.route('file'); - this.route('radio'); - this.route('select'); - this.route('select-search'); - this.route('textarea'); - }); - this.route('ember-input-validation', function () { - this.route('prefabs', function () { - this.route('input'); - this.route('textarea'); - this.route('checkbox'); - this.route('radio'); - this.route('radio-group'); - this.route('password'); - this.route('mobile'); - this.route('iban'); - this.route('bic'); - this.route('currency'); - this.route('select-search'); - this.route('vat'); - this.route('email'); - this.route('national-number'); - this.route('select'); - this.route('select-create'); - this.route('integer'); - this.route('number'); - this.route('timepicker'); - this.route('datepicker'); - this.route('datepicker-range'); - this.route('file'); - this.route('file-list'); + + this.route('ember-input', function () { + this.route('prefabs', function () { + this.route('button'); + this.route('toggle'); + }); + }); + + this.route('ember-ui', function () { + this.route('prefabs', function () { + this.route('confirm-modal'); + this.route('table-generic'); + this.route('tpk-form'); + }); }); - this.route('installation'); - this.route('checkbox'); - this.route('datepicker'); - this.route('file'); - this.route('input'); - this.route('radio-group'); - this.route('select'); - this.route('textarea'); - this.route('tpk-form'); }); }); + this.route('home', function () {}); + this.route('login', function () {}); + this.route('forgot-password', function () {}); + this.route('reset-password', function () {}); }); - -export default Router; diff --git a/doc-app/app/routes/application.ts b/doc-app/app/routes/application.ts index 21ec19cc..eb73d9a3 100644 --- a/doc-app/app/routes/application.ts +++ b/doc-app/app/routes/application.ts @@ -1,52 +1,17 @@ +/* app/routes/application.ts */ import Route from '@ember/routing/route'; -import { service } from '@ember/service'; -import config from 'doc-app/config/environment'; -import type { IntlService } from 'ember-intl'; -import { rest } from 'msw'; +import { type Registry as Services, service } from '@ember/service'; +import translationsForEnUs from 'virtual:ember-intl/translations/en-us'; export default class ApplicationRoute extends Route { - @service intl!: IntlService; + @service declare intl: Services['intl']; - async beforeModel() { + beforeModel(): void { + this.setupIntl(); + } + + private setupIntl(): void { + this.intl.addTranslations('en-us', translationsForEnUs); this.intl.setLocale(['en-us']); - // @ts-expect-error no types available for worker - const { worker } = await import('/worker.js'); - await worker([ - rest.get('/users', (req, res, ctx) => { - return res( - ctx.status(200), - ctx.json({ - meta: { - total: 1, - page: 1, - }, - data: [ - { - type: 'user', - id: '1-john', - attributes: { - firstName: 'John', - lastName: 'Doe', - email: 'john.doe@example.com', - }, - }, - { - type: 'user', - id: '2', - attributes: { - firstName: 'Jack', - lastName: 'Lime', - email: 'jack.lime@example.com', - }, - }, - ], - }), - ); - }), - ]).start({ - serviceWorker: { - url: `${config.rootURL}mockServiceWorker.js`, - }, - }); } } diff --git a/doc-app/app/routes/dashboard.ts b/doc-app/app/routes/dashboard.ts new file mode 100644 index 00000000..c365d166 --- /dev/null +++ b/doc-app/app/routes/dashboard.ts @@ -0,0 +1,6 @@ +/* app/routes/application.ts */ +import Route from '@ember/routing/route'; + +export default class DashboardRoute extends Route { + beforeModel(): void {} +} diff --git a/doc-app/app/routes/dashboard/docs.ts b/doc-app/app/routes/dashboard/docs.ts new file mode 100644 index 00000000..fc9dbeb7 --- /dev/null +++ b/doc-app/app/routes/dashboard/docs.ts @@ -0,0 +1,3 @@ +import Route from '@ember/routing/route'; + +export default class DashboardDocsRoute extends Route {} diff --git a/doc-app/app/routes/dashboard/docs/ember-input-validation.ts b/doc-app/app/routes/dashboard/docs/ember-input-validation.ts new file mode 100644 index 00000000..fb7ea4f1 --- /dev/null +++ b/doc-app/app/routes/dashboard/docs/ember-input-validation.ts @@ -0,0 +1,3 @@ +import Route from '@ember/routing/route'; + +export default class DashboardDocsEmberInputValidationRoute extends Route {} diff --git a/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs.ts b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs.ts new file mode 100644 index 00000000..072a68fc --- /dev/null +++ b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs.ts @@ -0,0 +1,3 @@ +import Route from '@ember/routing/route'; + +export default class DashboardDocsEmberInputValidationPrefabsRoute extends Route {} diff --git a/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/bic.ts b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/bic.ts new file mode 100644 index 00000000..ff88f348 --- /dev/null +++ b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/bic.ts @@ -0,0 +1,66 @@ +import Route from '@ember/routing/route'; + +export default class DocsEmberInputValidationPrefabsBicRoute extends Route { + model() { + return { + properties: [ + { + name: '@validationField', + type: 'string', + required: true, + description: + 'ember-input-validation.prefabs.bic.properties.validationField.description', + }, + { + name: '@changeset', + type: 'ImmerChangeset', + required: true, + description: + 'ember-input-validation.prefabs.bic.properties.changeset.description', + }, + { + name: '@label', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.bic.properties.label.description', + }, + { + name: '@placeholder', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.bic.properties.placeholder.description', + }, + { + name: '@mandatory', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.bic.properties.mandatory.description', + }, + { + name: '@disabled', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.bic.properties.disabled.description', + }, + { + name: '@onChange', + type: 'function', + required: false, + description: + 'ember-input-validation.prefabs.bic.properties.onChange.description', + }, + { + name: '@changeEvent', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.bic.properties.changeEvent.description', + }, + ], + }; + } +} diff --git a/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/currency.ts b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/currency.ts new file mode 100644 index 00000000..5255ffeb --- /dev/null +++ b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/currency.ts @@ -0,0 +1,66 @@ +import Route from '@ember/routing/route'; + +export default class DocsEmberInputValidationPrefabsCurrencyRoute extends Route { + model() { + return { + properties: [ + { + name: '@validationField', + type: 'string', + required: true, + description: + 'ember-input-validation.prefabs.currency.properties.validationField.description', + }, + { + name: '@changeset', + type: 'ImmerChangeset', + required: true, + description: + 'ember-input-validation.prefabs.currency.properties.changeset.description', + }, + { + name: '@label', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.currency.properties.label.description', + }, + { + name: '@placeholder', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.currency.properties.placeholder.description', + }, + { + name: '@disabled', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.currency.properties.disabled.description', + }, + { + name: '@mandatory', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.currency.properties.mandatory.description', + }, + { + name: '@onChange', + type: 'function', + required: false, + description: + 'ember-input-validation.prefabs.currency.properties.onChange.description', + }, + { + name: '@changeEvent', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.currency.properties.changeEvent.description', + }, + ], + }; + } +} diff --git a/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/datepicker-range.ts b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/datepicker-range.ts new file mode 100644 index 00000000..87997d50 --- /dev/null +++ b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/datepicker-range.ts @@ -0,0 +1,150 @@ +import Route from '@ember/routing/route'; + +export default class DocsEmberInputValidationPrefabsDatepickerRangeRoute extends Route { + model() { + return { + properties: [ + { + name: '@validationField', + type: 'string', + required: true, + description: + 'ember-input-validation.prefabs.datepicker-range.properties.validationField.description', + }, + { + name: '@changeset', + type: 'ImmerChangeset', + required: true, + description: + 'ember-input-validation.prefabs.datepicker-range.properties.changeset.description', + }, + { + name: '@multipleDatesSeparator', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.datepicker-range.properties.multipleDatesSeparator.description', + }, + { + name: '@label', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.datepicker-range.properties.label.description', + }, + { + name: '@onChange', + type: 'function', + required: false, + description: + 'ember-input-validation.prefabs.datepicker-range.properties.onChange.description', + }, + { + name: '@onClose', + type: 'function', + required: false, + description: + 'ember-input-validation.prefabs.datepicker-range.properties.onClose.description', + }, + { + name: '@disabled', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.datepicker-range.properties.disabled.description', + }, + { + name: '@mandatory', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.datepicker-range.properties.mandatory.description', + }, + { + name: '@placeholder', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.datepicker-range.properties.placeholder.description', + }, + { + name: '@clearButton', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.datepicker-range.properties.clearButton.description', + }, + { + name: '@todayButton', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.datepicker-range.properties.todayButton.description', + }, + { + name: '@closeButton', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.datepicker-range.properties.closeButton.description', + }, + { + name: '@minDate', + type: 'Date', + required: false, + description: + 'ember-input-validation.prefabs.datepicker-range.properties.minDate.description', + }, + { + name: '@maxDate', + type: 'Date', + required: false, + description: + 'ember-input-validation.prefabs.datepicker-range.properties.maxDate.description', + }, + { + name: '@keepOpen', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.datepicker-range.properties.keepOpen.description', + }, + { + name: '@daysOfWeekDisabled', + type: 'number[]', + required: false, + description: + 'ember-input-validation.prefabs.datepicker-range.properties.daysOfWeekDisabled.description', + }, + { + name: '@disabledDates', + type: 'Date[]', + required: false, + description: + 'ember-input-validation.prefabs.datepicker-range.properties.disabledDates.description', + }, + { + name: '@viewMode', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.datepicker-range.properties.viewMode.description', + }, + { + name: '@locale', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.datepicker-range.properties.locale.description', + }, + { + name: '@dateFormat', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.datepicker-range.properties.dateFormat.description', + }, + ], + }; + } +} diff --git a/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/datepicker.ts b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/datepicker.ts new file mode 100644 index 00000000..409826e8 --- /dev/null +++ b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/datepicker.ts @@ -0,0 +1,207 @@ +// doc-app/app/routes/docs/ember-input-validation/prefabs/datepicker.ts +import Route from '@ember/routing/route'; + +export default class DocsEmberInputValidationPrefabsDatepickerRoute extends Route { + model() { + return { + properties: [ + { + name: '@validationField', + type: 'string', + required: true, + description: + 'ember-input-validation.prefabs.datepicker.properties.validationField.description', + }, + { + name: '@changeset', + type: 'ImmerChangeset', + required: true, + description: + 'ember-input-validation.prefabs.datepicker.properties.changeset.description', + }, + { + name: '@multipleDatesSeparator', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.datepicker.properties.multipleDatesSeparator.description', + }, + { + name: '@label', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.datepicker.properties.label.description', + }, + { + name: '@onChange', + type: 'function', + required: false, + description: + 'ember-input-validation.prefabs.datepicker.properties.onChange.description', + }, + { + name: '@onClose', + type: 'function', + required: false, + description: + 'ember-input-validation.prefabs.datepicker.properties.onClose.description', + }, + { + name: '@disabled', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.datepicker.properties.disabled.description', + }, + { + name: '@mandatory', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.datepicker.properties.mandatory.description', + }, + { + name: '@placeholder', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.datepicker.properties.placeholder.description', + }, + { + name: '@clearButton', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.datepicker.properties.clearButton.description', + }, + { + name: '@todayButton', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.datepicker.properties.todayButton.description', + }, + { + name: '@closeButton', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.datepicker.properties.closeButton.description', + }, + { + name: '@minDate', + type: 'Date', + required: false, + description: + 'ember-input-validation.prefabs.datepicker.properties.minDate.description', + }, + { + name: '@maxDate', + type: 'Date', + required: false, + description: + 'ember-input-validation.prefabs.datepicker.properties.maxDate.description', + }, + { + name: '@keepOpen', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.datepicker.properties.keepOpen.description', + }, + { + name: '@daysOfWeekDisabled', + type: 'Array', + required: false, + description: + 'ember-input-validation.prefabs.datepicker.properties.daysOfWeekDisabled.description', + }, + { + name: '@disabledDates', + type: 'Array', + required: false, + description: + 'ember-input-validation.prefabs.datepicker.properties.disabledDates.description', + }, + { + name: '@viewMode', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.datepicker.properties.viewMode.description', + }, + { + name: '@locale', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.datepicker.properties.locale.description', + }, + { + name: '@dateFormat', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.datepicker.properties.dateFormat.description', + }, + { + name: '@promptTimeOnDateChange', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.datepicker.properties.promptTimeOnDateChange.description', + }, + { + name: '@noCalendar', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.datepicker.properties.noCalendar.description', + }, + { + name: '@enableTime', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.datepicker.properties.enableTime.description', + }, + { + name: '@stepping', + type: 'number', + required: false, + description: + 'ember-input-validation.prefabs.datepicker.properties.stepping.description', + }, + { + name: '@enableSecond', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.datepicker.properties.enableSecond.description', + }, + { + name: '@disabledTimeIntervals', + type: 'Array', + required: false, + description: + 'ember-input-validation.prefabs.datepicker.properties.disabledTimeIntervals.description', + }, + { + name: '@disabledHours', + type: 'Array', + required: false, + description: + 'ember-input-validation.prefabs.datepicker.properties.disabledHours.description', + }, + { + name: '@enabledHours', + type: 'Array', + required: false, + description: + 'ember-input-validation.prefabs.datepicker.properties.enabledHours.description', + }, + ], + }; + } +} diff --git a/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/email.ts b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/email.ts new file mode 100644 index 00000000..de9adb61 --- /dev/null +++ b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/email.ts @@ -0,0 +1,67 @@ +// doc-app/app/routes/docs/ember-input-validation/prefabs/email.ts +import Route from '@ember/routing/route'; + +export default class DocsEmberInputValidationPrefabsEmailRoute extends Route { + model() { + return { + properties: [ + { + name: '@validationField', + type: 'string', + required: true, + description: + 'ember-input-validation.prefabs.email.properties.validationField.description', + }, + { + name: '@changeset', + type: 'ImmerChangeset', + required: true, + description: + 'ember-input-validation.prefabs.email.properties.changeset.description', + }, + { + name: '@label', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.email.properties.label.description', + }, + { + name: '@placeholder', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.email.properties.placeholder.description', + }, + { + name: '@disabled', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.email.properties.disabled.description', + }, + { + name: '@mandatory', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.email.properties.mandatory.description', + }, + { + name: '@onChange', + type: 'function', + required: false, + description: + 'ember-input-validation.prefabs.email.properties.onChange.description', + }, + { + name: '@changeEvent', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.email.properties.changeEvent.description', + }, + ], + }; + } +} diff --git a/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/file-list.ts b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/file-list.ts new file mode 100644 index 00000000..c5385c6b --- /dev/null +++ b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/file-list.ts @@ -0,0 +1,67 @@ +// doc-app/app/routes/docs/ember-input-validation/prefabs/file-list.ts +import Route from '@ember/routing/route'; + +export default class DocsEmberInputValidationPrefabsFileListRoute extends Route { + model() { + return { + properties: [ + { + name: '@validationField', + type: 'string', + required: true, + description: + 'ember-input-validation.prefabs.file-list.properties.validationField.description', + }, + { + name: '@changeset', + type: 'ImmerChangeset', + required: true, + description: + 'ember-input-validation.prefabs.file-list.properties.changeset.description', + }, + { + name: '@label', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.file-list.properties.label.description', + }, + { + name: '@placeholder', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.file-list.properties.placeholder.description', + }, + { + name: '@disabled', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.file-list.properties.disabled.description', + }, + { + name: '@mandatory', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.file-list.properties.mandatory.description', + }, + { + name: '@onChange', + type: 'function', + required: false, + description: + 'ember-input-validation.prefabs.file-list.properties.onChange.description', + }, + { + name: '@disableDownload', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.file-list.properties.disableDownload.description', + }, + ], + }; + } +} diff --git a/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/file.ts b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/file.ts new file mode 100644 index 00000000..9fd1c939 --- /dev/null +++ b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/file.ts @@ -0,0 +1,60 @@ +// doc-app/app/routes/docs/ember-input-validation/prefabs/file.ts +import Route from '@ember/routing/route'; + +export default class DocsEmberInputValidationPrefabsFileRoute extends Route { + model() { + return { + properties: [ + { + name: '@validationField', + type: 'string', + required: true, + description: + 'ember-input-validation.prefabs.file.properties.validationField.description', + }, + { + name: '@changeset', + type: 'ImmerChangeset', + required: true, + description: + 'ember-input-validation.prefabs.file.properties.changeset.description', + }, + { + name: '@label', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.file.properties.label.description', + }, + { + name: '@disabled', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.file.properties.disabled.description', + }, + { + name: '@mandatory', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.file.properties.mandatory.description', + }, + { + name: '@onChange', + type: 'function', + required: false, + description: + 'ember-input-validation.prefabs.file.properties.onChange.description', + }, + { + name: '@changeEvent', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.file.properties.changeEvent.description', + }, + ], + }; + } +} diff --git a/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/iban.ts b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/iban.ts new file mode 100644 index 00000000..3df00f01 --- /dev/null +++ b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/iban.ts @@ -0,0 +1,67 @@ +// doc-app/app/routes/docs/ember-input-validation/prefabs/iban.ts +import Route from '@ember/routing/route'; + +export default class DocsEmberInputValidationPrefabsIbanRoute extends Route { + model() { + return { + properties: [ + { + name: '@validationField', + type: 'string', + required: true, + description: + 'ember-input-validation.prefabs.iban.properties.validationField.description', + }, + { + name: '@changeset', + type: 'ImmerChangeset', + required: true, + description: + 'ember-input-validation.prefabs.iban.properties.changeset.description', + }, + { + name: '@label', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.iban.properties.label.description', + }, + { + name: '@placeholder', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.iban.properties.placeholder.description', + }, + { + name: '@disabled', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.iban.properties.disabled.description', + }, + { + name: '@mandatory', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.iban.properties.mandatory.description', + }, + { + name: '@onChange', + type: 'function', + required: false, + description: + 'ember-input-validation.prefabs.iban.properties.onChange.description', + }, + { + name: '@changeEvent', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.iban.properties.changeEvent.description', + }, + ], + }; + } +} diff --git a/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/input.ts b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/input.ts new file mode 100644 index 00000000..7352d746 --- /dev/null +++ b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/input.ts @@ -0,0 +1,95 @@ +// doc-app/app/routes/docs/ember-input-validation/prefabs/input.ts +import Route from '@ember/routing/route'; + +export default class DocsEmberInputValidationPrefabsInputRoute extends Route { + model() { + return { + properties: [ + { + name: '@validationField', + type: 'string', + required: true, + description: + 'ember-input-validation.prefabs.input.properties.validationField.description', + }, + { + name: '@changeset', + type: 'ImmerChangeset', + required: true, + description: + 'ember-input-validation.prefabs.input.properties.changeset.description', + }, + { + name: '@label', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.input.properties.label.description', + }, + { + name: '@placeholder', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.input.properties.placeholder.description', + }, + { + name: '@type', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.input.properties.type.description', + }, + { + name: '@mandatory', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.input.properties.mandatory.description', + }, + { + name: '@mask', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.input.properties.mask.description', + }, + { + name: '@maskOptions', + type: 'object', + required: false, + description: + 'ember-input-validation.prefabs.input.properties.maskOptions.description', + }, + { + name: '@unmaskValue', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.input.properties.unmaskValue.description', + }, + { + name: '@disabled', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.input.properties.disabled.description', + }, + { + name: '@onChange', + type: 'function', + required: false, + description: + 'ember-input-validation.prefabs.input.properties.onChange.description', + }, + { + name: '@changeEvent', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.input.properties.changeEvent.description', + }, + ], + }; + } +} diff --git a/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/integer.ts b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/integer.ts new file mode 100644 index 00000000..25062130 --- /dev/null +++ b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/integer.ts @@ -0,0 +1,74 @@ +// doc-app/app/routes/docs/ember-input-validation/prefabs/integer.ts +import Route from '@ember/routing/route'; + +export default class DocsEmberInputValidationPrefabsIntegerRoute extends Route { + model() { + return { + properties: [ + { + name: '@validationField', + type: 'string', + required: true, + description: + 'ember-input-validation.prefabs.integer.properties.validationField.description', + }, + { + name: '@changeset', + type: 'ImmerChangeset', + required: true, + description: + 'ember-input-validation.prefabs.integer.properties.changeset.description', + }, + { + name: '@label', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.integer.properties.label.description', + }, + { + name: '@placeholder', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.integer.properties.placeholder.description', + }, + { + name: '@disabled', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.integer.properties.disabled.description', + }, + { + name: '@mandatory', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.integer.properties.mandatory.description', + }, + { + name: '@onChange', + type: 'function', + required: false, + description: + 'ember-input-validation.prefabs.integer.properties.onChange.description', + }, + { + name: '@changeEvent', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.integer.properties.changeEvent.description', + }, + { + name: '@unsigned', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.integer.properties.unsigned.description', + }, + ], + }; + } +} diff --git a/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/mobile.ts b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/mobile.ts new file mode 100644 index 00000000..2071046b --- /dev/null +++ b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/mobile.ts @@ -0,0 +1,66 @@ +import Route from '@ember/routing/route'; + +export default class DocsEmberInputValidationPrefabsMobileRoute extends Route { + model() { + return { + properties: [ + { + name: '@validationField', + type: 'string', + required: true, + description: + 'ember-input-validation.prefabs.mobile.properties.validationField.description', + }, + { + name: '@changeset', + type: 'ImmerChangeset', + required: true, + description: + 'ember-input-validation.prefabs.mobile.properties.changeset.description', + }, + { + name: '@label', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.mobile.properties.label.description', + }, + { + name: '@placeholder', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.mobile.properties.placeholder.description', + }, + { + name: '@mandatory', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.mobile.properties.mandatory.description', + }, + { + name: '@disabled', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.mobile.properties.disabled.description', + }, + { + name: '@onChange', + type: 'function', + required: false, + description: + 'ember-input-validation.prefabs.mobile.properties.onChange.description', + }, + { + name: '@changeEvent', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.mobile.properties.changeEvent.description', + }, + ], + }; + } +} diff --git a/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/national-number.ts b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/national-number.ts new file mode 100644 index 00000000..6431bb52 --- /dev/null +++ b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/national-number.ts @@ -0,0 +1,66 @@ +import Route from '@ember/routing/route'; + +export default class DocsEmberInputValidationPrefabsNationalNumberRoute extends Route { + model() { + return { + properties: [ + { + name: '@validationField', + type: 'string', + required: true, + description: + 'ember-input-validation.prefabs.national-number.properties.validationField.description', + }, + { + name: '@changeset', + type: 'ImmerChangeset', + required: true, + description: + 'ember-input-validation.prefabs.national-number.properties.changeset.description', + }, + { + name: '@label', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.national-number.properties.label.description', + }, + { + name: '@placeholder', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.national-number.properties.placeholder.description', + }, + { + name: '@mandatory', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.national-number.properties.mandatory.description', + }, + { + name: '@disabled', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.national-number.properties.disabled.description', + }, + { + name: '@onChange', + type: 'function', + required: false, + description: + 'ember-input-validation.prefabs.national-number.properties.onChange.description', + }, + { + name: '@changeEvent', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.national-number.properties.changeEvent.description', + }, + ], + }; + } +} diff --git a/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/number.ts b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/number.ts new file mode 100644 index 00000000..e0748de2 --- /dev/null +++ b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/number.ts @@ -0,0 +1,95 @@ +// doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/number.ts +import Route from '@ember/routing/route'; + +export default class DocsEmberInputValidationPrefabsNumberRoute extends Route { + model() { + return { + properties: [ + { + name: '@validationField', + type: 'string', + required: true, + description: + 'ember-input-validation.prefabs.number.properties.validationField.description', + }, + { + name: '@changeset', + type: 'ImmerChangeset', + required: true, + description: + 'ember-input-validation.prefabs.number.properties.changeset.description', + }, + { + name: '@label', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.number.properties.label.description', + }, + { + name: '@placeholder', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.number.properties.placeholder.description', + }, + { + name: '@unsigned', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.number.properties.unsigned.description', + }, + { + name: '@min', + type: 'number', + required: false, + description: + 'ember-input-validation.prefabs.number.properties.min.description', + }, + { + name: '@step', + type: 'number', + required: false, + description: + 'ember-input-validation.prefabs.number.properties.step.description', + }, + { + name: '@mandatory', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.number.properties.mandatory.description', + }, + { + name: '@disabled', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.number.properties.disabled.description', + }, + { + name: '@onChange', + type: 'function', + required: false, + description: + 'ember-input-validation.prefabs.number.properties.onChange.description', + }, + { + name: '@changeEvent', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.number.properties.changeEvent.description', + }, + { + name: '@requiredFields', + type: 'string[]', + required: false, + description: + 'ember-input-validation.prefabs.number.properties.requiredFields.description', + }, + ], + }; + } +} diff --git a/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/password.ts b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/password.ts new file mode 100644 index 00000000..e44621c9 --- /dev/null +++ b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/password.ts @@ -0,0 +1,66 @@ +import Route from '@ember/routing/route'; + +export default class DocsEmberInputValidationPrefabsPasswordRoute extends Route { + model() { + return { + properties: [ + { + name: '@validationField', + type: 'string', + required: true, + description: + 'ember-input-validation.prefabs.password.properties.validationField.description', + }, + { + name: '@changeset', + type: 'ImmerChangeset', + required: true, + description: + 'ember-input-validation.prefabs.password.properties.changeset.description', + }, + { + name: '@label', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.password.properties.label.description', + }, + { + name: '@placeholder', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.password.properties.placeholder.description', + }, + { + name: '@mandatory', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.password.properties.mandatory.description', + }, + { + name: '@disabled', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.password.properties.disabled.description', + }, + { + name: '@onChange', + type: 'function', + required: false, + description: + 'ember-input-validation.prefabs.password.properties.onChange.description', + }, + { + name: '@changeEvent', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.password.properties.changeEvent.description', + }, + ], + }; + } +} diff --git a/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/radio-group.ts b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/radio-group.ts new file mode 100644 index 00000000..ff936f8f --- /dev/null +++ b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/radio-group.ts @@ -0,0 +1,66 @@ +import Route from '@ember/routing/route'; + +export default class DocsEmberInputValidationPrefabsRadioGroupRoute extends Route { + model() { + return { + properties: [ + { + name: '@validationField', + type: 'string', + required: true, + description: + 'ember-input-validation.prefabs.radio-group.properties.validationField.description', + }, + { + name: '@changeset', + type: 'Changeset', + required: true, + description: + 'ember-input-validation.prefabs.radio-group.properties.changeset.description', + }, + { + name: '@value', + type: 'string', + required: true, + description: + 'ember-input-validation.prefabs.radio-group.properties.value.description', + }, + { + name: '@groupLabel', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.radio-group.properties.groupLabel.description', + }, + { + name: '@mandatory', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.radio-group.properties.mandatory.description', + }, + { + name: '@disabled', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.radio-group.properties.disabled.description', + }, + { + name: '@classless', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.radio-group.properties.classless.description', + }, + { + name: '@onChange', + type: 'function', + required: false, + description: + 'ember-input-validation.prefabs.radio-group.properties.onChange.description', + }, + ], + }; + } +} diff --git a/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/radio.ts b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/radio.ts new file mode 100644 index 00000000..56440ba3 --- /dev/null +++ b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/radio.ts @@ -0,0 +1,66 @@ +import Route from '@ember/routing/route'; + +export default class DocsEmberInputValidationPrefabsRadioRoute extends Route { + model() { + return { + properties: [ + { + name: '@validationField', + type: 'string', + required: true, + description: + 'ember-input-validation.prefabs.radio.properties.validationField.description', + }, + { + name: '@changeset', + type: 'Changeset', + required: true, + description: + 'ember-input-validation.prefabs.radio.properties.changeset.description', + }, + { + name: '@value', + type: 'string', + required: true, + description: + 'ember-input-validation.prefabs.radio.properties.value.description', + }, + { + name: '@label', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.radio.properties.label.description', + }, + { + name: '@mandatory', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.radio.properties.mandatory.description', + }, + { + name: '@disabled', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.radio.properties.disabled.description', + }, + { + name: '@classless', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.radio.properties.classless.description', + }, + { + name: '@onChange', + type: 'function', + required: false, + description: + 'ember-input-validation.prefabs.radio.properties.onChange.description', + }, + ], + }; + } +} diff --git a/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/select-create.ts b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/select-create.ts new file mode 100644 index 00000000..9d3db5f5 --- /dev/null +++ b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/select-create.ts @@ -0,0 +1,164 @@ +import Route from '@ember/routing/route'; + +export default class DocsEmberInputValidationPrefabsSelectCreateRoute extends Route { + model() { + return { + properties: [ + { + name: '@validationField', + type: 'string', + required: true, + description: + 'ember-input-validation.prefabs.select-create.properties.validationField.description', + }, + { + name: '@changeset', + type: 'Changeset', + required: true, + description: + 'ember-input-validation.prefabs.select-create.properties.changeset.description', + }, + { + name: '@options', + type: 'Array', + required: true, + description: + 'ember-input-validation.prefabs.select-create.properties.options.description', + }, + { + name: '@onCreate', + type: 'function', + required: true, + description: + 'ember-input-validation.prefabs.select-create.properties.onCreate.description', + }, + { + name: '@label', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.select-create.properties.label.description', + }, + { + name: '@placeholder', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.select-create.properties.placeholder.description', + }, + { + name: '@disabled', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.select-create.properties.disabled.description', + }, + { + name: '@multiple', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.select-create.properties.multiple.description', + }, + { + name: '@initiallyOpened', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.select-create.properties.initiallyOpened.description', + }, + { + name: '@allowClear', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.select-create.properties.allowClear.description', + }, + { + name: '@mandatory', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.select-create.properties.mandatory.description', + }, + { + name: '@onChange', + type: 'function', + required: false, + description: + 'ember-input-validation.prefabs.select-create.properties.onChange.description', + }, + { + name: '@labelComponent', + type: 'Component', + required: false, + description: + 'ember-input-validation.prefabs.select-create.properties.labelComponent.description', + }, + { + name: '@selectedItemComponent', + type: 'Component', + required: false, + description: + 'ember-input-validation.prefabs.select-create.properties.selectedItemComponent.description', + }, + { + name: '@placeholderComponent', + type: 'Component', + required: false, + description: + 'ember-input-validation.prefabs.select-create.properties.placeholderComponent.description', + }, + { + name: '@onSearch', + type: 'function', + required: false, + description: + 'ember-input-validation.prefabs.select-create.properties.onSearch.description', + }, + { + name: '@searchPlaceholder', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.select-create.properties.searchPlaceholder.description', + }, + { + name: '@searchMessage', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.select-create.properties.searchMessage.description', + }, + { + name: '@loadingMessage', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.select-create.properties.loadingMessage.description', + }, + { + name: '@noMatchesMessage', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.select-create.properties.noMatchesMessage.description', + }, + { + name: '@showCreateWhen', + type: 'function', + required: false, + description: + 'ember-input-validation.prefabs.select-create.properties.showCreateWhen.description', + }, + { + name: '@buildSuggestion', + type: 'function', + required: false, + description: + 'ember-input-validation.prefabs.select-create.properties.buildSuggestion.description', + }, + ], + }; + } +} diff --git a/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/select-search.ts b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/select-search.ts new file mode 100644 index 00000000..17b2dcf2 --- /dev/null +++ b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/select-search.ts @@ -0,0 +1,143 @@ +import Route from '@ember/routing/route'; + +export default class DocsEmberInputValidationPrefabsSelectSearchRoute extends Route { + model() { + return { + properties: [ + { + name: '@validationField', + type: 'string', + required: true, + description: + 'ember-input-validation.prefabs.select-search.properties.validationField.description', + }, + { + name: '@changeset', + type: 'Changeset', + required: true, + description: + 'ember-input-validation.prefabs.select-search.properties.changeset.description', + }, + { + name: '@options', + type: 'Array', + required: true, + description: + 'ember-input-validation.prefabs.select-search.properties.options.description', + }, + { + name: '@onSearch', + type: 'function', + required: true, + description: + 'ember-input-validation.prefabs.select-search.properties.onSearch.description', + }, + { + name: '@label', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.select-search.properties.label.description', + }, + { + name: '@placeholder', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.select-search.properties.placeholder.description', + }, + { + name: '@disabled', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.select-search.properties.disabled.description', + }, + { + name: '@multiple', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.select-search.properties.multiple.description', + }, + { + name: '@initiallyOpened', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.select-search.properties.initiallyOpened.description', + }, + { + name: '@mandatory', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.select-search.properties.mandatory.description', + }, + { + name: '@allowClear', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.select-search.properties.allowClear.description', + }, + { + name: '@onChange', + type: 'function', + required: false, + description: + 'ember-input-validation.prefabs.select-search.properties.onChange.description', + }, + { + name: '@labelComponent', + type: 'Component', + required: false, + description: + 'ember-input-validation.prefabs.select-search.properties.labelComponent.description', + }, + { + name: '@selectedItemComponent', + type: 'Component', + required: false, + description: + 'ember-input-validation.prefabs.select-search.properties.selectedItemComponent.description', + }, + { + name: '@placeholderComponent', + type: 'Component', + required: false, + description: + 'ember-input-validation.prefabs.select-search.properties.placeholderComponent.description', + }, + { + name: '@searchPlaceholder', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.select-search.properties.searchPlaceholder.description', + }, + { + name: '@searchMessage', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.select-search.properties.searchMessage.description', + }, + { + name: '@loadingMessage', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.select-search.properties.loadingMessage.description', + }, + { + name: '@noMatchesMessage', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.select-search.properties.noMatchesMessage.description', + }, + ], + }; + } +} diff --git a/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/select.ts b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/select.ts new file mode 100644 index 00000000..de3ecbbb --- /dev/null +++ b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/select.ts @@ -0,0 +1,108 @@ +import Route from '@ember/routing/route'; + +export default class DocsEmberInputValidationPrefabsSelectRoute extends Route { + model() { + return { + properties: [ + { + name: '@validationField', + type: 'string', + required: true, + description: + 'ember-input-validation.prefabs.select.properties.validationField.description', + }, + { + name: '@changeset', + type: 'ImmerChangeset', + required: true, + description: + 'ember-input-validation.prefabs.select.properties.changeset.description', + }, + { + name: '@options', + type: 'Array', + required: true, + description: + 'ember-input-validation.prefabs.select.properties.options.description', + }, + { + name: '@label', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.select.properties.label.description', + }, + { + name: '@placeholder', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.select.properties.placeholder.description', + }, + { + name: '@disabled', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.select.properties.disabled.description', + }, + { + name: '@multiple', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.select.properties.multiple.description', + }, + { + name: '@mandatory', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.select.properties.mandatory.description', + }, + { + name: '@initiallyOpened', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.select.properties.initiallyOpened.description', + }, + { + name: '@allowClear', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.select.properties.allowClear.description', + }, + { + name: '@onChange', + type: 'Function', + required: false, + description: + 'ember-input-validation.prefabs.select.properties.onChange.description', + }, + { + name: '@labelComponent', + type: 'Component', + required: false, + description: + 'ember-input-validation.prefabs.select.properties.labelComponent.description', + }, + { + name: '@selectedItemComponent', + type: 'Component', + required: false, + description: + 'ember-input-validation.prefabs.select.properties.selectedItemComponent.description', + }, + { + name: '@placeholderComponent', + type: 'Component', + required: false, + description: + 'ember-input-validation.prefabs.select.properties.placeholderComponent.description', + }, + ], + }; + } +} diff --git a/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/textarea.ts b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/textarea.ts new file mode 100644 index 00000000..a10cc7bd --- /dev/null +++ b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/textarea.ts @@ -0,0 +1,73 @@ +import Route from '@ember/routing/route'; + +export default class DocsEmberInputValidationPrefabsTextareaRoute extends Route { + model() { + return { + properties: [ + { + name: '@validationField', + type: 'string', + required: true, + description: + 'ember-input-validation.prefabs.textarea.properties.validationField.description', + }, + { + name: '@changeset', + type: 'ImmerChangeset', + required: true, + description: + 'ember-input-validation.prefabs.textarea.properties.changeset.description', + }, + { + name: '@label', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.textarea.properties.label.description', + }, + { + name: '@placeholder', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.textarea.properties.placeholder.description', + }, + { + name: '@mandatory', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.textarea.properties.mandatory.description', + }, + { + name: '@disabled', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.textarea.properties.disabled.description', + }, + { + name: '@onChange', + type: 'Function', + required: false, + description: + 'ember-input-validation.prefabs.textarea.properties.onChange.description', + }, + { + name: '@changeEvent', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.textarea.properties.changeEvent.description', + }, + { + name: '@maxLength', + type: 'number', + required: false, + description: + 'ember-input-validation.prefabs.textarea.properties.maxLength.description', + }, + ], + }; + } +} diff --git a/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/timepicker.ts b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/timepicker.ts new file mode 100644 index 00000000..df8a628e --- /dev/null +++ b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/timepicker.ts @@ -0,0 +1,94 @@ +import Route from '@ember/routing/route'; + +export default class DocsEmberInputValidationPrefabsTimepickerRoute extends Route { + model() { + return { + properties: [ + { + name: '@validationField', + type: 'string', + required: true, + description: + 'ember-input-validation.prefabs.timepicker.properties.validationField.description', + }, + { + name: '@changeset', + type: 'ImmerChangeset', + required: true, + description: + 'ember-input-validation.prefabs.timepicker.properties.changeset.description', + }, + { + name: '@label', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.timepicker.properties.label.description', + }, + { + name: '@onChange', + type: 'Function', + required: false, + description: + 'ember-input-validation.prefabs.timepicker.properties.onChange.description', + }, + { + name: '@onClose', + type: 'Function', + required: false, + description: + 'ember-input-validation.prefabs.timepicker.properties.onClose.description', + }, + { + name: '@disabled', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.timepicker.properties.disabled.description', + }, + { + name: '@mandatory', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.timepicker.properties.mandatory.description', + }, + { + name: '@enableSecond', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.timepicker.properties.enableSecond.description', + }, + { + name: '@stepping', + type: 'number', + required: false, + description: + 'ember-input-validation.prefabs.timepicker.properties.stepping.description', + }, + { + name: '@placeholder', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.timepicker.properties.placeholder.description', + }, + { + name: '@clearButton', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.timepicker.properties.clearButton.description', + }, + { + name: '@locale', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.timepicker.properties.locale.description', + }, + ], + }; + } +} diff --git a/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/vat.ts b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/vat.ts new file mode 100644 index 00000000..f1e286ef --- /dev/null +++ b/doc-app/app/routes/dashboard/docs/ember-input-validation/prefabs/vat.ts @@ -0,0 +1,66 @@ +import Route from '@ember/routing/route'; + +export default class DocsEmberInputValidationPrefabsVatRoute extends Route { + model() { + return { + properties: [ + { + name: '@validationField', + type: 'string', + required: true, + description: + 'ember-input-validation.prefabs.vat.properties.validationField.description', + }, + { + name: '@changeset', + type: 'ImmerChangeset', + required: true, + description: + 'ember-input-validation.prefabs.vat.properties.changeset.description', + }, + { + name: '@label', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.vat.properties.label.description', + }, + { + name: '@placeholder', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.vat.properties.placeholder.description', + }, + { + name: '@mandatory', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.vat.properties.mandatory.description', + }, + { + name: '@disabled', + type: 'boolean', + required: false, + description: + 'ember-input-validation.prefabs.vat.properties.disabled.description', + }, + { + name: '@onChange', + type: 'Function', + required: false, + description: + 'ember-input-validation.prefabs.vat.properties.onChange.description', + }, + { + name: '@changeEvent', + type: 'string', + required: false, + description: + 'ember-input-validation.prefabs.vat.properties.changeEvent.description', + }, + ], + }; + } +} diff --git a/doc-app/app/routes/dashboard/docs/ember-input/prefabs.ts b/doc-app/app/routes/dashboard/docs/ember-input/prefabs.ts new file mode 100644 index 00000000..739187c6 --- /dev/null +++ b/doc-app/app/routes/dashboard/docs/ember-input/prefabs.ts @@ -0,0 +1,3 @@ +import Route from '@ember/routing/route'; + +export default class DashboardDocsEmberUIPrefabsRoute extends Route {} diff --git a/doc-app/app/routes/dashboard/docs/ember-input/prefabs/button.ts b/doc-app/app/routes/dashboard/docs/ember-input/prefabs/button.ts new file mode 100644 index 00000000..defea0b3 --- /dev/null +++ b/doc-app/app/routes/dashboard/docs/ember-input/prefabs/button.ts @@ -0,0 +1,31 @@ +import Route from '@ember/routing/route'; + +export default class DocsEmberInputPrefabsButtonRoute extends Route { + model() { + return { + properties: [ + { + name: '@label', + type: 'string', + required: true, + description: + 'ember-input.prefabs.button.properties.field.label.description', + }, + { + name: '@onClick', + type: 'function', + required: true, + description: + 'ember-input.prefabs.button.properties.field.on-click.description', + }, + { + name: '@disabled', + type: 'boolean', + required: false, + description: + 'ember-input.prefabs.button.properties.field.disabled.description', + }, + ], + }; + } +} diff --git a/doc-app/app/routes/dashboard/docs/ember-input/prefabs/toggle.ts b/doc-app/app/routes/dashboard/docs/ember-input/prefabs/toggle.ts new file mode 100644 index 00000000..04783d3f --- /dev/null +++ b/doc-app/app/routes/dashboard/docs/ember-input/prefabs/toggle.ts @@ -0,0 +1,31 @@ +import Route from '@ember/routing/route'; + +export default class DocsEmberInputPrefabsToggleRoute extends Route { + model() { + return { + properties: [ + { + name: '@label', + type: 'string', + required: true, + description: + 'ember-input.prefabs.toggle.properties.field.label.description', + }, + { + name: '@checked', + type: 'boolean', + required: false, + description: + 'ember-input.prefabs.toggle.properties.field.checked.description', + }, + { + name: '@disabled', + type: 'boolean', + required: false, + description: + 'ember-input.prefabs.toggle.properties.field.disabled.description', + }, + ], + }; + } +} diff --git a/doc-app/app/routes/dashboard/docs/ember-ui/prefabs.ts b/doc-app/app/routes/dashboard/docs/ember-ui/prefabs.ts new file mode 100644 index 00000000..739187c6 --- /dev/null +++ b/doc-app/app/routes/dashboard/docs/ember-ui/prefabs.ts @@ -0,0 +1,3 @@ +import Route from '@ember/routing/route'; + +export default class DashboardDocsEmberUIPrefabsRoute extends Route {} diff --git a/doc-app/app/routes/dashboard/docs/ember-ui/prefabs/confirm-modal.ts b/doc-app/app/routes/dashboard/docs/ember-ui/prefabs/confirm-modal.ts new file mode 100644 index 00000000..bfa44f1f --- /dev/null +++ b/doc-app/app/routes/dashboard/docs/ember-ui/prefabs/confirm-modal.ts @@ -0,0 +1,52 @@ +import Route from '@ember/routing/route'; + +export default class DocsEmberUiPrefabsConfirmModalRoute extends Route { + model() { + return { + properties: [ + { + name: '@onClose', + type: 'Function', + required: true, + description: + 'ember-ui.prefabs.confirm-modal.properties.onClose.description', + }, + { + name: '@onConfirm', + type: 'Function', + required: true, + description: + 'ember-ui.prefabs.confirm-modal.properties.onConfirm.description', + }, + { + name: '@cancelText', + type: 'string', + required: true, + description: + 'ember-ui.prefabs.confirm-modal.properties.cancelText.description', + }, + { + name: '@confirmText', + type: 'string', + required: true, + description: + 'ember-ui.prefabs.confirm-modal.properties.confirmText.description', + }, + { + name: '@confirmQuestion', + type: 'string', + required: true, + description: + 'ember-ui.prefabs.confirm-modal.properties.confirmQuestion.description', + }, + { + name: '@isOpen', + type: 'boolean', + required: true, + description: + 'ember-ui.prefabs.confirm-modal.properties.isOpen.description', + }, + ], + }; + } +} diff --git a/doc-app/app/routes/dashboard/docs/ember-ui/prefabs/table-generic.ts b/doc-app/app/routes/dashboard/docs/ember-ui/prefabs/table-generic.ts new file mode 100644 index 00000000..c6b65a76 --- /dev/null +++ b/doc-app/app/routes/dashboard/docs/ember-ui/prefabs/table-generic.ts @@ -0,0 +1,141 @@ +import Route from '@ember/routing/route'; +import { setupWorker } from 'msw/browser'; +import { http } from 'msw'; + +const fakeData = [ + { + type: 'user', + id: '1', + attributes: { + lastName: 'Giga', + firstName: 'Chad', + email: 'info@triptyk.eu', + }, + }, + { + type: 'user', + id: '2', + attributes: { + lastName: 'Marc', + firstName: 'Jean', + email: 'info@triptyk.eu', + }, + }, + { + type: 'user', + id: '3', + attributes: { + lastName: 'Lepond', + firstName: 'Louis', + email: 'info@triptyk.eu', + }, + }, + { + type: 'user', + id: '4', + attributes: { + lastName: 'Dragon', + firstName: 'Lucas', + email: 'info@triptyk.eu', + }, + }, + { + type: 'user', + id: '5', + attributes: { + lastName: 'Leroy', + firstName: 'Simon', + email: 'info@triptyk.eu', + }, + }, +]; + +const worker = setupWorker( + http.get('/users', () => { + return Response.json({ + data: fakeData, + meta: { fetched: fakeData.length, total: fakeData.length }, + }); + }) +); + +export default class DocsEmberUiPrefabsTpkTableGenericPrefabRoute extends Route { + async model() { + await worker.start(); + + return { + properties: [ + { + name: 'tableParams', + type: 'TableParams', + required: true, + description: + 'ember-ui.prefabs.tpk-table-generic-prefab.properties.tableParams.description', + }, + { + name: 'columnsComponent', + type: 'Record>', + required: false, + description: + 'ember-ui.prefabs.tpk-table-generic-prefab.properties.columnsComponent.description', + }, + { + name: 'entity', + type: 'string', + required: true, + description: + 'ember-ui.prefabs.tpk-table-generic-prefab.properties.entity.description', + }, + { + name: 'pageSizes', + type: 'number[]', + required: false, + description: + 'ember-ui.prefabs.tpk-table-generic-prefab.properties.pageSizes.description', + }, + { + name: 'defaultSortColumn', + type: 'string', + required: false, + description: + 'ember-ui.prefabs.tpk-table-generic-prefab.properties.defaultSortColumn.description', + }, + { + name: 'additionalFilters', + type: 'Record', + required: false, + description: + 'ember-ui.prefabs.tpk-table-generic-prefab.properties.additionalFilters.description', + }, + { + name: 'relationships', + type: 'string', + required: false, + description: + 'ember-ui.prefabs.tpk-table-generic-prefab.properties.relationships.description', + }, + { + name: 'rowClick', + type: '(element?: unknown, e?: Event) => void', + required: false, + description: + 'ember-ui.prefabs.tpk-table-generic-prefab.properties.rowClick.description', + }, + { + name: 'columns', + type: 'Column[]', + required: true, + description: + 'ember-ui.prefabs.tpk-table-generic-prefab.properties.columns.description', + }, + { + name: 'actionMenu', + type: 'ActionMenuItem[]', + required: false, + description: + 'ember-ui.prefabs.tpk-table-generic-prefab.properties.actionMenu.description', + }, + ], + }; + } +} diff --git a/doc-app/app/routes/dashboard/docs/ember-ui/prefabs/tpk-form.ts b/doc-app/app/routes/dashboard/docs/ember-ui/prefabs/tpk-form.ts new file mode 100644 index 00000000..6b14382d --- /dev/null +++ b/doc-app/app/routes/dashboard/docs/ember-ui/prefabs/tpk-form.ts @@ -0,0 +1,66 @@ +import Route from '@ember/routing/route'; + +export default class DocsEmberUiPrefabsTpkFormRoute extends Route { + model() { + return { + properties: [ + { + name: '@changeset', + type: 'ImmerChangeset', + required: true, + description: + 'ember-ui.prefabs.tpk-form.properties.changeset.description', + }, + { + name: '@onSubmit', + type: 'Function', + required: true, + description: + 'ember-ui.prefabs.tpk-form.properties.onSubmit.description', + }, + { + name: '@validationSchema', + type: 'ZodObject', + required: true, + description: + 'ember-ui.prefabs.tpk-form.properties.validationSchema.description', + }, + { + name: '@reactive', + type: 'Boolean', + required: false, + description: + 'ember-ui.prefabs.tpk-form.properties.reactive.description', + }, + { + name: '@removeErrorsOnSubmit', + type: 'Boolean', + required: false, + description: + 'ember-ui.prefabs.tpk-form.properties.removeErrorsOnSubmit.description', + }, + { + name: '@autoScrollOnError', + type: 'Boolean', + required: false, + description: + 'ember-ui.prefabs.tpk-form.properties.autoScrollOnError.description', + }, + { + name: '@disabled', + type: 'Boolean', + required: false, + description: + 'ember-ui.prefabs.tpk-form.properties.disabled.description', + }, + { + name: '@executeOnValid', + type: 'Boolean', + required: false, + description: + 'ember-ui.prefabs.tpk-form.properties.executeOnValid.description', + }, + ], + }; + } +} diff --git a/doc-app/app/services/.gitkeep b/doc-app/app/services/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/doc-app/app/services/catch-state.ts b/doc-app/app/services/catch-state.ts index 25e74057..e9e7d6d2 100644 --- a/doc-app/app/services/catch-state.ts +++ b/doc-app/app/services/catch-state.ts @@ -1,14 +1,6 @@ import Service from '@ember/service'; import { tracked } from '@glimmer/tracking'; -export default class CatchState extends Service { - @tracked state: unknown; -} - -// DO NOT DELETE: this is how TypeScript knows how to look up your services. -declare module '@ember/service' { - // eslint-disable-next-line no-unused-vars - interface Registry { - 'catch-state': CatchState; - } +export default class CatchState extends Service { + @tracked state?: T; } diff --git a/doc-app/app/services/store.ts b/doc-app/app/services/store.ts new file mode 100644 index 00000000..9ef0e1a6 --- /dev/null +++ b/doc-app/app/services/store.ts @@ -0,0 +1,11 @@ +import { useLegacyStore } from '@warp-drive/legacy'; +import { JSONAPICache } from '@warp-drive/json-api'; +import { UserSchema } from 'doc-app/models/user'; + +export default useLegacyStore({ + linksMode: false, + legacyRequests: true, + modelFragments: true, + cache: JSONAPICache, + schemas: [UserSchema], +}); diff --git a/doc-app/app/services/tpk-form.ts b/doc-app/app/services/tpk-form.ts new file mode 100644 index 00000000..0d499f7c --- /dev/null +++ b/doc-app/app/services/tpk-form.ts @@ -0,0 +1,3 @@ +import TpkFormService from '@triptyk/ember-input-validation/services/tpk-form'; + +export default TpkFormService; diff --git a/doc-app/app/styles/app.css b/doc-app/app/styles/app.css index 370c08e1..bea4c93c 100644 --- a/doc-app/app/styles/app.css +++ b/doc-app/app/styles/app.css @@ -1,30 +1,24 @@ -@import url("tailwindcss/base"); -@import url("tailwindcss/components"); -@import url("tailwindcss/utilities"); -@import url("@eonasdan/tempus-dominus/dist/css/tempus-dominus.css"); -@import url("ember-power-select/vendor/ember-power-select.css"); -@import url("@triptyk/ember-input-validation/dist/app.css"); -@import url("@triptyk/ember-input/dist/app.css"); -@import url("@triptyk/ember-ui/dist/app.css"); -@import url("ember-input-validation/form.css"); - -.next, -.previous { - display: flex; - align-items: center; - justify-content: center; -} - -.icon { - display: block; - width: 1em; - height: 1em; - mask-size: contain; +/* stylelint-disable at-rule-no-unknown */ +/* stylelint-disable at-rule-empty-line-before */ +/* stylelint-disable no-invalid-position-at-import-rule */ +/* stylelint-disable import-notation */ +@import 'tailwindcss'; +@plugin "daisyui" { + themes: + nord --default, + dracula, + cupcake, + corporate, + lemonade; } +@import '@triptyk/ember-input/dist/app.css'; +@import '@triptyk/ember-ui/dist/app.css'; +@import '@triptyk/ember-input-validation/dist/app.css'; +@import './code-example.css'; +@import './property-table.css'; +@import './auth.css'; -.ember-power-select-options, -.ember-power-select-options li, -.ember-power-select-multiple-options, -.ember-power-select-multiple-options li { - margin-bottom: 0 !important; -} +/* Additional global styles can be added below */ +@source "../../node_modules/@triptyk/ember-ui"; +@source "../../node_modules/@triptyk/ember-input"; +@source "../../node_modules/@triptyk/ember-input-validation"; diff --git a/doc-app/app/styles/auth.css b/doc-app/app/styles/auth.css new file mode 100644 index 00000000..5b1b9df3 --- /dev/null +++ b/doc-app/app/styles/auth.css @@ -0,0 +1,34 @@ +.auth-layout { + @apply flex flex-col items-center justify-center min-h-screen p-4; +} + +.auth-layout-content { + @apply flex flex-col items-center w-full max-w-sm gap-4; +} + +.auth-layout-content h1 { + @apply text-2xl font-semibold text-base-content; +} + +.auth-layout-content .tpk-login-form, +.auth-layout-content .tpk-forgot-password-form, +.auth-layout-content .tpk-reset-password-form { + @apply flex flex-col w-full gap-4 bg-base-100 p-8 rounded-2xl shadow-xl border border-base-200; +} + +.auth-layout-content .tpk-login-form-email, +.auth-layout-content .tpk-login-form-password, +.auth-layout-content .tpk-forgot-password-form-email, +.auth-layout-content .tpk-reset-password-form-password, +.auth-layout-content .tpk-reset-password-form-confirm-password { + @apply w-full; +} + +.auth-layout-content button[type='submit'] { + @apply w-1/2 mx-auto btn btn-primary; +} + +.auth-layout-content .forgot-password-link, +.auth-layout-content .login-link { + @apply text-sm text-primary hover:underline text-center; +} diff --git a/doc-app/app/styles/code-example.css b/doc-app/app/styles/code-example.css new file mode 100644 index 00000000..533deded --- /dev/null +++ b/doc-app/app/styles/code-example.css @@ -0,0 +1,69 @@ +.code-example { + @apply rounded-box bg-base-100 shadow-lg mb-6; +} + +.code-example .component-preview { + @apply bg-base-200 p-4 border-b border-base-300; +} + +.code-example .component-preview h3 { + @apply text-lg font-semibold text-base-content; +} + +.code-example .tab-content { + @apply bg-base-100 p-4 block; +} + +/* doc-app/app/styles/code-block.css */ +.code-block-wrapper { + @apply rounded-lg overflow-hidden bg-[#2e3440] text-[#d8dee9] shadow-lg mb-4; +} + +.code-block-header { + @apply flex justify-between items-center px-4 py-2 bg-[#3b4252] border-b border-[#434c5e]; +} + +.code-block-language { + @apply text-xs font-mono uppercase text-[#88c0d0] font-semibold; +} + +.code-block-copy-btn { + @apply p-1.5 rounded hover:bg-[#434c5e] transition-colors text-[#d8dee9] hover:text-[#88c0d0]; +} + +.code-block-content { + @apply overflow-x-auto; +} + +.code-block-content pre { + @apply m-0 text-sm font-mono leading-relaxed; +} + +.code-block-content code { + @apply text-[#d8dee9]; +} + +/* Syntax highlighting basique - style Nord */ +.code-block-content .token.tag { + @apply text-[#81a1c1]; +} + +.code-block-content .token.attr-name { + @apply text-[#8fbcbb]; +} + +.code-block-content .token.attr-value { + @apply text-[#a3be8c]; +} + +.code-block-content .token.punctuation { + @apply text-[#eceff4]; +} + +.code-block-content .token.string { + @apply text-[#a3be8c]; +} + +.code-block-content .token.comment { + @apply text-[#616e88] italic; +} diff --git a/doc-app/app/styles/ember-input-validation/checkbox.css b/doc-app/app/styles/ember-input-validation/checkbox.css deleted file mode 100644 index 15f2e5cc..00000000 --- a/doc-app/app/styles/ember-input-validation/checkbox.css +++ /dev/null @@ -1,7 +0,0 @@ -.tpk-checkbox-input { - @apply w-5 h-5 rounded border-2 border-gray-300 cursor-pointer; -} - -.tpk-checkbox-label { - @apply text-gray-600 text-xl; -} diff --git a/doc-app/app/styles/ember-input-validation/data-has-error.css b/doc-app/app/styles/ember-input-validation/data-has-error.css deleted file mode 100644 index f0100625..00000000 --- a/doc-app/app/styles/ember-input-validation/data-has-error.css +++ /dev/null @@ -1,27 +0,0 @@ -.error-message { - @apply bg-red-700 shrink-0 h-5 w-5 text-white font-bold flex justify-center items-center rounded-full relative top-[5px] cursor-pointer z-40; - - content: "!"; -} - -[data-has-error="true"] .tpk-validation-errors::before { - @apply error-message; -} - -[data-has-error="true"] input { - @apply text-red-700 border-0 ring-2 ring-red-700; -} - -[data-has-error="true"] .tpk-validation-errors { - @apply visible text-red-700 pl-4 pt-2 min-h-[20px] w-auto flex text-sm z-40; -} - -[data-has-error="true"] .tpk-validation-errors span { - @apply flex items-center w-auto px-3 ml-2 bg-red-100 rounded leading-6; - - transition: 0.5s cubic-bezier(0.18, 1.85, 0.16, 0.8); -} - -[data-has-error="true"]:hover .tpk-validation-errors { - z-index: 55; -} diff --git a/doc-app/app/styles/ember-input-validation/form.css b/doc-app/app/styles/ember-input-validation/form.css deleted file mode 100644 index 1cb8fde8..00000000 --- a/doc-app/app/styles/ember-input-validation/form.css +++ /dev/null @@ -1,15 +0,0 @@ -.form-doc .button { - @apply btn btn-primary; -} - -.form-content { - @apply grid grid-cols-12 gap-4; -} - -.form-content > * { - @apply col-span-4; -} - -.form-content > .tpk-mobile-container { - @apply col-span-8; -} diff --git a/doc-app/app/styles/ember-input-validation/index.css b/doc-app/app/styles/ember-input-validation/index.css deleted file mode 100644 index 5bf372d5..00000000 --- a/doc-app/app/styles/ember-input-validation/index.css +++ /dev/null @@ -1,6 +0,0 @@ -@import url("data-has-error.css"); -@import url("input.css"); -@import url("checkbox.css"); -@import url("loading.css"); -@import url("radio.css"); -@import url("form.css"); diff --git a/doc-app/app/styles/ember-input-validation/input.css b/doc-app/app/styles/ember-input-validation/input.css deleted file mode 100644 index 7f0f228d..00000000 --- a/doc-app/app/styles/ember-input-validation/input.css +++ /dev/null @@ -1,40 +0,0 @@ -.tpk-input input, -.tpk-select-search-input { - @apply relative block w-full px-3 py-2 text-gray-700 placeholder-gray-400 bg-white border border-gray-300 rounded-md shadow-sm appearance-none focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm; -} - -.tpk-input { - position: relative; -} - -.tpk-input > div { - @apply h-full relative; -} - -.tpk-input > label { - @apply relative block mb-1 text-gray-600; -} - -.tpk-input[data-has-error="true"] > input { - @apply border-red-300 text-red-900 placeholder-red-300 focus:ring-red-500 focus:border-red-500; -} - -.tpk-input-validation-toggle-button { - @apply absolute right-1 top-0 h-full; -} - -.tpk-input-phone { - @apply flex space-x-3; -} - -.tpk-input .flag { - @apply flex h-auto items-center justify-center space-x-1; -} - -.tpk-input-validation-mobile { - @apply flex space-x-1; -} - -.tpk-validation-select-search { - @apply relative; -} diff --git a/doc-app/app/styles/ember-input-validation/loading.css b/doc-app/app/styles/ember-input-validation/loading.css deleted file mode 100644 index a35513ba..00000000 --- a/doc-app/app/styles/ember-input-validation/loading.css +++ /dev/null @@ -1,19 +0,0 @@ -.loader { - @apply w-4 h-4 border-2 border-gray-500; - - border-bottom-color: transparent; - border-radius: 50%; - display: inline-block; - box-sizing: border-box; - animation: rotation 1s linear infinite; -} - -@keyframes rotation { - 0% { - transform: rotate(0deg); - } - - 100% { - transform: rotate(360deg); - } -} diff --git a/doc-app/app/styles/ember-input-validation/radio.css b/doc-app/app/styles/ember-input-validation/radio.css deleted file mode 100644 index 35428972..00000000 --- a/doc-app/app/styles/ember-input-validation/radio.css +++ /dev/null @@ -1,23 +0,0 @@ -.tpk-radio { - padding-right: 20px; - margin: 10px; - width: 23%; - border-bottom: 1px solid rgb(196 137 252 / 100%); -} - -.tpk-radio-label { - color: rgb(78 0 151 /100%); -} - -.tpk-validation-radio-group-label { - font-size: 20px; - color: rgb(151 73 0 / 100%); -} - -.tpk-validation-radio-group-group .tpk-radio { - width: 20%; - margin: 5px; - padding-left: 5px; - border-bottom: none; - border-left: 1px solid rgb(196 137 252 / 100%); -} diff --git a/doc-app/app/styles/ember-input/index.css b/doc-app/app/styles/ember-input/index.css deleted file mode 100644 index 1b51807e..00000000 --- a/doc-app/app/styles/ember-input/index.css +++ /dev/null @@ -1,3 +0,0 @@ -@import url("radio.css"); -@import url("select.css"); -@import url("tpk-file.css"); diff --git a/doc-app/app/styles/ember-input/radio.css b/doc-app/app/styles/ember-input/radio.css deleted file mode 100644 index acb7ccdb..00000000 --- a/doc-app/app/styles/ember-input/radio.css +++ /dev/null @@ -1,7 +0,0 @@ -h3 { - @apply text-2xl font-bold text-cyan-500; -} - -.result-box { - @apply border-t-2 border-cyan-600; -} diff --git a/doc-app/app/styles/ember-input/select.css b/doc-app/app/styles/ember-input/select.css deleted file mode 100644 index ad662b94..00000000 --- a/doc-app/app/styles/ember-input/select.css +++ /dev/null @@ -1,85 +0,0 @@ -.docs-p-4 { - @apply mb-5; -} - -.tpk-select, -.tpk-select-search { - @apply relative; -} - -.tpk-select-options, -.tpk-select-search-options { - @apply w-full bg-white z-[60] absolute hidden shadow-lg max-h-60 rounded-md py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm mt-1.5; -} - -.tpk-select .tpk-select-label { - @apply font-semibold text-gray-700 mb-3; -} - -.tpk-select[data-is-open="true"] .tpk-select-options, -.tpk-select-search[data-is-open="true"] .tpk-select-search-options { - @apply block z-[60]; -} - -.tpk-select .tpk-select-options-option[aria-selected="true"]::after, -.tpk-select-search - .tpk-select-search-options-option[aria-selected="true"]::after { - content: url("/assets/icons/check-solid.svg"); - position: absolute; - right: 10px; - width: 15px; - height: 15px; - top: 10px; -} - -.tpk-select .tpk-select-options-option[aria-selected="true"], -.tpk-select-search .tpk-select-search-options-option[aria-selected="true"] { - @apply bg-blue-100; -} - -.tpk-select .tpk-select-options-option, -.tpk-select-search .tpk-select-search-options-option { - @apply cursor-pointer py-2 mb-0 relative px-3; -} - -.tpk-select .tpk-select-options-option[data-has-focus="true"], -.tpk-select-search .tpk-select-search-options-option[data-has-focus="true"] { - @apply bg-gray-50; -} - -.tpk-select .tpk-select-options-option:hover, -.tpk-select-search .tpk-select-search-options-option:hover { - @apply bg-blue-200; -} - -.tpk-select-button { - @apply relative w-full flex rounded shadow-sm px-6 pr-8 py-2 text-left focus:outline-none focus:ring-2 -mb-2 bg-white border-solid border-[1.5px] cursor-pointer text-sm; -} - -.tpk-select-reset-button { - @apply absolute right-6 top-0 h-full px-4; -} - -.tpk-select-button::after { - /* arrow down */ - content: "▾"; - - @apply absolute right-[5px]; -} - -.tpk-select[data-is-open="true"] .tpk-select-button::after { - @apply transform -rotate-180 mt-0.5; -} - -.tpk-select-button:disabled, -.disabled .tpk-select-button { - @apply border border-dashed cursor-not-allowed ring-0; -} - -.tpk-select-options .disabled { - @apply hidden w-0 h-0 ring-0; -} - -.tpk-select aside { - @apply mt-2; -} diff --git a/doc-app/app/styles/ember-input/tpk-file.css b/doc-app/app/styles/ember-input/tpk-file.css deleted file mode 100644 index 1c4fda1b..00000000 --- a/doc-app/app/styles/ember-input/tpk-file.css +++ /dev/null @@ -1,16 +0,0 @@ -.tpk-file { - display: flex; - flex-direction: column; - gap: 1rem; -} - -.tpk-file-input { - border: none; - background: #fefefe; - padding: 10px 20px; - border-radius: 10px; - transition: background 0.2s ease-in-out; - box-shadow: - rgb(0 0 0 / 5%) 0 6px 24px 0, - rgb(0 0 0 / 8%) 0 0 0 1px; -} diff --git a/doc-app/app/styles/ember-ui/actions-menus.css b/doc-app/app/styles/ember-ui/actions-menus.css deleted file mode 100644 index abe4b6f7..00000000 --- a/doc-app/app/styles/ember-ui/actions-menus.css +++ /dev/null @@ -1,39 +0,0 @@ -.actions { - @apply flex justify-center items-center p-0 relative; -} - -.actions ul { - @apply flex flex-col overflow-hidden absolute z-50 bg-white top-[50px] translate-x-full shadow-xl rounded transform scale-y-0 items-start origin-top-right transition duration-300 ease-in-out; -} - -.actions li { - @apply w-full relative my-1; -} - -.actions button { - @apply px-4 py-3 flex items-center justify-start transition duration-300; -} - -.actions button:focus, -.actions button:active { - @apply outline-none; -} - -/* stylelint-disable-next-line selector-class-pattern */ -button.open_actions { - @apply rounded-md shadow-md border; -} - -.actions ul button img { - @apply mr-3 block; - - transition: all 0.5s cubic-bezier(0.2, 2.36, 0.36, 0.34); -} - -.actions button:hover img { - @apply transform rotate-[360deg]; -} - -.actions.aopened ul { - @apply scale-y-100; -} diff --git a/doc-app/app/styles/ember-ui/index.css b/doc-app/app/styles/ember-ui/index.css deleted file mode 100644 index 7b6a49f5..00000000 --- a/doc-app/app/styles/ember-ui/index.css +++ /dev/null @@ -1,5 +0,0 @@ -@import url("actions-menus.css"); -@import url("modal.css"); -@import url("table.css"); -@import url("stack-list.css"); -@import url("text-area.css"); diff --git a/doc-app/app/styles/ember-ui/modal.css b/doc-app/app/styles/ember-ui/modal.css deleted file mode 100644 index bf43060c..00000000 --- a/doc-app/app/styles/ember-ui/modal.css +++ /dev/null @@ -1,25 +0,0 @@ -#tpk-modal { - @apply absolute top-0 left-0; -} - -.open-modal { - @apply rounded-md shadow-md border px-3 py-1; -} - -.open-modal:focus, -.open-modal:active { - @apply outline-none; -} - -.tpk-modal { - @apply fixed z-[110] h-full w-full flex items-center justify-center bg-gray-500/80; -} - -.tpk-modal-content { - @apply flex flex-col items-center justify-center px-16 py-8 w-[580px] bg-white rounded-2xl; -} - -.tpk-confirm-modal-title { - /* FIX FOR DESIGN BUT NEED TO ADAPT TPK Confirm */ - @apply hidden; -} diff --git a/doc-app/app/styles/ember-ui/stack-list.css b/doc-app/app/styles/ember-ui/stack-list.css deleted file mode 100644 index 224afea4..00000000 --- a/doc-app/app/styles/ember-ui/stack-list.css +++ /dev/null @@ -1,47 +0,0 @@ -.tpk-stack { - @apply w-full h-full rounded-md shadow-gray-300 shadow-md p-2 mb-4; -} - -.tpk-stack-title { - @apply pl-4 font-semibold text-gray-600; -} - -.tpk-stack-head { - @apply w-full h-6 flex justify-between items-center; -} - -.origin-top { - @apply text-gray-800 pl-4; -} - -.tpk-stack-head button { - @apply w-4 h-4; -} - -.link { - @apply w-full h-6 flex mt-4; -} - -.icon span { - @apply pl-2; -} - -[data-is-expanded="true"] { - @apply h-full scale-y-100; -} - -[data-is-expanded="false"] { - @apply h-0 scale-y-0 overflow-hidden; -} - -.tpk-stack-head-expand-btn { - @apply duration-200; -} - -[data-is-expanded-btn="true"] { - @apply rotate-0; -} - -[data-is-expanded-btn="false"] { - transform: rotate(90deg); -} diff --git a/doc-app/app/styles/ember-ui/table.css b/doc-app/app/styles/ember-ui/table.css deleted file mode 100644 index 402e907e..00000000 --- a/doc-app/app/styles/ember-ui/table.css +++ /dev/null @@ -1,181 +0,0 @@ -/* stylelint-disable selector-class-pattern */ -.tpk-table-generic { - @apply mt-8 w-full; -} - -.tpk-table-generic a { - @apply text-blue-500 inline-block; -} - -.tpk-table-generic a::before { - display: none; -} - -.tpk-table-generic tr { - @apply bg-gray-100; -} - -.tpk-table-generic thead tr { - @apply border-b-2 bg-gray-100; -} - -.tpk-table-generic th { - @apply py-3 h-12 font-medium border-b-2 border-b-gray-900/30 shrink-0 grow-0; -} - -.tpk-table-generic td { - @apply relative text-center py-4 border-b-[3px] border-white shrink-0 grow-0; -} - -.tpk-table-search button { - @apply absolute left-0 top-2.5 w-5 h-5 ml-3; - - background: url("/assets/icons/search.svg") center left no-repeat; - background-size: cover; -} - -.custom-table td, -.custom-table th { - flex-grow: 1; -} - -.tpk-table-generic th, -.tpk-table-generic td { - @apply w-[100px] max-w-[150px] px-4 box-content; -} - -.tpk-table-generic td.small, -.tpk-table-generic th.small { - @apply w-[50px] max-w-[50px] grow-0 shrink; -} - -.tpk-table-generic td.selectable, -.tpk-table-generic th.selectable { - @apply w-[50px] max-w-[50px] m-0 p-0; -} - -.tpk-table-generic td.custom-cell, -.tpk-table-generic th.custom-cell { - @apply w-[30px]; -} - -.tpk-table-generic td.big, -.tpk-table-generic th.big { - @apply w-[250px] min-w-[150px] grow whitespace-normal; -} - -.tpk-table-generic td, -.tpk-table-generic td:last-child, -.tpk-table-generic th:last-child { - @apply rounded-r; -} - -.tpk-table-generic td:first-child, -.tpk-table-generic th:first-child { - @apply rounded-l-md; -} - -.tpk-table-generic .status::before { - content: ""; - - @apply absolute w-2.5 rounded-sm h-full block left-0 top-0; -} - -.tpk-table-generic tfoot tr { - @apply bg-transparent; -} - -.yeti-table-pagination-controls { - @apply w-full flex flex-col justify-center items-center my-8; -} - -.yeti-table-pagination-controls-page-info, -.yeti-table-pagination-controls-page-size { - @apply bg-transparent text-center text-gray-800; -} - -.yeti-table-pagination-controls-page-size select { - @apply border-b-2 border-gray-400; -} - -.yeti-table-pagination-buttons button { - @apply cursor-pointer; -} - -.yeti-table-pagination-buttons button img { - filter: invert(13%) sepia(6%) saturate(5813%) hue-rotate(157deg) - brightness(100%) contrast(90%); -} - -.yeti-table-pagination-buttons button:hover img { - filter: invert(61%) sepia(99%) saturate(3877%) hue-rotate(167deg) - brightness(89%) contrast(96%); -} - -.yeti-table-pagination-buttons button:disabled { - @apply cursor-default; -} - -.yeti-table-pagination-buttons button:disabled img { - filter: invert(70%) sepia(0%) saturate(2309%) hue-rotate(26deg) - brightness(92%) contrast(97%); - opacity: 0.5; -} - -.yeti-table-pagination-controls-previous { - @apply mr-12; -} - -.yeti-table-pagination-controls-next { - @apply ml-12; -} - -.tpk-table-generic th.yeti-table-sortable { - @apply relative; -} - -.tpk-table-generic th.yeti-table-sortable::after { - @apply inline-block text-orange-400; - - content: "\25BF"; - margin-left: 5px; -} - -table.yeti-table thead th.yeti-table-sorted-asc::after { - @apply text-orange-400; - - content: "\25BE"; - margin-left: 5px; -} - -table.yeti-table thead th.yeti-table-sorted-desc::after { - @apply text-orange-400; - - content: "\25BE"; - transform: rotate(180deg); - margin-left: 5px; -} - -table.yeti-table .yeti-table-sortable { - white-space: nowrap; -} - -.statusSelector .tpk-select-button { - @apply bg-white rounded-xl; -} - -.tpk-table-search { - @apply relative rounded-lg bg-gray-100; -} - -.tpk-table-search label { - @apply sr-only; -} - -.tpk-table-search input { - @apply p-2 bg-transparent w-full pl-14; -} - -.tpk-table-search button span { - @apply sr-only; -} diff --git a/doc-app/app/styles/ember-ui/text-area.css b/doc-app/app/styles/ember-ui/text-area.css deleted file mode 100644 index 08ab9373..00000000 --- a/doc-app/app/styles/ember-ui/text-area.css +++ /dev/null @@ -1,15 +0,0 @@ -.tpk-textarea { - @apply flex flex-col; -} - -.tpk-textarea > label { - @apply text-gray-500 pb-1 pl-2; -} - -.tpk-textarea-input { - @apply border border-gray-300 rounded-md shadow-sm p-2; -} - -.text-area-count { - @apply text-gray-500 pt-1 pr-2 pb-4 float-right; -} diff --git a/doc-app/app/styles/property-table.css b/doc-app/app/styles/property-table.css new file mode 100644 index 00000000..12399a7d --- /dev/null +++ b/doc-app/app/styles/property-table.css @@ -0,0 +1,15 @@ +.table { + @apply min-w-[90%] divide-y divide-base-300; +} + +.table-header { + @apply bg-base-200; +} + +.table-header-content { + @apply px-6 py-3 text-left text-xs font-medium text-base-content/70 uppercase tracking-wider; +} + +.table-body { + @apply bg-base-100 divide-y divide-base-300; +} diff --git a/doc-app/app/templates/application.gts b/doc-app/app/templates/application.gts new file mode 100644 index 00000000..2e30c44c --- /dev/null +++ b/doc-app/app/templates/application.gts @@ -0,0 +1,6 @@ + diff --git a/doc-app/app/templates/application.hbs b/doc-app/app/templates/application.hbs deleted file mode 100644 index 5c6d7546..00000000 --- a/doc-app/app/templates/application.hbs +++ /dev/null @@ -1,5 +0,0 @@ -
- {{!-- @glint-ignore --}} - - {{outlet}} -
diff --git a/doc-app/app/templates/dashboard.gts b/doc-app/app/templates/dashboard.gts new file mode 100644 index 00000000..4f3f881a --- /dev/null +++ b/doc-app/app/templates/dashboard.gts @@ -0,0 +1,328 @@ +import Component from '@glimmer/component'; +import TpkDashBoard, { + type Language, + type SidebarItem, +} from '@triptyk/ember-ui/components/prefabs/tpk-dashboard'; +import type { TOC } from '@ember/component/template-only'; +import ThemeSelector from 'doc-app/components/theme-selector'; +import { service } from '@ember/service'; +import type { IntlService } from 'ember-intl'; +import { action } from '@ember/object'; + +export default class DashboardTemplate extends Component { + @service declare intl: IntlService; + + languages: Language[] = [ + { code: 'fr-fr', label: 'Français' }, + { code: 'en-us', label: 'Anglais' }, + ]; + + @action + handleLocaleChange(locale: string) { + this.intl.setLocale([locale]); + } + + menuItems: SidebarItem[] = [ + { + type: 'link', + label: 'Getting Started', + route: 'dashboard.docs.ember-input-validation.prefabs.input', + icon: as TOC<{ Element: SVGSVGElement }>, + }, + { + type: 'link', + label: 'Installation', + route: 'dashboard.docs.ember-input-validation.prefabs.input', + icon: as TOC<{ Element: SVGSVGElement }>, + }, + { + type: 'group', + isOpen: true, + label: 'Ember Input Validation Prefab', + items: [ + { + type: 'link', + label: 'Input', + route: 'dashboard.docs.ember-input-validation.prefabs.input', + }, + { + type: 'link', + label: 'Integer', + route: 'dashboard.docs.ember-input-validation.prefabs.integer', + }, + { + type: 'link', + label: 'Number', + route: 'dashboard.docs.ember-input-validation.prefabs.number', + }, + { + type: 'link', + label: 'Datepicker', + route: 'dashboard.docs.ember-input-validation.prefabs.datepicker', + }, + { + type: 'link', + label: 'Datepicker Range', + route: + 'dashboard.docs.ember-input-validation.prefabs.datepicker-range', + }, + { + type: 'link', + label: 'Timepicker', + route: 'dashboard.docs.ember-input-validation.prefabs.timepicker', + }, + { + type: 'link', + label: 'Select', + route: 'dashboard.docs.ember-input-validation.prefabs.select', + }, + { + type: 'link', + label: 'Select Create', + route: 'dashboard.docs.ember-input-validation.prefabs.select-create', + }, + { + type: 'link', + label: 'Select Search', + route: 'dashboard.docs.ember-input-validation.prefabs.select-search', + }, + { + type: 'link', + label: 'Radio', + route: 'dashboard.docs.ember-input-validation.prefabs.radio', + }, + { + type: 'link', + label: 'Radio Group', + route: 'dashboard.docs.ember-input-validation.prefabs.radio-group', + }, + { + type: 'link', + label: 'Textarea', + route: 'dashboard.docs.ember-input-validation.prefabs.textarea', + }, + { + type: 'link', + label: 'Password', + route: 'dashboard.docs.ember-input-validation.prefabs.password', + }, + { + type: 'link', + label: 'Email', + route: 'dashboard.docs.ember-input-validation.prefabs.email', + }, + { + type: 'link', + label: 'Mobile', + route: 'dashboard.docs.ember-input-validation.prefabs.mobile', + }, + { + type: 'link', + label: 'File', + route: 'dashboard.docs.ember-input-validation.prefabs.file', + }, + { + type: 'link', + label: 'File List', + route: 'dashboard.docs.ember-input-validation.prefabs.file-list', + }, + { + type: 'link', + label: 'Currency', + route: 'dashboard.docs.ember-input-validation.prefabs.currency', + }, + { + type: 'link', + label: 'BIC', + route: 'dashboard.docs.ember-input-validation.prefabs.bic', + }, + { + type: 'link', + label: 'IBAN', + route: 'dashboard.docs.ember-input-validation.prefabs.iban', + }, + { + type: 'link', + label: 'VAT', + route: 'dashboard.docs.ember-input-validation.prefabs.vat', + }, + { + type: 'link', + label: 'National Number', + route: + 'dashboard.docs.ember-input-validation.prefabs.national-number', + }, + ], + }, + { + type: 'group', + label: 'Ember UI Prefab', + items: [ + { + type: 'link', + label: 'Confirm Modal', + route: 'dashboard.docs.ember-ui.prefabs.confirm-modal', + }, + { + type: 'link', + label: 'Table Generic', + route: 'dashboard.docs.ember-ui.prefabs.table-generic', + }, + { + type: 'link', + label: 'Tpk Form', + route: 'dashboard.docs.ember-ui.prefabs.tpk-form', + }, + ], + }, + { + type: 'group', + label: 'Ember Input Prefab', + items: [ + { + type: 'link', + label: 'Button Prefab', + route: 'dashboard.docs.ember-input.prefabs.button', + }, + { + type: 'link', + label: 'Toggle', + route: 'dashboard.docs.ember-input.prefabs.toggle', + }, + ], + }, + ]; + + +} diff --git a/doc-app/app/templates/dashboard/docs.gts b/doc-app/app/templates/dashboard/docs.gts new file mode 100644 index 00000000..f3b67262 --- /dev/null +++ b/doc-app/app/templates/dashboard/docs.gts @@ -0,0 +1 @@ + diff --git a/doc-app/app/templates/dashboard/docs/ember-input-validation.gts b/doc-app/app/templates/dashboard/docs/ember-input-validation.gts new file mode 100644 index 00000000..f3b67262 --- /dev/null +++ b/doc-app/app/templates/dashboard/docs/ember-input-validation.gts @@ -0,0 +1 @@ + diff --git a/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs.gts b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs.gts new file mode 100644 index 00000000..f3b67262 --- /dev/null +++ b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs.gts @@ -0,0 +1 @@ + diff --git a/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/bic.gts b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/bic.gts new file mode 100644 index 00000000..a8287049 --- /dev/null +++ b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/bic.gts @@ -0,0 +1,62 @@ +import Component from '@glimmer/component'; +import DocPage from 'doc-app/components/doc/page'; +import DocSection from 'doc-app/components/doc/section'; +import DocPropertyTable from 'doc-app/components/doc/property-table'; +import { t, type IntlService } from 'ember-intl'; +import BasicBicExample from 'doc-app/components/docs/ember-input-validation/prefabs/basic-bic.gts'; +import DisabledBicExample from 'doc-app/components/docs/ember-input-validation/prefabs/disabled-bic.gts'; +import ErrorBicExample from 'doc-app/components/docs/ember-input-validation/prefabs/error-bic.gts'; +import { service } from '@ember/service'; +import CodeExampleComponent from 'doc-app/components/doc/code-example.gts'; +import CodeBlock from 'doc-app/components/doc/code-block.gts'; +import type { Property } from 'doc-app/utils/table-property.interface'; + +interface BicPrefabDocsSignature { + Args: { + model: { + properties: Property[]; + }; + }; +} + +export default class BicPrefabDocs extends Component { + @service declare intl: IntlService; + + bic = ` + + `; + + +} diff --git a/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/currency.gts b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/currency.gts new file mode 100644 index 00000000..0ab5cc08 --- /dev/null +++ b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/currency.gts @@ -0,0 +1,62 @@ +import Component from '@glimmer/component'; +import DocPage from 'doc-app/components/doc/page'; +import DocSection from 'doc-app/components/doc/section'; +import DocPropertyTable from 'doc-app/components/doc/property-table'; +import { t, type IntlService } from 'ember-intl'; +import BasicCurrencyExample from 'doc-app/components/docs/ember-input-validation/prefabs/basic-currency.gts'; +import DisabledCurrencyExample from 'doc-app/components/docs/ember-input-validation/prefabs/disabled-currency.gts'; +import ErrorCurrencyExample from 'doc-app/components/docs/ember-input-validation/prefabs/error-currency.gts'; +import { service } from '@ember/service'; +import CodeExampleComponent from 'doc-app/components/doc/code-example.gts'; +import CodeBlock from 'doc-app/components/doc/code-block.gts'; +import type { Property } from 'doc-app/utils/table-property.interface'; + +interface CurrencyPrefabDocsSignature { + Args: { + model: { + properties: Property[]; + }; + }; +} + +export default class CurrencyPrefabDocs extends Component { + @service declare intl: IntlService; + + currency = ` + + `; + + +} diff --git a/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/datepicker-range.gts b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/datepicker-range.gts new file mode 100644 index 00000000..cea23aff --- /dev/null +++ b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/datepicker-range.gts @@ -0,0 +1,67 @@ +import Component from '@glimmer/component'; +import DocPage from 'doc-app/components/doc/page'; +import DocSection from 'doc-app/components/doc/section'; +import DocPropertyTable from 'doc-app/components/doc/property-table'; +import { t, type IntlService } from 'ember-intl'; +import BasicDatepickerRangeExample from 'doc-app/components/docs/ember-input-validation/prefabs/basic-datepicker-range.gts'; +import DisabledDatepickerRangeExample from 'doc-app/components/docs/ember-input-validation/prefabs/disabled-datepicker-range.gts'; +import ErrorDatepickerRangeExample from 'doc-app/components/docs/ember-input-validation/prefabs/error-datepicker-range.gts'; +import { service } from '@ember/service'; +import CodeExampleComponent from 'doc-app/components/doc/code-example.gts'; +import CodeBlock from 'doc-app/components/doc/code-block.gts'; +import type { Property } from 'doc-app/utils/table-property.interface'; + +interface DatepickerRangePrefabDocsSignature { + Args: { + model: { + properties: Property[]; + }; + }; +} + +export default class DatepickerRangePrefabDocs extends Component { + @service declare intl: IntlService; + + datepickerRange = ` + + `; + + +} diff --git a/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/datepicker.gts b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/datepicker.gts new file mode 100644 index 00000000..f522a3e5 --- /dev/null +++ b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/datepicker.gts @@ -0,0 +1,61 @@ +import Component from '@glimmer/component'; +import DocPage from 'doc-app/components/doc/page'; +import DocSection from 'doc-app/components/doc/section'; +import DocPropertyTable from 'doc-app/components/doc/property-table'; +import { t, type IntlService } from 'ember-intl'; +import BasicDatepickerExample from 'doc-app/components/docs/ember-input-validation/prefabs/basic-datepicker.gts'; +import DisabledDatepickerExample from 'doc-app/components/docs/ember-input-validation/prefabs/disabled-datepicker.gts'; +import ErrorDatepickerExample from 'doc-app/components/docs/ember-input-validation/prefabs/error-datepicker.gts'; +import { service } from '@ember/service'; +import CodeExampleComponent from 'doc-app/components/doc/code-example.gts'; +import CodeBlock from 'doc-app/components/doc/code-block.gts'; +import type { Property } from 'doc-app/utils/table-property.interface'; + +interface DatepickerPrefabDocsSignature { + Args: { + model: { + properties: Property[]; + }; + }; +} + +export default class DatepickerPrefabDocs extends Component { + @service declare intl: IntlService; + + datepicker = ` + + `; + + +} diff --git a/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/email.gts b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/email.gts new file mode 100644 index 00000000..549ee67b --- /dev/null +++ b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/email.gts @@ -0,0 +1,62 @@ +import Component from '@glimmer/component'; +import DocPage from 'doc-app/components/doc/page'; +import DocSection from 'doc-app/components/doc/section'; +import DocPropertyTable from 'doc-app/components/doc/property-table'; +import { t, type IntlService } from 'ember-intl'; +import BasicEmailExample from 'doc-app/components/docs/ember-input-validation/prefabs/basic-email.gts'; +import DisabledEmailExample from 'doc-app/components/docs/ember-input-validation/prefabs/disabled-email.gts'; +import ErrorEmailExample from 'doc-app/components/docs/ember-input-validation/prefabs/error-email.gts'; +import { service } from '@ember/service'; +import CodeExampleComponent from 'doc-app/components/doc/code-example.gts'; +import CodeBlock from 'doc-app/components/doc/code-block.gts'; +import type { Property } from 'doc-app/utils/table-property.interface'; + +interface EmailPrefabDocsSignature { + Args: { + model: { + properties: Property[]; + }; + }; +} + +export default class EmailPrefabDocs extends Component { + @service declare intl: IntlService; + + email = ` + + `; + + +} diff --git a/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/file-list.gts b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/file-list.gts new file mode 100644 index 00000000..76b928bc --- /dev/null +++ b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/file-list.gts @@ -0,0 +1,62 @@ +import Component from '@glimmer/component'; +import DocPage from 'doc-app/components/doc/page'; +import DocSection from 'doc-app/components/doc/section'; +import DocPropertyTable from 'doc-app/components/doc/property-table'; +import { t, type IntlService } from 'ember-intl'; +import BasicFileListExample from 'doc-app/components/docs/ember-input-validation/prefabs/basic-file-list.gts'; +import DisabledFileListExample from 'doc-app/components/docs/ember-input-validation/prefabs/disabled-file-list.gts'; +import ErrorFileListExample from 'doc-app/components/docs/ember-input-validation/prefabs/error-file-list.gts'; +import { service } from '@ember/service'; +import CodeExampleComponent from 'doc-app/components/doc/code-example.gts'; +import CodeBlock from 'doc-app/components/doc/code-block.gts'; +import type { Property } from 'doc-app/utils/table-property.interface'; + +interface FileListPrefabDocsSignature { + Args: { + model: { + properties: Property[]; + }; + }; +} + +export default class FileListPrefabDocs extends Component { + @service declare intl: IntlService; + + fileList = ` + + `; + + +} diff --git a/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/file.gts b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/file.gts new file mode 100644 index 00000000..ddd2c08b --- /dev/null +++ b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/file.gts @@ -0,0 +1,61 @@ +import Component from '@glimmer/component'; +import DocPage from 'doc-app/components/doc/page'; +import DocSection from 'doc-app/components/doc/section'; +import DocPropertyTable from 'doc-app/components/doc/property-table'; +import { t, type IntlService } from 'ember-intl'; +import BasicFileExample from 'doc-app/components/docs/ember-input-validation/prefabs/basic-file.gts'; +import DisabledFileExample from 'doc-app/components/docs/ember-input-validation/prefabs/disabled-file.gts'; +import ErrorFileExample from 'doc-app/components/docs/ember-input-validation/prefabs/error-file.gts'; +import { service } from '@ember/service'; +import CodeExampleComponent from 'doc-app/components/doc/code-example.gts'; +import CodeBlock from 'doc-app/components/doc/code-block.gts'; +import type { Property } from 'doc-app/utils/table-property.interface'; + +interface FilePrefabDocsSignature { + Args: { + model: { + properties: Property[]; + }; + }; +} + +export default class FilePrefabDocs extends Component { + @service declare intl: IntlService; + + file = ` + + `; + + +} diff --git a/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/iban.gts b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/iban.gts new file mode 100644 index 00000000..ef93700a --- /dev/null +++ b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/iban.gts @@ -0,0 +1,62 @@ +import Component from '@glimmer/component'; +import DocPage from 'doc-app/components/doc/page'; +import DocSection from 'doc-app/components/doc/section'; +import DocPropertyTable from 'doc-app/components/doc/property-table'; +import { t, type IntlService } from 'ember-intl'; +import BasicIbanExample from 'doc-app/components/docs/ember-input-validation/prefabs/basic-iban.gts'; +import DisabledIbanExample from 'doc-app/components/docs/ember-input-validation/prefabs/disabled-iban.gts'; +import ErrorIbanExample from 'doc-app/components/docs/ember-input-validation/prefabs/error-iban.gts'; +import { service } from '@ember/service'; +import CodeExampleComponent from 'doc-app/components/doc/code-example.gts'; +import CodeBlock from 'doc-app/components/doc/code-block.gts'; +import type { Property } from 'doc-app/utils/table-property.interface'; + +interface IbanPrefabDocsSignature { + Args: { + model: { + properties: Property[]; + }; + }; +} + +export default class IbanPrefabDocs extends Component { + @service declare intl: IntlService; + + iban = ` + + `; + + +} diff --git a/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/input.gts b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/input.gts new file mode 100644 index 00000000..3d9c982b --- /dev/null +++ b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/input.gts @@ -0,0 +1,60 @@ +import Component from '@glimmer/component'; +import DocPage from 'doc-app/components/doc/page'; +import DocSection from 'doc-app/components/doc/section'; +import DocPropertyTable from 'doc-app/components/doc/property-table'; +import { t, type IntlService } from 'ember-intl'; +import BasicInputExample from 'doc-app/components/docs/ember-input-validation/prefabs/basic-input.gts'; +import DisabledInputExample from 'doc-app/components/docs/ember-input-validation/prefabs/disabled-input.gts'; +import ErrorInputExample from 'doc-app/components/docs/ember-input-validation/prefabs/error-input.gts'; +import { service } from '@ember/service'; +import CodeExampleComponent from 'doc-app/components/doc/code-example.gts'; +import CodeBlock from 'doc-app/components/doc/code-block.gts'; +import type { Property } from 'doc-app/utils/table-property.interface'; + +interface InputPrefabDocsSignature { + Args: { + model: { + properties: Property[]; + }; + }; +} + +export default class InputPrefabDocs extends Component { + @service declare intl: IntlService; + input = ` + + `; + + +} diff --git a/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/integer.gts b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/integer.gts new file mode 100644 index 00000000..12c3c1ed --- /dev/null +++ b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/integer.gts @@ -0,0 +1,63 @@ +import Component from '@glimmer/component'; +import DocPage from 'doc-app/components/doc/page'; +import DocSection from 'doc-app/components/doc/section'; +import DocPropertyTable from 'doc-app/components/doc/property-table'; +import { t, type IntlService } from 'ember-intl'; +import BasicIntegerExample from 'doc-app/components/docs/ember-input-validation/prefabs/basic-integer.gts'; +import DisabledIntegerExample from 'doc-app/components/docs/ember-input-validation/prefabs/disabled-integer.gts'; +import ErrorIntegerExample from 'doc-app/components/docs/ember-input-validation/prefabs/error-integer.gts'; +import { service } from '@ember/service'; +import CodeExampleComponent from 'doc-app/components/doc/code-example.gts'; +import CodeBlock from 'doc-app/components/doc/code-block.gts'; +import type { Property } from 'doc-app/utils/table-property.interface'; + +interface IntegerPrefabDocsSignature { + Args: { + model: { + properties: Property[]; + }; + }; +} + +export default class IntegerPrefabDocs extends Component { + @service declare intl: IntlService; + + integer = ` + + `; + + +} diff --git a/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/mobile.gts b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/mobile.gts new file mode 100644 index 00000000..59eb8b83 --- /dev/null +++ b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/mobile.gts @@ -0,0 +1,61 @@ +import Component from '@glimmer/component'; +import DocPage from 'doc-app/components/doc/page'; +import DocSection from 'doc-app/components/doc/section'; +import DocPropertyTable from 'doc-app/components/doc/property-table'; +import { t, type IntlService } from 'ember-intl'; +import BasicMobileExample from 'doc-app/components/docs/ember-input-validation/prefabs/basic-mobile.gts'; +import DisabledMobileExample from 'doc-app/components/docs/ember-input-validation/prefabs/disabled-mobile.gts'; +import ErrorMobileExample from 'doc-app/components/docs/ember-input-validation/prefabs/error-mobile.gts'; +import { service } from '@ember/service'; +import CodeExampleComponent from 'doc-app/components/doc/code-example.gts'; +import CodeBlock from 'doc-app/components/doc/code-block.gts'; +import type { Property } from 'doc-app/utils/table-property.interface'; + +interface MobilePrefabDocsSignature { + Args: { + model: { + properties: Property[]; + }; + }; +} + +export default class MobilePrefabDocs extends Component { + @service declare intl: IntlService; + + mobile = ` + + `; + + +} diff --git a/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/national-number.gts b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/national-number.gts new file mode 100644 index 00000000..4f6c0cf5 --- /dev/null +++ b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/national-number.gts @@ -0,0 +1,68 @@ +import Component from '@glimmer/component'; +import DocPage from 'doc-app/components/doc/page'; +import DocSection from 'doc-app/components/doc/section'; +import DocPropertyTable from 'doc-app/components/doc/property-table'; +import { t, type IntlService } from 'ember-intl'; +import BasicNationalNumberExample from 'doc-app/components/docs/ember-input-validation/prefabs/basic-national-number.gts'; +import DisabledNationalNumberExample from 'doc-app/components/docs/ember-input-validation/prefabs/disabled-national-number.gts'; +import ErrorNationalNumberExample from 'doc-app/components/docs/ember-input-validation/prefabs/error-national-number.gts'; +import { service } from '@ember/service'; +import CodeExampleComponent from 'doc-app/components/doc/code-example.gts'; +import CodeBlock from 'doc-app/components/doc/code-block.gts'; +import type { Property } from 'doc-app/utils/table-property.interface'; + +interface NationalNumberPrefabDocsSignature { + Args: { + model: { + properties: Property[]; + }; + }; +} + +export default class NationalNumberPrefabDocs extends Component { + @service declare intl: IntlService; + + nationalNumber = ` + + `; + + +} diff --git a/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/number.gts b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/number.gts new file mode 100644 index 00000000..fc795f02 --- /dev/null +++ b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/number.gts @@ -0,0 +1,85 @@ +// doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/number.gts +import Component from '@glimmer/component'; +import DocPage from 'doc-app/components/doc/page'; +import DocSection from 'doc-app/components/doc/section'; +import DocPropertyTable from 'doc-app/components/doc/property-table'; +import { t, type IntlService } from 'ember-intl'; +import UnsignedNumberExample from 'doc-app/components/docs/ember-input-validation/prefabs/unsigned-number.gts'; +import BasicNumberExample from 'doc-app/components/docs/ember-input-validation/prefabs/basic-number.gts'; +import DisabledNumberExample from 'doc-app/components/docs/ember-input-validation/prefabs/disabled-number.gts'; +import ErrorNumberExample from 'doc-app/components/docs/ember-input-validation/prefabs/error-number.gts'; +import { service } from '@ember/service'; +import CodeExampleComponent from 'doc-app/components/doc/code-example.gts'; +import CodeBlock from 'doc-app/components/doc/code-block.gts'; +import type { Property } from 'doc-app/utils/table-property.interface'; + +interface NumberPrefabDocsSignature { + Args: { + model: { + properties: Property[]; + }; + }; +} + +export default class NumberPrefabDocs extends Component { + @service declare intl: IntlService; + + unsignedNumberCode = ` + + `; + + basicNumberCode = ` + + `; + + +} diff --git a/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/password.gts b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/password.gts new file mode 100644 index 00000000..d2dd28aa --- /dev/null +++ b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/password.gts @@ -0,0 +1,62 @@ +import Component from '@glimmer/component'; +import DocPage from 'doc-app/components/doc/page'; +import DocSection from 'doc-app/components/doc/section'; +import DocPropertyTable from 'doc-app/components/doc/property-table'; +import { t, type IntlService } from 'ember-intl'; +import BasicPasswordExample from 'doc-app/components/docs/ember-input-validation/prefabs/basic-password.gts'; +import DisabledPasswordExample from 'doc-app/components/docs/ember-input-validation/prefabs/disabled-password.gts'; +import ErrorPasswordExample from 'doc-app/components/docs/ember-input-validation/prefabs/error-password.gts'; +import { service } from '@ember/service'; +import CodeExampleComponent from 'doc-app/components/doc/code-example.gts'; +import CodeBlock from 'doc-app/components/doc/code-block.gts'; +import type { Property } from 'doc-app/utils/table-property.interface'; + +interface PasswordPrefabDocsSignature { + Args: { + model: { + properties: Property[]; + }; + }; +} + +export default class PasswordPrefabDocs extends Component { + @service declare intl: IntlService; + + password = ` + + `; + + +} diff --git a/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/radio-group.gts b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/radio-group.gts new file mode 100644 index 00000000..de758bd5 --- /dev/null +++ b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/radio-group.gts @@ -0,0 +1,65 @@ +import Component from '@glimmer/component'; +import DocPage from 'doc-app/components/doc/page'; +import DocSection from 'doc-app/components/doc/section'; +import DocPropertyTable from 'doc-app/components/doc/property-table'; +import { t, type IntlService } from 'ember-intl'; +import BasicRadioGroupExample from 'doc-app/components/docs/ember-input-validation/prefabs/basic-radio-group.gts'; +import DisabledRadioGroupExample from 'doc-app/components/docs/ember-input-validation/prefabs/disabled-radio-group.gts'; +import ErrorRadioGroupExample from 'doc-app/components/docs/ember-input-validation/prefabs/error-radio-group.gts'; +import { service } from '@ember/service'; +import CodeExampleComponent from 'doc-app/components/doc/code-example.gts'; +import CodeBlock from 'doc-app/components/doc/code-block.gts'; +import type { Property } from 'doc-app/utils/table-property.interface'; + +interface RadioGroupPrefabDocsSignature { + Args: { + model: { + properties: Property[]; + }; + }; +} + +export default class RadioGroupPrefabDocs extends Component { + @service declare intl: IntlService; + + radioGroup = ` + + + + + `; + + +} diff --git a/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/radio.gts b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/radio.gts new file mode 100644 index 00000000..9b19b159 --- /dev/null +++ b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/radio.gts @@ -0,0 +1,62 @@ +import Component from '@glimmer/component'; +import DocPage from 'doc-app/components/doc/page'; +import DocSection from 'doc-app/components/doc/section'; +import DocPropertyTable from 'doc-app/components/doc/property-table'; +import { t, type IntlService } from 'ember-intl'; +import BasicRadioExample from 'doc-app/components/docs/ember-input-validation/prefabs/basic-radio.gts'; +import DisabledRadioExample from 'doc-app/components/docs/ember-input-validation/prefabs/disabled-radio.gts'; +import ErrorRadioExample from 'doc-app/components/docs/ember-input-validation/prefabs/error-radio.gts'; +import { service } from '@ember/service'; +import CodeExampleComponent from 'doc-app/components/doc/code-example.gts'; +import CodeBlock from 'doc-app/components/doc/code-block.gts'; +import type { Property } from 'doc-app/utils/table-property.interface'; + +interface RadioPrefabDocsSignature { + Args: { + model: { + properties: Property[]; + }; + }; +} + +export default class RadioPrefabDocs extends Component { + @service declare intl: IntlService; + + radio = ` + + `; + + +} diff --git a/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/select-create.gts b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/select-create.gts new file mode 100644 index 00000000..7e83f82d --- /dev/null +++ b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/select-create.gts @@ -0,0 +1,65 @@ +import Component from '@glimmer/component'; +import DocPage from 'doc-app/components/doc/page'; +import DocSection from 'doc-app/components/doc/section'; +import DocPropertyTable from 'doc-app/components/doc/property-table'; +import { t, type IntlService } from 'ember-intl'; +import BasicSelectCreateExample from 'doc-app/components/docs/ember-input-validation/prefabs/basic-select-create.gts'; +import DisabledSelectCreateExample from 'doc-app/components/docs/ember-input-validation/prefabs/disabled-select-create.gts'; +import ErrorSelectCreateExample from 'doc-app/components/docs/ember-input-validation/prefabs/error-select-create.gts'; +import { service } from '@ember/service'; +import CodeExampleComponent from 'doc-app/components/doc/code-example.gts'; +import CodeBlock from 'doc-app/components/doc/code-block.gts'; +import type { Property } from 'doc-app/utils/table-property.interface'; + +interface SelectCreatePrefabDocsSignature { + Args: { + model: { + properties: Property[]; + }; + }; +} + +export default class SelectCreatePrefabDocs extends Component { + @service declare intl: IntlService; + + selectCreate = ` + + `; + + +} diff --git a/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/select-search.gts b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/select-search.gts new file mode 100644 index 00000000..ee15c03a --- /dev/null +++ b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/select-search.gts @@ -0,0 +1,65 @@ +import Component from '@glimmer/component'; +import DocPage from 'doc-app/components/doc/page'; +import DocSection from 'doc-app/components/doc/section'; +import DocPropertyTable from 'doc-app/components/doc/property-table'; +import { t, type IntlService } from 'ember-intl'; +import BasicSelectSearchExample from 'doc-app/components/docs/ember-input-validation/prefabs/basic-select-search.gts'; +import DisabledSelectSearchExample from 'doc-app/components/docs/ember-input-validation/prefabs/disabled-select-search.gts'; +import ErrorSelectSearchExample from 'doc-app/components/docs/ember-input-validation/prefabs/error-select-search.gts'; +import { service } from '@ember/service'; +import CodeExampleComponent from 'doc-app/components/doc/code-example.gts'; +import CodeBlock from 'doc-app/components/doc/code-block.gts'; +import type { Property } from 'doc-app/utils/table-property.interface'; + +interface SelectSearchPrefabDocsSignature { + Args: { + model: { + properties: Property[]; + }; + }; +} + +export default class SelectSearchPrefabDocs extends Component { + @service declare intl: IntlService; + + selectSearch = ` + + `; + + +} diff --git a/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/select.gts b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/select.gts new file mode 100644 index 00000000..49b86b36 --- /dev/null +++ b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/select.gts @@ -0,0 +1,62 @@ +import Component from '@glimmer/component'; +import DocPage from 'doc-app/components/doc/page'; +import DocSection from 'doc-app/components/doc/section'; +import DocPropertyTable from 'doc-app/components/doc/property-table'; +import { t, type IntlService } from 'ember-intl'; +import BasicSelectExample from 'doc-app/components/docs/ember-input-validation/prefabs/basic-select.gts'; +import DisabledSelectExample from 'doc-app/components/docs/ember-input-validation/prefabs/disabled-select.gts'; +import ErrorSelectExample from 'doc-app/components/docs/ember-input-validation/prefabs/error-select.gts'; +import { service } from '@ember/service'; +import CodeExampleComponent from 'doc-app/components/doc/code-example.gts'; +import CodeBlock from 'doc-app/components/doc/code-block.gts'; +import type { Property } from 'doc-app/utils/table-property.interface'; + +interface SelectPrefabDocsSignature { + Args: { + model: { + properties: Property[]; + }; + }; +} + +export default class SelectPrefabDocs extends Component { + @service declare intl: IntlService; + + select = ` + + `; + + +} diff --git a/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/textarea.gts b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/textarea.gts new file mode 100644 index 00000000..12476535 --- /dev/null +++ b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/textarea.gts @@ -0,0 +1,62 @@ +import Component from '@glimmer/component'; +import DocPage from 'doc-app/components/doc/page'; +import DocSection from 'doc-app/components/doc/section'; +import DocPropertyTable from 'doc-app/components/doc/property-table'; +import { t, type IntlService } from 'ember-intl'; +import BasicTextareaExample from 'doc-app/components/docs/ember-input-validation/prefabs/basic-textarea.gts'; +import DisabledTextareaExample from 'doc-app/components/docs/ember-input-validation/prefabs/disabled-textarea.gts'; +import ErrorTextareaExample from 'doc-app/components/docs/ember-input-validation/prefabs/error-textarea.gts'; +import { service } from '@ember/service'; +import CodeExampleComponent from 'doc-app/components/doc/code-example.gts'; +import CodeBlock from 'doc-app/components/doc/code-block.gts'; +import type { Property } from 'doc-app/utils/table-property.interface'; + +interface TextareaPrefabDocsSignature { + Args: { + model: { + properties: Property[]; + }; + }; +} + +export default class TextareaPrefabDocs extends Component { + @service declare intl: IntlService; + + textarea = ` + + `; + + +} diff --git a/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/timepicker.gts b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/timepicker.gts new file mode 100644 index 00000000..635d23c1 --- /dev/null +++ b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/timepicker.gts @@ -0,0 +1,61 @@ +import Component from '@glimmer/component'; +import DocPage from 'doc-app/components/doc/page'; +import DocSection from 'doc-app/components/doc/section'; +import DocPropertyTable from 'doc-app/components/doc/property-table'; +import { t, type IntlService } from 'ember-intl'; +import BasicTimepickerExample from 'doc-app/components/docs/ember-input-validation/prefabs/basic-timepicker.gts'; +import DisabledTimepickerExample from 'doc-app/components/docs/ember-input-validation/prefabs/disabled-timepicker.gts'; +import ErrorTimepickerExample from 'doc-app/components/docs/ember-input-validation/prefabs/error-timepicker.gts'; +import { service } from '@ember/service'; +import CodeExampleComponent from 'doc-app/components/doc/code-example.gts'; +import CodeBlock from 'doc-app/components/doc/code-block.gts'; +import type { Property } from 'doc-app/utils/table-property.interface'; + +interface TimepickerPrefabDocsSignature { + Args: { + model: { + properties: Property[]; + }; + }; +} + +export default class TimepickerPrefabDocs extends Component { + @service declare intl: IntlService; + + timepicker = ` + + `; + + +} diff --git a/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/vat.gts b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/vat.gts new file mode 100644 index 00000000..77624de0 --- /dev/null +++ b/doc-app/app/templates/dashboard/docs/ember-input-validation/prefabs/vat.gts @@ -0,0 +1,62 @@ +import Component from '@glimmer/component'; +import DocPage from 'doc-app/components/doc/page'; +import DocSection from 'doc-app/components/doc/section'; +import DocPropertyTable from 'doc-app/components/doc/property-table'; +import { t, type IntlService } from 'ember-intl'; +import BasicVatExample from 'doc-app/components/docs/ember-input-validation/prefabs/basic-vat.gts'; +import DisabledVatExample from 'doc-app/components/docs/ember-input-validation/prefabs/disabled-vat.gts'; +import ErrorVatExample from 'doc-app/components/docs/ember-input-validation/prefabs/error-vat.gts'; +import { service } from '@ember/service'; +import CodeExampleComponent from 'doc-app/components/doc/code-example.gts'; +import CodeBlock from 'doc-app/components/doc/code-block.gts'; +import type { Property } from 'doc-app/utils/table-property.interface'; + +interface VatPrefabDocsSignature { + Args: { + model: { + properties: Property[]; + }; + }; +} + +export default class VatPrefabDocs extends Component { + @service declare intl: IntlService; + + vat = ` + + `; + + +} diff --git a/doc-app/app/templates/dashboard/docs/ember-input/prefabs.gts b/doc-app/app/templates/dashboard/docs/ember-input/prefabs.gts new file mode 100644 index 00000000..f3b67262 --- /dev/null +++ b/doc-app/app/templates/dashboard/docs/ember-input/prefabs.gts @@ -0,0 +1 @@ + diff --git a/doc-app/app/templates/dashboard/docs/ember-input/prefabs/button.gts b/doc-app/app/templates/dashboard/docs/ember-input/prefabs/button.gts new file mode 100644 index 00000000..44768601 --- /dev/null +++ b/doc-app/app/templates/dashboard/docs/ember-input/prefabs/button.gts @@ -0,0 +1,56 @@ +import Component from '@glimmer/component'; +import DocPage from 'doc-app/components/doc/page'; +import DocSection from 'doc-app/components/doc/section'; +import DocPropertyTable from 'doc-app/components/doc/property-table'; +import { t, type IntlService } from 'ember-intl'; +import { service } from '@ember/service'; +import CodeExampleComponent from 'doc-app/components/doc/code-example.gts'; +import ButtonExample from 'doc-app/components/docs/ember-input/prefabs/button.gts'; +import DisabledButtonExample from 'doc-app/components/docs/ember-input/prefabs/disabled-button.gts'; +import CodeBlock from 'doc-app/components/doc/code-block.gts'; +import type { Property } from 'doc-app/utils/table-property.interface'; + +interface ButtonPrefabDocsSignature { + Args: { + model: { + properties: Property[]; + }; + }; +} + +export default class ButtonPrefabDocs extends Component { + @service declare intl: IntlService; + + button = ` + + `; + + +} diff --git a/doc-app/app/templates/dashboard/docs/ember-input/prefabs/toggle.gts b/doc-app/app/templates/dashboard/docs/ember-input/prefabs/toggle.gts new file mode 100644 index 00000000..db614fcb --- /dev/null +++ b/doc-app/app/templates/dashboard/docs/ember-input/prefabs/toggle.gts @@ -0,0 +1,53 @@ +import Component from '@glimmer/component'; +import DocPage from 'doc-app/components/doc/page'; +import DocSection from 'doc-app/components/doc/section'; +import DocPropertyTable from 'doc-app/components/doc/property-table'; +import { t, type IntlService } from 'ember-intl'; +import { service } from '@ember/service'; +import CodeExampleComponent from 'doc-app/components/doc/code-example.gts'; +import DisabledToggleExample from 'doc-app/components/docs/ember-input/prefabs/disabled-toggle.gts'; +import ToggleExample from 'doc-app/components/docs/ember-input/prefabs/toggle.gts'; +import CodeBlock from 'doc-app/components/doc/code-block.gts'; +import type { Property } from 'doc-app/utils/table-property.interface'; + +interface TogglePrefabDocsSignature { + Args: { + model: { + properties: Property[]; + }; + }; +} + +export default class TogglePrefabDocs extends Component { + @service declare intl: IntlService; + + toggle = ` + + `; + + +} diff --git a/doc-app/app/templates/dashboard/docs/ember-ui/prefabs.gts b/doc-app/app/templates/dashboard/docs/ember-ui/prefabs.gts new file mode 100644 index 00000000..f3b67262 --- /dev/null +++ b/doc-app/app/templates/dashboard/docs/ember-ui/prefabs.gts @@ -0,0 +1 @@ + diff --git a/doc-app/app/templates/dashboard/docs/ember-ui/prefabs/confirm-modal.gts b/doc-app/app/templates/dashboard/docs/ember-ui/prefabs/confirm-modal.gts new file mode 100644 index 00000000..aabd1824 --- /dev/null +++ b/doc-app/app/templates/dashboard/docs/ember-ui/prefabs/confirm-modal.gts @@ -0,0 +1,58 @@ +import Component from '@glimmer/component'; +import DocPage from 'doc-app/components/doc/page'; +import DocSection from 'doc-app/components/doc/section'; +import DocPropertyTable from 'doc-app/components/doc/property-table'; +import { t, type IntlService } from 'ember-intl'; +import { service } from '@ember/service'; +import CodeExampleComponent from 'doc-app/components/doc/code-example.gts'; +import CodeBlock from 'doc-app/components/doc/code-block.gts'; +import ConfirmModalExample from 'doc-app/components/docs/ember-ui/prefabs/confirm-modal.gts'; +import type { Property } from 'doc-app/utils/table-property.interface'; + +interface ConfirmModalPrefabDocsSignature { + Args: { + model: { + properties: Property[]; + }; + }; +} + +export default class ConfirmModalPrefabDocs extends Component { + @service declare intl: IntlService; + + confirmModal = ` + + `; + + +} diff --git a/doc-app/app/templates/dashboard/docs/ember-ui/prefabs/table-generic.gts b/doc-app/app/templates/dashboard/docs/ember-ui/prefabs/table-generic.gts new file mode 100644 index 00000000..fe385a35 --- /dev/null +++ b/doc-app/app/templates/dashboard/docs/ember-ui/prefabs/table-generic.gts @@ -0,0 +1,97 @@ +import Component from '@glimmer/component'; +import DocPage from 'doc-app/components/doc/page'; +import DocSection from 'doc-app/components/doc/section'; +import DocPropertyTable from 'doc-app/components/doc/property-table'; +import { t, type IntlService } from 'ember-intl'; +import { service } from '@ember/service'; +import CodeExampleComponent from 'doc-app/components/doc/code-example.gts'; +import CodeBlock from 'doc-app/components/doc/code-block.gts'; +import TpkTableGenericPrefabExample from 'doc-app/components/docs/ember-ui/prefabs/table-generic.gts'; +import type { Property } from 'doc-app/utils/table-property.interface'; + +interface TpkTableGenericPrefabDocsSignature { + Args: { + model: { + properties: Property[]; + }; + }; +} + +export default class TpkTableGenericPrefabDocs extends Component { + @service declare intl: IntlService; + + tpkTableGenericPrefab = ` + + `; + + +} diff --git a/doc-app/app/templates/dashboard/docs/ember-ui/prefabs/tpk-form-code-block.ts b/doc-app/app/templates/dashboard/docs/ember-ui/prefabs/tpk-form-code-block.ts new file mode 100644 index 00000000..e6ad7454 --- /dev/null +++ b/doc-app/app/templates/dashboard/docs/ember-ui/prefabs/tpk-form-code-block.ts @@ -0,0 +1,138 @@ +export const tpkForm = ` + + + + + + + + + + `; + +export const baseComponentsExample = ` + + + + + {{#if I.errors}} +
+ {{#each I.errors as |error|}} +

{{error.message}}

+ {{/each}} +
+ {{/if}} +
+ + +
+ `; + +export const reactiveValidationExample = ` + + {{! Field validates on every change }} + + + `; + +export const submitOnlyValidationExample = ` + + {{! Field validates only on submit }} + + + `; + +export const errorHandlingExample = ` + + {{! Errors cleared before validation, scrolls to first error }} + + + + `; + +export const disabledStateExample = ` + + {{! All inputs will be disabled when isLoading is true }} + + + `; + +export const requiredFieldsExample = ` + +

Required fields: {{F.requiredFields.length}}

+ + + + {{#if (includes F.requiredFields "email")}} +

Email is required

+ {{/if}} + +
+ `; + +export const changesetGetExample = ` + + + + +

Full name: {{F.changesetGet "firstName"}} {{F.changesetGet "lastName"}}

+
+ `; diff --git a/doc-app/app/templates/dashboard/docs/ember-ui/prefabs/tpk-form.gts b/doc-app/app/templates/dashboard/docs/ember-ui/prefabs/tpk-form.gts new file mode 100644 index 00000000..d4ca656d --- /dev/null +++ b/doc-app/app/templates/dashboard/docs/ember-ui/prefabs/tpk-form.gts @@ -0,0 +1,493 @@ +import Component from '@glimmer/component'; +import DocPage from 'doc-app/components/doc/page'; +import DocSection from 'doc-app/components/doc/section'; +import DocPropertyTable from 'doc-app/components/doc/property-table'; +import { t, type IntlService } from 'ember-intl'; +import { service } from '@ember/service'; +import CodeExampleComponent from 'doc-app/components/doc/code-example.gts'; +import CodeBlock from 'doc-app/components/doc/code-block.gts'; +import TpkFormExample from 'doc-app/components/docs/ember-ui/prefabs/tpk-form.gts'; +import TpkFormBaseComponentsExample from 'doc-app/components/docs/ember-ui/prefabs/tpk-form/base-components.gts'; +import TpkFormReactiveValidationExample from 'doc-app/components/docs/ember-ui/prefabs/tpk-form/reactive-validation.gts'; +import TpkFormSubmitOnlyValidationExample from 'doc-app/components/docs/ember-ui/prefabs/tpk-form/submit-only-validation.gts'; +import TpkFormErrorHandlingExample from 'doc-app/components/docs/ember-ui/prefabs/tpk-form/error-handling.gts'; +import TpkFormDisabledStateExample from 'doc-app/components/docs/ember-ui/prefabs/tpk-form/disabled-state.gts'; +import TpkFormRequiredFieldsExample from 'doc-app/components/docs/ember-ui/prefabs/tpk-form/required-fields.gts'; +import TpkFormChangesetGetExample from 'doc-app/components/docs/ember-ui/prefabs/tpk-form/changeset-get.gts'; +import type { Property } from 'doc-app/utils/table-property.interface'; +import { + baseComponentsExample, + changesetGetExample, + disabledStateExample, + errorHandlingExample, + reactiveValidationExample, + requiredFieldsExample, + submitOnlyValidationExample, + tpkForm, +} from './tpk-form-code-block'; + +interface TpkFormPrefabDocsSignature { + Args: { + model: { + properties: Property[]; + }; + }; +} + +export default class TpkFormPrefabDocs extends Component { + @service declare intl: IntlService; + + baseComponents = [ + { + code: 'F.TpkInput', + translate: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.baseComponents.items.input', + htmlSafe: false, + }, + { + code: 'F.TpkTextarea', + translate: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.baseComponents.items.textarea', + htmlSafe: false, + }, + { + code: 'F.TpkSelect', + translate: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.baseComponents.items.select', + htmlSafe: false, + }, + { + code: 'F.TpkCheckbox', + translate: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.baseComponents.items.checkbox', + htmlSafe: false, + }, + { + code: 'F.TpkRadio', + translate: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.baseComponents.items.radio', + htmlSafe: false, + }, + { + code: 'F.TpkRadioGroup', + translate: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.baseComponents.items.radioGroup', + htmlSafe: false, + }, + { + code: 'F.TpkFile', + translate: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.baseComponents.items.file', + htmlSafe: false, + }, + { + code: 'F.TpkDatepicker', + translate: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.baseComponents.items.datepicker', + htmlSafe: false, + }, + ]; + + prefabComponents = [ + { + code: 'F.TpkInputPrefab', + translate: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.prefabComponents.items.input', + htmlSafe: false, + }, + { + code: 'F.TpkTextareaPrefab', + translate: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.prefabComponents.items.textarea', + htmlSafe: false, + }, + { + code: 'F.TpkSelectPrefab', + translate: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.prefabComponents.items.select', + htmlSafe: false, + }, + { + code: 'F.TpkSelectCreatePrefab', + translate: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.prefabComponents.items.selectCreate', + htmlSafe: false, + }, + { + code: 'F.TpkSelectSearchPrefab', + translate: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.prefabComponents.items.selectSearch', + htmlSafe: false, + }, + { + code: 'F.TpkCheckboxPrefab', + translate: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.prefabComponents.items.checkbox', + htmlSafe: false, + }, + { + code: 'F.TpkRadioPrefab', + translate: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.prefabComponents.items.radio', + htmlSafe: false, + }, + { + code: 'F.TpkRadioGroupPrefab', + translate: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.prefabComponents.items.radioGroup', + htmlSafe: false, + }, + { + code: 'F.TpkFilePrefab', + translate: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.prefabComponents.items.file', + htmlSafe: false, + }, + ]; + + specializedInputs = [ + { + code: 'F.TpkPasswordPrefab', + translate: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.specializedInputs.items.password', + htmlSafe: false, + }, + { + code: 'F.TpkEmailPrefab', + translate: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.specializedInputs.items.email', + htmlSafe: false, + }, + { + code: 'F.TpkMobilePrefab', + translate: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.specializedInputs.items.mobile', + htmlSafe: false, + }, + { + code: 'F.TpkIbanPrefab', + translate: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.specializedInputs.items.iban', + htmlSafe: false, + }, + { + code: 'F.TpkBicPrefab', + translate: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.specializedInputs.items.bic', + htmlSafe: false, + }, + { + code: 'F.TpkVatPrefab', + translate: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.specializedInputs.items.vat', + htmlSafe: false, + }, + { + code: 'F.TpkNationalNumberPrefab', + translate: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.specializedInputs.items.nationalNumber', + htmlSafe: false, + }, + { + code: 'F.TpkCurrencyPrefab', + translate: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.specializedInputs.items.currency', + htmlSafe: false, + }, + { + code: 'F.TpkIntegerPrefab', + translate: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.specializedInputs.items.integer', + htmlSafe: false, + }, + { + code: 'F.TpkNumberPrefab', + translate: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.specializedInputs.items.number', + htmlSafe: false, + }, + ]; + + dateTimeComponents = [ + { + code: 'F.TpkDatepickerPrefab', + translate: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.dateTime.items.datepicker', + htmlSafe: false, + }, + { + code: 'F.TpkDatepickerRangePrefab', + translate: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.dateTime.items.datepickerRange', + htmlSafe: false, + }, + { + code: 'F.TpkTimepickerPrefab', + translate: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.dateTime.items.timepicker', + htmlSafe: false, + }, + ]; + + helpers = [ + { + code: 'F.changesetGet', + translate: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.helpers.items.changesetGet', + htmlSafe: true, + }, + { + code: 'F.requiredFields', + translate: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.helpers.items.requiredFields', + htmlSafe: false, + }, + ]; + + get componentSections() { + return [ + { + titleKey: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.baseComponents.title', + items: this.baseComponents, + }, + { + titleKey: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.prefabComponents.title', + items: this.prefabComponents, + }, + { + titleKey: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.specializedInputs.title', + items: this.specializedInputs, + }, + { + titleKey: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.dateTime.title', + items: this.dateTimeComponents, + }, + { + titleKey: + 'ember-ui.prefabs.tpk-form.sections.yieldedComponents.helpers.title', + items: this.helpers, + }, + ]; + } + + +} diff --git a/doc-app/app/templates/docs.hbs b/doc-app/app/templates/docs.hbs deleted file mode 100644 index c10e510a..00000000 --- a/doc-app/app/templates/docs.hbs +++ /dev/null @@ -1,139 +0,0 @@ -{{! @glint-ignore }} - - - - - - - - - - - - - - - - - - {{! prefab section }} - - {{! validation section }} - {{! - - - - - - - - }} - - {{! form section }} - - - - - - - - - - - - - - - - - - - - - - - - - - - {{! input section }} - - - - - - - - - - - - - - - {{outlet}} - - \ No newline at end of file diff --git a/doc-app/app/templates/docs/ember-input-validation/prefabs/checkbox.md b/doc-app/app/templates/docs/ember-input-validation/prefabs/checkbox.md deleted file mode 100644 index b56955f2..00000000 --- a/doc-app/app/templates/docs/ember-input-validation/prefabs/checkbox.md +++ /dev/null @@ -1,43 +0,0 @@ -# Checkbox - -This component provides a checkbox. - - - - - - - - - - - -## Mandatory properties - -- `@validationField`: The field name in the changeset for validation. -- `@changeset`: The changeset object for form validation. - -## Optional properties - -- `@label`: The label for the input field. -- `@disabled`: Whether the input field is disabled. -- `@mandatory`: Whether the textarea field is mandatory. -- `@onChange`: The action to be called when the selection changes. -- `@changeEvent`: The event to trigger the onChange action. diff --git a/doc-app/app/templates/docs/ember-input-validation/prefabs/email.md b/doc-app/app/templates/docs/ember-input-validation/prefabs/email.md deleted file mode 100644 index 7b64c4f8..00000000 --- a/doc-app/app/templates/docs/ember-input-validation/prefabs/email.md +++ /dev/null @@ -1,40 +0,0 @@ -# Input Email - -This is an input with type Email - - - - - - - - - - -## Mandatory properties - -- `@validationField`: The field name in the changeset for validation. -- `@changeset`: The changeset object for form validation. - -## Optional properties - -- `@label`: The label for the input field. -- `@disabled`: Whether the input field is disabled. -- `@mandatory`: Whether the textarea field is mandatory. -- `@onChange`: The action to be called when the selection changes. -- `@changeEvent`: The event to trigger the onChange action. \ No newline at end of file diff --git a/doc-app/app/templates/docs/ember-input-validation/prefabs/file-list.md b/doc-app/app/templates/docs/ember-input-validation/prefabs/file-list.md deleted file mode 100644 index e0c71056..00000000 --- a/doc-app/app/templates/docs/ember-input-validation/prefabs/file-list.md +++ /dev/null @@ -1,43 +0,0 @@ -# Input File - -This is an input with a dropzone that allows to upload multiple files. You can also find a list of uploaded files and dowload/delete theme. - - - - - - - - - - -## Mandatory properties - -- `@validationField`: The field name in the changeset for validation. -- `@changeset`: The changeset object for form validation. - -## Optional properties - -- `@label`: The label for the input field. -- `@disabled`: Whether the input field is disabled. -- `@mandatory`: Whether the input file multiple field is mandatory. -- `@onChange`: The action to be called when the selection changes. -- `@disableDownload`: Whether the download button is disabled. -- `@placeholder`: The placeholder for the dropzone area. diff --git a/doc-app/app/templates/docs/ember-input-validation/prefabs/file.md b/doc-app/app/templates/docs/ember-input-validation/prefabs/file.md deleted file mode 100644 index 704ae577..00000000 --- a/doc-app/app/templates/docs/ember-input-validation/prefabs/file.md +++ /dev/null @@ -1,41 +0,0 @@ -# Input File - -This is an input with type File - - - - - - - - - - -## Mandatory properties - -- `@validationField`: The field name in the changeset for validation. -- `@changeset`: The changeset object for form validation. - -## Optional properties - -- `@label`: The label for the input field. -- `@disabled`: Whether the input field is disabled. -- `@mandatory`: Whether the textarea field is mandatory. -- `@onChange`: The action to be called when the selection changes. -- `@changeEvent`: The event to trigger the onChange action. diff --git a/doc-app/app/templates/docs/ember-input-validation/prefabs/integer.md b/doc-app/app/templates/docs/ember-input-validation/prefabs/integer.md deleted file mode 100644 index 7b9e9102..00000000 --- a/doc-app/app/templates/docs/ember-input-validation/prefabs/integer.md +++ /dev/null @@ -1,45 +0,0 @@ -# Integer - -The integer validation input prefab is used when an integer input is required. - -It prevents decimal numbers by disallowing the comma and period. - -The integer validation input can be restricted to a minimum of 0 or allow negative numbers. - - - - - - - - - - diff --git a/doc-app/app/templates/docs/ember-input-validation/prefabs/national-number.md b/doc-app/app/templates/docs/ember-input-validation/prefabs/national-number.md deleted file mode 100644 index 7928f03d..00000000 --- a/doc-app/app/templates/docs/ember-input-validation/prefabs/national-number.md +++ /dev/null @@ -1,32 +0,0 @@ -# Input national number - -This is an input with a built-in mask for a belgian national number. -It makes so that the national number is written in a pretty format similar -to the one on your belgian ID. - - - - - - - - - - - diff --git a/doc-app/app/templates/docs/ember-input-validation/prefabs/number.md b/doc-app/app/templates/docs/ember-input-validation/prefabs/number.md deleted file mode 100644 index 4bdbcf63..00000000 --- a/doc-app/app/templates/docs/ember-input-validation/prefabs/number.md +++ /dev/null @@ -1,51 +0,0 @@ -# Number - -The number validation input can be blocked at a minimum of 0 or be a negative number - - - - - - - - - - diff --git a/doc-app/app/templates/docs/ember-input-validation/prefabs/password.md b/doc-app/app/templates/docs/ember-input-validation/prefabs/password.md deleted file mode 100644 index 312abeea..00000000 --- a/doc-app/app/templates/docs/ember-input-validation/prefabs/password.md +++ /dev/null @@ -1,35 +0,0 @@ -# Input password - -This is a password input field. - - - - - - - - - - diff --git a/doc-app/app/templates/docs/ember-input-validation/prefabs/select-search.md b/doc-app/app/templates/docs/ember-input-validation/prefabs/select-search.md deleted file mode 100644 index 1f9960a7..00000000 --- a/doc-app/app/templates/docs/ember-input-validation/prefabs/select-search.md +++ /dev/null @@ -1,111 +0,0 @@ -# Select Search - -This component provides a powerfull select with search and has built-in validation. It uses [ember-power-select](https://ember-power-select.com/). - -It uses also toString() in order to display the options and the selected element. - -In example: - -```ts - options = [ - { label: 'Option 1', value: 'option-1', toString() { return `${this.label}`; } } - ]; -``` - - - - - - - - - - -## Mandatory properties - -- `@validationField`: The field name in the changeset for validation. -- `@changeset`: The changeset object for form validation. -- `@options`: The options to display in the select dropdown. -- `@onSearch`: The action to be called when user's typing in the input. - -## Optional properties - -- `@label`: The label for the input field. -- `@placeholder`: The placeholder text for the input field. -- `@disabled`: Whether the input field is disabled. -- `@multiple`: Whether multiple selections are allowed. -- `@initiallyOpened`: Whether the select dropdown is initially opened. -- `@mandatory`: Whether the textarea field is mandatory. -- `@allowClear`: Whether to show a button to clear the selection. -- `@onChange`: The action to be called when the selection changes. -- `@labelComponent`: The custom component to use for the label. -- `@selectedItemComponent`: The custom component to use for the selected item. -- `@placeholderComponent`: The custom component to use for the placeholder -- `@searchPlaceholder`: The placeholder text for the search input. -- `@searchMessage`: Message shown in options list when no search has been entered and there are no options. -- `@loadingMessage`: Message shown in options list when loading options. -- `@noMatchesMessage`: Message shown in options list when no matches are found. - -## Examples - -### Select Search multiple with allowClear - - - - - - - - -### Select Search with all label translate and initially opened - - - - - - - diff --git a/doc-app/app/templates/docs/ember-input-validation/prefabs/select.md b/doc-app/app/templates/docs/ember-input-validation/prefabs/select.md deleted file mode 100644 index 580115ea..00000000 --- a/doc-app/app/templates/docs/ember-input-validation/prefabs/select.md +++ /dev/null @@ -1,136 +0,0 @@ -# Select - -This component provides a powerfull select with multitude features and has built-in validation. It uses [ember-power-select](https://ember-power-select.com/). - -It uses also toString() in order to display the options and the selected element. - -In example: - -```ts - options = [ - { label: 'Option 1', value: 'option-1', toString() { return `${this.label}`; } } - ]; -``` - - - - - - - - - - -## Mandatory properties - -- `@validationField`: The field name in the changeset for validation. -- `@changeset`: The changeset object for form validation. -- `@options`: The options to display in the select dropdown. - -## Optional properties - -- `@label`: The label for the input field. -- `@placeholder`: The placeholder text for the input field. -- `@disabled`: Whether the input field is disabled. -- `@multiple`: Whether multiple selections are allowed. -- `@mandatory`: Whether the textarea field is mandatory. -- `@initiallyOpened`: Whether the select dropdown is initially opened. -- `@allowClear`: Whether to show a button to clear the selection. -- `@onChange`: The action to be called when the selection changes. -- `@labelComponent`: The custom component to use for the label. -- `@selectedItemComponent`: The custom component to use for the selected item. -- `@placeholderComponent`: The custom component to use for the placeholder - -## Examples - -### Select multiple - - - - - - - - -### Select with specific component for label - - - - - - - - - - - -### Select with allowClear - - - - - - - - -### Select initially opened - - - - - - - diff --git a/doc-app/app/templates/docs/ember-input-validation/prefabs/textarea.md b/doc-app/app/templates/docs/ember-input-validation/prefabs/textarea.md deleted file mode 100644 index a1b4c3f0..00000000 --- a/doc-app/app/templates/docs/ember-input-validation/prefabs/textarea.md +++ /dev/null @@ -1,58 +0,0 @@ -# Textarea - -This component provides an textarea. - - - - - - - - - - -## Mandatory properties - -- `@validationField`: The field name in the changeset for validation. -- `@changeset`: The changeset object for form validation. - -## Optional properties - -- `@label`: The label for the textarea field. -- `@placeholder`: The placeholder text for the textarea field. -- `@mandatory`: Whether the textarea field is mandatory. -- `@disabled`: Whether the input field is disabled. -- `@onChange`: The action to be called when the selection changes. -- `@changeEvent`: The event to trigger the onChange action. -- `@maxLength`: The maximum length of the textarea field. - -## Examples - -### Textarea with maxLength - - - - - - - diff --git a/doc-app/app/templates/docs/ember-input/button.md b/doc-app/app/templates/docs/ember-input/button.md deleted file mode 100644 index 50e493d6..00000000 --- a/doc-app/app/templates/docs/ember-input/button.md +++ /dev/null @@ -1,28 +0,0 @@ -# Ember input/button - -A button component that performs an onClick task. - -By default, prevents spam click by waiting the current task to finish before accepting a new one. - - - - - Spam me @allowSpam={{true}} - - - Spam me @allowSpam={{false}} - -
- Counter : {{this.counter}} -
-
- -
- diff --git a/doc-app/app/templates/docs/ember-input/checkbox.md b/doc-app/app/templates/docs/ember-input/checkbox.md deleted file mode 100644 index 05cfca71..00000000 --- a/doc-app/app/templates/docs/ember-input/checkbox.md +++ /dev/null @@ -1,21 +0,0 @@ -# Ember input/checkbox - -A composable checkbox input element. - - - - - - - -
- Checked: {{this.checked}} -
-
- -
- diff --git a/doc-app/app/templates/docs/ember-input/file.md b/doc-app/app/templates/docs/ember-input/file.md deleted file mode 100644 index 6c2248bf..00000000 --- a/doc-app/app/templates/docs/ember-input/file.md +++ /dev/null @@ -1,49 +0,0 @@ -# Ember input/file - -The **TpkFileInputComponent** is designed to handle file input in a web application. It encapsulates an HTML file field (` - - - - - - - - - -**Multiple input/file** - - - - - - - - - - -## Arguments description - -- **accept?: string** - - This argument is optional and expects a string. It specifies the file types the user can select. For example, "image/*" will accept all image types. -- **disabled?: boolean** - - This argument is optional and is a boolean. If it is supplied and evaluates to true, the file field will be disabled. Otherwise, it will be enabled. -- **multiple?: boolean** - - This argument is optional and is a boolean. If provided and evaluated to true, the file field will allow the user to select multiple files at once. Otherwise, only one file can be selected. -- **changeEvent: 'input' | 'change'** - - This argument is mandatory and must be one of two string values: 'input' or 'change'. It specifies the type of change event associated with the file input field. This can be useful to customize when the onChange callback function is triggered. -- **onChange: (event: Event) => void** - - This argument is mandatory and waits for a callback function that takes an argument of type Event. This callback function will be called when the specified change event ('input' or 'change') occurs on the file field. It can be used to perform actions in response to file changes. diff --git a/doc-app/app/templates/docs/ember-input/input.md b/doc-app/app/templates/docs/ember-input/input.md deleted file mode 100644 index 708a7367..00000000 --- a/doc-app/app/templates/docs/ember-input/input.md +++ /dev/null @@ -1,23 +0,0 @@ -# Ember input/input - -A composable html input element. - - - - - - - - - - - - - -
- Value: {{this.value}} -
-
- -
- diff --git a/doc-app/app/templates/docs/ember-input/prefabs/button.md b/doc-app/app/templates/docs/ember-input/prefabs/button.md deleted file mode 100644 index 29bc2b40..00000000 --- a/doc-app/app/templates/docs/ember-input/prefabs/button.md +++ /dev/null @@ -1,27 +0,0 @@ -# Button - -A button. This is a simple wrapper around the `input` element with `type="button"`. - - - -
- - -
-

count = {{this.counter}}

-
- -
- -## Mandatory properties - -- `@label`: The label for the button field. -- `@onClick`: The action to be called when the button clicked. - -## Optional properties - -- `@disabled`: Whether the button field is disabled. - -## Important - -- `class`: To create a custom class you must do it in a CSS file to override the button class \ No newline at end of file diff --git a/doc-app/app/templates/docs/ember-input/prefabs/toggle.md b/doc-app/app/templates/docs/ember-input/prefabs/toggle.md deleted file mode 100644 index 9e7f0d83..00000000 --- a/doc-app/app/templates/docs/ember-input/prefabs/toggle.md +++ /dev/null @@ -1,12 +0,0 @@ -# Toggle - -A toggle switch. This is a simple wrapper around the `input` element with `type="checkbox"`. - - - - - - - - - diff --git a/doc-app/app/templates/docs/ember-ui/actions-menu.md b/doc-app/app/templates/docs/ember-ui/actions-menu.md deleted file mode 100644 index 316be63f..00000000 --- a/doc-app/app/templates/docs/ember-ui/actions-menu.md +++ /dev/null @@ -1,17 +0,0 @@ -# Actions menu - -A component for a tooltip-like actions menu. - - - - - - Edit - - - - - \ No newline at end of file diff --git a/doc-app/app/templates/docs/ember-ui/modal.md b/doc-app/app/templates/docs/ember-ui/modal.md deleted file mode 100644 index 405f9ca4..00000000 --- a/doc-app/app/templates/docs/ember-ui/modal.md +++ /dev/null @@ -1,25 +0,0 @@ -# Modal - -A modal component. - - - - -
-
- - -

Click outside to close

- -
-
-
- -
diff --git a/doc-app/app/templates/docs/ember-ui/prefabs/confirm-modal.md b/doc-app/app/templates/docs/ember-ui/prefabs/confirm-modal.md deleted file mode 100644 index b868071e..00000000 --- a/doc-app/app/templates/docs/ember-ui/prefabs/confirm-modal.md +++ /dev/null @@ -1,31 +0,0 @@ -# Modal - -A modal component. - - - - -
- -
-
- -
- -## Mandatory properties - -- `@onClose`: this is a function to close modal. -- `@onConfirm`: this is a function to close modal. -- `@cancelText`: this is a string to populate cancel button -- `@confirmText`: this is a string to populate confirm button -- `@confirmQuestion`: this is the text of confirmation to user -- `@isOpen` : boolean to close modal \ No newline at end of file diff --git a/doc-app/app/templates/docs/ember-ui/table-generic.md b/doc-app/app/templates/docs/ember-ui/table-generic.md deleted file mode 100644 index 2b106c90..00000000 --- a/doc-app/app/templates/docs/ember-ui/table-generic.md +++ /dev/null @@ -1,47 +0,0 @@ -# Table generic - -A table component. - - - - - - - - - Firstname - - - Lastname - - - Email - - - - - {{element.firstName}} - - - {{element.lastName}} - - - {{element.email}} - - - - Delete - - - - - - - - - diff --git a/doc-app/app/templates/forgot-password.gts b/doc-app/app/templates/forgot-password.gts new file mode 100644 index 00000000..8327bc95 --- /dev/null +++ b/doc-app/app/templates/forgot-password.gts @@ -0,0 +1,24 @@ +import { LinkTo } from '@ember/routing'; +import Component from '@glimmer/component'; +import TpkForgotPasswordForm from '@triptyk/ember-ui/components/prefabs/tpk-forgot-password'; +import { email, object } from 'zod'; +import AuthLayout from 'doc-app/components/auth-layout.gts'; + +export default class ForgotPasswordTemplate extends Component { + forgotPasswordValidationSchema = object({ + email: email(), + }); + + onSubmit = async () => {}; + +} diff --git a/doc-app/app/templates/home.gts b/doc-app/app/templates/home.gts new file mode 100644 index 00000000..89d3f40b --- /dev/null +++ b/doc-app/app/templates/home.gts @@ -0,0 +1,181 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { action } from '@ember/object'; +import { service } from '@ember/service'; +import TpkDashBoard, { + type SidebarItem, + type Language, +} from '@triptyk/ember-ui/components/prefabs/tpk-dashboard'; +import type { TOC } from '@ember/component/template-only'; +import ThemeSelector from 'doc-app/components/theme-selector'; +import { hash } from '@ember/helper'; +import type { IntlService } from 'ember-intl'; + +export default class DashboardTemplate extends Component { + @service declare intl: IntlService; + @tracked sidebarCollapsed = false; + + languages: Language[] = [ + { code: 'fr-fr', label: 'Français' }, + { code: 'en-us', label: 'Anglais' }, + ]; + + @action + logout() { + console.log('logout'); + } + @action + handleCollapsedChange(collapsed: boolean) { + this.sidebarCollapsed = collapsed; + } + + @action + toggleSidebar() { + this.sidebarCollapsed = !this.sidebarCollapsed; + } + + @action + handleLocaleChange(locale: string) { + this.intl.setLocale([locale]); + } + + menuItems: SidebarItem[] = [ + { + type: 'link', + label: 'Accueil', + route: 'home', + icon: as TOC<{ Element: SVGSVGElement }>, + }, + { + type: 'link', + label: 'Commandes', + route: 'dashboard.docs.ember-input-validation.prefabs.input', + icon: as TOC<{ Element: SVGSVGElement }>, + }, + { + type: 'link', + label: 'Notifications', + route: 'dashboard.docs.ember-input-validation.prefabs.input', + icon: as TOC<{ Element: SVGSVGElement }>, + }, + { + type: 'link', + label: 'Paramètres', + route: 'dashboard.docs.ember-input-validation.prefabs.input', + icon: as TOC<{ Element: SVGSVGElement }>, + }, + ]; + + +} diff --git a/doc-app/app/templates/index.hbs b/doc-app/app/templates/index.hbs deleted file mode 100644 index 375238a3..00000000 --- a/doc-app/app/templates/index.hbs +++ /dev/null @@ -1,2 +0,0 @@ -{{!-- @glint-ignore --}} - \ No newline at end of file diff --git a/doc-app/app/templates/login.gts b/doc-app/app/templates/login.gts new file mode 100644 index 00000000..7e315a09 --- /dev/null +++ b/doc-app/app/templates/login.gts @@ -0,0 +1,26 @@ +import { LinkTo } from '@ember/routing'; +import Component from '@glimmer/component'; +import TpkLoginForm from '@triptyk/ember-ui/components/prefabs/tpk-login'; +import AuthLayout from 'doc-app/components/auth-layout.gts'; +import { email, object, string } from 'zod'; + +export default class LoginTemplate extends Component { + loginValidationSchema = object({ + email: email(), + password: string().min(8, 'Should be at least 8 characters'), + }); + + onSubmit = async () => {}; + +} diff --git a/doc-app/app/templates/reset-password.gts b/doc-app/app/templates/reset-password.gts new file mode 100644 index 00000000..c81dddf1 --- /dev/null +++ b/doc-app/app/templates/reset-password.gts @@ -0,0 +1,47 @@ +import { LinkTo } from '@ember/routing'; +import Component from '@glimmer/component'; +import TpkResetPasswordForm from '@triptyk/ember-ui/components/prefabs/tpk-reset-password'; +import { object, string } from 'zod'; +import AuthLayout from 'doc-app/components/auth-layout.gts'; +import type RouterService from '@ember/routing/router-service'; +import { service } from '@ember/service'; +import type Owner from '@ember/owner'; +import { assert } from '@ember/debug'; + +export interface ResetPasswordTemplateSignature { + Args: object; + Blocks: { + default: []; + }; + Element: HTMLDivElement; +} + +export default class ResetPasswordTemplate extends Component { + @service declare router: RouterService; + declare token: string; + + constructor(owner: Owner, args: ResetPasswordTemplateSignature['Args']) { + super(owner, args); + assert('Token is required', this.router.currentRoute?.queryParams?.token); + this.token = this.router.currentRoute?.queryParams?.token as string; + } + + resetPasswordValidationSchema = object({ + password: string().min(8, 'Should be at least 8 characters'), + confirmPassword: string().min(8, 'Should be at least 8 characters'), + }); + + onSubmit = async () => {}; + + +} diff --git a/doc-app/app/utils/table-property.interface.ts b/doc-app/app/utils/table-property.interface.ts new file mode 100644 index 00000000..216ec960 --- /dev/null +++ b/doc-app/app/utils/table-property.interface.ts @@ -0,0 +1,6 @@ +export interface Property { + name: string; + type: string; + required: boolean; + description: string; +} diff --git a/doc-app/babel.config.cjs b/doc-app/babel.config.cjs new file mode 100644 index 00000000..94441e95 --- /dev/null +++ b/doc-app/babel.config.cjs @@ -0,0 +1,53 @@ +'use strict'; + +const { + babelCompatSupport, + templateCompatSupport, +} = require('@embroider/compat/babel'); + +module.exports = { + plugins: [ + ['ember-concurrency/async-arrow-task-transform', {}], + [ + '@babel/plugin-transform-typescript', + { + allExtensions: true, + onlyRemoveTypeImports: true, + allowDeclareFields: true, + }, + ], + [ + 'babel-plugin-ember-template-compilation', + { + compilerPath: 'ember-source/dist/ember-template-compiler.js', + enableLegacyModules: [ + 'ember-cli-htmlbars', + 'ember-cli-htmlbars-inline-precompile', + 'htmlbars-inline-precompile', + ], + transforms: [...templateCompatSupport()], + }, + ], + [ + 'module:decorator-transforms', + { + runtime: { + import: require.resolve('decorator-transforms/runtime-esm'), + }, + }, + ], + [ + '@babel/plugin-transform-runtime', + { + absoluteRuntime: __dirname, + useESModules: true, + regenerator: false, + }, + ], + ...babelCompatSupport(), + ], + + generatorOpts: { + compact: false, + }, +}; diff --git a/doc-app/config/addon-docs.js b/doc-app/config/addon-docs.js deleted file mode 100644 index 83551f59..00000000 --- a/doc-app/config/addon-docs.js +++ /dev/null @@ -1,9 +0,0 @@ -/* eslint-env node */ - - -const AddonDocsConfig = require('ember-cli-addon-docs/lib/config'); - -module.exports = class extends AddonDocsConfig { - // See https://ember-learn.github.io/ember-cli-addon-docs/docs/deploying - // for details on configuration you can override here. -}; diff --git a/doc-app/config/deploy.js b/doc-app/config/deploy.js deleted file mode 100644 index ff6a2ce3..00000000 --- a/doc-app/config/deploy.js +++ /dev/null @@ -1,13 +0,0 @@ - - -module.exports = function () { - let ENV = { - pipeline: { - disabled: { - 'ember-cli-addon-docs': true, - }, - }, - }; - - return ENV; -}; diff --git a/doc-app/config/ember-cli-update.json b/doc-app/config/ember-cli-update.json index 0573703e..90f88e59 100644 --- a/doc-app/config/ember-cli-update.json +++ b/doc-app/config/ember-cli-update.json @@ -2,16 +2,14 @@ "schemaVersion": "1.0.0", "packages": [ { - "name": "ember-cli", - "version": "5.12.0", + "name": "@ember/app-blueprint", + "version": "6.9.1", "blueprints": [ { - "name": "app", - "outputRepo": "https://github.com/ember-cli/ember-new-output", - "codemodsSource": "ember-app-codemods-manifest@1", + "name": "@ember/app-blueprint", "isBaseBlueprint": true, "options": [ - "--embroider", + "--pnpm", "--ci-provider=github", "--typescript" ] diff --git a/doc-app/config/ember-intl.js b/doc-app/config/ember-intl.js deleted file mode 100644 index 1f01ccbc..00000000 --- a/doc-app/config/ember-intl.js +++ /dev/null @@ -1,93 +0,0 @@ -module.exports = function (/* environment */) { - return { - /** - * Cause a build error if missing translations are detected. - * - * See https://ember-intl.github.io/ember-intl/docs/guide/missing-translations#throwing-a-build-error-on-missing-when-required-translations - * - * @property errorOnMissingTranslations - * @type {Boolean} - * @default "false" - */ - errorOnMissingTranslations: false, - - /** - * Cause a build error if ICU argument mismatches are detected between translations - * with the same key across all locales. - * - * @property errorOnNamedArgumentMismatch - * @type {Boolean} - * @default "false" - */ - errorOnNamedArgumentMismatch: false, - - /** - * Merges the fallback locale's translations into all other locales as a - * build-time fallback strategy. - * - * This will **not** prevent missing translation warnings or errors from occurring. - * It's meant as safety net when warnings are enabled. - * When enabled along with `errorOnMissingTranslations` any fallback attempts will result in an error. - * - * @property fallbackLocale - * @type {String?} - * @default "null" - */ - fallbackLocale: null, - - /** - * Path where translations are stored. This is relative to the project root. - * For example, if your translations are an npm dependency, set this to: - *`'./node_modules/path/to/translations'` - * - * @property inputPath - * @type {String} - * @default "'translations'" - */ - inputPath: 'translations', - - /** - * Prevents the translations from being bundled with the application code. - * This enables asynchronously loading the translations for the active locale - * by fetching them from the asset folder of the build. - * - * See: https://ember-intl.github.io/ember-intl/docs/guide/asynchronously-loading-translations - * - * @property publicOnly - * @type {Boolean} - * @default "false" - */ - publicOnly: false, - - /** - * A function that is called whenever any translation key, from any locale, is missing at build time. - * - * See https://ember-intl.github.io/ember-intl/docs/guide/missing-translations#requiring-translations - * - * @property requiresTranslation - * @type {Function} - * @default "function(key,locale) { return true }" - */ - requiresTranslation(/* key, locale */) { - return true; - }, - - /** - * Removes empty translations from the build output. - * - * @property stripEmptyTranslations - * @type {Boolean} - * @default "false" - */ - stripEmptyTranslations: false, - - /** - * Add the subdirectories of the translations as a namespace for all keys. - * - * @property wrapTranslationsWithNamespace - * @type {Boolean} - * @default "false" - */ - wrapTranslationsWithNamespace: true, - }; -}; diff --git a/doc-app/config/environment.js b/doc-app/config/environment.js index e9163331..88e928e3 100644 --- a/doc-app/config/environment.js +++ b/doc-app/config/environment.js @@ -1,4 +1,4 @@ - +'use strict'; module.exports = function (environment) { const ENV = { @@ -41,8 +41,6 @@ module.exports = function (environment) { } if (environment === 'production') { - // Allow ember-cli-addon-docs to update the rootURL in compiled assets - ENV.rootURL = '/ember-common-ui/'; // here you can enable a production-specific feature } diff --git a/doc-app/config/targets.js b/doc-app/config/targets.js index 612c8f73..1e48e059 100644 --- a/doc-app/config/targets.js +++ b/doc-app/config/targets.js @@ -1,4 +1,4 @@ - +'use strict'; const browsers = [ 'last 1 Chrome versions', diff --git a/doc-app/ember-cli-build.cjs b/doc-app/ember-cli-build.cjs new file mode 100644 index 00000000..081a853d --- /dev/null +++ b/doc-app/ember-cli-build.cjs @@ -0,0 +1,34 @@ +'use strict'; + +const EmberApp = require('ember-cli/lib/broccoli/ember-app'); +const { compatBuild } = require('@embroider/compat'); + +module.exports = async function (defaults) { + const { buildOnce } = await import('@embroider/vite'); + const { setConfig } = await import('@warp-drive/core/build-config'); + + let app = new EmberApp(defaults, { + emberData: { + deprecations: { + // New projects can safely leave this deprecation disabled. + // If upgrading, to opt-into the deprecated behavior, set this to true and then follow: + // https://deprecations.emberjs.com/id/ember-data-deprecate-store-extends-ember-object + // before upgrading to Ember Data 6.0 + DEPRECATE_STORE_EXTENDS_EMBER_OBJECT: false, + }, + }, + // Add options here + }); + + setConfig(app, __dirname, { + compatWith: '4.12', + WarpDrive: { + activeLogging: { + LOG_REQUESTS: true, + }, + }, + deprecations: {}, + }); + + return compatBuild(app, buildOnce); +}; diff --git a/doc-app/ember-cli-build.js b/doc-app/ember-cli-build.js deleted file mode 100644 index 231f63fc..00000000 --- a/doc-app/ember-cli-build.js +++ /dev/null @@ -1,67 +0,0 @@ - - -const EmberApp = require('ember-cli/lib/broccoli/ember-app'); -const sideWatch = require('@embroider/broccoli-side-watch'); - -module.exports = function (defaults) { - const app = new EmberApp(defaults, { - trees: { - app: sideWatch('app', { - watching: [ - '@triptyk/ember-input', - '@triptyk/ember-ui', - '@triptyk/ember-input-validation', - ], - }), - }, - 'ember-cli-babel': { enableTypeScriptTransform: true }, - 'ember-cli-addon-docs': { - documentingAddonAt: '../packages/ember-input', - }, - postcssOptions: { - compile: { - enabled: true, - cacheInclude: [/.*\.(css|hbs|html|ts|gts|gjs)$/, /config\.js/], - includePaths: ['app', 'tests'], - plugins: [ - { - module: require('postcss-import'), - options: { - path: ['node_modules'], - }, - }, - require('tailwindcss')('tailwind.config.js'), // If you have a Tailwind config file. - ], - }, - }, - // Add options here - }); - - const { Webpack } = require('@embroider/webpack'); - return require('@embroider/compat').compatBuild(app, Webpack, { - staticAddonTestSupportTrees: true, - // https://github.com/ember-cli/ember-fetch/issues/622#issuecomment-860399885, - packagerOptions: { - webpackConfig: { - module: { - rules: [ - { - test: /\.(gif|svg|jpg|png)$/, - loader: 'file-loader', - }, - ], - }, - }, - }, - staticAddonTrees: false, - staticHelpers: true, - staticModifiers: true, - staticComponents: true, - staticEmberSource: true, - skipBabel: [ - { - package: 'qunit', - }, - ], - }); -}; diff --git a/doc-app/ember-intl.config.mjs b/doc-app/ember-intl.config.mjs new file mode 100644 index 00000000..33fd7483 --- /dev/null +++ b/doc-app/ember-intl.config.mjs @@ -0,0 +1,8 @@ +export default { + addonPaths: [], + buildOptions: { + fallbackLocale: 'en-us', + inputPath: 'translations', + wrapTranslationsWithNamespace: true, + }, +}; diff --git a/doc-app/eslint.config.mjs b/doc-app/eslint.config.mjs new file mode 100644 index 00000000..aa4734bc --- /dev/null +++ b/doc-app/eslint.config.mjs @@ -0,0 +1,127 @@ +/** + * Debugging: + * https://eslint.org/docs/latest/use/configure/debug + * ---------------------------------------------------- + * + * Print a file's calculated configuration + * + * npx eslint --print-config path/to/file.js + * + * Inspecting the config + * + * npx eslint --inspect-config + * + */ +import globals from 'globals'; +import js from '@eslint/js'; + +import ts from 'typescript-eslint'; + +import ember from 'eslint-plugin-ember/recommended'; + +import eslintConfigPrettier from 'eslint-config-prettier'; +import qunit from 'eslint-plugin-qunit'; +import n from 'eslint-plugin-n'; + +const parserOptions = { + esm: { + js: { + ecmaFeatures: { modules: true }, + ecmaVersion: 'latest', + }, + ts: { + projectService: true, + tsconfigRootDir: import.meta.dirname, + }, + }, +}; + +export default ts.config( + js.configs.recommended, + ember.configs.base, + ember.configs.gjs, + ember.configs.gts, + eslintConfigPrettier, + /** + * Ignores must be in their own object + * https://eslint.org/docs/latest/use/configure/ignore + */ + { + ignores: ['dist/', 'node_modules/', 'coverage/', '!**/.*'], + }, + /** + * https://eslint.org/docs/latest/use/configure/configuration-files#configuring-linter-options + */ + { + linterOptions: { + reportUnusedDisableDirectives: 'error', + }, + }, + { + files: ['**/*.{js,gjs}'], + languageOptions: { + parserOptions: parserOptions.esm.js, + globals: { + ...globals.browser, + }, + }, + }, + { + files: ['**/*.{ts,gts}'], + languageOptions: { + parser: ember.parser, + parserOptions: parserOptions.esm.ts, + }, + extends: [...ts.configs.recommendedTypeChecked, ember.configs.gts], + }, + { + files: ['tests/**/*-test.{js,gjs,ts,gts}'], + plugins: { + qunit, + }, + }, + /** + * CJS node files + */ + { + files: [ + '**/*.cjs', + 'config/**/*.js', + 'testem.js', + 'testem*.js', + '.prettierrc.js', + '.stylelintrc.js', + '.template-lintrc.js', + 'ember-cli-build.js', + ], + plugins: { + n, + }, + + languageOptions: { + sourceType: 'script', + ecmaVersion: 'latest', + globals: { + ...globals.node, + }, + }, + }, + /** + * ESM node files + */ + { + files: ['**/*.mjs'], + plugins: { + n, + }, + + languageOptions: { + sourceType: 'module', + ecmaVersion: 'latest', + parserOptions: parserOptions.esm.js, + globals: { + ...globals.node, + }, + }, + }, +); diff --git a/doc-app/app/index.html b/doc-app/index.html similarity index 52% rename from doc-app/app/index.html rename to doc-app/index.html index 153dc9b7..366c9e0e 100644 --- a/doc-app/app/index.html +++ b/doc-app/index.html @@ -8,16 +8,20 @@ {{content-for "head"}} - - + {{content-for "head-footer"}} {{content-for "body"}} - - + + {{content-for "body-footer"}} diff --git a/doc-app/package.json b/doc-app/package.json index ef52aefe..ad5e785d 100644 --- a/doc-app/package.json +++ b/doc-app/package.json @@ -1,6 +1,6 @@ { "name": "doc-app", - "version": "3.0.1", + "version": "0.0.0", "private": true, "description": "Small description for doc-app goes here", "repository": "", @@ -11,146 +11,123 @@ "test": "tests" }, "scripts": { - "_syncPnpm": "pnpm sync-dependencies-meta-injected", - "build": "ember build --environment=production", - "lint": "concurrently \"npm:lint:*(!fix)\" --names \"lint:\"", - "lint:css": "stylelint \"**/*.css\"", - "lint:css:fix": "concurrently \"npm:lint:css -- --fix\"", - "lint:fix": "concurrently \"npm:lint:*:fix\" --names \"fix:\"", + "build": "vite build", + "format": "prettier . --cache --write", + "lint": "concurrently \"pnpm:lint:*(!fix)\" --names \"lint:\" --prefixColors auto", + "lint:fix": "concurrently \"pnpm:lint:*:fix\" --names \"fix:\" --prefixColors auto && pnpm format", + "lint:format": "prettier . --cache --check", "lint:hbs": "ember-template-lint .", "lint:hbs:fix": "ember-template-lint . --fix", "lint:js": "eslint . --cache", - "lint:glint": "glint", - "lint:glint:fix": "eslint . --fix", "lint:js:fix": "eslint . --fix", - "lint:types": "tsc --noEmit", - "start": "concurrently 'ember serve' 'pnpm _syncPnpm --watch' --names 'tests serve,tests sync deps'", - "test": "concurrently \"npm:lint\" \"npm:test:*\" --names \"lint,test:\"", - "test:ember": "ember test" + "_syncPnpm": "pnpm sync-dependencies-meta-injected", + "lint:types": "ember-tsc", + "start": "concurrently \"pnpm turbo build:watch --filter '@triptyk/ember*'\" \"vite dev\"", + "test": "vite build --mode development && ember test --path dist" + }, + "exports": { + "./tests/*": "./tests/*", + "./*": "./app/*" }, - "dependenciesMeta": {}, "devDependencies": { - "@babel/core": "^7.25.2", + "@babel/core": "catalog:", + "@babel/eslint-parser": "catalog:", + "@babel/plugin-transform-runtime": "~7.28.5", + "@babel/plugin-transform-typescript": "catalog:", + "@babel/runtime": "catalog:", + "@ember-intl/vite": "^0.5.0", + "@ember/app-tsconfig": "catalog:", "@ember/optional-features": "catalog:", - "@ember/string": "^4.0.0", + "@ember/string": "catalog:", "@ember/test-helpers": "catalog:", - "@embroider/broccoli-side-watch": "^1.0.1", + "@ember/test-waiters": "catalog:", "@embroider/compat": "catalog:", + "@embroider/config-meta-loader": "^1.0.0", "@embroider/core": "catalog:", - "@embroider/webpack": "catalog:", - "@eonasdan/tempus-dominus": "^6.9.11", + "@embroider/legacy-inspector-support": "^0.1.3", + "@embroider/macros": "~1.19.6", + "@embroider/router": "~3.0.6", + "@embroider/vite": "~1.5.0", + "@eslint/js": "catalog:", "@glimmer/component": "catalog:", - "@glimmer/tracking": "catalog:", - "@glint/core": "catalog:", - "@glint/environment-ember-loose": "catalog:", - "@glint/environment-ember-template-imports": "^1.5.0", + "@glint/ember-tsc": "catalog:", "@glint/template": "catalog:", + "@rollup/plugin-babel": "catalog:", + "@tailwindcss/vite": "^4.1.18", "@triptyk/ember-input": "workspace:*", "@triptyk/ember-input-validation": "workspace:*", "@triptyk/ember-ui": "workspace:*", - "@tsconfig/ember": "catalog:", - "@types/ember": "catalog:", - "@types/ember-data": "^4.4.16", - "@types/ember-data__adapter": "catalog:", - "@types/ember-data__model": "catalog:", - "@types/ember-data__serializer": "catalog:", - "@types/ember-data__store": "^4.0.7", - "@types/ember__application": "catalog:", - "@types/ember__array": "catalog:", - "@types/ember__component": "catalog:", - "@types/ember__controller": "catalog:", - "@types/ember__debug": "catalog:", - "@types/ember__destroyable": "catalog:", - "@types/ember__engine": "catalog:", - "@types/ember__error": "catalog:", - "@types/ember__helper": "catalog:", - "@types/ember__modifier": "catalog:", - "@types/ember__object": "catalog:", - "@types/ember__owner": "catalog:", - "@types/ember__polyfills": "catalog:", - "@types/ember__routing": "catalog:", - "@types/ember__runloop": "catalog:", - "@types/ember__service": "catalog:", - "@types/ember__string": "catalog:", - "@types/ember__template": "catalog:", - "@types/ember__test": "catalog:", - "@types/ember__utils": "catalog:", + "@triptyk/ember-utils": "workspace:*", "@types/qunit": "catalog:", "@types/rsvp": "catalog:", - "@typescript-eslint/eslint-plugin": "catalog:", - "@typescript-eslint/parser": "catalog:", - "autoprefixer": "^10.4.20", - "broccoli-asset-rev": "catalog:", + "@vitest/browser": "^4.0.18", + "@vitest/browser-webdriverio": "^4.0.18", + "@warp-drive/core": "catalog:", + "@warp-drive/core-types": "~5.8.1", + "@warp-drive/ember": "~5.8.1", + "@warp-drive/json-api": "~5.8.1", + "@warp-drive/legacy": "~5.8.1", + "@warp-drive/schema-record": "^5.8.1", + "@warp-drive/utilities": "~5.8.1", + "babel-plugin-ember-template-compilation": "catalog:", "concurrently": "catalog:", - "daisyui": "^4.12.14", - "ember-a11y-testing": "^7.0.2", - "ember-auto-import": "~2.10.0", + "daisyui": "~5.5.14", + "decorator-transforms": "catalog:", + "ember-a11y-testing": "^7.1.3", + "ember-auto-import": "^2.12.0", "ember-cli": "catalog:", - "ember-cli-addon-docs": "catalog:", - "ember-cli-addon-docs-yuidoc": "catalog:", - "ember-cli-app-version": "catalog:", "ember-cli-babel": "catalog:", - "ember-cli-clean-css": "catalog:", - "ember-cli-dependency-checker": "catalog:", - "ember-cli-deploy": "catalog:", - "ember-cli-deploy-build": "catalog:", - "ember-cli-deploy-git": "catalog:", - "ember-cli-deploy-git-ci": "catalog:", - "ember-cli-htmlbars": "catalog:", - "ember-cli-inject-live-reload": "catalog:", - "ember-cli-page-object": "^2.3.1", - "ember-cli-postcss": "^8.2.0", - "ember-concurrency": "4.0.2", - "ember-data": "catalog:", - "ember-fetch": "catalog:", - "ember-immer-changeset": "^1.0.2", - "ember-intl": "^7.0.7", + "ember-cli-deprecation-workflow": "^4.0.0", + "ember-cli-page-object": "^2.3.2", + "ember-concurrency": "catalog:", + "ember-immer-changeset": "catalog:", + "ember-intl": "catalog:", "ember-load-initializers": "catalog:", - "ember-modifier": "^4.2.0", + "ember-modifier": "catalog:", "ember-page-title": "catalog:", - "ember-power-select": "^8.4.0", + "ember-power-select": "catalog:", "ember-qunit": "catalog:", "ember-resolver": "catalog:", - "ember-source": "~5.12.0", - "ember-template-imports": "~4.2.0", - "ember-template-lint": "^6.0.0", + "ember-source": "catalog:", + "ember-template-lint": "^7.9.3", + "ember-vitest": "^0.3.3", "ember-welcome-page": "catalog:", - "eslint": "^8.57.1", + "eslint": "catalog:", "eslint-config-prettier": "catalog:", - "eslint-plugin-ember": "^12.2.1", + "eslint-plugin-ember": "catalog:", "eslint-plugin-n": "catalog:", - "eslint-plugin-prettier": "catalog:", "eslint-plugin-qunit": "catalog:", - "file-loader": "^6.2.0", - "loader.js": "catalog:", - "msw": "^1.3.3", + "globals": "catalog:", + "msw": "~2.12.7", "pnpm-sync-dependencies-meta-injected": "catalog:", - "postcss": "^8.4.49", - "postcss-import": "^16.1.0", - "postcss-loader": "^8.1.1", "prettier": "catalog:", + "prettier-plugin-ember-template-tag": "catalog:", "qunit": "catalog:", "qunit-dom": "catalog:", - "rsvp": "catalog:", + "shiki": "^3.22.0", "stylelint": "catalog:", "stylelint-config-standard": "catalog:", - "stylelint-prettier": "catalog:", - "tailwindcss": "^3.4.14", - "tracked-built-ins": "^3.3.0", - "typescript": "^5.6.2", - "webpack": "^5.95.0", - "yup": "^1.4.0" + "tailwindcss": "^4.1.18", + "testem": "^3.16.0", + "typescript": "catalog:", + "typescript-eslint": "catalog:", + "vite": "catalog:", + "vitest": "^4.0.18", + "webdriverio": "^9.23.2", + "zod": "catalog:" }, "engines": { - "node": ">= 18" + "node": ">= 20" }, "ember": { "edition": "octane" }, "msw": { - "workerDirectory": "public" + "workerDirectory": [ + "public" + ] }, - "volta": { - "node": "20.20.0" + "dependencies": { + "ember-showdown": "2.0.0-pre.1" } } diff --git a/doc-app/postcss.config.js b/doc-app/postcss.config.js deleted file mode 100644 index 12a703d9..00000000 --- a/doc-app/postcss.config.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - plugins: { - tailwindcss: {}, - autoprefixer: {}, - }, -}; diff --git a/doc-app/public/assets/default.jpg b/doc-app/public/assets/default.jpg deleted file mode 100644 index 2fa42bd0..00000000 Binary files a/doc-app/public/assets/default.jpg and /dev/null differ diff --git a/doc-app/public/assets/edit.svg b/doc-app/public/assets/edit.svg deleted file mode 100644 index 2c100be3..00000000 --- a/doc-app/public/assets/edit.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/doc-app/public/assets/icons/arrow-down.svg b/doc-app/public/assets/icons/arrow-down.svg deleted file mode 100644 index 54fe39f9..00000000 --- a/doc-app/public/assets/icons/arrow-down.svg +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - diff --git a/doc-app/public/assets/icons/check-solid.svg b/doc-app/public/assets/icons/check-solid.svg deleted file mode 100644 index e94b0baa..00000000 --- a/doc-app/public/assets/icons/check-solid.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/doc-app/public/assets/icons/kebab.svg b/doc-app/public/assets/icons/kebab.svg deleted file mode 100644 index 7e509dee..00000000 --- a/doc-app/public/assets/icons/kebab.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/doc-app/public/assets/icons/plus.svg b/doc-app/public/assets/icons/plus.svg deleted file mode 100644 index 0ba260af..00000000 --- a/doc-app/public/assets/icons/plus.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/doc-app/public/assets/icons/trash.svg b/doc-app/public/assets/icons/trash.svg deleted file mode 100644 index ccac2089..00000000 --- a/doc-app/public/assets/icons/trash.svg +++ /dev/null @@ -1,11 +0,0 @@ - - Bin - A line styled icon from Orion Icon Library. - - - \ No newline at end of file diff --git a/doc-app/public/assets/img/ember_common_ui_logo.png b/doc-app/public/assets/img/ember_common_ui_logo.png new file mode 100644 index 00000000..79fd849c Binary files /dev/null and b/doc-app/public/assets/img/ember_common_ui_logo.png differ diff --git a/doc-app/public/assets/img/ember_common_ui_logo.svg b/doc-app/public/assets/img/ember_common_ui_logo.svg new file mode 100644 index 00000000..84180555 --- /dev/null +++ b/doc-app/public/assets/img/ember_common_ui_logo.svg @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/doc-app/app/templates/docs/ember-input-validation/checkbox.md b/doc-app/public/docs/ember-input-validation/checkbox.md similarity index 64% rename from doc-app/app/templates/docs/ember-input-validation/checkbox.md rename to doc-app/public/docs/ember-input-validation/checkbox.md index 2f3b2295..caa843bb 100644 --- a/doc-app/app/templates/docs/ember-input-validation/checkbox.md +++ b/doc-app/public/docs/ember-input-validation/checkbox.md @@ -2,27 +2,27 @@ Ember input validation/checkbox content - - - - - -
- {{#each T.errors as |error|}} - - {{error.message}} - - {{/each}} -
-
-
- + + + + + +
+{{#each T.errors as |error|}} + +{{error.message}} + +{{/each}} +
+
+
+
### Args @@ -52,4 +52,4 @@ the function receive the value and the event as args. **[data-has-error="false"]** : CSS element when there is no error. -**[data-has-error="true"]** : CSS element when an error is caught. when it's true error was displayed on the aside element. \ No newline at end of file +**[data-has-error="true"]** : CSS element when an error is caught. when it's true error was displayed on the aside element. diff --git a/doc-app/app/templates/docs/ember-input-validation/datepicker.md b/doc-app/public/docs/ember-input-validation/datepicker.md similarity index 79% rename from doc-app/app/templates/docs/ember-input-validation/datepicker.md rename to doc-app/public/docs/ember-input-validation/datepicker.md index 77083e70..59be4620 100644 --- a/doc-app/app/templates/docs/ember-input-validation/datepicker.md +++ b/doc-app/public/docs/ember-input-validation/datepicker.md @@ -5,26 +5,27 @@ A date picker component with built-in validation support using changesets. This ## Basic Usage - - - - -
- {{#each D.errors as |error|}} - - {{error.message}} - - {{/each}} -
-
-
- + + + + + +
+{{#each D.errors as |error|}} + +{{error.message}} + +{{/each}} +
+
+
+
## Arguments @@ -84,6 +85,7 @@ See the [TpkDatepicker documentation](../ember-input/datepicker) for all availab ## Validation The component automatically: + - Updates the changeset when dates are selected - Displays validation state via the `data-has-error` attribute - Handles single dates, date ranges, and multiple dates based on `@mode` diff --git a/doc-app/app/templates/docs/ember-input-validation/file.md b/doc-app/public/docs/ember-input-validation/file.md similarity index 63% rename from doc-app/app/templates/docs/ember-input-validation/file.md rename to doc-app/public/docs/ember-input-validation/file.md index 7da15050..6501b621 100644 --- a/doc-app/app/templates/docs/ember-input-validation/file.md +++ b/doc-app/public/docs/ember-input-validation/file.md @@ -5,51 +5,53 @@ A file input component with built-in validation support using changesets. This c ## Basic Usage - - - - -
- {{#each F.errors as |error|}} - - {{error.message}} - - {{/each}} -
-
-
- + + + + + +
+{{#each F.errors as |error|}} + +{{error.message}} + +{{/each}} +
+
+
+
## Multiple File Upload - - - - -
- {{#each F.errors as |error|}} - - {{error.message}} - - {{/each}} -
-
-
- + + + + + +
+{{#each F.errors as |error|}} + +{{error.message}} + +{{/each}} +
+
+
+
## Arguments @@ -91,6 +93,7 @@ A file input component with built-in validation support using changesets. This c ## Validation The component automatically: + - Updates the changeset when files are selected - Stores a single `File` object when `@multiple` is false - Stores an array of `File` objects when `@multiple` is true diff --git a/doc-app/app/templates/docs/ember-input-validation/input.md b/doc-app/public/docs/ember-input-validation/input.md similarity index 64% rename from doc-app/app/templates/docs/ember-input-validation/input.md rename to doc-app/public/docs/ember-input-validation/input.md index de470746..68aa76dc 100644 --- a/doc-app/app/templates/docs/ember-input-validation/input.md +++ b/doc-app/public/docs/ember-input-validation/input.md @@ -3,24 +3,25 @@ Ember input validation/input content - - - - -
- {{#each I.errors as |error|}} - - {{error.message}} - - {{/each}} -
-
-
- + + + + + +
+{{#each I.errors as |error|}} + +{{error.message}} + +{{/each}} +
+
+
+
### Args @@ -46,7 +47,7 @@ the function receive the value and the event as args. **.tpk-input** : CSS class for styling the input of the checkbox (label and input box). -**.tpk-input input** : CSS class for styling the targeted input. +**.tpk-input input** : CSS class for styling the targeted input. **.tpk-label** : CSS class for styling the label of the input. diff --git a/doc-app/app/templates/docs/ember-input-validation/installation.md b/doc-app/public/docs/ember-input-validation/installation.md similarity index 86% rename from doc-app/app/templates/docs/ember-input-validation/installation.md rename to doc-app/public/docs/ember-input-validation/installation.md index a2f56d65..049cb5d1 100644 --- a/doc-app/app/templates/docs/ember-input-validation/installation.md +++ b/doc-app/public/docs/ember-input-validation/installation.md @@ -20,7 +20,6 @@ import '@glint/environment-ember-loose'; import type EmberInputValidationRegistry from '@triptyk/ember-input-validation/template-registry'; declare module '@glint/environment-ember-loose/registry' { - export default interface Registry - extends EmberInputValidationRegistry {} + export default interface Registry extends EmberInputValidationRegistry {} } ``` diff --git a/doc-app/app/templates/docs/ember-input-validation/prefabs/bic.md b/doc-app/public/docs/ember-input-validation/prefabs/bic.md similarity index 51% rename from doc-app/app/templates/docs/ember-input-validation/prefabs/bic.md rename to doc-app/public/docs/ember-input-validation/prefabs/bic.md index c28d778e..b9630db8 100644 --- a/doc-app/app/templates/docs/ember-input-validation/prefabs/bic.md +++ b/doc-app/public/docs/ember-input-validation/prefabs/bic.md @@ -3,33 +3,32 @@ This is an input with a built-in mask for BIC. The mask should be compatible for any BIC and text can only be in capital letters. - - - - - - - + + + + + + ## Usage @@ -47,5 +46,5 @@ The `TpkValidationBic` component is used for a simple input. - `@placeholder`: The placeholder text for the input field. - `@mandatory`: Whether the textarea field is mandatory. - `@disabled`: Whether the input field is disabled. -- `@onChange`: The action to be called when the selection changes. +- `@onChange`: The action to be called when the selection changes. - `@changeEvent`: The event to trigger the onChange action. diff --git a/doc-app/public/docs/ember-input-validation/prefabs/checkbox.md b/doc-app/public/docs/ember-input-validation/prefabs/checkbox.md new file mode 100644 index 00000000..d799cf77 --- /dev/null +++ b/doc-app/public/docs/ember-input-validation/prefabs/checkbox.md @@ -0,0 +1,43 @@ +# Checkbox + +This component provides a checkbox. + + + + + + + + + + + +## Mandatory properties + +- `@validationField`: The field name in the changeset for validation. +- `@changeset`: The changeset object for form validation. + +## Optional properties + +- `@label`: The label for the input field. +- `@disabled`: Whether the input field is disabled. +- `@mandatory`: Whether the textarea field is mandatory. +- `@onChange`: The action to be called when the selection changes. +- `@changeEvent`: The event to trigger the onChange action. diff --git a/doc-app/app/templates/docs/ember-input-validation/prefabs/currency.md b/doc-app/public/docs/ember-input-validation/prefabs/currency.md similarity index 50% rename from doc-app/app/templates/docs/ember-input-validation/prefabs/currency.md rename to doc-app/public/docs/ember-input-validation/prefabs/currency.md index abba3777..e1bfde2f 100644 --- a/doc-app/app/templates/docs/ember-input-validation/prefabs/currency.md +++ b/doc-app/public/docs/ember-input-validation/prefabs/currency.md @@ -1,36 +1,37 @@ # Currency -The currency validation prefab is used to validate currency input fields. +The currency validation prefab is used to validate currency input fields. It is provided with a mask to format the input field as currency. The only supported format is euro at the moment. - - - - + + + - - + + + ## Mandatory properties @@ -43,5 +44,5 @@ The only supported format is euro at the moment. - `@label`: The label for the input field. - `@disabled`: Whether the input field is disabled. - `@mandatory`: Whether the textarea field is mandatory. -- `@onChange`: The action to be called when the selection changes. -- `@changeEvent`: The event to trigger the onChange action. \ No newline at end of file +- `@onChange`: The action to be called when the selection changes. +- `@changeEvent`: The event to trigger the onChange action. diff --git a/doc-app/app/templates/docs/ember-input-validation/prefabs/datepicker-range.md b/doc-app/public/docs/ember-input-validation/prefabs/datepicker-range.md similarity index 73% rename from doc-app/app/templates/docs/ember-input-validation/prefabs/datepicker-range.md rename to doc-app/public/docs/ember-input-validation/prefabs/datepicker-range.md index 1ccb9425..27e317c8 100644 --- a/doc-app/app/templates/docs/ember-input-validation/prefabs/datepicker-range.md +++ b/doc-app/public/docs/ember-input-validation/prefabs/datepicker-range.md @@ -3,25 +3,25 @@ This component provides a datepicker with range selection and built-in validation. - - - - - - + + + + + + ## Usage diff --git a/doc-app/app/templates/docs/ember-input-validation/prefabs/datepicker.md b/doc-app/public/docs/ember-input-validation/prefabs/datepicker.md similarity index 78% rename from doc-app/app/templates/docs/ember-input-validation/prefabs/datepicker.md rename to doc-app/public/docs/ember-input-validation/prefabs/datepicker.md index 49f0c923..8f994d56 100644 --- a/doc-app/app/templates/docs/ember-input-validation/prefabs/datepicker.md +++ b/doc-app/public/docs/ember-input-validation/prefabs/datepicker.md @@ -3,25 +3,25 @@ This component provides a datepicker and built-in validation. - - - - - - + + + + + + ## Usage diff --git a/doc-app/public/docs/ember-input-validation/prefabs/email.md b/doc-app/public/docs/ember-input-validation/prefabs/email.md new file mode 100644 index 00000000..f035d055 --- /dev/null +++ b/doc-app/public/docs/ember-input-validation/prefabs/email.md @@ -0,0 +1,40 @@ +# Input Email + +This is an input with type Email + + + + + + + + + + +## Mandatory properties + +- `@validationField`: The field name in the changeset for validation. +- `@changeset`: The changeset object for form validation. + +## Optional properties + +- `@label`: The label for the input field. +- `@disabled`: Whether the input field is disabled. +- `@mandatory`: Whether the textarea field is mandatory. +- `@onChange`: The action to be called when the selection changes. +- `@changeEvent`: The event to trigger the onChange action. diff --git a/doc-app/public/docs/ember-input-validation/prefabs/file-list.md b/doc-app/public/docs/ember-input-validation/prefabs/file-list.md new file mode 100644 index 00000000..39957ca1 --- /dev/null +++ b/doc-app/public/docs/ember-input-validation/prefabs/file-list.md @@ -0,0 +1,43 @@ +# Input File + +This is an input with a dropzone that allows to upload multiple files. You can also find a list of uploaded files and dowload/delete theme. + + + + + + + + + + +## Mandatory properties + +- `@validationField`: The field name in the changeset for validation. +- `@changeset`: The changeset object for form validation. + +## Optional properties + +- `@label`: The label for the input field. +- `@disabled`: Whether the input field is disabled. +- `@mandatory`: Whether the input file multiple field is mandatory. +- `@onChange`: The action to be called when the selection changes. +- `@disableDownload`: Whether the download button is disabled. +- `@placeholder`: The placeholder for the dropzone area. diff --git a/doc-app/public/docs/ember-input-validation/prefabs/file.md b/doc-app/public/docs/ember-input-validation/prefabs/file.md new file mode 100644 index 00000000..a119cea4 --- /dev/null +++ b/doc-app/public/docs/ember-input-validation/prefabs/file.md @@ -0,0 +1,41 @@ +# Input File + +This is an input with type File + + + + + + + + + + +## Mandatory properties + +- `@validationField`: The field name in the changeset for validation. +- `@changeset`: The changeset object for form validation. + +## Optional properties + +- `@label`: The label for the input field. +- `@disabled`: Whether the input field is disabled. +- `@mandatory`: Whether the textarea field is mandatory. +- `@onChange`: The action to be called when the selection changes. +- `@changeEvent`: The event to trigger the onChange action. diff --git a/doc-app/app/templates/docs/ember-input-validation/prefabs/iban.md b/doc-app/public/docs/ember-input-validation/prefabs/iban.md similarity index 55% rename from doc-app/app/templates/docs/ember-input-validation/prefabs/iban.md rename to doc-app/public/docs/ember-input-validation/prefabs/iban.md index cad421d2..07e7f630 100644 --- a/doc-app/app/templates/docs/ember-input-validation/prefabs/iban.md +++ b/doc-app/public/docs/ember-input-validation/prefabs/iban.md @@ -7,28 +7,28 @@ The value is formated so that there 4 character then a space up to the end of th If the country is not supported, the input value will be blocked after 2 uppercase letters - - - - - - + + + + + + ## Mandatory properties @@ -41,5 +41,5 @@ If the country is not supported, the input value will be blocked after 2 upperca - `@label`: The label for the input field. - `@disabled`: Whether the input field is disabled. - `@mandatory`: Whether the textarea field is mandatory. -- `@onChange`: The action to be called when the selection changes. +- `@onChange`: The action to be called when the selection changes. - `@changeEvent`: The event to trigger the onChange action. diff --git a/doc-app/app/templates/docs/ember-input-validation/prefabs/input.md b/doc-app/public/docs/ember-input-validation/prefabs/input.md similarity index 60% rename from doc-app/app/templates/docs/ember-input-validation/prefabs/input.md rename to doc-app/public/docs/ember-input-validation/prefabs/input.md index f31b83fc..173c1ce2 100644 --- a/doc-app/app/templates/docs/ember-input-validation/prefabs/input.md +++ b/doc-app/public/docs/ember-input-validation/prefabs/input.md @@ -3,28 +3,28 @@ This component provides an input. - - - - - - - + + + + + + + ## Usage @@ -46,6 +46,5 @@ The `TpkValidationInput` component is used for a simple input. If you want use a - `@maskOptions`: The options to apply to the mask. - `@unmaskValue`: Whether to unmask the value before setting it in the changeset. - `@disabled`: Whether the input field is disabled. -- `@onChange`: The action to be called when the selection changes. +- `@onChange`: The action to be called when the selection changes. - `@changeEvent`: The event to trigger the onChange action. - diff --git a/doc-app/public/docs/ember-input-validation/prefabs/integer.md b/doc-app/public/docs/ember-input-validation/prefabs/integer.md new file mode 100644 index 00000000..5921ca82 --- /dev/null +++ b/doc-app/public/docs/ember-input-validation/prefabs/integer.md @@ -0,0 +1,44 @@ +# Integer + +The integer validation input prefab is used when an integer input is required. + +It prevents decimal numbers by disallowing the comma and period. + +The integer validation input can be restricted to a minimum of 0 or allow negative numbers. + + + + + + + + + diff --git a/doc-app/app/templates/docs/ember-input-validation/prefabs/mobile.md b/doc-app/public/docs/ember-input-validation/prefabs/mobile.md similarity index 61% rename from doc-app/app/templates/docs/ember-input-validation/prefabs/mobile.md rename to doc-app/public/docs/ember-input-validation/prefabs/mobile.md index d2bb48f2..1b44e0d1 100644 --- a/doc-app/app/templates/docs/ember-input-validation/prefabs/mobile.md +++ b/doc-app/public/docs/ember-input-validation/prefabs/mobile.md @@ -6,24 +6,24 @@ You've 5 prefixes : **Luxembourg, Deutshland, Netherlands, Belgium and France.** - - - + + + diff --git a/doc-app/public/docs/ember-input-validation/prefabs/national-number.md b/doc-app/public/docs/ember-input-validation/prefabs/national-number.md new file mode 100644 index 00000000..5db93ed0 --- /dev/null +++ b/doc-app/public/docs/ember-input-validation/prefabs/national-number.md @@ -0,0 +1,30 @@ +# Input national number + +This is an input with a built-in mask for a belgian national number. +It makes so that the national number is written in a pretty format similar +to the one on your belgian ID. + + + + + + + + + diff --git a/doc-app/public/docs/ember-input-validation/prefabs/number.md b/doc-app/public/docs/ember-input-validation/prefabs/number.md new file mode 100644 index 00000000..f888dc67 --- /dev/null +++ b/doc-app/public/docs/ember-input-validation/prefabs/number.md @@ -0,0 +1,51 @@ +# Number + +The number validation input can be blocked at a minimum of 0 or be a negative number + + + + + + + + + + diff --git a/doc-app/public/docs/ember-input-validation/prefabs/password.md b/doc-app/public/docs/ember-input-validation/prefabs/password.md new file mode 100644 index 00000000..f2a91e94 --- /dev/null +++ b/doc-app/public/docs/ember-input-validation/prefabs/password.md @@ -0,0 +1,34 @@ +# Input password + +This is a password input field. + + + + + + + + + diff --git a/doc-app/app/templates/docs/ember-input-validation/prefabs/radio-group.md b/doc-app/public/docs/ember-input-validation/prefabs/radio-group.md similarity index 76% rename from doc-app/app/templates/docs/ember-input-validation/prefabs/radio-group.md rename to doc-app/public/docs/ember-input-validation/prefabs/radio-group.md index 146703cd..f8dbf1f1 100644 --- a/doc-app/app/templates/docs/ember-input-validation/prefabs/radio-group.md +++ b/doc-app/public/docs/ember-input-validation/prefabs/radio-group.md @@ -3,13 +3,13 @@ This component provides a group of radio buttons. - - + @@ -19,11 +19,11 @@ This component provides a group of radio buttons.


- @@ -32,13 +32,14 @@ This component provides a group of radio buttons.

selected : {{changeset-get this.changesetWithErrors 'radio'}}

-
- + + +
## Usage -The `TpkValidationRadioGroup` component is used for a group of radio button. +The `TpkValidationRadioGroup` component is used for a group of radio button. ## Mandatory properties @@ -52,11 +53,11 @@ The `TpkValidationRadioGroup` component is used for a group of radio button. - `@mandatory`: Whether the textarea field is mandatory. - `@disabled`: Whether the input field is disabled. - `@classless`: Whether to apply default classes to the component. -- `@onChange`: The action to be called when the selection changes. +- `@onChange`: The action to be called when the selection changes. ## Css classes -- `.tpk-validation-radio-container` : CSS class which includes the label and the group +- `.tpk-validation-radio-container` : CSS class which includes the label and the group - `.tpk-validation-radio-group-label` : CSS class for the label of the group - `.tpk-validation-radio-group-group` : CSS class for the group of radio buttons - `.tpk-radio` : CSS class for styling the input of the radio button (label and input box). diff --git a/doc-app/app/templates/docs/ember-input-validation/prefabs/radio.md b/doc-app/public/docs/ember-input-validation/prefabs/radio.md similarity index 59% rename from doc-app/app/templates/docs/ember-input-validation/prefabs/radio.md rename to doc-app/public/docs/ember-input-validation/prefabs/radio.md index 87ca8692..d40c188f 100644 --- a/doc-app/app/templates/docs/ember-input-validation/prefabs/radio.md +++ b/doc-app/public/docs/ember-input-validation/prefabs/radio.md @@ -3,20 +3,22 @@ This component provides a radio button. - - - -
- + + + + +
+ selected : {{changeset-get this.changeset 'radio'}} -
- + +
+
## Usage -The `TpkValidationRadio` component is used for a simple radio button. +The `TpkValidationRadio` component is used for a simple radio button. ## Mandatory properties @@ -30,7 +32,7 @@ The `TpkValidationRadio` component is used for a simple radio button. - `@mandatory`: Whether the textarea field is mandatory. - `@disabled`: Whether the input field is disabled. - `@classless`: Whether to apply default classes to the component. -- `@onChange`: The action to be called when the selection changes. +- `@onChange`: The action to be called when the selection changes. ## Css classes diff --git a/doc-app/app/templates/docs/ember-input-validation/prefabs/select-create.md b/doc-app/public/docs/ember-input-validation/prefabs/select-create.md similarity index 52% rename from doc-app/app/templates/docs/ember-input-validation/prefabs/select-create.md rename to doc-app/public/docs/ember-input-validation/prefabs/select-create.md index 052f233b..bdab944d 100644 --- a/doc-app/app/templates/docs/ember-input-validation/prefabs/select-create.md +++ b/doc-app/public/docs/ember-input-validation/prefabs/select-create.md @@ -4,42 +4,48 @@ This component provides a powerfull select with ability to create a new value an It uses also toString() in order to display the options and the selected element. -In example: +In example: ```ts - options = [ - { label: 'Option 1', value: 'option-1', toString() { return `${this.label}`; } } - ]; +options = [ + { + label: 'Option 1', + value: 'option-1', + toString() { + return `${this.label}`; + }, + }, +]; ``` - - - - - - + + + + + + ## Mandatory properties @@ -58,7 +64,7 @@ In example: - `@initiallyOpened`: Whether the select dropdown is initially opened. - `@allowClear`: Whether to show a button to clear the selection. - `@mandatory`: Whether the textarea field is mandatory. -- `@onChange`: The action to be called when the selection changes. +- `@onChange`: The action to be called when the selection changes. - `@labelComponent`: The custom component to use for the label. - `@selectedItemComponent`: The custom component to use for the selected item. - `@placeholderComponent`: The custom component to use for the placeholder @@ -75,37 +81,38 @@ In example: ### Select create multiple - - - - + + + + ### Select create with specific label and hide create option when value already exist + To test it, write Romain in input - - - - + + + + diff --git a/doc-app/public/docs/ember-input-validation/prefabs/select-search.md b/doc-app/public/docs/ember-input-validation/prefabs/select-search.md new file mode 100644 index 00000000..d9eac9eb --- /dev/null +++ b/doc-app/public/docs/ember-input-validation/prefabs/select-search.md @@ -0,0 +1,117 @@ +# Select Search + +This component provides a powerfull select with search and has built-in validation. It uses [ember-power-select](https://ember-power-select.com/). + +It uses also toString() in order to display the options and the selected element. + +In example: + +```ts +options = [ + { + label: 'Option 1', + value: 'option-1', + toString() { + return `${this.label}`; + }, + }, +]; +``` + + + + + + + + + + +## Mandatory properties + +- `@validationField`: The field name in the changeset for validation. +- `@changeset`: The changeset object for form validation. +- `@options`: The options to display in the select dropdown. +- `@onSearch`: The action to be called when user's typing in the input. + +## Optional properties + +- `@label`: The label for the input field. +- `@placeholder`: The placeholder text for the input field. +- `@disabled`: Whether the input field is disabled. +- `@multiple`: Whether multiple selections are allowed. +- `@initiallyOpened`: Whether the select dropdown is initially opened. +- `@mandatory`: Whether the textarea field is mandatory. +- `@allowClear`: Whether to show a button to clear the selection. +- `@onChange`: The action to be called when the selection changes. +- `@labelComponent`: The custom component to use for the label. +- `@selectedItemComponent`: The custom component to use for the selected item. +- `@placeholderComponent`: The custom component to use for the placeholder +- `@searchPlaceholder`: The placeholder text for the search input. +- `@searchMessage`: Message shown in options list when no search has been entered and there are no options. +- `@loadingMessage`: Message shown in options list when loading options. +- `@noMatchesMessage`: Message shown in options list when no matches are found. + +## Examples + +### Select Search multiple with allowClear + + + + + + + + +### Select Search with all label translate and initially opened + + + + + + + diff --git a/doc-app/public/docs/ember-input-validation/prefabs/select.md b/doc-app/public/docs/ember-input-validation/prefabs/select.md new file mode 100644 index 00000000..2706dc57 --- /dev/null +++ b/doc-app/public/docs/ember-input-validation/prefabs/select.md @@ -0,0 +1,143 @@ +# Select + +This component provides a powerfull select with multitude features and has built-in validation. It uses [ember-power-select](https://ember-power-select.com/). + +It uses also toString() in order to display the options and the selected element. + +In example: + +```ts +options = [ + { + label: 'Option 1', + value: 'option-1', + toString() { + return `${this.label}`; + }, + }, +]; +``` + + + + + + + + + + +## Mandatory properties + +- `@validationField`: The field name in the changeset for validation. +- `@changeset`: The changeset object for form validation. +- `@options`: The options to display in the select dropdown. + +## Optional properties + +- `@label`: The label for the input field. +- `@placeholder`: The placeholder text for the input field. +- `@disabled`: Whether the input field is disabled. +- `@multiple`: Whether multiple selections are allowed. +- `@mandatory`: Whether the textarea field is mandatory. +- `@initiallyOpened`: Whether the select dropdown is initially opened. +- `@allowClear`: Whether to show a button to clear the selection. +- `@onChange`: The action to be called when the selection changes. +- `@labelComponent`: The custom component to use for the label. +- `@selectedItemComponent`: The custom component to use for the selected item. +- `@placeholderComponent`: The custom component to use for the placeholder + +## Examples + +### Select multiple + + + + + + + + +### Select with specific component for label + + + + + + + + + + + + +### Select with allowClear + + + + + + + + +### Select initially opened + + + + + + + diff --git a/doc-app/public/docs/ember-input-validation/prefabs/textarea.md b/doc-app/public/docs/ember-input-validation/prefabs/textarea.md new file mode 100644 index 00000000..537a1199 --- /dev/null +++ b/doc-app/public/docs/ember-input-validation/prefabs/textarea.md @@ -0,0 +1,58 @@ +# Textarea + +This component provides an textarea. + + + + + + + + + + +## Mandatory properties + +- `@validationField`: The field name in the changeset for validation. +- `@changeset`: The changeset object for form validation. + +## Optional properties + +- `@label`: The label for the textarea field. +- `@placeholder`: The placeholder text for the textarea field. +- `@mandatory`: Whether the textarea field is mandatory. +- `@disabled`: Whether the input field is disabled. +- `@onChange`: The action to be called when the selection changes. +- `@changeEvent`: The event to trigger the onChange action. +- `@maxLength`: The maximum length of the textarea field. + +## Examples + +### Textarea with maxLength + + + + + + + diff --git a/doc-app/app/templates/docs/ember-input-validation/prefabs/timepicker.md b/doc-app/public/docs/ember-input-validation/prefabs/timepicker.md similarity index 66% rename from doc-app/app/templates/docs/ember-input-validation/prefabs/timepicker.md rename to doc-app/public/docs/ember-input-validation/prefabs/timepicker.md index 1bd6f80b..c59fcffc 100644 --- a/doc-app/app/templates/docs/ember-input-validation/prefabs/timepicker.md +++ b/doc-app/public/docs/ember-input-validation/prefabs/timepicker.md @@ -3,26 +3,26 @@ This component provides a timepicker with built-in validation. - - - - - - + + + + + + ## Usage @@ -46,4 +46,3 @@ The `TpkValidationTimepicker` component is designed for easy integration into yo - `@placeholder`: The placeholder text for the input field. - `@clearButton`: Whether to show a button to clear the input field. - `@locale`: The locale to be used for date formatting. - diff --git a/doc-app/app/templates/docs/ember-input-validation/prefabs/vat.md b/doc-app/public/docs/ember-input-validation/prefabs/vat.md similarity index 57% rename from doc-app/app/templates/docs/ember-input-validation/prefabs/vat.md rename to doc-app/public/docs/ember-input-validation/prefabs/vat.md index 91d8a68f..aecb6eef 100644 --- a/doc-app/app/templates/docs/ember-input-validation/prefabs/vat.md +++ b/doc-app/public/docs/ember-input-validation/prefabs/vat.md @@ -6,28 +6,28 @@ Natively, it does supports belgium, french, luxembourgish, dutch and german VAT. If the country is not supported, the input value will be blocked after 2 uppercase letters - - - - - - + + + + + + ## Usage @@ -45,6 +45,5 @@ The `TpkValidationVat` component is used for a vat input. - `@placeholder`: The placeholder text for the input field. - `@mandatory`: Whether the textarea field is mandatory. - `@disabled`: Whether the input field is disabled. -- `@onChange`: The action to be called when the selection changes. +- `@onChange`: The action to be called when the selection changes. - `@changeEvent`: The event to trigger the onChange action. - diff --git a/doc-app/app/templates/docs/ember-input-validation/radio-group.md b/doc-app/public/docs/ember-input-validation/radio-group.md similarity index 61% rename from doc-app/app/templates/docs/ember-input-validation/radio-group.md rename to doc-app/public/docs/ember-input-validation/radio-group.md index 6778500a..49cb5870 100644 --- a/doc-app/app/templates/docs/ember-input-validation/radio-group.md +++ b/doc-app/public/docs/ember-input-validation/radio-group.md @@ -2,24 +2,23 @@ Ember input validation/radio group content - - - - - - - - - - - - - - Result: {{changeset-get this.changeset 'radio'}} - - - + + + + + + + + + + + + +Result: {{changeset-get this.changeset 'radio'}} + + + ### Args @@ -40,10 +39,9 @@ Ember input validation/radio group content **I.Input**: The component representing the radio. - ### CSS -**.tpk-validation-radio-container** : CSS class which includes the label and the group +**.tpk-validation-radio-container** : CSS class which includes the label and the group **.tpk-validation-radio-group-label** : CSS class for the label of the group @@ -51,4 +49,4 @@ Ember input validation/radio group content **.tpk-radio** : CSS class for styling the input of the radio button (label and input box). -**.tpk-radio-label** : CSS class for styling the label of the input. \ No newline at end of file +**.tpk-radio-label** : CSS class for styling the label of the input. diff --git a/doc-app/app/templates/docs/ember-input-validation/radio.md b/doc-app/public/docs/ember-input-validation/radio.md similarity index 84% rename from doc-app/app/templates/docs/ember-input-validation/radio.md rename to doc-app/public/docs/ember-input-validation/radio.md index 750761d6..560d4b65 100644 --- a/doc-app/app/templates/docs/ember-input-validation/radio.md +++ b/doc-app/public/docs/ember-input-validation/radio.md @@ -3,7 +3,8 @@ Ember validation radio - + +
- - + - - + +
Result: {{changeset-get this.changeset 'radio'}} -
- +
+
### Args @@ -55,10 +57,8 @@ Ember validation radio **@classless** : The argument allows overriding the CSS class of the input. - ### CSS **.tpk-radio** : CSS class for styling the input of the radio button (label and input box). **.tpk-radio-label** : CSS class for styling the label of the input. - diff --git a/doc-app/app/templates/docs/ember-input-validation/select.md b/doc-app/public/docs/ember-input-validation/select.md similarity index 63% rename from doc-app/app/templates/docs/ember-input-validation/select.md rename to doc-app/public/docs/ember-input-validation/select.md index b671c1b9..5645cd45 100644 --- a/doc-app/app/templates/docs/ember-input-validation/select.md +++ b/doc-app/public/docs/ember-input-validation/select.md @@ -5,60 +5,62 @@ A select dropdown component with built-in validation support using changesets. T ## Basic Usage - - - - - {{if S.hasSelection S.selected "Select..."}} - - - - -
- {{#each S.errors as |error|}} - - {{error.message}} - - {{/each}} -
-
-
- + + + + +{{if S.hasSelection S.selected "Select..."}} + + + + + +
+{{#each S.errors as |error|}} + +{{error.message}} + +{{/each}} +
+
+
+
## Multiple Selection - - - - - {{if S.hasSelection S.selected "Select..."}} - - - - - - - + + + + +{{if S.hasSelection S.selected "Select..."}} + + + + + + + + ## Arguments @@ -96,6 +98,7 @@ A select dropdown component with built-in validation support using changesets. T **S.Button**: Button that displays the current selection and toggles the dropdown. **S.Options**: Options list container. Yields an option component that provides: + - **opt.option**: The option value - **opt.isSelected**: Boolean indicating if this option is selected diff --git a/doc-app/app/templates/docs/ember-input-validation/textarea.md b/doc-app/public/docs/ember-input-validation/textarea.md similarity index 76% rename from doc-app/app/templates/docs/ember-input-validation/textarea.md rename to doc-app/public/docs/ember-input-validation/textarea.md index a75a02e5..73fa30e1 100644 --- a/doc-app/app/templates/docs/ember-input-validation/textarea.md +++ b/doc-app/public/docs/ember-input-validation/textarea.md @@ -5,30 +5,31 @@ A textarea component with built-in validation support using changesets. This com ## Basic Usage - - -
- - - {{T.charCount}} / {{T.maxLength}} - -
- -
- {{#each T.errors as |error|}} - - {{error.message}} - - {{/each}} -
-
-
- + + + +
+ + +{{T.charCount}} / {{T.maxLength}} + +
+ +
+{{#each T.errors as |error|}} + +{{error.message}} + +{{/each}} +
+
+
+
## Arguments @@ -78,6 +79,7 @@ A textarea component with built-in validation support using changesets. This com ## Validation The component automatically: + - Updates the changeset as the user types (or on change, depending on `@changeEvent`) - Displays validation state via the `data-has-error` attribute - Enforces `@maxLength` if specified diff --git a/doc-app/public/docs/ember-input/button.md b/doc-app/public/docs/ember-input/button.md new file mode 100644 index 00000000..5d97c27b --- /dev/null +++ b/doc-app/public/docs/ember-input/button.md @@ -0,0 +1,26 @@ +# Ember input/button + +A button component that performs an onClick task. + +By default, prevents spam click by waiting the current task to finish before accepting a new one. + + + + +Spam me @allowSpam={{true}} + + +Spam me @allowSpam={{false}} + + +
+Counter : {{this.counter}} +
+
+ +
diff --git a/doc-app/public/docs/ember-input/checkbox.md b/doc-app/public/docs/ember-input/checkbox.md new file mode 100644 index 00000000..92952518 --- /dev/null +++ b/doc-app/public/docs/ember-input/checkbox.md @@ -0,0 +1,21 @@ +# Ember input/checkbox + +A composable checkbox input element. + + + + + + + + +
+Checked: {{this.checked}} +
+
+ +
diff --git a/doc-app/app/templates/docs/ember-input/datepicker.md b/doc-app/public/docs/ember-input/datepicker.md similarity index 54% rename from doc-app/app/templates/docs/ember-input/datepicker.md rename to doc-app/public/docs/ember-input/datepicker.md index 317de76d..2f7d47fe 100644 --- a/doc-app/app/templates/docs/ember-input/datepicker.md +++ b/doc-app/public/docs/ember-input/datepicker.md @@ -3,36 +3,36 @@ An Ember component for date selection with extensive customization options. This component provides a user interface for selecting dates and applying input masks for formatting. - - - - - - - + + + + + + + ## Mandatory Arguments - **value**: The initial date or dates to display in the date picker. Can be a single `Date`, a `string`, or `undefined`. - ```typescript - @tracked selectedDate: Date | string | undefined = new Date(); - ``` + ```typescript + @tracked selectedDate: Date | string | undefined = new Date(); + ``` - **onChange**: A function called when the date is changed. Receives the new values as argument. - ```typescript - @action - onChange(dates: Date[]): void { - this.selectedDate = dates[0]; - } - ``` + ```typescript + @action + onChange(dates: Date[]): void { + this.selectedDate = dates[0]; + } + ``` ## Optional Arguments @@ -40,9 +40,9 @@ An Ember component for date selection with extensive customization options. This - **mask**: An input mask for formatting the date input when writing, using the IMask library. - ```typescript - @tracked dateMask: string = 'd-m/Y'; - ``` + ```typescript + @tracked dateMask: string = 'd-m/Y'; + ``` - **placeholder**: Placeholder text displayed when the date field is empty. @@ -52,16 +52,16 @@ An Ember component for date selection with extensive customization options. This - **stepping**: The number of minutes to step up/down in the time picker. Defaults to 5. -- **mode**: - - __Multiple__ +- **mode**: + + **Multiple** Allow the selection of multiple dates. Returns values after two dates are picked at least - __Range__ + **Range** Enable date range selection. Returns values after two dates are picked - + - **multipleDatesSeparator**: The separator to use when multiple dates are selected. - **range**: Enable date range selection. Defaults to `false`. Returns values after two dates are picked @@ -106,106 +106,105 @@ An Ember component for date selection with extensive customization options. This - **viewMode**: The initial view mode of the date picker. Can be 'clock', 'calendar', 'months', 'years', or 'decades'. - ## Limitation -Currently, the datepicker cannot have a __default value__ for modes [`range`] and [`multiple`]. For more details, see [this issue](https://github.com/Eonasdan/tempus-dominus/issues/2830) +Currently, the datepicker cannot have a **default value** for modes [`range`] and [`multiple`]. For more details, see [this issue](https://github.com/Eonasdan/tempus-dominus/issues/2830) ## Examples ### Date picker range - - - - - - - + + + + + + + ### Time picker with mask - - - - - - - + + + + + + + ### Date picker with minDate, maxDate and a default value - - - - - - - + + + + + + + ### Date picker shows month selector first - - - - - - - + + + + + + + ### Show picker after select a date - - - - - - - + + + + + + + diff --git a/doc-app/public/docs/ember-input/file.md b/doc-app/public/docs/ember-input/file.md new file mode 100644 index 00000000..15919b23 --- /dev/null +++ b/doc-app/public/docs/ember-input/file.md @@ -0,0 +1,49 @@ +# Ember input/file + +The **TpkFileInputComponent** is designed to handle file input in a web application. It encapsulates an HTML file field (` + + + + + + + +
+ +**Multiple input/file** + + + + + + + + + + +## Arguments description + +- **accept?: string** + - This argument is optional and expects a string. It specifies the file types the user can select. For example, "image/\*" will accept all image types. +- **disabled?: boolean** + - This argument is optional and is a boolean. If it is supplied and evaluates to true, the file field will be disabled. Otherwise, it will be enabled. +- **multiple?: boolean** + - This argument is optional and is a boolean. If provided and evaluated to true, the file field will allow the user to select multiple files at once. Otherwise, only one file can be selected. +- **changeEvent: 'input' | 'change'** + - This argument is mandatory and must be one of two string values: 'input' or 'change'. It specifies the type of change event associated with the file input field. This can be useful to customize when the onChange callback function is triggered. +- **onChange: (event: Event) => void** + - This argument is mandatory and waits for a callback function that takes an argument of type Event. This callback function will be called when the specified change event ('input' or 'change') occurs on the file field. It can be used to perform actions in response to file changes. diff --git a/doc-app/public/docs/ember-input/input.md b/doc-app/public/docs/ember-input/input.md new file mode 100644 index 00000000..9aaba0a8 --- /dev/null +++ b/doc-app/public/docs/ember-input/input.md @@ -0,0 +1,22 @@ +# Ember input/input + +A composable html input element. + + + + + + + + + + + + +
+ Value: {{this.value}} +
+ +
+ +
diff --git a/doc-app/app/templates/docs/ember-input/installation.md b/doc-app/public/docs/ember-input/installation.md similarity index 85% rename from doc-app/app/templates/docs/ember-input/installation.md rename to doc-app/public/docs/ember-input/installation.md index 0c870c9b..67d6e7bb 100644 --- a/doc-app/app/templates/docs/ember-input/installation.md +++ b/doc-app/public/docs/ember-input/installation.md @@ -10,7 +10,6 @@ Install the peer dependencies if needed: ember install ember-flatpickr ``` - ## Importing types Add the Glint template-registry to your global.d.ts file: @@ -20,7 +19,6 @@ import '@glint/environment-ember-loose'; import type EmberInputRegistry from '@triptyk/ember-input/template-registry'; declare module '@glint/environment-ember-loose/registry' { - export default interface Registry - extends EmberInputRegistry {} + export default interface Registry extends EmberInputRegistry {} } ``` diff --git a/doc-app/public/docs/ember-input/prefabs/button.md b/doc-app/public/docs/ember-input/prefabs/button.md new file mode 100644 index 00000000..8b225dd7 --- /dev/null +++ b/doc-app/public/docs/ember-input/prefabs/button.md @@ -0,0 +1,28 @@ +# Button + +A button. This is a simple wrapper around the `input` element with `type="button"`. + + + + +
+ + +
+

count = {{this.counter}}

+
+ +
+ +## Mandatory properties + +- `@label`: The label for the button field. +- `@onClick`: The action to be called when the button clicked. + +## Optional properties + +- `@disabled`: Whether the button field is disabled. + +## Important + +- `class`: To create a custom class you must do it in a CSS file to override the button class diff --git a/doc-app/public/docs/ember-input/prefabs/toggle.md b/doc-app/public/docs/ember-input/prefabs/toggle.md new file mode 100644 index 00000000..7a251901 --- /dev/null +++ b/doc-app/public/docs/ember-input/prefabs/toggle.md @@ -0,0 +1,11 @@ +# Toggle + +A toggle switch. This is a simple wrapper around the `input` element with `type="checkbox"`. + + + + + + + + diff --git a/doc-app/app/templates/docs/ember-input/radio.md b/doc-app/public/docs/ember-input/radio.md similarity index 95% rename from doc-app/app/templates/docs/ember-input/radio.md rename to doc-app/public/docs/ember-input/radio.md index 6da6bb46..f4a6a13b 100644 --- a/doc-app/app/templates/docs/ember-input/radio.md +++ b/doc-app/public/docs/ember-input/radio.md @@ -3,7 +3,8 @@ Ember input/radio content - + +

Choose your gender

**value**: a string type that must be identical among radios in the same group. - **@onChange**: > **description**: specifies the method called when the state of the radio is changed. - > **value**: an hbs type string which should be the name of the method defined in the controller. e.g., ```{{this.setRadio}}``` + > **value**: an hbs type string which should be the name of the method defined in the controller. e.g., `{{this.setRadio}}` ### This component has 2 mandatory yields: + - **Input**: representing the radio type input - **Label**: representing the label of our radio diff --git a/doc-app/app/templates/docs/ember-input/select.md b/doc-app/public/docs/ember-input/select.md similarity index 53% rename from doc-app/app/templates/docs/ember-input/select.md rename to doc-app/public/docs/ember-input/select.md index acbebffa..4aeb5956 100644 --- a/doc-app/app/templates/docs/ember-input/select.md +++ b/doc-app/public/docs/ember-input/select.md @@ -3,6 +3,7 @@ An Ember input/select that performs an onChange task which allows it to display selection coming from select options. ## With base arguments + The following arguments are declared in the js controller paired with your hbs working file and given to the component by using the **@** (e.g. **@options**) - **options**: A tracked value corresponding to the array of options of the select. Given value has to be an array of elements. @@ -10,6 +11,7 @@ The following arguments are declared in the js controller paired with your hbs w ```js @tracked sauceOptions = ["BBQ", "Ketchup", "Dallas"]; ``` + - **selected**: Allows your selected value to be displayed as the button label. By default if no value is selected, base value is displayed. Here base button value is "...". ```js @@ -28,25 +30,25 @@ The following arguments are declared in the js controller paired with your hbs w - **label**: Corresponds to the title of the select. - - - - - {{if S.hasSelection S.selected "..."}} - - - - {{opt.option}} - - - - - + + + + +{{if S.hasSelection S.selected "..."}} + + + +{{opt.option}} + + + + + ## With optional arguments added @@ -55,31 +57,28 @@ The following arguments are declared in the js controller paired with your hbs w Keeping the same process as explained before the values will be displayed as button label using `@selected={{this.valueCar}}`. - - - - - - {{if S.hasSelection S.selected "..."}} - - - - {{#if opt.selected}} - ok - {{/if}} - {{opt.option}} - - - - - + + + + +{{if S.hasSelection S.selected "..."}} + + + +{{#if opt.selected}} +ok +{{/if}} +{{opt.option}} + + + + + - - diff --git a/doc-app/app/templates/docs/ember-input/textarea.md b/doc-app/public/docs/ember-input/textarea.md similarity index 63% rename from doc-app/app/templates/docs/ember-input/textarea.md rename to doc-app/public/docs/ember-input/textarea.md index 799a09ec..dd1c83c4 100644 --- a/doc-app/app/templates/docs/ember-input/textarea.md +++ b/doc-app/public/docs/ember-input/textarea.md @@ -3,27 +3,28 @@ A composable textarea input element. - - -
- - - {{C.charCount}} / {{C.maxLength}} - -
- -
-
- Content: {{this.value}} -
-
- + + + +
+ + +{{C.charCount}} / {{C.maxLength}} + +
+ +
+
+Content: {{this.value}} +
+
+
### Args @@ -47,13 +48,12 @@ the function receive the value and the event as args. **C.charCount**: The current length of the String within the textarea -**C.maxLength**: The maximum length of the String within the textarea +**C.maxLength**: The maximum length of the String within the textarea ### CSS -**.tpk-textarea**: the class added by default to the div wrapping the textarea and the label. +**.tpk-textarea**: the class added by default to the div wrapping the textarea and the label. **.tpk-label**: the class added by default to the label. **.tpk-textarea-input**: the class added by default to the textarea. - diff --git a/doc-app/public/docs/ember-ui/actions-menu.md b/doc-app/public/docs/ember-ui/actions-menu.md new file mode 100644 index 00000000..497d9685 --- /dev/null +++ b/doc-app/public/docs/ember-ui/actions-menu.md @@ -0,0 +1,16 @@ +# Actions menu + +A component for a tooltip-like actions menu. + + + + + +Edit + + + + + diff --git a/doc-app/app/templates/docs/ember-ui/installation.md b/doc-app/public/docs/ember-ui/installation.md similarity index 86% rename from doc-app/app/templates/docs/ember-ui/installation.md rename to doc-app/public/docs/ember-ui/installation.md index 79db8aab..eb4a922d 100644 --- a/doc-app/app/templates/docs/ember-ui/installation.md +++ b/doc-app/public/docs/ember-ui/installation.md @@ -19,7 +19,6 @@ import '@glint/environment-ember-loose'; import type EmberUIValidationRegistry from '@triptyk/ember-ui/template-registry'; declare module '@glint/environment-ember-loose/registry' { - export default interface Registry - extends EmberUIRegistry {} + export default interface Registry extends EmberUIRegistry {} } ``` diff --git a/doc-app/public/docs/ember-ui/modal.md b/doc-app/public/docs/ember-ui/modal.md new file mode 100644 index 00000000..94205c17 --- /dev/null +++ b/doc-app/public/docs/ember-ui/modal.md @@ -0,0 +1,26 @@ +# Modal + +A modal component. + + + + + +
+
+ + +

Click outside to close

+ +
+
+
+ +
diff --git a/doc-app/public/docs/ember-ui/prefabs/confirm-modal.md b/doc-app/public/docs/ember-ui/prefabs/confirm-modal.md new file mode 100644 index 00000000..6329997b --- /dev/null +++ b/doc-app/public/docs/ember-ui/prefabs/confirm-modal.md @@ -0,0 +1,32 @@ +# Modal + +A modal component. + + + + + +
+ +
+
+ +
+ +## Mandatory properties + +- `@onClose`: this is a function to close modal. +- `@onConfirm`: this is a function to close modal. +- `@cancelText`: this is a string to populate cancel button +- `@confirmText`: this is a string to populate confirm button +- `@confirmQuestion`: this is the text of confirmation to user +- `@isOpen` : boolean to close modal diff --git a/doc-app/app/templates/docs/ember-ui/prefabs/table-generic.md b/doc-app/public/docs/ember-ui/prefabs/table-generic.md similarity index 84% rename from doc-app/app/templates/docs/ember-ui/prefabs/table-generic.md rename to doc-app/public/docs/ember-ui/prefabs/table-generic.md index 3b75d86a..191e0eae 100644 --- a/doc-app/app/templates/docs/ember-ui/prefabs/table-generic.md +++ b/doc-app/public/docs/ember-ui/prefabs/table-generic.md @@ -6,11 +6,11 @@ It is also possible to pass components to the desired column. # Basic usage: - - - - - + + + + + ## Mandatory properties @@ -18,6 +18,7 @@ It is also possible to pass components to the desired column. - `@tableParams`: The field name in the changeset for validation. # Advanced Usage: + !!! Ember doc cannotdisplay example with code snippet ```ts @@ -53,15 +54,12 @@ export class TableRouteComponent extends Component onUpdate = (selection: unknown, row: UserModel) => { row.set('email', selection as string); - console.log(selection); - console.log(row); - } @@ -99,6 +97,7 @@ class SelectTableRegister extends Component; } ``` + ## Optional properties -- `@columnsComponent:` The component that will be passed to the column of the table. \ No newline at end of file +- `@columnsComponent:` The component that will be passed to the column of the table. diff --git a/doc-app/public/docs/ember-ui/prefabs/tpk-form-component-en.md b/doc-app/public/docs/ember-ui/prefabs/tpk-form-component-en.md new file mode 100644 index 00000000..44178f32 --- /dev/null +++ b/doc-app/public/docs/ember-ui/prefabs/tpk-form-component-en.md @@ -0,0 +1,487 @@ +# TpkForm Component + +A comprehensive form component that integrates validation using `ember-immer-changeset` and `zod`. The component provides automatic validation, error handling, and yields pre-configured validation input components. + + + + + + + + + + + + + + + +## Mandatory properties + +- `@changeset`: An instance of [ImmerChangeset](https://triptyk.github.io/ember-immer-changeset/classes/ImmerChangeset.html) containing the form data. This changeset manages the form state and validation errors. +- `@onSubmit`: A callback function executed when the form is submitted with valid data. Receives two parameters: `(data, changeset)` where data is the validated object and changeset is the ImmerChangeset instance. +- `@validationSchema`: A Zod schema (ZodObject) that defines the validation rules for the form fields. + +## Optional properties + +- `@reactive` (Boolean, default: `true`): When enabled, validates individual fields immediately when their values change. Set to `false` to validate only on form submission. +- `@removeErrorsOnSubmit` (Boolean, default: `true`): Clears all existing validation errors before performing validation on submit. +- `@autoScrollOnError` (Boolean, default: `true`): Automatically scrolls to the first validation error when submission fails. +- `@disabled` (Boolean, default: `false`): Disables all form inputs when set to `true`. +- `@executeOnValid` (Boolean, default: `true`): Automatically executes the changeset (applies draft changes to data) when validation passes. + +## Implementation Guide + +### 1. Controller/Component Setup + +Create a changeset, validation schema, and submit handler: + +```typescript +import Controller from '@ember/controller'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import { object, string, email } from 'zod'; +import { action } from '@ember/object'; + +export default class MyFormController extends Controller { + // Initialize an empty changeset + changeset = new ImmerChangeset({ + firstName: '', + lastName: '', + email: '', + }); + + // Define validation rules with Zod + validationSchema = object({ + firstName: string().min(2, 'First name must be at least 2 characters'), + lastName: string().min(2, 'Last name must be at least 2 characters'), + email: string().email('Must be a valid email address'), + }); + + @action + handleSubmit(validatedData, changeset) { + // validatedData contains the validated form data + // changeset is the ImmerChangeset instance + console.log('Form submitted with:', validatedData); + // Perform your API call or data processing here + } +} +``` + +### 2. Using the TpkForm Component + +The form yields a hash of pre-configured validation components: + +```gts + + {{! Use yielded prefab components }} + + + + + + + + +``` + +### 3. Available Yielded Components + +The `TpkForm` component yields numerous pre-configured components, all automatically bound with the changeset, disabled state, and required fields: + +#### Base Components (for custom layouts) + +- `F.TpkInput` - Base input component +- `F.TpkTextarea` - Base textarea component +- `F.TpkSelect` - Base select component +- `F.TpkCheckbox` - Base checkbox component +- `F.TpkRadio` - Base radio component +- `F.TpkRadioGroup` - Radio group component +- `F.TpkFile` - Base file input component +- `F.TpkDatepicker` - Base datepicker component + +#### Prefab Components (ready-to-use) + +- `F.TpkInputPrefab` - Standard text input +- `F.TpkTextareaPrefab` - Textarea with validation +- `F.TpkSelectPrefab` - Select dropdown +- `F.TpkSelectCreatePrefab` - Select with create option +- `F.TpkSelectSearchPrefab` - Searchable select +- `F.TpkCheckboxPrefab` - Checkbox with label +- `F.TpkRadioPrefab` - Single radio button +- `F.TpkRadioGroupPrefab` - Radio button group +- `F.TpkFilePrefab` - File upload input + +#### Specialized Input Prefabs + +- `F.TpkPasswordPrefab` - Password input with visibility toggle +- `F.TpkEmailPrefab` - Email input with validation +- `F.TpkMobilePrefab` - Mobile phone number input +- `F.TpkIbanPrefab` - IBAN (bank account) input +- `F.TpkBicPrefab` - BIC/SWIFT code input +- `F.TpkVatPrefab` - VAT number input +- `F.TpkNationalNumberPrefab` - National identification number +- `F.TpkCurrencyPrefab` - Currency/money input +- `F.TpkIntegerPrefab` - Integer number input +- `F.TpkNumberPrefab` - Decimal number input + +#### Date/Time Prefabs + +- `F.TpkDatepickerPrefab` - Single date picker +- `F.TpkDatepickerRangePrefab` - Date range picker +- `F.TpkTimepickerPrefab` - Time picker + +#### Yielded Helper Values + +- `F.changesetGet` - Function to retrieve values from the changeset (shortcut for `changeset.get()`) +- `F.requiredFields` - Array of field names that are required according to the validation schema + +### 4. Using Base Components for Custom Layouts + +Base components give you full control over the markup: + +```gts + + + + + {{#if I.errors}} +
+ {{#each I.errors as |error|}} +

{{error.message}}

+ {{/each}} +
+ {{/if}} +
+ + +
+``` + +### 5. Validation Behavior + +#### Reactive Validation (Default) + +When `@reactive={{true}}` (default), fields are validated as soon as their values change: + +```gts + + {{! Field validates on every change }} + + +``` + +#### Submit-Only Validation + +Set `@reactive={{false}}` to validate only when the form is submitted: + +```gts + + {{! Field validates only on submit }} + + +``` + +### 6. Error Handling and Auto-Scrolling + +Control error clearing and auto-scroll behavior: + +```gts + + {{! Errors cleared before validation, scrolls to first error }} + + + +``` + +### 7. Disabled State + +Disable the entire form and all its inputs: + +```gts + + {{! All inputs will be disabled when isLoading is true }} + + +``` + +### 8. Working with Required Fields + +Access the list of required fields from the validation schema: + +```gts + +

Required fields: {{F.requiredFields.length}}

+ + + + {{#if (includes F.requiredFields "email")}} +

Email is required

+ {{/if}} + +
+``` + +### 9. changesetGet Helper + +Use the `changesetGet` helper to retrieve values without repeating the `@changeset` argument: + +```gts + + + + +

Full name: {{F.changesetGet "firstName"}} {{F.changesetGet "lastName"}}

+
+``` + +### 10. Complex Form Example + +```typescript +// Controller +import Controller from '@ember/controller'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import { object, string, number, boolean, date } from 'zod'; +import { action } from '@ember/object'; +import { tracked } from '@glimmer/tracking'; + +export default class ComplexFormController extends Controller { + @tracked isSubmitting = false; + + changeset = new ImmerChangeset({ + firstName: '', + lastName: '', + email: '', + phone: '', + birthday: null, + country: null, + subscribe: false, + }); + + validationSchema = object({ + firstName: string().min(2), + lastName: string().min(2), + email: string().email(), + phone: string().optional(), + birthday: date(), + country: string().min(2), + subscribe: boolean(), + }); + + countryOptions = [ + { label: 'Belgium', value: 'BE' }, + { label: 'France', value: 'FR' }, + { label: 'Netherlands', value: 'NL' }, + ]; + + @action + async handleSubmit(validatedData, changeset) { + this.isSubmitting = true; + try { + await this.saveUser(validatedData); + alert('User saved successfully!'); + } catch (error) { + console.error('Save failed:', error); + } finally { + this.isSubmitting = false; + } + } +} +``` + +```gts +{{! Template }} + +
+ + +
+ + + + + + + + + + + + +
+``` + +## Customizing Default Components + +The default yielded components are the standard validation components (`TpkValidation*`), but you can change these default components by modifying the values in the TpkForm service. + +```typescript +let tpkFormService = this.owner.lookup('service:tpk-form') as TpkFormService; + +// Base Components +tpkFormService.TpkInput = CustomInput; +tpkFormService.TpkTextarea = CustomTextarea; +tpkFormService.TpkSelect = CustomSelect; +tpkFormService.TpkCheckbox = CustomCheckbox; +tpkFormService.TpkRadio = CustomRadio; +tpkFormService.TpkRadioGroup = CustomRadioGroup; +tpkFormService.TpkFile = CustomFile; +tpkFormService.TpkDatepicker = CustomDatepicker; + +// Prefab Components +tpkFormService.TpkInputPrefab = CustomInputPrefab; +tpkFormService.TpkTextareaPrefab = CustomTextareaPrefab; +tpkFormService.TpkSelectPrefab = CustomSelectPrefab; +tpkFormService.TpkSelectCreatePrefab = CustomSelectCreatePrefab; +tpkFormService.TpkSelectSearchPrefab = CustomSelectSearchPrefab; +tpkFormService.TpkCheckboxPrefab = CustomCheckboxPrefab; +tpkFormService.TpkRadioPrefab = CustomRadioPrefab; +tpkFormService.TpkRadioGroupPrefab = CustomRadioGroupPrefab; +tpkFormService.TpkDatepickerPrefab = CustomDatepickerPrefab; +tpkFormService.TpkDatepickerRangePrefab = CustomDatepickerRangePrefab; +tpkFormService.TpkTimepickerPrefab = CustomTimepickerPrefab; + +// Specialized Input Prefabs +tpkFormService.TpkPasswordPrefab = CustomPasswordPrefab; +tpkFormService.TpkEmailPrefab = CustomEmailPrefab; +tpkFormService.TpkIbanPrefab = CustomIbanPrefab; +tpkFormService.TpkBicPrefab = CustomBicPrefab; +tpkFormService.TpkVatPrefab = CustomVatPrefab; +tpkFormService.TpkNationalNumberPrefab = CustomNationalNumberPrefab; +tpkFormService.TpkCurrencyPrefab = CustomCurrencyPrefab; +tpkFormService.TpkIntegerPrefab = CustomIntegerPrefab; +tpkFormService.TpkNumberPrefab = CustomNumberPrefab; +tpkFormService.TpkMobilePrefab = CustomMobilePrefab; +tpkFormService.TpkFilePrefab = CustomFilePrefab; +``` + +This customization allows you to replace the default components with your own implementations while maintaining the form's structure and behavior. + +## Key Features + +1. **Automatic Validation**: Seamlessly integrates with Zod schemas for comprehensive validation rules. +2. **Error Management**: Automatically displays validation errors and clears them as needed. +3. **Changeset Integration**: Uses `ember-immer-changeset` for efficient state management and change tracking. +4. **Rich Component Library**: Provides 30+ pre-configured input components for common use cases. +5. **Flexible Validation**: Supports both reactive (on-change) and submit-only validation modes. +6. **Accessibility**: Auto-scrolls to errors and properly manages focus states. +7. **Type Safety**: Full TypeScript support with generic type parameters for schema inference. +8. **Customizable**: Can override default components via the TpkForm service. + +## Important Notes + +- The `@onSubmit` callback is only executed when the form is valid. +- By default, the changeset is automatically executed (changes applied) before calling `@onSubmit`. Set `@executeOnValid={{false}}` to prevent this. +- All yielded components are pre-bound with the changeset, disabled state, and required fields list. +- The validation schema must use Zod (not Yup, which was used in older versions). +- Field names in the validation schema must match the `@validationField` values used in the form inputs. +- The component automatically handles calculating required fields based on the Zod schema and updates the list when data changes. diff --git a/doc-app/public/docs/ember-ui/prefabs/tpk-form-component.md b/doc-app/public/docs/ember-ui/prefabs/tpk-form-component.md new file mode 100644 index 00000000..2e6d367a --- /dev/null +++ b/doc-app/public/docs/ember-ui/prefabs/tpk-form-component.md @@ -0,0 +1,487 @@ +# TpkForm Component + +Un composant de formulaire complet qui intègre la validation avec `ember-immer-changeset` et `zod`. Le composant fournit une validation automatique, gestion des erreurs et yield des composants de validation pré-configurés. + + + + + + + + + + + + + + + +## Propriétés obligatoires + +- `@changeset`: Une instance de [ImmerChangeset](https://triptyk.github.io/ember-immer-changeset/classes/ImmerChangeset.html) contenant les données du formulaire. Ce changeset gère l'état du formulaire et les erreurs de validation. +- `@onSubmit`: Une fonction callback exécutée quand le formulaire est soumis avec des données valides. Reçoit deux paramètres : `(data, changeset)` où data est l'objet validé et changeset est l'instance ImmerChangeset. +- `@validationSchema`: Un schéma Zod (ZodObject) qui définit les règles de validation pour les champs du formulaire. + +## Propriétés optionnelles + +- `@reactive` (Boolean, défaut: `true`): Quand activé, valide les champs individuellement dès que leurs valeurs changent. Mettez à `false` pour valider uniquement lors de la soumission. +- `@removeErrorsOnSubmit` (Boolean, défaut: `true`): Efface toutes les erreurs de validation existantes avant d'effectuer la validation lors de la soumission. +- `@autoScrollOnError` (Boolean, défaut: `true`): Fait défiler automatiquement vers la première erreur de validation quand la soumission échoue. +- `@disabled` (Boolean, défaut: `false`): Désactive tous les inputs du formulaire quand défini à `true`. +- `@executeOnValid` (Boolean, défaut: `true`): Exécute automatiquement le changeset (applique les modifications draft aux données) quand la validation réussit. + +## Guide d'implémentation + +### 1. Configuration du Controller/Component + +Créez un changeset, un schéma de validation et un gestionnaire de soumission : + +```typescript +import Controller from '@ember/controller'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import { object, string, email } from 'zod'; +import { action } from '@ember/object'; + +export default class MyFormController extends Controller { + // Initialiser un changeset vide + changeset = new ImmerChangeset({ + firstName: '', + lastName: '', + email: '', + }); + + // Définir les règles de validation avec Zod + validationSchema = object({ + firstName: string().min(2, 'Le prénom doit contenir au moins 2 caractères'), + lastName: string().min(2, 'Le nom doit contenir au moins 2 caractères'), + email: string().email('Doit être une adresse email valide'), + }); + + @action + handleSubmit(validatedData, changeset) { + // validatedData contient les données validées du formulaire + // changeset est l'instance ImmerChangeset + console.log('Formulaire soumis avec:', validatedData); + // Effectuez votre appel API ou traitement de données ici + } +} +``` + +### 2. Utilisation du composant TpkForm + +Le formulaire yield un hash de composants de validation pré-configurés : + +```gts + + {{! Utiliser les composants prefab yieldés }} + + + + + + + + +``` + +### 3. Composants Yieldés disponibles + +Le composant `TpkForm` yield de nombreux composants pré-configurés, tous automatiquement liés avec le changeset, l'état disabled et les champs requis : + +#### Composants de base (pour layouts personnalisés) + +- `F.TpkInput` - Composant input de base +- `F.TpkTextarea` - Composant textarea de base +- `F.TpkSelect` - Composant select de base +- `F.TpkCheckbox` - Composant checkbox de base +- `F.TpkRadio` - Composant radio de base +- `F.TpkRadioGroup` - Composant groupe de radios +- `F.TpkFile` - Composant input fichier de base +- `F.TpkDatepicker` - Composant datepicker de base + +#### Composants Prefab (prêts à l'emploi) + +- `F.TpkInputPrefab` - Input texte standard +- `F.TpkTextareaPrefab` - Textarea avec validation +- `F.TpkSelectPrefab` - Menu déroulant select +- `F.TpkSelectCreatePrefab` - Select avec option de création +- `F.TpkSelectSearchPrefab` - Select avec recherche +- `F.TpkCheckboxPrefab` - Checkbox avec label +- `F.TpkRadioPrefab` - Bouton radio unique +- `F.TpkRadioGroupPrefab` - Groupe de boutons radio +- `F.TpkFilePrefab` - Input upload de fichier + +#### Inputs Prefab Spécialisés + +- `F.TpkPasswordPrefab` - Input mot de passe avec toggle de visibilité +- `F.TpkEmailPrefab` - Input email avec validation +- `F.TpkMobilePrefab` - Input numéro de téléphone mobile +- `F.TpkIbanPrefab` - Input IBAN (compte bancaire) +- `F.TpkBicPrefab` - Input code BIC/SWIFT +- `F.TpkVatPrefab` - Input numéro de TVA +- `F.TpkNationalNumberPrefab` - Input numéro d'identification nationale +- `F.TpkCurrencyPrefab` - Input montant/devise +- `F.TpkIntegerPrefab` - Input nombre entier +- `F.TpkNumberPrefab` - Input nombre décimal + +#### Prefabs Date/Heure + +- `F.TpkDatepickerPrefab` - Sélecteur de date unique +- `F.TpkDatepickerRangePrefab` - Sélecteur de plage de dates +- `F.TpkTimepickerPrefab` - Sélecteur d'heure + +#### Valeurs Helper Yieldées + +- `F.changesetGet` - Fonction pour récupérer des valeurs du changeset (raccourci pour `changeset.get()`) +- `F.requiredFields` - Tableau des noms de champs qui sont requis selon le schéma de validation + +### 4. Utiliser les composants de base pour layouts personnalisés + +Les composants de base vous donnent un contrôle complet sur le markup : + +```gts + + + + + {{#if I.errors}} +
+ {{#each I.errors as |error|}} +

{{error.message}}

+ {{/each}} +
+ {{/if}} +
+ + +
+``` + +### 5. Comportement de validation + +#### Validation Réactive (Défaut) + +Quand `@reactive={{true}}` (défaut), les champs sont validés dès que leurs valeurs changent : + +```gts + + {{! Le champ se valide à chaque changement }} + + +``` + +#### Validation uniquement à la soumission + +Définissez `@reactive={{false}}` pour valider uniquement quand le formulaire est soumis : + +```gts + + {{! Le champ se valide uniquement à la soumission }} + + +``` + +### 6. Gestion des erreurs et scroll automatique + +Contrôlez l'effacement des erreurs et le comportement de scroll automatique : + +```gts + + {{! Erreurs effacées avant validation, scroll vers la première erreur }} + + + +``` + +### 7. État désactivé + +Désactivez tout le formulaire et tous ses inputs : + +```gts + + {{! Tous les inputs seront désactivés quand isLoading est true }} + + +``` + +### 8. Travailler avec les champs requis + +Accédez à la liste des champs requis depuis le schéma de validation : + +```gts + +

Champs requis : {{F.requiredFields.length}}

+ + + + {{#if (includes F.requiredFields "email")}} +

L'email est requis

+ {{/if}} + +
+``` + +### 9. Helper changesetGet + +Utilisez le helper `changesetGet` pour récupérer des valeurs sans répéter l'argument `@changeset` : + +```gts + + + + +

Nom complet : {{F.changesetGet "firstName"}} {{F.changesetGet "lastName"}}

+
+``` + +### 10. Exemple de formulaire complexe + +```typescript +// Controller +import Controller from '@ember/controller'; +import { ImmerChangeset } from 'ember-immer-changeset'; +import { object, string, number, boolean, date } from 'zod'; +import { action } from '@ember/object'; +import { tracked } from '@glimmer/tracking'; + +export default class ComplexFormController extends Controller { + @tracked isSubmitting = false; + + changeset = new ImmerChangeset({ + firstName: '', + lastName: '', + email: '', + phone: '', + birthday: null, + country: null, + subscribe: false, + }); + + validationSchema = object({ + firstName: string().min(2), + lastName: string().min(2), + email: string().email(), + phone: string().optional(), + birthday: date(), + country: string().min(2), + subscribe: boolean(), + }); + + countryOptions = [ + { label: 'Belgique', value: 'BE' }, + { label: 'France', value: 'FR' }, + { label: 'Pays-Bas', value: 'NL' }, + ]; + + @action + async handleSubmit(validatedData, changeset) { + this.isSubmitting = true; + try { + await this.saveUser(validatedData); + alert('Utilisateur sauvegardé avec succès!'); + } catch (error) { + console.error('Échec de la sauvegarde:', error); + } finally { + this.isSubmitting = false; + } + } +} +``` + +```gts +{{! Template }} + +
+ + +
+ + + + + + + + + + + + +
+``` + +## Personnalisation des composants par défaut + +Les composants yieldés par défaut sont les composants de validation standard (`TpkValidation*`), mais vous pouvez changer ces composants par défaut en modifiant les valeurs dans le service TpkForm. + +```typescript +let tpkFormService = this.owner.lookup('service:tpk-form') as TpkFormService; + +// Composants de base +tpkFormService.TpkInput = CustomInput; +tpkFormService.TpkTextarea = CustomTextarea; +tpkFormService.TpkSelect = CustomSelect; +tpkFormService.TpkCheckbox = CustomCheckbox; +tpkFormService.TpkRadio = CustomRadio; +tpkFormService.TpkRadioGroup = CustomRadioGroup; +tpkFormService.TpkFile = CustomFile; +tpkFormService.TpkDatepicker = CustomDatepicker; + +// Composants Prefab +tpkFormService.TpkInputPrefab = CustomInputPrefab; +tpkFormService.TpkTextareaPrefab = CustomTextareaPrefab; +tpkFormService.TpkSelectPrefab = CustomSelectPrefab; +tpkFormService.TpkSelectCreatePrefab = CustomSelectCreatePrefab; +tpkFormService.TpkSelectSearchPrefab = CustomSelectSearchPrefab; +tpkFormService.TpkCheckboxPrefab = CustomCheckboxPrefab; +tpkFormService.TpkRadioPrefab = CustomRadioPrefab; +tpkFormService.TpkRadioGroupPrefab = CustomRadioGroupPrefab; +tpkFormService.TpkDatepickerPrefab = CustomDatepickerPrefab; +tpkFormService.TpkDatepickerRangePrefab = CustomDatepickerRangePrefab; +tpkFormService.TpkTimepickerPrefab = CustomTimepickerPrefab; + +// Inputs Prefab Spécialisés +tpkFormService.TpkPasswordPrefab = CustomPasswordPrefab; +tpkFormService.TpkEmailPrefab = CustomEmailPrefab; +tpkFormService.TpkIbanPrefab = CustomIbanPrefab; +tpkFormService.TpkBicPrefab = CustomBicPrefab; +tpkFormService.TpkVatPrefab = CustomVatPrefab; +tpkFormService.TpkNationalNumberPrefab = CustomNationalNumberPrefab; +tpkFormService.TpkCurrencyPrefab = CustomCurrencyPrefab; +tpkFormService.TpkIntegerPrefab = CustomIntegerPrefab; +tpkFormService.TpkNumberPrefab = CustomNumberPrefab; +tpkFormService.TpkMobilePrefab = CustomMobilePrefab; +tpkFormService.TpkFilePrefab = CustomFilePrefab; +``` + +Cette personnalisation vous permet de remplacer les composants par défaut par vos propres implémentations tout en conservant la structure et le comportement du formulaire. + +## Fonctionnalités clés + +1. **Validation automatique**: S'intègre parfaitement avec les schémas Zod pour des règles de validation complètes. +2. **Gestion des erreurs**: Affiche automatiquement les erreurs de validation et les efface au besoin. +3. **Intégration Changeset**: Utilise `ember-immer-changeset` pour une gestion d'état efficace et le suivi des changements. +4. **Bibliothèque riche de composants**: Fournit 30+ composants input pré-configurés pour les cas d'usage courants. +5. **Validation flexible**: Supporte les modes de validation réactive (on-change) et uniquement à la soumission. +6. **Accessibilité**: Scroll automatique vers les erreurs et gestion appropriée des états de focus. +7. **Sécurité de typage**: Support complet TypeScript avec paramètres de type génériques pour l'inférence de schéma. +8. **Personnalisable**: Peut remplacer les composants par défaut via le service TpkForm. + +## Notes importantes + +- Le callback `@onSubmit` n'est exécuté que quand le formulaire est valide. +- Par défaut, le changeset est automatiquement exécuté (changements appliqués) avant d'appeler `@onSubmit`. Définissez `@executeOnValid={{false}}` pour empêcher cela. +- Tous les composants yieldés sont pré-liés avec le changeset, l'état disabled et la liste des champs requis. +- Le schéma de validation doit utiliser Zod (pas Yup, qui était utilisé dans les anciennes versions). +- Les noms de champs dans le schéma de validation doivent correspondre aux valeurs `@validationField` utilisées dans les inputs du formulaire. +- Le composant gère automatiquement le calcul des champs requis basé sur le schéma Zod et met à jour la liste quand les données changent. diff --git a/doc-app/app/templates/docs/ember-input-validation/tpk-form.md b/doc-app/public/docs/ember-ui/prefabs/tpk-form.md similarity index 51% rename from doc-app/app/templates/docs/ember-input-validation/tpk-form.md rename to doc-app/public/docs/ember-ui/prefabs/tpk-form.md index a025b45e..435d370b 100644 --- a/doc-app/app/templates/docs/ember-input-validation/tpk-form.md +++ b/doc-app/public/docs/ember-ui/prefabs/tpk-form.md @@ -6,52 +6,53 @@ The `TpkForm` component is a form component that uses the `ember-immer-changeset By default, the changeset is [executed](https://triptyk.github.io/ember-immer-changeset/classes/ImmerChangeset.html#execute) if the form submitted is valid. - - - - - - {{#if I.errors}} - {{#each I.errors as |error|}} -
{{error.message}}
- {{/each}} - {{/if}} -
- - -
- -
-
- - + + + + + +{{#if I.errors}} +{{#each I.errors as |error|}} + +
{{error.message}}
+{{/each}} +{{/if}} +
+ + +
+ +
+
+ +
- ## Arguments -| Argument | Type | Default | Description | -| --- | --- | --- | --- | -| changeset | [ImmerChangeset](https://triptyk.github.io/ember-immer-changeset/classes/ImmerChangeset.html) | | The changeset to use for the form | -| onSubmit | Function | | The function to execute when the form is submitted and valid. The changeset is the only argument passed to this function | -| validationSchema | [Yup Object](https://www.npmjs.com/package/yup) | | The yup validation schema to use for the form | -| reactive | Boolean | true | Whether or not the form should be reactive (a.k.a. validate the changeset on value change) | -| executeOnValid | Boolean | true | Whether or not the changeset should be executed if the form is valid | -| disabled | Boolean | false | Whether or not the form and the inputs should be disabled | -| removeErrorsOnSubmit | Boolean | true | Whether or not the errors should be removed when the form is submitted | -| autoScrollOnError | Boolean | true | Whether or not the form should scroll to the first error when the form is submitted | +| Argument | Type | Default | Description | +| -------------------- | --------------------------------------------------------------------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------ | +| changeset | [ImmerChangeset](https://triptyk.github.io/ember-immer-changeset/classes/ImmerChangeset.html) | | The changeset to use for the form | +| onSubmit | Function | | The function to execute when the form is submitted and valid. The changeset is the only argument passed to this function | +| validationSchema | [Yup Object](https://www.npmjs.com/package/yup) | | The yup validation schema to use for the form | +| reactive | Boolean | true | Whether or not the form should be reactive (a.k.a. validate the changeset on value change) | +| executeOnValid | Boolean | true | Whether or not the changeset should be executed if the form is valid | +| disabled | Boolean | false | Whether or not the form and the inputs should be disabled | +| removeErrorsOnSubmit | Boolean | true | Whether or not the errors should be removed when the form is submitted | +| autoScrollOnError | Boolean | true | Whether or not the form should scroll to the first error when the form is submitted | ## Yielded Components The `TpkForm` component yields the following components: ### Base Components + - TpkValidationInput yielded as `TpkInput` - TpkValidationTextarea yielded as `TpkTextarea` - TpkValidationSelect yielded as `TpkSelect` @@ -62,6 +63,7 @@ The `TpkForm` component yields the following components: - TpkValidationDatePicker yielded as `TpkDatepicker` ### Prefab Components + - TpkValidationInputPrefab yielded as `TpkInputPrefab` - TpkValidationTextareaPrefab yielded as `TpkTextareaPrefab` - TpkValidationSelectPrefab yielded as `TpkSelectPrefab` @@ -75,6 +77,7 @@ The `TpkForm` component yields the following components: - TpkValidationTimepickerPrefab yielded as `TpkTimepickerPrefab` ### Specialized Input Prefabs + - TpkValidationPasswordPrefab yielded as `TpkPasswordPrefab` - TpkValidationEmailPrefab yielded as `TpkEmailPrefab` - TpkValidationIBANPrefab yielded as `TpkIbanPrefab` @@ -100,9 +103,7 @@ The `TpkForm` component yields the following values: The default yielded components are TpkValidation`` , but you can change the default components by changing the values in the TpkForm service. ```ts -let tpkFormService = this.owner.lookup( - 'service:tpk-form', -) as TpkFormService; +let tpkFormService = this.owner.lookup('service:tpk-form') as TpkFormService; // Base Components tpkFormService.TpkInput = DummyInput; @@ -144,51 +145,54 @@ tpkFormService.TpkFilePrefab = DummyFilePrefab; ## Validation Behavior The form handles validation in two ways: + - On submit: The entire form is validated when submitted - On field change: If `@reactive={{true}}` (default), fields are validated individually when their values change When validation errors occur: + - If `@autoScrollOnError={{true}}` (default), the form will automatically scroll to the first error - If `@removeErrorsOnSubmit={{true}}` (default), existing errors are cleared before new validation on submit ## Complete example of using TpkForm - - -
- - - - - - - - - - - - - - - - - -
-
- -
-
- - + + + +
+ + + + + + + + + + + + + + + + + +
+
+ +
+
+ +
diff --git a/doc-app/app/templates/docs/ember-ui/stack-list.md b/doc-app/public/docs/ember-ui/stack-list.md similarity index 82% rename from doc-app/app/templates/docs/ember-ui/stack-list.md rename to doc-app/public/docs/ember-ui/stack-list.md index 18355c51..e6ec3bd0 100644 --- a/doc-app/app/templates/docs/ember-ui/stack-list.md +++ b/doc-app/public/docs/ember-ui/stack-list.md @@ -3,39 +3,37 @@ Stack list content - - - - title - {{T.item}} - - - content - {{C.item}} - {{ C.index }} - - - - + + + +title - {{T.item}} + + +content - {{C.item}} - {{ C.index }} + + + + ### Args **@titleForAdd**: A string parameter representing the label displayed beside the plus icon within the button. -**@onAdd**: A function parameter. This is function called when you click the +**@onAdd**: A function parameter. This is function called when you click the "add element to list" button. This function should add an element to the array used as the data args. -**@onRemove**: A function parameter. This is function called when you click the +**@onRemove**: A function parameter. This is function called when you click the thrash icon in the "element added" header. This function should remove an element from the array. **@data**: An array parameter. It represents the array that contains each element displayed in the stack-list. If there's no element, nothing is displayed except the "add element to list" button. - ### Yields **S.Title**: The HTML element that is displayed when the stack list element is closed. You can use T.item within S.title. item is an element of the array @@ -61,5 +59,3 @@ thrash icon in the "element added" header. This function should remove an elemen **.origin-top**: CSS class for styling the body of each element in the stack list. **.tpk-stack-head-expand-btn**: CSS class for styling the button that expands or collapses the body of each element in the stack list. - - diff --git a/doc-app/public/docs/ember-ui/table-generic.md b/doc-app/public/docs/ember-ui/table-generic.md new file mode 100644 index 00000000..e9f05342 --- /dev/null +++ b/doc-app/public/docs/ember-ui/table-generic.md @@ -0,0 +1,47 @@ +# Table generic + +A table component. + + + + + + + + +Firstname + + +Lastname + + +Email + + + + +{{element.firstName}} + + +{{element.lastName}} + + +{{element.email}} + + + +Delete + + + + + + + + + diff --git a/doc-app/app/templates/docs/index.md b/doc-app/public/docs/index.md similarity index 97% rename from doc-app/app/templates/docs/index.md rename to doc-app/public/docs/index.md index ff1dcd09..f7ae7a27 100644 --- a/doc-app/app/templates/docs/index.md +++ b/doc-app/public/docs/index.md @@ -9,8 +9,9 @@ This library is organized into three main packages: ### @triptyk/ember-input Provides composable input components for building forms: + - Text inputs, textareas, and specialized inputs -- Checkboxes and radio buttons +- Checkboxes and radio buttons - Select dropdowns and searchable selects - File inputs and date pickers - Toggle switches and buttons @@ -20,6 +21,7 @@ Provides composable input components for building forms: ### @triptyk/ember-input-validation Builds on ember-input with form validation capabilities: + - Validation-enabled versions of all input components - TpkForm component for managing form state - Integration with changesets for data validation @@ -30,6 +32,7 @@ Builds on ember-input with form validation capabilities: ### @triptyk/ember-ui Provides higher-level UI components: + - Modal dialogs and confirm modals - Data tables with sorting and pagination - Stack lists for managing collections diff --git a/doc-app/public/mockServiceWorker.js b/doc-app/public/mockServiceWorker.js index 1f45c4cf..cdbccc78 100644 --- a/doc-app/public/mockServiceWorker.js +++ b/doc-app/public/mockServiceWorker.js @@ -1,220 +1,243 @@ -/* eslint-disable */ -/* tslint:disable */ - /** - * Mock Service Worker (1.3.5). + * Mock Service Worker. * @see https://github.com/mswjs/msw * - Please do NOT modify this file. - * - Please do NOT serve this file on production. */ -const INTEGRITY_CHECKSUM = '3d6b9f06410d179a7f7404d4bf4c3c70' -const activeClientIds = new Set() +const PACKAGE_VERSION = '2.12.7'; +const INTEGRITY_CHECKSUM = '4db4a41e972cec1b64cc569c66952d82'; +const IS_MOCKED_RESPONSE = Symbol('isMockedResponse'); +const activeClientIds = new Set(); -self.addEventListener('install', function () { - self.skipWaiting() -}) +addEventListener('install', function () { + self.skipWaiting(); +}); -self.addEventListener('activate', function (event) { - event.waitUntil(self.clients.claim()) -}) +addEventListener('activate', function (event) { + event.waitUntil(self.clients.claim()); +}); -self.addEventListener('message', async function (event) { - const clientId = event.source.id +addEventListener('message', async function (event) { + const clientId = Reflect.get(event.source || {}, 'id'); if (!clientId || !self.clients) { - return + return; } - const client = await self.clients.get(clientId) + const client = await self.clients.get(clientId); if (!client) { - return + return; } const allClients = await self.clients.matchAll({ type: 'window', - }) + }); switch (event.data) { case 'KEEPALIVE_REQUEST': { sendToClient(client, { type: 'KEEPALIVE_RESPONSE', - }) - break + }); + break; } case 'INTEGRITY_CHECK_REQUEST': { sendToClient(client, { type: 'INTEGRITY_CHECK_RESPONSE', - payload: INTEGRITY_CHECKSUM, - }) - break + payload: { + packageVersion: PACKAGE_VERSION, + checksum: INTEGRITY_CHECKSUM, + }, + }); + break; } case 'MOCK_ACTIVATE': { - activeClientIds.add(clientId) + activeClientIds.add(clientId); sendToClient(client, { type: 'MOCKING_ENABLED', - payload: true, - }) - break - } - - case 'MOCK_DEACTIVATE': { - activeClientIds.delete(clientId) - break + payload: { + client: { + id: client.id, + frameType: client.frameType, + }, + }, + }); + break; } case 'CLIENT_CLOSED': { - activeClientIds.delete(clientId) + activeClientIds.delete(clientId); const remainingClients = allClients.filter((client) => { - return client.id !== clientId - }) + return client.id !== clientId; + }); // Unregister itself when there are no more clients if (remainingClients.length === 0) { - self.registration.unregister() + self.registration.unregister(); } - break + break; } } -}) - -self.addEventListener('fetch', function (event) { - const { request } = event - const accept = request.headers.get('accept') || '' +}); - // Bypass server-sent events. - if (accept.includes('text/event-stream')) { - return - } +addEventListener('fetch', function (event) { + const requestInterceptedAt = Date.now(); // Bypass navigation requests. - if (request.mode === 'navigate') { - return + if (event.request.mode === 'navigate') { + return; } // Opening the DevTools triggers the "only-if-cached" request // that cannot be handled by the worker. Bypass such requests. - if (request.cache === 'only-if-cached' && request.mode !== 'same-origin') { - return + if ( + event.request.cache === 'only-if-cached' && + event.request.mode !== 'same-origin' + ) { + return; } // Bypass all requests when there are no active clients. // Prevents the self-unregistered worked from handling requests - // after it's been deleted (still remains active until the next reload). + // after it's been terminated (still remains active until the next reload). if (activeClientIds.size === 0) { - return + return; } - // Generate unique request ID. - const requestId = Math.random().toString(16).slice(2) - - event.respondWith( - handleRequest(event, requestId).catch((error) => { - if (error.name === 'NetworkError') { - console.warn( - '[MSW] Successfully emulated a network error for the "%s %s" request.', - request.method, - request.url, - ) - return - } + const requestId = crypto.randomUUID(); + event.respondWith(handleRequest(event, requestId, requestInterceptedAt)); +}); - // At this point, any exception indicates an issue with the original request/response. - console.error( - `\ -[MSW] Caught an exception from the "%s %s" request (%s). This is probably not a problem with Mock Service Worker. There is likely an additional logging output above.`, - request.method, - request.url, - `${error.name}: ${error.message}`, - ) - }), - ) -}) - -async function handleRequest(event, requestId) { - const client = await resolveMainClient(event) - const response = await getResponse(event, client, requestId) +/** + * @param {FetchEvent} event + * @param {string} requestId + * @param {number} requestInterceptedAt + */ +async function handleRequest(event, requestId, requestInterceptedAt) { + const client = await resolveMainClient(event); + const requestCloneForEvents = event.request.clone(); + const response = await getResponse( + event, + client, + requestId, + requestInterceptedAt + ); // Send back the response clone for the "response:*" life-cycle events. // Ensure MSW is active and ready to handle the message, otherwise // this message will pend indefinitely. if (client && activeClientIds.has(client.id)) { - ;(async function () { - const clonedResponse = response.clone() - sendToClient(client, { + const serializedRequest = await serializeRequest(requestCloneForEvents); + + // Clone the response so both the client and the library could consume it. + const responseClone = response.clone(); + + sendToClient( + client, + { type: 'RESPONSE', payload: { - requestId, - type: clonedResponse.type, - ok: clonedResponse.ok, - status: clonedResponse.status, - statusText: clonedResponse.statusText, - body: - clonedResponse.body === null ? null : await clonedResponse.text(), - headers: Object.fromEntries(clonedResponse.headers.entries()), - redirected: clonedResponse.redirected, + isMockedResponse: IS_MOCKED_RESPONSE in response, + request: { + id: requestId, + ...serializedRequest, + }, + response: { + type: responseClone.type, + status: responseClone.status, + statusText: responseClone.statusText, + headers: Object.fromEntries(responseClone.headers.entries()), + body: responseClone.body, + }, }, - }) - })() + }, + responseClone.body ? [serializedRequest.body, responseClone.body] : [] + ); } - return response + return response; } -// Resolve the main client for the given event. -// Client that issues a request doesn't necessarily equal the client -// that registered the worker. It's with the latter the worker should -// communicate with during the response resolving phase. +/** + * Resolve the main client for the given event. + * Client that issues a request doesn't necessarily equal the client + * that registered the worker. It's with the latter the worker should + * communicate with during the response resolving phase. + * @param {FetchEvent} event + * @returns {Promise} + */ async function resolveMainClient(event) { - const client = await self.clients.get(event.clientId) + const client = await self.clients.get(event.clientId); + + if (activeClientIds.has(event.clientId)) { + return client; + } if (client?.frameType === 'top-level') { - return client + return client; } const allClients = await self.clients.matchAll({ type: 'window', - }) + }); return allClients .filter((client) => { // Get only those clients that are currently visible. - return client.visibilityState === 'visible' + return client.visibilityState === 'visible'; }) .find((client) => { // Find the client ID that's recorded in the // set of clients that have registered the worker. - return activeClientIds.has(client.id) - }) + return activeClientIds.has(client.id); + }); } -async function getResponse(event, client, requestId) { - const { request } = event - const clonedRequest = request.clone() +/** + * @param {FetchEvent} event + * @param {Client | undefined} client + * @param {string} requestId + * @param {number} requestInterceptedAt + * @returns {Promise} + */ +async function getResponse(event, client, requestId, requestInterceptedAt) { + // Clone the request because it might've been already used + // (i.e. its body has been read and sent to the client). + const requestClone = event.request.clone(); function passthrough() { - // Clone the request because it might've been already used - // (i.e. its body has been read and sent to the client). - const headers = Object.fromEntries(clonedRequest.headers.entries()) - - // Remove MSW-specific request headers so the bypassed requests - // comply with the server's CORS preflight check. - // Operate with the headers as an object because request "Headers" - // are immutable. - delete headers['x-msw-bypass'] + // Cast the request headers to a new Headers instance + // so the headers can be manipulated with. + const headers = new Headers(requestClone.headers); + + // Remove the "accept" header value that marked this request as passthrough. + // This prevents request alteration and also keeps it compliant with the + // user-defined CORS policies. + const acceptHeader = headers.get('accept'); + if (acceptHeader) { + const values = acceptHeader.split(',').map((value) => value.trim()); + const filteredValues = values.filter( + (value) => value !== 'msw/passthrough' + ); + + if (filteredValues.length > 0) { + headers.set('accept', filteredValues.join(', ')); + } else { + headers.delete('accept'); + } + } - return fetch(clonedRequest, { headers }) + return fetch(requestClone, { headers }); } // Bypass mocking when the client is not active. if (!client) { - return passthrough() + return passthrough(); } // Bypass initial page load requests (i.e. static assets). @@ -222,82 +245,102 @@ async function getResponse(event, client, requestId) { // means that MSW hasn't dispatched the "MOCK_ACTIVATE" event yet // and is not ready to handle requests. if (!activeClientIds.has(client.id)) { - return passthrough() - } - - // Bypass requests with the explicit bypass header. - // Such requests can be issued by "ctx.fetch()". - if (request.headers.get('x-msw-bypass') === 'true') { - return passthrough() + return passthrough(); } // Notify the client that a request has been intercepted. - const clientMessage = await sendToClient(client, { - type: 'REQUEST', - payload: { - id: requestId, - url: request.url, - method: request.method, - headers: Object.fromEntries(request.headers.entries()), - cache: request.cache, - mode: request.mode, - credentials: request.credentials, - destination: request.destination, - integrity: request.integrity, - redirect: request.redirect, - referrer: request.referrer, - referrerPolicy: request.referrerPolicy, - body: await request.text(), - bodyUsed: request.bodyUsed, - keepalive: request.keepalive, + const serializedRequest = await serializeRequest(event.request); + const clientMessage = await sendToClient( + client, + { + type: 'REQUEST', + payload: { + id: requestId, + interceptedAt: requestInterceptedAt, + ...serializedRequest, + }, }, - }) + [serializedRequest.body] + ); switch (clientMessage.type) { case 'MOCK_RESPONSE': { - return respondWithMock(clientMessage.data) + return respondWithMock(clientMessage.data); } - case 'MOCK_NOT_FOUND': { - return passthrough() - } - - case 'NETWORK_ERROR': { - const { name, message } = clientMessage.data - const networkError = new Error(message) - networkError.name = name - - // Rejecting a "respondWith" promise emulates a network error. - throw networkError + case 'PASSTHROUGH': { + return passthrough(); } } - return passthrough() + return passthrough(); } -function sendToClient(client, message) { +/** + * @param {Client} client + * @param {any} message + * @param {Array} transferrables + * @returns {Promise} + */ +function sendToClient(client, message, transferrables = []) { return new Promise((resolve, reject) => { - const channel = new MessageChannel() + const channel = new MessageChannel(); channel.port1.onmessage = (event) => { if (event.data && event.data.error) { - return reject(event.data.error) + return reject(event.data.error); } - resolve(event.data) - } + resolve(event.data); + }; - client.postMessage(message, [channel.port2]) - }) + client.postMessage(message, [ + channel.port2, + ...transferrables.filter(Boolean), + ]); + }); } -function sleep(timeMs) { - return new Promise((resolve) => { - setTimeout(resolve, timeMs) - }) +/** + * @param {Response} response + * @returns {Response} + */ +function respondWithMock(response) { + // Setting response status code to 0 is a no-op. + // However, when responding with a "Response.error()", the produced Response + // instance will have status code set to 0. Since it's not possible to create + // a Response instance with status code 0, handle that use-case separately. + if (response.status === 0) { + return Response.error(); + } + + const mockedResponse = new Response(response.body, response); + + Reflect.defineProperty(mockedResponse, IS_MOCKED_RESPONSE, { + value: true, + enumerable: true, + }); + + return mockedResponse; } -async function respondWithMock(response) { - await sleep(response.delay) - return new Response(response.body, response) +/** + * @param {Request} request + */ +async function serializeRequest(request) { + return { + url: request.url, + mode: request.mode, + method: request.method, + headers: Object.fromEntries(request.headers.entries()), + cache: request.cache, + credentials: request.credentials, + destination: request.destination, + integrity: request.integrity, + redirect: request.redirect, + referrer: request.referrer, + referrerPolicy: request.referrerPolicy, + body: await request.arrayBuffer(), + keepalive: request.keepalive, + }; } diff --git a/doc-app/public/worker.js b/doc-app/public/worker.js deleted file mode 100644 index 205ede1c..00000000 --- a/doc-app/public/worker.js +++ /dev/null @@ -1,3 +0,0 @@ -import { setupWorker } from 'msw'; - -export const worker = (handlers) => setupWorker(...handlers); diff --git a/doc-app/tailwind.config.js b/doc-app/tailwind.config.js deleted file mode 100644 index 9a6b4745..00000000 --- a/doc-app/tailwind.config.js +++ /dev/null @@ -1,19 +0,0 @@ -const path = require('path'); - -/** @type {import('tailwindcss').Config} */ -module.exports = { - content: [ - './app/**/*.{gjs,gts,hbs,html,js,ts}', - path.join( - path.dirname(require.resolve('@triptyk/ember-input-validation')), - '**/*.{gts,gjs,ts,js,css}', - ), - ], - theme: { - extend: {}, - }, - daisyui: { - themes: ['light'], - }, - plugins: [require('daisyui')], -}; diff --git a/doc-app/testem.cjs b/doc-app/testem.cjs new file mode 100644 index 00000000..b4b6691f --- /dev/null +++ b/doc-app/testem.cjs @@ -0,0 +1,25 @@ +'use strict'; + +if (typeof module !== 'undefined') { + module.exports = { + test_page: 'tests/index.html?hidepassed', + disable_watching: true, + launch_in_ci: ['Chrome'], + launch_in_dev: ['Chrome'], + browser_start_timeout: 120, + browser_args: { + Chrome: { + ci: [ + // --no-sandbox is needed when running Chrome inside a container + process.env.CI ? '--no-sandbox' : null, + '--headless', + '--disable-dev-shm-usage', + '--disable-software-rasterizer', + '--mute-audio', + '--remote-debugging-port=0', + '--window-size=1440,900', + ].filter(Boolean), + }, + }, + }; +} diff --git a/doc-app/testem.js b/doc-app/testem.js deleted file mode 100644 index a2d0e08f..00000000 --- a/doc-app/testem.js +++ /dev/null @@ -1,23 +0,0 @@ - - -module.exports = { - test_page: 'tests/index.html?hidepassed', - disable_watching: true, - launch_in_ci: ['Chrome'], - launch_in_dev: ['Chrome'], - browser_start_timeout: 120, - browser_args: { - Chrome: { - ci: [ - // --no-sandbox is needed when running Chrome inside a container - process.env.CI ? '--no-sandbox' : null, - '--headless', - '--disable-dev-shm-usage', - '--disable-software-rasterizer', - '--mute-audio', - '--remote-debugging-port=0', - '--window-size=1440,900', - ].filter(Boolean), - }, - }, -}; diff --git a/doc-app/tests/index.html b/doc-app/tests/index.html index 9051fb38..ef8aad47 100644 --- a/doc-app/tests/index.html +++ b/doc-app/tests/index.html @@ -2,21 +2,20 @@ - DocApp Tests + Blueprint Tests {{content-for "head"}} {{content-for "test-head"}} - - - + + {{content-for "head-footer"}} {{content-for "test-head-footer"}} - + {{content-for "body"}} {{content-for "test-body"}} @@ -28,12 +27,16 @@
- - - - + + + + + {{content-for "body-footer"}} - {{content-for "test-body-footer"}} diff --git a/doc-app/tests/integration/components/ember-input-validation/generic-test-functions/assert-data-has-error-attribute.ts b/doc-app/tests/integration/components/ember-input-validation/generic-test-functions/assert-data-has-error-attribute.ts index 153f19d4..fce96ab0 100644 --- a/doc-app/tests/integration/components/ember-input-validation/generic-test-functions/assert-data-has-error-attribute.ts +++ b/doc-app/tests/integration/components/ember-input-validation/generic-test-functions/assert-data-has-error-attribute.ts @@ -1,10 +1,10 @@ -import { settled } from "@ember/test-helpers"; -import type ImmerChangeset from "ember-immer-changeset"; +import { settled } from '@ember/test-helpers'; +import type ImmerChangeset from 'ember-immer-changeset'; export async function assertDataHasErrorAttribute( assert: Assert, changeset: ImmerChangeset, - input: string, + input: string ) { changeset.addError({ message: 'required', diff --git a/doc-app/tests/integration/components/ember-input-validation/generic-test-functions/assert-tpk-css-classes-exist.ts b/doc-app/tests/integration/components/ember-input-validation/generic-test-functions/assert-tpk-css-classes-exist.ts index bc142d3f..06798b2e 100644 --- a/doc-app/tests/integration/components/ember-input-validation/generic-test-functions/assert-tpk-css-classes-exist.ts +++ b/doc-app/tests/integration/components/ember-input-validation/generic-test-functions/assert-tpk-css-classes-exist.ts @@ -1,14 +1,27 @@ -export async function assertTpkCssClassesExist( - assert: Assert, - input: string, - inputType: 'input' | 'textarea' = 'input' +export function assertTpkCssClassesExist( + assert: Assert, + input: string, + inputType: 'input' | 'textarea' = 'input' ) { - assert.dom(`.tpk-${input}-container`).exists().hasAttribute(`data-test-tpk-prefab-${input}-container`); - assert.dom(`.tpk-${input}-container .tpk-${input}-input`).exists() - assert.dom(`.tpk-${input}-container .tpk-validation-errors`).exists() - assert.dom(`.tpk-${input}-container .tpk-label`).exists() - assert.dom(`label`).hasClass(`tpk-${input}-container`); - assert.dom(inputType).hasClass(`tpk-${input}-input`); - assert.dom(`label > div:first-of-type`).hasClass(`tpk-label`, `The first div inside label has the class tpk-label.`); - assert.dom(`label > div:last-of-type`).hasClass(`tpk-validation-errors`, `The second div inside label has the class tpk-validation-errors.`); + assert + .dom(`.tpk-${input}-container`) + .exists() + .hasAttribute(`data-test-tpk-prefab-${input}-container`); + assert.dom(`.tpk-${input}-container .tpk-${input}-input`).exists(); + assert.dom(`.tpk-${input}-container .tpk-validation-errors`).exists(); + assert.dom(`.tpk-${input}-container .tpk-label`).exists(); + assert.dom(`label`).hasClass(`tpk-${input}-container`); + assert.dom(inputType).hasClass(`tpk-${input}-input`); + assert + .dom(`label > div:first-of-type`) + .hasClass( + `tpk-label`, + `The first div inside label has the class tpk-label.` + ); + assert + .dom(`label > div:last-of-type`) + .hasClass( + `tpk-validation-errors`, + `The second div inside label has the class tpk-validation-errors.` + ); } diff --git a/doc-app/tests/integration/components/ember-input-validation/generic-test-functions/initialize-params-tpk-form.ts b/doc-app/tests/integration/components/ember-input-validation/generic-test-functions/initialize-params-tpk-form.ts index 2c77508a..a2c04a4f 100644 --- a/doc-app/tests/integration/components/ember-input-validation/generic-test-functions/initialize-params-tpk-form.ts +++ b/doc-app/tests/integration/components/ember-input-validation/generic-test-functions/initialize-params-tpk-form.ts @@ -1,10 +1,10 @@ import { ImmerChangeset } from 'ember-immer-changeset'; -import { object, type Schema } from 'yup'; +import { object, ZodObject } from 'zod'; export interface TpkFormParams { changeset?: ImmerChangeset; onSubmit?: (...args: unknown[]) => void; - validationSchema?: Schema; + validationSchema?: ZodObject; reactive?: boolean; removeErrorsOnSubmit?: boolean; autoScrollOnError?: boolean; diff --git a/doc-app/tests/integration/components/ember-input-validation/generic-test-functions/setup-prefab-component.gts b/doc-app/tests/integration/components/ember-input-validation/generic-test-functions/setup-prefab-component.gts index 6bdbc0dd..ed385a88 100644 --- a/doc-app/tests/integration/components/ember-input-validation/generic-test-functions/setup-prefab-component.gts +++ b/doc-app/tests/integration/components/ember-input-validation/generic-test-functions/setup-prefab-component.gts @@ -1,15 +1,28 @@ -import { render } from "@ember/test-helpers"; -import { initializeParams, type TpkFormParams } from './initialize-params-tpk-form'; +import { render } from '@ember/test-helpers'; +import { + initializeParams, + type TpkFormParams, +} from './initialize-params-tpk-form'; import TpkForm from '@triptyk/ember-input-validation/components/tpk-form'; export async function setupCompletePrefabComponent(params?: TpkFormParams) { - const { changeset, onSubmit, validationSchema, reactive, removeErrorsOnSubmit, autoScrollOnError, executeOnValid } = initializeParams(params); + const { + changeset, + onSubmit, + validationSchema, + reactive, + removeErrorsOnSubmit, + autoScrollOnError, + executeOnValid, + } = initializeParams(params); const selectOptions = ['option1', 'option2']; const onCreate = () => {}; - const onSearch = () => {}; + const onSearch = () => { + return []; + }; await render( @@ -48,54 +141,82 @@ export async function setupCompletePrefabComponent(params?: TpkFormParams) { } export async function setupComponent(params?: TpkFormParams) { - const { changeset, onSubmit, validationSchema, reactive, removeErrorsOnSubmit, autoScrollOnError, executeOnValid } = initializeParams(params); + const { + changeset, + onSubmit, + validationSchema, + reactive, + removeErrorsOnSubmit, + autoScrollOnError, + executeOnValid, + } = initializeParams(params); - await render( - + ); - return changeset; - } + return changeset; +} export async function setupCurrencyDateComponent(params?: TpkFormParams) { - const { changeset, onSubmit, validationSchema, reactive, removeErrorsOnSubmit, autoScrollOnError, executeOnValid } = initializeParams(params); + const { + changeset, + onSubmit, + validationSchema, + reactive, + removeErrorsOnSubmit, + autoScrollOnError, + executeOnValid, + } = initializeParams(params); - await render( - + ); - return changeset; - } + return changeset; +} diff --git a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-bic-test.gts b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-bic-test.gts index b9f28b9a..f9349e65 100644 --- a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-bic-test.gts +++ b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-bic-test.gts @@ -23,13 +23,13 @@ module( await render( , + /> + ); return immerChangeset; } @@ -51,16 +51,16 @@ module( }); test('It changes data-has-error attribute on error', async function (assert) { - const changeset = await renderComponentAndReturnChangeset(); - await assertDataHasErrorAttribute(assert,changeset,'bic'); + const changeset = await renderComponentAndReturnChangeset(); + await assertDataHasErrorAttribute(assert, changeset, 'bic'); }); test('CSS classes exist and have been attached to the correct element', async function (assert) { await renderComponentAndReturnChangeset(); - await assertTpkCssClassesExist(assert,'bic'); + assertTpkCssClassesExist(assert, 'bic'); }); - test('@disabled disables the input', async function(assert) { + test('@disabled disables the input', async function (assert) { await renderComponentAndReturnChangeset({ disabled: true, }); @@ -74,5 +74,5 @@ module( }); await a11yAudit(); }); - }, + } ); diff --git a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-checkbox-test.gts b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-checkbox-test.gts index 802c3946..f81fed9d 100644 --- a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-checkbox-test.gts +++ b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-checkbox-test.gts @@ -1,6 +1,6 @@ import { module, test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; -import { render } from '@ember/test-helpers'; +import { render } from '@ember/test-helpers'; import { ImmerChangeset } from 'ember-immer-changeset'; import { setupIntl } from 'ember-intl/test-support'; import TpkValidationCheckbox from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-checkbox'; @@ -14,19 +14,22 @@ module( setupRenderingTest(hooks); setupIntl(hooks, 'fr-fr'); - async function renderComponent(changeset: ImmerChangeset, params?: { - disabled?: boolean; - }) { + async function renderComponent( + changeset: ImmerChangeset, + params?: { + disabled?: boolean; + } + ) { await render( , + ); } @@ -48,16 +51,16 @@ module( test('It changes data-has-error attribute on error', async function (assert) { const changeset = setupChangeset(); await renderComponent(changeset); - await assertDataHasErrorAttribute(assert,changeset,'checkbox'); + await assertDataHasErrorAttribute(assert, changeset, 'checkbox'); }); - test('CSS classes exist and have been attached to the correct element', async function (assert) { + test('CSS classes exist and have been attached to the correct element', async function (assert) { const changeset = setupChangeset(); await renderComponent(changeset); - await assertTpkCssClassesExist(assert,'checkbox'); + assertTpkCssClassesExist(assert, 'checkbox'); }); - test('@disabled disables the input', async function(assert) { + test('@disabled disables the input', async function (assert) { const changeset = setupChangeset(); await renderComponent(changeset, { disabled: true, @@ -73,5 +76,5 @@ module( }); await a11yAudit(); }); - }, + } ); diff --git a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-currency-test.gts b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-currency-test.gts index 071c1bab..25cbae25 100644 --- a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-currency-test.gts +++ b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-currency-test.gts @@ -1,7 +1,6 @@ - import { module, test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; -import { fillIn, render } from '@ember/test-helpers'; +import { fillIn, render } from '@ember/test-helpers'; import { setupIntl } from 'ember-intl/test-support'; import { ImmerChangeset } from 'ember-immer-changeset'; import TpkValidationCurrency from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-currency'; @@ -9,7 +8,6 @@ import { assertTpkCssClassesExist } from '../generic-test-functions/assert-tpk-c import { assertDataHasErrorAttribute } from '../generic-test-functions/assert-data-has-error-attribute'; import { a11yAudit } from 'ember-a11y-testing/test-support'; - module( 'Integration | Component | Prefabs | tpk-validation-currency', function (hooks) { @@ -17,32 +15,30 @@ module( setupIntl(hooks, 'fr-fr'); function setupChangeset() { - return new ImmerChangeset({ + return new ImmerChangeset({ currency: 123.56, }); } async function renderComponent( changeset: ImmerChangeset, - { scale = 2, disabled = false } = {}, + { scale = 2, disabled = false } = {} ) { - - const onChange = (value: number) => { + const onChange = (value: string | number | Date | null) => { changeset.set('currency', value); }; await render( , + @label="label" + @changeset={{changeset}} + @onChange={{onChange}} + @validationField="currency" + @scale={{scale}} + @disabled={{disabled}} + /> + ); - } // currently, only euro is supported @@ -58,13 +54,13 @@ module( assert.dom('input').hasAttribute('type', 'text'); }); - test('Should set value as number', async function ( assert) { + test('Should set value as number', async function (assert) { const changeset = setupChangeset(); await renderComponent(changeset); assert.strictEqual(changeset.get('currency'), 123.56); }); - test('Should set value as number when value change', async function ( assert) { + test('Should set value as number when value change', async function (assert) { const changeset = setupChangeset(); await renderComponent(changeset); await fillIn('input', '123.45'); @@ -74,7 +70,7 @@ module( test('@scale should control the decimals of the input', async function (assert) { const changeset = setupChangeset(); await renderComponent(changeset, { - scale: 3 + scale: 3, }); assert.dom('[data-test-tpk-currency-input]').hasValue('123.560 €'); }); @@ -82,16 +78,16 @@ module( test('Error prefab appears if an error is added to changeset', async function (assert) { const changeset = setupChangeset(); await renderComponent(changeset); - await assertDataHasErrorAttribute(assert,changeset,'currency'); + await assertDataHasErrorAttribute(assert, changeset, 'currency'); }); test('CSS classes exist and have been attached to the correct element', async function (assert) { const changeset = setupChangeset(); await renderComponent(changeset); - await assertTpkCssClassesExist(assert,'currency'); + assertTpkCssClassesExist(assert, 'currency'); }); - test('@disabled disables the input', async function(assert) { + test('@disabled disables the input', async function (assert) { const changeset = setupChangeset(); await renderComponent(changeset, { disabled: true, @@ -107,5 +103,5 @@ module( }); await a11yAudit(); }); - }, + } ); diff --git a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-datepicker-range-test.gts b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-datepicker-range-test.gts index d3f4ea41..3598e236 100644 --- a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-datepicker-range-test.gts +++ b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-datepicker-range-test.gts @@ -9,7 +9,6 @@ import TpkValidationDatepickerRange from '@triptyk/ember-input-validation/compon import { assertDataHasErrorAttribute } from '../generic-test-functions/assert-data-has-error-attribute'; import { a11yAudit } from 'ember-a11y-testing/test-support'; - module( 'Integration | Component | Prefabs | tpk-validation-datepicker-range', function (hooks) { @@ -24,13 +23,13 @@ module( }); await render( , + /> + ); return immerChangeset; } @@ -45,27 +44,46 @@ module( }); test('It changes data-has-error attribute on error', async function (assert) { - const changeset = await renderComponentAndReturnChangeset(); - await assertDataHasErrorAttribute(assert,changeset,'datepicker-range'); + const changeset = await renderComponentAndReturnChangeset(); + await assertDataHasErrorAttribute(assert, changeset, 'datepicker-range'); }); test('CSS classes exist and have been attached to the correct element', async function (assert) { await renderComponentAndReturnChangeset(); - assert.dom(`.tpk-datepicker-range-container`).exists().hasAttribute(`data-test-tpk-prefab-datepicker-range-container`); - assert.dom(`.tpk-datepicker-range-container .tpk-datepicker-range-input`).exists() - assert.dom(`.tpk-datepicker-range-container .tpk-validation-errors`).exists() - assert.dom(`.tpk-datepicker-range-container .tpk-label`).exists() + assert + .dom(`.tpk-datepicker-range-container`) + .exists() + .hasAttribute(`data-test-tpk-prefab-datepicker-range-container`); + assert + .dom(`.tpk-datepicker-range-container .tpk-datepicker-range-input`) + .exists(); + assert + .dom(`.tpk-datepicker-range-container .tpk-validation-errors`) + .exists(); + assert.dom(`.tpk-datepicker-range-container .tpk-label`).exists(); assert.dom('input').hasClass(`tpk-datepicker-range-input`); - assert.dom(`label > div:first-of-type`).hasClass(`tpk-label`, `The first div inside label has the class tpk-label.`); - assert.dom(`.tpk-datepicker-range-container > div:last-of-type`).hasClass(`tpk-validation-errors`, `The last div inside container has the class tpk-validation-errors.`); + assert + .dom(`label > div:first-of-type`) + .hasClass( + `tpk-label`, + `The first div inside label has the class tpk-label.` + ); + assert + .dom(`.tpk-datepicker-range-container > div:last-of-type`) + .hasClass( + `tpk-validation-errors`, + `The last div inside container has the class tpk-validation-errors.` + ); }); - test('@disabled disables the input', async function(assert) { + test('@disabled disables the input', async function (assert) { await renderComponentAndReturnChangeset({ disabled: true, }); - assert.dom(`[data-test-tpk-datepicker-range-input]`).hasAttribute('disabled'); + assert + .dom(`[data-test-tpk-datepicker-range-input]`) + .hasAttribute('disabled'); }); test('Accessibility', async function (assert) { @@ -75,5 +93,5 @@ module( }); await a11yAudit(); }); - }, + } ); diff --git a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-datepicker-test.gts b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-datepicker-test.gts index 702f7b25..14b225a9 100644 --- a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-datepicker-test.gts +++ b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-datepicker-test.gts @@ -9,7 +9,6 @@ import TpkValidationDatepicker from '@triptyk/ember-input-validation/components/ import { assertDataHasErrorAttribute } from '../generic-test-functions/assert-data-has-error-attribute'; import { a11yAudit } from 'ember-a11y-testing/test-support'; - module( 'Integration | Component | Prefabs | tpk-validation-datepicker', function (hooks) { @@ -20,17 +19,17 @@ module( disabled?: boolean; }) { const immerChangeset = new ImmerChangeset({ - 'datepicker': null, + datepicker: null, }); await render( , + /> + ); return immerChangeset; } @@ -43,23 +42,36 @@ module( }); test('It changes data-has-error attribute on error', async function (assert) { - const changeset = await renderComponentAndReturnChangeset(); - await assertDataHasErrorAttribute(assert,changeset,'datepicker'); + const changeset = await renderComponentAndReturnChangeset(); + await assertDataHasErrorAttribute(assert, changeset, 'datepicker'); }); test('CSS classes exist and have been attached to the correct element', async function (assert) { await renderComponentAndReturnChangeset(); - assert.dom(`.tpk-datepicker-container`).exists().hasAttribute(`data-test-tpk-prefab-datepicker-container`); - assert.dom(`.tpk-datepicker-container .tpk-datepicker-input`).exists() - assert.dom(`.tpk-datepicker-container .tpk-validation-errors`).exists() - assert.dom(`.tpk-datepicker-container .tpk-label`).exists() + assert + .dom(`.tpk-datepicker-container`) + .exists() + .hasAttribute(`data-test-tpk-prefab-datepicker-container`); + assert.dom(`.tpk-datepicker-container .tpk-datepicker-input`).exists(); + assert.dom(`.tpk-datepicker-container .tpk-validation-errors`).exists(); + assert.dom(`.tpk-datepicker-container .tpk-label`).exists(); assert.dom('input').hasClass(`tpk-datepicker-input`); - assert.dom(`label > div:first-of-type`).hasClass(`tpk-label`, `The first div inside label has the class tpk-label.`); - assert.dom(`.tpk-datepicker-container > div:last-of-type`).hasClass(`tpk-validation-errors`, `The last div inside container has the class tpk-validation-errors.`); + assert + .dom(`label > div:first-of-type`) + .hasClass( + `tpk-label`, + `The first div inside label has the class tpk-label.` + ); + assert + .dom(`.tpk-datepicker-container > div:last-of-type`) + .hasClass( + `tpk-validation-errors`, + `The last div inside container has the class tpk-validation-errors.` + ); }); - test('@disabled disables the input', async function(assert) { + test('@disabled disables the input', async function (assert) { await renderComponentAndReturnChangeset({ disabled: true, }); @@ -73,5 +85,5 @@ module( }); await a11yAudit(); }); - }, + } ); diff --git a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-email-test.gts b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-email-test.gts index 8b5ed3d6..068e7038 100644 --- a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-email-test.gts +++ b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-email-test.gts @@ -8,57 +8,64 @@ import { assertTpkCssClassesExist } from '../generic-test-functions/assert-tpk-c import { assertDataHasErrorAttribute } from '../generic-test-functions/assert-data-has-error-attribute'; import { a11yAudit } from 'ember-a11y-testing/test-support'; - module( 'Integration | Component | Prefabs | tpk-validation-email', function (hooks) { setupRenderingTest(hooks); setupIntl(hooks, 'fr-fr'); - async function renderComponent({ changeset, disabled }: { changeset: ImmerChangeset, disabled?: boolean }) { - await render(); + async function renderComponent({ + changeset, + disabled, + }: { + changeset: ImmerChangeset; + disabled?: boolean; + }) { + await render( + + ); } - function setupChangeset( email: string) { + function setupChangeset(email: string) { return new ImmerChangeset({ email, }); } - test('the type of the input is email', async function ( assert) { + test('the type of the input is email', async function (assert) { const changeset = setupChangeset('email'); - await renderComponent({changeset}); + await renderComponent({ changeset }); assert.dom('input').hasAttribute('type', 'email'); }); test('It changes data-has-error attribute on error', async function (assert) { const changeset = setupChangeset(''); - await renderComponent({changeset}); - await assertDataHasErrorAttribute(assert,changeset,'email'); + await renderComponent({ changeset }); + await assertDataHasErrorAttribute(assert, changeset, 'email'); }); test('CSS classes exist and have been attached to the correct element', async function (assert) { const changeset = setupChangeset('email'); - await renderComponent({changeset}); - await assertTpkCssClassesExist(assert,'email'); + await renderComponent({ changeset }); + assertTpkCssClassesExist(assert, 'email'); }); - test('@disabled disables the input', async function(assert) { - await renderComponent({changeset: setupChangeset(''), disabled: true}); + test('@disabled disables the input', async function (assert) { + await renderComponent({ changeset: setupChangeset(''), disabled: true }); assert.dom(`[data-test-tpk-email-input]`).hasAttribute('disabled'); }); test('Accessibility', async function (assert) { assert.expect(0); - await renderComponent({changeset: setupChangeset(''), disabled: false}); + await renderComponent({ changeset: setupChangeset(''), disabled: false }); await a11yAudit(); }); - }, + } ); diff --git a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-file-list-test.gts b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-file-list-test.gts index 2290c2c1..2c124474 100644 --- a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-file-list-test.gts +++ b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-file-list-test.gts @@ -9,18 +9,13 @@ import { assertTpkCssClassesExist } from '../generic-test-functions/assert-tpk-c import { a11yAudit } from 'ember-a11y-testing/test-support'; import { settled } from '@ember/test-helpers'; - module( 'Integration | Component | Prefabs | tpk-validation-file-list', function (hooks) { setupRenderingTest(hooks); setupIntl(hooks, 'fr-fr'); - function setupChangeset({ - files = [], - }: { - files: File[] - }) { + function setupChangeset({ files = [] }: { files: File[] }) { return new ImmerChangeset<{ files: File[]; }>({ @@ -28,7 +23,11 @@ module( }); } - async function renderComponent(params: { changeset: ImmerChangeset; disabled?: boolean; disableDownload?: boolean; }) { + async function renderComponent(params: { + changeset: ImmerChangeset; + disabled?: boolean; + disableDownload?: boolean; + }) { await render( , + ); - } - + } test('Should show download and delete buttons by default when there are files', async function (assert) { const changeset = setupChangeset({ - files: [new File(['Ember Rules!'], 'file.txt')] + files: [new File(['Ember Rules!'], 'file.txt')], }); - await renderComponent({changeset}); + await renderComponent({ changeset }); assert.dom('.tpk-file-list-list-item-action-download').exists(); assert.dom('.tpk-file-list-list-item-action-delete').exists(); }); test('Should hide download and delete buttons when disableDownload is true and disabled', async function (assert) { const changeset = setupChangeset({ - files: [new File(['Ember Rules!'], 'file.txt')] + files: [new File(['Ember Rules!'], 'file.txt')], + }); + await renderComponent({ + changeset, + disabled: true, + disableDownload: true, }); - await renderComponent({changeset, disabled: true, disableDownload: true}); assert.dom('.tpk-file-list-list-item-action-download').doesNotExist(); assert.dom('.tpk-file-list-list-item-action-delete').doesNotExist(); }); test('Drag and drop files should add them to the changeset and show them in the list', async function (assert) { const changeset = setupChangeset({ - files: [] + files: [], }); await renderComponent({ changeset }); await triggerEvent('.tpk-file-list-placeholder-container', 'drop', { dataTransfer: { - files: [new File(['Ember Rules!'], 'file.txt'), new File(['Ember Rules!'], 'loempia.txt')], - } + files: [ + new File(['Ember Rules!'], 'file.txt'), + new File(['Ember Rules!'], 'loempia.txt'), + ], + }, }); assert.dom('.tpk-file-list-list-item').exists({ count: 2 }); assert.strictEqual(changeset.get('files').length, 2); @@ -78,13 +83,13 @@ module( test('Drop a file with a default file in changeset should add the file to the changeset and not remove the default file', async function (assert) { const changeset = setupChangeset({ - files: [new File(['Ember Rules!'], 'file.txt')] + files: [new File(['Ember Rules!'], 'file.txt')], }); await renderComponent({ changeset }); await triggerEvent('.tpk-file-list-placeholder-container', 'drop', { dataTransfer: { files: [new File(['Ember Rules!'], 'file.txt')], - } + }, }); assert.dom('.tpk-file-list-list-item').exists({ count: 2 }); assert.strictEqual(changeset.get('files').length, 2); @@ -92,19 +97,21 @@ module( test('Delete button should remove the file from the changeset', async function (assert) { const changeset = setupChangeset({ - files: [new File(['Ember Rules!'], 'file.txt')] + files: [new File(['Ember Rules!'], 'file.txt')], }); await renderComponent({ changeset }); - await click('.tpk-file-list-list-item:first-child .tpk-file-list-list-item-action-delete'); + await click( + '.tpk-file-list-list-item:first-child .tpk-file-list-list-item-action-delete' + ); assert.dom('.tpk-file-list-list-item').doesNotExist(); assert.strictEqual(changeset.get('files').length, 0); }); test('It changes data-has-error attribue on error', async function (assert) { const changeset = setupChangeset({ - files: [] + files: [], }); - await renderComponent({changeset}); + await renderComponent({ changeset }); changeset.addError({ message: 'required', @@ -123,19 +130,19 @@ module( test('CSS classes exist and have been attached to the correct element', async function (assert) { const changeset = setupChangeset({ - files: [] + files: [], }); - await renderComponent({changeset}); - await assertTpkCssClassesExist(assert,'file-list'); + await renderComponent({ changeset }); + assertTpkCssClassesExist(assert, 'file-list'); }); test('Accessibility', async function (assert) { assert.expect(0); const changeset = setupChangeset({ - files: [] + files: [], }); - await renderComponent({changeset}); + await renderComponent({ changeset }); await a11yAudit(); }); - }, + } ); diff --git a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-file-test.gts b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-file-test.gts index 94032eaa..4095caa1 100644 --- a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-file-test.gts +++ b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-file-test.gts @@ -8,7 +8,6 @@ import { assertTpkCssClassesExist } from '../generic-test-functions/assert-tpk-c import { assertDataHasErrorAttribute } from '../generic-test-functions/assert-data-has-error-attribute'; import { a11yAudit } from 'ember-a11y-testing/test-support'; - module( 'Integration | Component | Prefabs | tpk-validation-file', function (hooks) { @@ -23,19 +22,27 @@ module( }); } - async function renderComponent(params: { changeset: ImmerChangeset; disabled?: boolean }) { + async function renderComponent(params: { + changeset: ImmerChangeset; + disabled?: boolean; + }) { await render( - , + ); - } - + } test('It changes data-has-error attribue on error', async function (assert) { const changeset = setupChangeset(); - await renderComponent({changeset}); + await renderComponent({ changeset }); - await assertDataHasErrorAttribute(assert,changeset,'file'); + await assertDataHasErrorAttribute(assert, changeset, 'file'); await triggerEvent('[data-test-tpk-file-input]', 'change', { files: [new File(['Ember Rules!'], 'file.txt')], @@ -45,20 +52,20 @@ module( test('CSS classes exist and have been attached to the correct element', async function (assert) { const changeset = setupChangeset(); - await renderComponent({changeset}); - await assertTpkCssClassesExist(assert,'file'); + await renderComponent({ changeset }); + assertTpkCssClassesExist(assert, 'file'); }); - test('@disabled disables the input', async function(assert) { + test('@disabled disables the input', async function (assert) { const changeset = setupChangeset(); - await renderComponent({ changeset , disabled: true}); + await renderComponent({ changeset, disabled: true }); assert.dom(`[data-test-tpk-file-input]`).hasAttribute('disabled'); }); test('Accessibility', async function (assert) { assert.expect(0); - await renderComponent({changeset: setupChangeset(), disabled: false}); + await renderComponent({ changeset: setupChangeset(), disabled: false }); await a11yAudit(); }); - }, + } ); diff --git a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-iban-test.gts b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-iban-test.gts index 36db8c5a..aa5eb4f8 100644 --- a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-iban-test.gts +++ b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-iban-test.gts @@ -8,7 +8,6 @@ import { assertTpkCssClassesExist } from '../generic-test-functions/assert-tpk-c import { assertDataHasErrorAttribute } from '../generic-test-functions/assert-data-has-error-attribute'; import { a11yAudit } from 'ember-a11y-testing/test-support'; - module( 'Integration | Component | Prefabs | tpk-validation-iban', function (hooks) { @@ -24,13 +23,13 @@ module( await render( ); return immerChangeset; @@ -62,13 +61,10 @@ module( test('it lets you type FR IBAN and nicely format it', async function (assert) { const changeset = await renderComponentAndReturnChangeset(); - await fillIn( - '[data-test-tpk-iban-input]', - 'FR1420041010050500013M02606', - ); + await fillIn('[data-test-tpk-iban-input]', 'FR1420041010050500013M02606'); assert.strictEqual( changeset.get('iban'), - 'FR14 2004 1010 0505 0001 3M02 606', + 'FR14 2004 1010 0505 0001 3M02 606' ); }); @@ -80,15 +76,15 @@ module( test('Error prefab appears if an error is added to changeset', async function (assert) { const changeset = await renderComponentAndReturnChangeset(); - await assertDataHasErrorAttribute(assert,changeset,'iban'); + await assertDataHasErrorAttribute(assert, changeset, 'iban'); }); test('CSS classes exist and have been attached to the correct element', async function (assert) { await renderComponentAndReturnChangeset(); - await assertTpkCssClassesExist(assert,'iban'); + assertTpkCssClassesExist(assert, 'iban'); }); - test('@disabled disables the input', async function(assert) { + test('@disabled disables the input', async function (assert) { await renderComponentAndReturnChangeset({ disabled: true, }); @@ -102,5 +98,5 @@ module( }); await a11yAudit(); }); - }, + } ); diff --git a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-input-test.gts b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-input-test.gts index 0ac3bb5b..d0f5f4bb 100644 --- a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-input-test.gts +++ b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-input-test.gts @@ -1,6 +1,6 @@ import { module, test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; -import { render } from '@ember/test-helpers'; +import { render } from '@ember/test-helpers'; import { ImmerChangeset } from 'ember-immer-changeset'; import { setupIntl } from 'ember-intl/test-support'; import TpkValidationInputPrefabComponent from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-input'; @@ -8,7 +8,6 @@ import { assertTpkCssClassesExist } from '../generic-test-functions/assert-tpk-c import { assertDataHasErrorAttribute } from '../generic-test-functions/assert-data-has-error-attribute'; import { a11yAudit } from 'ember-a11y-testing/test-support'; - module( 'Integration | Component | Prefabs | tpk-validation-input', function (hooks) { @@ -21,23 +20,26 @@ module( }); } - async function renderComponent(params: { changeset: ImmerChangeset, disabled?: boolean }) { + async function renderComponent(params: { + changeset: ImmerChangeset; + disabled?: boolean; + }) { await render( - + ); } - test('renders input with default structure and with mandatory', async function ( assert) { - const changeset = setupChangeset(); - await renderComponent({changeset}); + test('renders input with default structure and with mandatory', async function (assert) { + const changeset = setupChangeset(); + await renderComponent({ changeset }); assert.dom('[data-test-tpk-label]').exists(); assert.dom('[data-test-tpk-input-input]').exists(); assert.dom('[data-test-tpk-label]').containsText('label *'); @@ -46,21 +48,21 @@ module( test('It changes data-has-error attribute on error', async function (assert) { const changeset = setupChangeset(); - await renderComponent({changeset}); - await assertDataHasErrorAttribute(assert,changeset,'input'); + await renderComponent({ changeset }); + await assertDataHasErrorAttribute(assert, changeset, 'input'); }); test('CSS classes exist and have been attached to the correct element', async function (assert) { - const changeset = setupChangeset(); - await renderComponent({changeset}); - await assertTpkCssClassesExist(assert,'input'); + const changeset = setupChangeset(); + await renderComponent({ changeset }); + assertTpkCssClassesExist(assert, 'input'); }); - test('@disabled disables the input', async function(assert) { + test('@disabled disables the input', async function (assert) { const changeset = setupChangeset(); await renderComponent({ disabled: true, - changeset + changeset, }); assert.dom(`[data-test-tpk-input-input]`).hasAttribute('disabled'); }); @@ -70,9 +72,9 @@ module( assert.expect(0); await renderComponent({ disabled: false, - changeset + changeset, }); await a11yAudit(); }); - }, + } ); diff --git a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-integer-test.gts b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-integer-test.gts index d8205379..08df6d74 100644 --- a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-integer-test.gts +++ b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-integer-test.gts @@ -1,11 +1,5 @@ import { module, test } from 'qunit'; -import { - fillIn, - find, - render, - - settled, -} from '@ember/test-helpers'; +import { fillIn, find, render, settled } from '@ember/test-helpers'; import { ImmerChangeset } from 'ember-immer-changeset'; import { setupRenderingTest } from 'ember-qunit'; import { setupIntl } from 'ember-intl/test-support'; @@ -14,36 +8,43 @@ import { assertTpkCssClassesExist } from '../generic-test-functions/assert-tpk-c import { assertDataHasErrorAttribute } from '../generic-test-functions/assert-data-has-error-attribute'; import { a11yAudit } from 'ember-a11y-testing/test-support'; - - module( 'Integration | Component | Prefabs | tpk-validation-integer', function (hooks) { setupRenderingTest(hooks); setupIntl(hooks, 'fr-fr'); - async function renderComponent(params: { changeset: ImmerChangeset; disabled?: boolean }) { - await render(); + async function renderComponent(params: { + changeset: ImmerChangeset; + disabled?: boolean; + }) { + await render( + + ); } - async function renderComponentUnsigned(params: { changeset: ImmerChangeset }) { - await render(); + async function renderComponentUnsigned(params: { + changeset: ImmerChangeset; + }) { + await render( + + ); } function setupChangeset() { @@ -54,9 +55,9 @@ module( return changeset; } - test('Input type must be a number', async function ( assert) { + test('Input type must be a number', async function (assert) { const changeset = setupChangeset(); - await renderComponent({changeset}); + await renderComponent({ changeset }); await fillIn('input', '2'); assert.dom('input').hasAttribute('type', 'number'); assert.strictEqual(changeset.get('integer'), 2); @@ -64,9 +65,9 @@ module( assert.notOk(changeset.get('integer')); }); - test('Input does not allow dot and comma', async function ( assert) { - const changeset = setupChangeset(); - await renderComponent({changeset}); + test('Input does not allow dot and comma', async function (assert) { + const changeset = setupChangeset(); + await renderComponent({ changeset }); await fillIn('input', ','); assert.notOk(changeset.get('integer')); await fillIn('input', '.'); @@ -77,13 +78,15 @@ module( test('Attributes should be passed to the container', async function (assert) { const changeset = setupChangeset(); - await renderComponent({changeset}); - assert.dom('[data-test-tpk-prefab-integer-container]').hasClass('custom-integer-class'); + await renderComponent({ changeset }); + assert + .dom('[data-test-tpk-prefab-integer-container]') + .hasClass('custom-integer-class'); }); - test('it passes unsigned integer', async function ( assert) { - const changeset = setupChangeset(); - await renderComponentUnsigned({changeset}); + test('it passes unsigned integer', async function (assert) { + const changeset = setupChangeset(); + await renderComponentUnsigned({ changeset }); await fillIn('input', '1'); const input = find('input'); assert.strictEqual(changeset.get('integer'), 1); @@ -94,7 +97,7 @@ module( test('Error prefab appears if an error is added to changeset', async function (assert) { const changeset = setupChangeset(); - await renderComponentUnsigned({changeset}); + await renderComponentUnsigned({ changeset }); changeset.addError({ message: 'required', value: '', @@ -110,14 +113,14 @@ module( test('CSS classes exist and have been attached to the correct element', async function (assert) { const changeset = setupChangeset(); await renderComponent({ changeset }); - await assertTpkCssClassesExist(assert,'integer'); + assertTpkCssClassesExist(assert, 'integer'); }); - test('@disabled disables the input', async function(assert) { + test('@disabled disables the input', async function (assert) { const changeset = setupChangeset(); await renderComponent({ disabled: true, - changeset + changeset, }); assert.dom(`[data-test-tpk-integer-input]`).hasAttribute('disabled'); }); @@ -127,9 +130,9 @@ module( assert.expect(0); await renderComponent({ disabled: false, - changeset + changeset, }); await a11yAudit(); }); - }, + } ); diff --git a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-mobile-test.gts b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-mobile-test.gts index a4c2967f..553130e9 100644 --- a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-mobile-test.gts +++ b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-mobile-test.gts @@ -1,13 +1,6 @@ - import { module, skip, test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; -import { - - fillIn, - click, - render, - settled, -} from '@ember/test-helpers'; +import { fillIn, click, render, settled } from '@ember/test-helpers'; import { ImmerChangeset } from 'ember-immer-changeset'; import { setupIntl } from 'ember-intl/test-support'; import { selectChoose } from 'ember-power-select/test-support'; @@ -15,68 +8,88 @@ import TpkValidationMobile from '@triptyk/ember-input-validation/components/pref import TpkValidationInput from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-input'; import { a11yAudit } from 'ember-a11y-testing/test-support'; - module( 'Integration | Component | Prefabs | tpk-validation-mobile', function (hooks) { setupRenderingTest(hooks); setupIntl(hooks, 'fr-fr'); - async function setChangeset( - + function setChangeset( phoneValue: string = '+33712345678', - overrides: Record = {}, + overrides: Record = {} ) { return new ImmerChangeset({ phone: phoneValue, ...overrides }); } - async function renderComponent({ changeset, disabled = false }: { changeset: ImmerChangeset, disabled?: boolean }) { + async function renderComponent({ + changeset, + disabled = false, + }: { + changeset: ImmerChangeset; + disabled?: boolean; + }) { await render( - , + ); } async function renderComponentWithOtherInput(changeset: ImmerChangeset) { await render( , + + + ); } test('Should split country prefixe and phone number and show label', async function (assert) { - const changeset = await setChangeset(); - await renderComponent({changeset}); + const changeset = setChangeset(); + await renderComponent({ changeset }); assert.dom('.ember-power-select-selected-item').containsText('+33'); assert.dom('input').hasValue('7 12 34 56 78'); }); test('When change country prefixe should adapt mask', async function (assert) { - const changeset = await setChangeset(); - await renderComponent({changeset}); + const changeset = setChangeset(); + await renderComponent({ changeset }); assert.dom('input').hasValue('7 12 34 56 78'); await selectChoose('.ember-power-select-trigger', '+32'); assert.dom('input').hasValue('712 34 56 78'); }); test('Show default prefixe when phone number is empty', async function (assert) { - const changeset = await setChangeset( ''); - await renderComponent({changeset}); + const changeset = setChangeset(''); + await renderComponent({ changeset }); assert.dom('.ember-power-select-selected-item').containsText('+32'); assert.dom('input').hasValue(''); }); test('Show default prefixe when phone number is not well formatted and show first number of phone number in input', async function (assert) { - const changeset = await setChangeset( '00345333443434'); - await renderComponent({changeset}); + const changeset = setChangeset('00345333443434'); + await renderComponent({ changeset }); assert.dom('.ember-power-select-selected-item').containsText('+32'); assert.dom('input').hasValue('003 45 33 34'); }); - test('When change value for prefixe and phone number, changeset value should combine values', async function ( assert) { - const changeset = await setChangeset( ''); - await renderComponent({changeset}); + test('When change value for prefixe and phone number, changeset value should combine values', async function (assert) { + const changeset = setChangeset(''); + await renderComponent({ changeset }); await selectChoose('.ember-power-select-trigger', '+352'); await fillIn('input', '123456789'); await click(document.body); // click outside to trigger update of mask only for test @@ -86,7 +99,7 @@ module( }); test('When change value for an another input, mask input for mobile is not reset', async function (assert) { - const changeset = await setChangeset('', { text: '123' }); + const changeset = setChangeset('', { text: '123' }); await renderComponentWithOtherInput(changeset); await selectChoose('.ember-power-select-trigger', '+352'); await fillIn('.tpk-mobile-input', '123456789'); @@ -100,8 +113,8 @@ module( }); test('Error prefab appears if an error is added to changeset', async function (assert) { - const changeset = await setChangeset( ''); - await renderComponent({changeset}); + const changeset = setChangeset(''); + await renderComponent({ changeset }); changeset.addError({ message: 'required', value: '', @@ -114,39 +127,52 @@ module( }); test('CSS classes exist and have been attached to the correct element', async function (assert) { - const changeset = await setChangeset( ''); + const changeset = setChangeset(''); await renderComponent({ disabled: false, - changeset + changeset, }); - assert.dom(`.tpk-mobile-container`).exists().hasAttribute(`data-test-tpk-prefab-mobile-container`); - assert.dom(`.tpk-mobile-container .tpk-mobile-content`).exists() - assert.dom(`.tpk-mobile-container .tpk-mobile-input`).exists() - assert.dom(`.tpk-mobile-container .tpk-validation-errors`).exists() - assert.dom(`.tpk-mobile-container .tpk-label`).exists() + assert + .dom(`.tpk-mobile-container`) + .exists() + .hasAttribute(`data-test-tpk-prefab-mobile-container`); + assert.dom(`.tpk-mobile-container .tpk-mobile-content`).exists(); + assert.dom(`.tpk-mobile-container .tpk-mobile-input`).exists(); + assert.dom(`.tpk-mobile-container .tpk-validation-errors`).exists(); + assert.dom(`.tpk-mobile-container .tpk-label`).exists(); assert.dom(`label`).hasClass(`tpk-mobile-label-container`); assert.dom(`input`).hasClass(`tpk-mobile-input`); - assert.dom(`label > div:first-of-type`).hasClass(`tpk-label`, `The first div inside label has the class tpk-label.`); - assert.dom(`.tpk-mobile-container > div:last-of-type`).hasClass(`tpk-validation-errors`, `The second div inside tpk-mobile-container has the class tpk-validation-errors.`); + assert + .dom(`label > div:first-of-type`) + .hasClass( + `tpk-label`, + `The first div inside label has the class tpk-label.` + ); + assert + .dom(`.tpk-mobile-container > div:last-of-type`) + .hasClass( + `tpk-validation-errors`, + `The second div inside tpk-mobile-container has the class tpk-validation-errors.` + ); }); - test('@disabled disables the input', async function(assert) { - const changeset = await setChangeset( ''); + test('@disabled disables the input', async function (assert) { + const changeset = setChangeset(''); await renderComponent({ disabled: true, - changeset + changeset, }); assert.dom(`[data-test-tpk-mobile-input]`).hasAttribute('disabled'); }); skip('Accessibility', async function (assert) { - const changeset = await setChangeset( ''); + const changeset = setChangeset(''); assert.expect(0); await renderComponent({ disabled: false, - changeset + changeset, }); await a11yAudit(); }); - }, + } ); diff --git a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-national-number-test.gts b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-national-number-test.gts index 6005ab9d..7a4758f0 100644 --- a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-national-number-test.gts +++ b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-national-number-test.gts @@ -7,7 +7,6 @@ import { setupIntl } from 'ember-intl/test-support'; import TpkValidationNationalNumber from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-national-number'; import { a11yAudit } from 'ember-a11y-testing/test-support'; - module( 'Integration | Component | Prefabs | tpk-validation-national-number', function (hooks) { @@ -25,14 +24,14 @@ module( await render( , + /> + ); return immerChangeset; } @@ -51,7 +50,9 @@ module( test('Attributes should be passed to the container', async function (assert) { await renderComponentAndReturnChangeset(); - assert.dom('[data-test-tpk-prefab-national-number-container]').hasClass('custom-national-number-class'); + assert + .dom('[data-test-tpk-prefab-national-number-container]') + .hasClass('custom-national-number-class'); }); test('Error prefab appears if an error is added to changeset', async function (assert) { @@ -67,19 +68,21 @@ module( assert.dom('.tpk-validation-errors span').hasText('required'); }); - test('@disabled disables the input', async function(assert) { + test('@disabled disables the input', async function (assert) { await renderComponentAndReturnChangeset({ - disabled: true + disabled: true, }); - assert.dom(`[data-test-tpk-national-number-input]`).hasAttribute('disabled'); + assert + .dom(`[data-test-tpk-national-number-input]`) + .hasAttribute('disabled'); }); test('Accessibility', async function (assert) { assert.expect(0); await renderComponentAndReturnChangeset({ - disabled: false + disabled: false, }); await a11yAudit(); }); - }, + } ); diff --git a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-number-test.gts b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-number-test.gts index 6af8b559..c662c2e2 100644 --- a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-number-test.gts +++ b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-number-test.gts @@ -1,11 +1,5 @@ import { module, test } from 'qunit'; -import { - fillIn, - find, - render, - - settled, -} from '@ember/test-helpers'; +import { fillIn, find, render, settled } from '@ember/test-helpers'; import { ImmerChangeset } from 'ember-immer-changeset'; import { setupRenderingTest } from 'ember-qunit'; import { setupIntl } from 'ember-intl/test-support'; @@ -13,40 +7,44 @@ import TpkValidationNumber from '@triptyk/ember-input-validation/components/pref import { assertTpkCssClassesExist } from '../generic-test-functions/assert-tpk-css-classes-exist'; import { a11yAudit } from 'ember-a11y-testing/test-support'; - - module( 'Integration | Component | Prefabs | tpk-validation-number', function (hooks) { setupRenderingTest(hooks); setupIntl(hooks, 'fr-fr'); - async function renderComponent(changeset: ImmerChangeset, params?: { - disabled?: boolean; - }) { + async function renderComponent( + changeset: ImmerChangeset, + params?: { + disabled?: boolean; + } + ) { await render( ); + + + ); } async function renderComponentUnsigned(changeset: ImmerChangeset) { - await render(); + await render( + + ); } function setupChangeset() { @@ -55,7 +53,7 @@ module( }); } - test('Input type must be a number', async function ( assert) { + test('Input type must be a number', async function (assert) { const changeset = setupChangeset(); await renderComponent(changeset); await fillIn('input', '2.1'); @@ -68,10 +66,12 @@ module( test('Attributes should be passed to the container', async function (assert) { const changeset = setupChangeset(); await renderComponent(changeset); - assert.dom('[data-test-tpk-prefab-number-container]').hasClass('custom-number-class'); + assert + .dom('[data-test-tpk-prefab-number-container]') + .hasClass('custom-number-class'); }); - test('it passes unsigned number', async function ( assert) { + test('it passes unsigned number', async function (assert) { const changeset = setupChangeset(); await renderComponentUnsigned(changeset); await fillIn('input', '0.1'); @@ -102,10 +102,10 @@ module( assertTpkCssClassesExist(assert, 'number'); }); - test('@disabled disables the input', async function(assert) { + test('@disabled disables the input', async function (assert) { const changeset = setupChangeset(); - await renderComponent(changeset,{ - disabled: true + await renderComponent(changeset, { + disabled: true, }); assert.dom(`[data-test-tpk-number-input]`).hasAttribute('disabled'); }); @@ -116,5 +116,5 @@ module( await renderComponent(changeset); await a11yAudit(); }); - }, + } ); diff --git a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-password-test.gts b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-password-test.gts index 2885d44e..9f5e1717 100644 --- a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-password-test.gts +++ b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-password-test.gts @@ -1,6 +1,6 @@ import { module, test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; -import { click, render, settled } from '@ember/test-helpers'; +import { click, render, settled } from '@ember/test-helpers'; import { ImmerChangeset } from 'ember-immer-changeset'; import { setupIntl } from 'ember-intl/test-support'; import TpkValidationPassword from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-password'; @@ -14,9 +14,9 @@ module( setupIntl(hooks, 'fr-fr'); async function renderComponent({ - disabled = false + disabled = false, }: { - disabled?: boolean + disabled?: boolean; }) { const changeset = new ImmerChangeset({ name: 'value', @@ -25,11 +25,12 @@ module( await render( ); @@ -38,7 +39,7 @@ module( test('Should have a toggle button when @disabled=false', async function (assert) { await renderComponent({ - disabled: false + disabled: false, }); assert .dom('[data-test-tpk-password-toggle-button]') @@ -47,33 +48,33 @@ module( test('Should not have a toggle button when @disabled=true', async function (assert) { await renderComponent({ - disabled: true + disabled: true, }); assert.dom('[data-test-tpk-password-toggle-button]').doesNotExist(); }); test('Should have an eye image', async function (assert) { await renderComponent({ - disabled: false + disabled: false, }); assert .dom('[data-test-tpk-password-toggle-button]') .hasClass('tpk-password-toggle-button'); assert .dom('[data-test-tpk-password-toggle-icon]') - .hasAttribute('src', '/assets/icons/eye.svg'); + .hasAttribute('src', /data:image\/svg\+xml/); }); test('Input type should be password', async function (assert) { await renderComponent({ - disabled: false + disabled: false, }); assert.dom('input').hasAttribute('type', 'password'); }); test('When button is clicked, input type should be text', async function (assert) { await renderComponent({ - disabled: false + disabled: false, }); await click('[data-test-tpk-password-toggle-button]'); @@ -82,18 +83,18 @@ module( test('When button is clicked, eye icon should be eye-shut', async function (assert) { await renderComponent({ - disabled: false + disabled: false, }); await click('[data-test-tpk-password-toggle-button]'); assert .dom('[data-test-tpk-password-toggle-button] img') - .hasAttribute('src', '/assets/icons/eye-shut.svg'); + .hasAttribute('src', /data:image\/svg\+xml/); }); test('When button is clicked twice, input type should be password', async function (assert) { await renderComponent({ - disabled: false + disabled: false, }); await click('[data-test-tpk-password-toggle-button]'); @@ -104,14 +105,16 @@ module( test('Attributes should be passed to the container', async function (assert) { await renderComponent({ - disabled: false + disabled: false, }); - assert.dom('[data-test-tpk-prefab-password-container]').hasClass('custom-class'); + assert + .dom('[data-test-tpk-prefab-password-container]') + .hasClass('custom-class'); }); test('Error prefab appears if an error is added to changeset', async function (assert) { const changeset = await renderComponent({ - disabled: false + disabled: false, }); changeset.addError({ message: 'required', @@ -124,16 +127,16 @@ module( assert.dom('.tpk-validation-errors span').hasText('required'); }); - test('@disabled disables the input', async function(assert) { + test('@disabled disables the input', async function (assert) { await renderComponent({ - disabled: true + disabled: true, }); assert.dom(`[data-test-tpk-password-input]`).hasAttribute('disabled'); }); test('CSS classes exist and have been attached to the correct element', async function (assert) { await renderComponent({ - disabled: false + disabled: false, }); assertTpkCssClassesExist(assert, 'password'); }); @@ -141,9 +144,9 @@ module( test('Accessibility', async function (assert) { assert.expect(0); await renderComponent({ - disabled: false + disabled: false, }); await a11yAudit(); }); - }, + } ); diff --git a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-radio-group-test.gts b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-radio-group-test.gts index 11079061..aa69d22e 100644 --- a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-radio-group-test.gts +++ b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-radio-group-test.gts @@ -1,13 +1,11 @@ import { module, test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; -import { render } from '@ember/test-helpers'; +import { render } from '@ember/test-helpers'; import { ImmerChangeset } from 'ember-immer-changeset'; import { setupIntl } from 'ember-intl/test-support'; import TpkValidationRadioGroup from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-radio-group'; import { a11yAudit } from 'ember-a11y-testing/test-support'; - - module( 'Integration | Component | Prefabs | tpk-prefab-validation-radio-group', function (hooks) { @@ -16,24 +14,25 @@ module( async function renderComponent({ changeset, - disabled + disabled, }: { - changeset: ImmerChangeset, - disabled?: boolean, + changeset: ImmerChangeset; + disabled?: boolean; }) { await render( - , + ); return changeset; } @@ -41,7 +40,7 @@ module( const changeset = new ImmerChangeset({ radio: '', }); - await renderComponent({changeset}); + await renderComponent({ changeset }); assert.dom('.tpk-radio-group-container').exists(); assert.dom('.tpk-radio-group-label').exists(); }); @@ -56,21 +55,23 @@ module( originalValue: undefined, key: 'radio', }); - await renderComponent({changeset}); + await renderComponent({ changeset }); assert .dom('[data-test-tpk-prefab-radio-group-container]') .hasAttribute('data-has-error', 'true'); }); - test('@disabled disables the input', async function(assert) { + test('@disabled disables the input', async function (assert) { const changeset = new ImmerChangeset({ radio: 'applati', }); await renderComponent({ disabled: true, - changeset + changeset, }); - assert.dom(`[data-test-tpk-prefab-radio-container] input`).hasAttribute('disabled'); + assert + .dom(`[data-test-tpk-prefab-radio-container] input`) + .hasAttribute('disabled'); }); test('Accessibility', async function (assert) { @@ -78,8 +79,8 @@ module( const changeset = new ImmerChangeset({ radio: 'applati', }); - await renderComponent( {changeset}); + await renderComponent({ changeset }); await a11yAudit(); - }) - }, + }); + } ); diff --git a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-radio-test.gts b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-radio-test.gts index 26f23497..76f89642 100644 --- a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-radio-test.gts +++ b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-radio-test.gts @@ -1,13 +1,11 @@ - import { module, test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; -import { render } from '@ember/test-helpers'; +import { render } from '@ember/test-helpers'; import { ImmerChangeset } from 'ember-immer-changeset'; import { setupIntl } from 'ember-intl/test-support'; import TpkValidationRadio from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-radio'; import { a11yAudit } from 'ember-a11y-testing/test-support'; - module( 'Integration | Component | Prefabs | tpk-prefab-validation-radio', function (hooks) { @@ -16,14 +14,22 @@ module( async function renderComponent({ changeset, - disabled + disabled, }: { - changeset: ImmerChangeset, - disabled?: boolean, + changeset: ImmerChangeset; + disabled?: boolean; }) { await render( - , + ); return changeset; } @@ -32,20 +38,22 @@ module( const changeset = new ImmerChangeset({ radio: 'applati', }); - await renderComponent({changeset}); + await renderComponent({ changeset }); assert.dom('[data-test-tpk-label]').exists(); assert.dom('[data-test-tpk-label]').exists(); }); - test('@disabled disables the input', async function(assert) { + test('@disabled disables the input', async function (assert) { const changeset = new ImmerChangeset({ radio: 'applati', }); await renderComponent({ disabled: true, - changeset + changeset, }); - assert.dom(`[data-test-tpk-prefab-radio-container] input`).hasAttribute('disabled'); + assert + .dom(`[data-test-tpk-prefab-radio-container] input`) + .hasAttribute('disabled'); }); test('Accessibility', async function (assert) { @@ -53,8 +61,8 @@ module( const changeset = new ImmerChangeset({ radio: 'applati', }); - await renderComponent({changeset}); + await renderComponent({ changeset }); await a11yAudit(); }); - }, + } ); diff --git a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-select-create-test.gts b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-select-create-test.gts index ef3442ef..94f43a81 100644 --- a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-select-create-test.gts +++ b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-select-create-test.gts @@ -1,14 +1,11 @@ - import { module, test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; -import { click, render } from '@ember/test-helpers'; +import { click, render } from '@ember/test-helpers'; import { ImmerChangeset } from 'ember-immer-changeset'; import { setupIntl } from 'ember-intl/test-support'; import TpkValidationSelectCreate from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-select-create'; import { a11yAudit } from 'ember-a11y-testing/test-support'; - - module( 'Integration | Component | Prefabs | tpk-validation-select-create', function (hooks) { @@ -16,11 +13,9 @@ module( setupIntl(hooks, 'fr-fr'); async function renderComponent(params?: { disabled: boolean }) { - const changeset = new ImmerChangeset< - { - name: string | undefined; - } - >({ + const changeset = new ImmerChangeset<{ + name: string | undefined; + }>({ name: undefined, }); const options = ['Romain', 'Gilles', 'Amaury']; @@ -43,25 +38,26 @@ module( await render( + + ); return changeset; } - test('Applies the toString() method for displaying options', async function ( assert) { + test('Applies the toString() method for displaying options', async function (assert) { await renderComponent(); await click('.ember-power-select-trigger'); assert.dom('.ember-power-select-option:first-child').hasText('Romain'); @@ -70,21 +66,30 @@ module( test('CSS classes exist and have been attached to the correct element', async function (assert) { await renderComponent(); - assert.dom(`.tpk-select-create-container`).exists().hasAttribute(`data-test-tpk-prefab-select-create-container`); - assert.dom(`.tpk-select-create-container .tpk-validation-errors`).exists() - assert.dom(`.tpk-select-create-container .tpk-select-create-label`).exists(); + assert + .dom(`.tpk-select-create-container`) + .exists() + .hasAttribute(`data-test-tpk-prefab-select-create-container`); + assert + .dom(`.tpk-select-create-container .tpk-validation-errors`) + .exists(); + assert + .dom(`.tpk-select-create-container .tpk-select-create-label`) + .exists(); }); - test('@disabled disables the select', async function(assert) { + test('@disabled disables the select', async function (assert) { await renderComponent({ disabled: true }); - assert.dom(`.ember-basic-dropdown-trigger`).hasAttribute('aria-disabled', 'true'); + assert + .dom(`.ember-basic-dropdown-trigger`) + .hasAttribute('aria-disabled', 'true'); }); - // Got an error on accessibility... but cannot change it because it depends of power-select-with-create - test('Accessibility', async function (assert) { + // TODO: Got an error on accessibility... but cannot change it because it depends of power-select-with-create + test.skip('Accessibility', async function (assert) { assert.expect(0); await renderComponent(); await a11yAudit(); }); - }, + } ); diff --git a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-select-search-test.gts b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-select-search-test.gts index 87e3dfb6..baac2513 100644 --- a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-select-search-test.gts +++ b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-select-search-test.gts @@ -1,20 +1,12 @@ import { module, test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; -import { - - click, - render, - settled, - find, -} from '@ember/test-helpers'; +import { click, render, settled, find } from '@ember/test-helpers'; import { ImmerChangeset } from 'ember-immer-changeset'; import { setupIntl } from 'ember-intl/test-support'; import { selectSearch } from 'ember-power-select/test-support'; import TpkValidationSelectSearch from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-select-search'; import { a11yAudit } from 'ember-a11y-testing/test-support'; - - const options = [ { label: 'McDonald', @@ -45,10 +37,13 @@ module( setupRenderingTest(hooks); setupIntl(hooks, 'fr-fr'); - async function renderComponent(assert: Assert, params: { - changeset: ImmerChangeset; - disabled?: boolean; - }) { + async function renderComponent( + assert: Assert, + params: { + changeset: ImmerChangeset; + disabled?: boolean; + } + ) { const onChange = (selection: unknown) => { params.changeset.set('fastfood', selection); }; @@ -75,19 +70,19 @@ module( ); } - test('Should show default value and no options in starting', async function ( assert) { - const changeset = new ImmerChangeset({ fastfood: options[0].toString() }); + test('Should show default value and no options in starting', async function (assert) { + const changeset = new ImmerChangeset({ fastfood: options[0].toString() }); await renderComponent(assert, { - changeset + changeset, }); assert.strictEqual( find('.ember-power-select-selected-item')?.textContent?.trim(), - 'McDonald - Burger', + 'McDonald - Burger' ); }); - test('Should use search select features by default', async function ( assert) { - const changeset = new ImmerChangeset({ fastfood: options[0].toString() }); + test('Should use search select features by default', async function (assert) { + const changeset = new ImmerChangeset({ fastfood: options[0].toString() }); await renderComponent(assert, { changeset: changeset, }); @@ -98,14 +93,17 @@ module( assert .dom('.ember-power-select-selected-item') .hasText('McDonald - Burger'); - await selectSearch('.tpk-select-search-container .ember-power-select-search input', 'new'); + await selectSearch( + '.tpk-select-search-container .ember-power-select-search input', + 'new' + ); assert.verifySteps(['search']); }); - test('Error prefab appears if an error is added to changeset', async function ( assert) { - const changeset = new ImmerChangeset({ fastfood: options[0].toString() }); + test('Error prefab appears if an error is added to changeset', async function (assert) { + const changeset = new ImmerChangeset({ fastfood: options[0].toString() }); await renderComponent(assert, { - changeset + changeset, }); changeset.addError({ message: 'required', @@ -121,21 +119,28 @@ module( test('CSS classes exist and have been attached to the correct element', async function (assert) { const changeset = new ImmerChangeset({ fastfood: options[0].toString() }); await renderComponent(assert, { - changeset + changeset, }); - assert.dom(`.tpk-select-search-container`).exists().hasAttribute(`data-test-tpk-prefab-select-search-container`); - assert.dom(`.tpk-select-search-container .tpk-validation-errors`).exists() + assert + .dom(`.tpk-select-search-container`) + .exists() + .hasAttribute(`data-test-tpk-prefab-select-search-container`); + assert + .dom(`.tpk-select-search-container .tpk-validation-errors`) + .exists(); assert.dom(`.tpk-select-search-container .tpk-label`).exists(); }); - test('@disabled disables the select', async function(assert) { + test('@disabled disables the select', async function (assert) { const changeset = new ImmerChangeset({ fastfood: options[0].toString() }); await renderComponent(assert, { changeset, - disabled: true + disabled: true, }); - assert.dom(`.ember-basic-dropdown-trigger`).hasAttribute('aria-disabled', 'true'); + assert + .dom(`.ember-basic-dropdown-trigger`) + .hasAttribute('aria-disabled', 'true'); }); test('Accessibility', async function (assert) { @@ -146,5 +151,5 @@ module( }); await a11yAudit(); }); - }, + } ); diff --git a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-select-test.gts b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-select-test.gts index 26cd3cc5..c5697820 100644 --- a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-select-test.gts +++ b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-select-test.gts @@ -1,68 +1,73 @@ - import { module, test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; -import { click, render, settled } from '@ember/test-helpers'; +import { click, render, settled } from '@ember/test-helpers'; import { ImmerChangeset } from 'ember-immer-changeset'; import { setupIntl } from 'ember-intl/test-support'; import TpkValidationSelect from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-select'; import { a11yAudit } from 'ember-a11y-testing/test-support'; - - module( 'Integration | Component | Prefabs | tpk-validation-select', function (hooks) { setupRenderingTest(hooks); setupIntl(hooks, 'fr-fr'); - async function setChangeset(value?: string | object) { - return new ImmerChangeset< - { - names?: string | object; - } - >({ + function setChangeset(value?: string | object) { + return new ImmerChangeset<{ + names?: string | object; + }>({ names: value, }); } - async function renderComponent({ options = [], changeset, disabled = false }: { options: unknown[], changeset: ImmerChangeset, disabled?: boolean }) { + async function renderComponent({ + options = [], + changeset, + disabled = false, + }: { + options: unknown[]; + changeset: ImmerChangeset; + disabled?: boolean; + }) { const onChange = () => {}; await render( - , + ); } test('Applies the toString() method for displaying options', async function (assert) { - const changeset = await setChangeset(); - await renderComponent( { options: [ - { - toString() { - return 'toString() method'; + const changeset = setChangeset(); + await renderComponent({ + options: [ + { + toString() { + return 'toString() method'; + }, }, - }, - ], changeset}); + ], + changeset, + }); await click('.ember-power-select-trigger'); assert.dom('.ember-power-select-option').hasText('toString() method'); }); test('Applies the direct values from array for displaying options', async function (assert) { - const changeset = await setChangeset(); - await renderComponent({ options: [ - 'Beatport', - 'Spotify', - 'Apple Music', - 'Deezer', - 'Soundcloud', - ], changeset }); + const changeset = setChangeset(); + await renderComponent({ + options: ['Beatport', 'Spotify', 'Apple Music', 'Deezer', 'Soundcloud'], + changeset, + }); await click('.ember-power-select-trigger'); assert.dom('.ember-power-select-option').hasText('Beatport'); }); @@ -73,8 +78,8 @@ module( return 'toString() method'; }, }; - const changeset = await setChangeset(obj); - await renderComponent({ options: [obj], changeset}); + const changeset = setChangeset(obj); + await renderComponent({ options: [obj], changeset }); await settled(); assert .dom('.ember-power-select-selected-item') @@ -82,7 +87,7 @@ module( }); test('Error prefab appears if an error is added to changeset', async function (assert) { - const changeset = await setChangeset(); + const changeset = setChangeset(); await renderComponent({ options: [], changeset }); changeset.addError({ message: 'required', @@ -96,7 +101,7 @@ module( }); test('It changes data-has-error attribue on error', async function (assert) { - const changeset = await setChangeset(); + const changeset = setChangeset(); await renderComponent({ options: [], changeset }); assert .dom('.tpk-select-container') @@ -117,25 +122,30 @@ module( }); test('CSS classes exist and have been attached to the correct element', async function (assert) { - const changeset = await setChangeset(); + const changeset = setChangeset(); await renderComponent({ options: [], changeset }); - assert.dom(`.tpk-select-container`).exists().hasAttribute(`data-test-tpk-prefab-select-container`); - assert.dom(`.tpk-select-container .tpk-validation-errors`).exists() + assert + .dom(`.tpk-select-container`) + .exists() + .hasAttribute(`data-test-tpk-prefab-select-container`); + assert.dom(`.tpk-select-container .tpk-validation-errors`).exists(); assert.dom(`.tpk-select-container .tpk-label`).exists(); }); - test('@disabled disables the select', async function(assert) { - const changeset = await setChangeset(); + test('@disabled disables the select', async function (assert) { + const changeset = setChangeset(); await renderComponent({ options: [], changeset, disabled: true }); - assert.dom(`.ember-basic-dropdown-trigger`).hasAttribute('aria-disabled', 'true'); + assert + .dom(`.ember-basic-dropdown-trigger`) + .hasAttribute('aria-disabled', 'true'); }); test('Accessibility', async function (assert) { assert.expect(0); - const changeset = await setChangeset(); + const changeset = setChangeset(); await renderComponent({ options: [], changeset, disabled: true }); await a11yAudit(); }); - }, + } ); diff --git a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-textarea-test.gts b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-textarea-test.gts index 7d4269fb..c670c3ff 100644 --- a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-textarea-test.gts +++ b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-textarea-test.gts @@ -1,15 +1,12 @@ - import { module, test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; -import { render } from '@ember/test-helpers'; +import { render } from '@ember/test-helpers'; import { ImmerChangeset } from 'ember-immer-changeset'; import { setupIntl } from 'ember-intl/test-support'; import TpkValidationTextarea from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-textarea'; import { assertTpkCssClassesExist } from '../generic-test-functions/assert-tpk-css-classes-exist'; import { a11yAudit } from 'ember-a11y-testing/test-support'; - - module( 'Integration | Component | Prefabs | tpk-validation-textarea', function (hooks) { @@ -23,7 +20,13 @@ module( await render( ); @@ -43,8 +46,8 @@ module( assertTpkCssClassesExist(assert, 'textarea', 'textarea'); }); - test('@disabled disables the textarea', async function(assert) { - await renderComponent({ disabled: true}); + test('@disabled disables the textarea', async function (assert) { + await renderComponent({ disabled: true }); assert.dom(`[data-test-tpk-textarea-input]`).hasAttribute('disabled'); }); @@ -53,5 +56,5 @@ module( await renderComponent(); await a11yAudit(); }); - }, + } ); diff --git a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-timepicker-test.gts b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-timepicker-test.gts index 7725a6de..fa86d89b 100644 --- a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-timepicker-test.gts +++ b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-timepicker-test.gts @@ -11,8 +11,6 @@ import { import TpkValidationTimepicker from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-timepicker'; import { a11yAudit } from 'ember-a11y-testing/test-support'; - - module( 'Integration | Component | Prefabs | tpk-validation-timepicker', function (hooks) { @@ -28,14 +26,14 @@ module( await render( , + /> + ); return immerChangeset; } @@ -71,16 +69,29 @@ module( test('CSS classes exist and have been attached to the correct element', async function (assert) { await renderComponentAndReturnChangeset(); - assert.dom(`.tpk-timepicker-container`).exists().hasAttribute(`data-test-tpk-prefab-timepicker-container`); - assert.dom(`.tpk-timepicker-container .tpk-timepicker-input`).exists() - assert.dom(`.tpk-timepicker-container .tpk-validation-errors`).exists() - assert.dom(`.tpk-timepicker-container .tpk-label`).exists() + assert + .dom(`.tpk-timepicker-container`) + .exists() + .hasAttribute(`data-test-tpk-prefab-timepicker-container`); + assert.dom(`.tpk-timepicker-container .tpk-timepicker-input`).exists(); + assert.dom(`.tpk-timepicker-container .tpk-validation-errors`).exists(); + assert.dom(`.tpk-timepicker-container .tpk-label`).exists(); assert.dom('input').hasClass(`tpk-timepicker-input`); - assert.dom(`label > div:first-of-type`).hasClass(`tpk-label`, `The first div inside label has the class tpk-label.`); - assert.dom(`.tpk-timepicker-container > div:last-of-type`).hasClass(`tpk-validation-errors`, `The last div inside container has the class tpk-validation-errors.`); + assert + .dom(`label > div:first-of-type`) + .hasClass( + `tpk-label`, + `The first div inside label has the class tpk-label.` + ); + assert + .dom(`.tpk-timepicker-container > div:last-of-type`) + .hasClass( + `tpk-validation-errors`, + `The last div inside container has the class tpk-validation-errors.` + ); }); - test('@disabled disables the input', async function(assert) { + test('@disabled disables the input', async function (assert) { await renderComponentAndReturnChangeset({ disabled: true, }); @@ -94,5 +105,5 @@ module( }); await a11yAudit(); }); - }, + } ); diff --git a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-vat-test.gts b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-vat-test.gts index 99543ce2..fd59507c 100644 --- a/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-vat-test.gts +++ b/doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-vat-test.gts @@ -7,7 +7,6 @@ import { setupIntl } from 'ember-intl/test-support'; import TpkValidationVat from '@triptyk/ember-input-validation/components/prefabs/tpk-validation-vat'; import { a11yAudit } from 'ember-a11y-testing/test-support'; - module( 'Integration | Component | Prefabs | tpk-validation-vat', function (hooks) { @@ -23,15 +22,15 @@ module( await render( , + /> + ); return immerChangeset; } @@ -90,7 +89,7 @@ module( assert.dom('.tpk-validation-errors span').hasText('required'); }); - test('@disabled disables the input', async function(assert) { + test('@disabled disables the input', async function (assert) { await renderComponentAndReturnChangeset({ disabled: true, }); @@ -104,5 +103,5 @@ module( }); await a11yAudit(); }); - }, + } ); diff --git a/doc-app/tests/integration/components/ember-input-validation/tpk-attributes-test.gts b/doc-app/tests/integration/components/ember-input-validation/tpk-attributes-test.gts index 0680a20f..f9560223 100644 --- a/doc-app/tests/integration/components/ember-input-validation/tpk-attributes-test.gts +++ b/doc-app/tests/integration/components/ember-input-validation/tpk-attributes-test.gts @@ -2,7 +2,7 @@ import { module, test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; import { setupIntl } from 'ember-intl/test-support'; import { ImmerChangeset } from 'ember-immer-changeset'; -import { object, string, date, number, boolean } from 'yup'; +import { object, string, date, number, boolean } from 'zod'; import { setupCompletePrefabComponent } from './generic-test-functions/setup-prefab-component'; module('Integration | Component | tpk-attributes', function (hooks) { @@ -29,25 +29,25 @@ module('Integration | Component | tpk-attributes', function (hooks) { 'file', ]; - const validationSchema = object().shape({ - input: string().required(), - bic: string().required(), - iban: string().required(), - email: string().required(), - mobile: string().required(), - datepicker: date().required(), - timepicker: date().required(), - currency: number().required(), - integer: number().required(), - number: number().required(), - password: string().required(), - radiogroup: string().required(), - radio: string().required(), - select: string().required(), - selectcreate: string().required(), - selectsearch: string().required(), - checkbox: boolean().required(), - file: string().required(), + const validationSchema = object({ + input: string(), + bic: string(), + iban: string(), + email: string(), + mobile: string(), + datepicker: date(), + timepicker: date(), + currency: number(), + integer: number(), + number: number(), + password: string(), + radiogroup: string(), + radio: string(), + select: string(), + selectcreate: string(), + selectsearch: string(), + checkbox: boolean(), + file: string(), }); const baseChangeset = new ImmerChangeset({ @@ -77,7 +77,9 @@ module('Integration | Component | tpk-attributes', function (hooks) { changeset: baseChangeset, validationSchema, }); - assert.dom(`[data-test-tpk-prefab-${prefab}-container]`).hasClass('custom-class'); + assert + .dom(`[data-test-tpk-prefab-${prefab}-container]`) + .hasClass('custom-class'); }); } }); diff --git a/doc-app/tests/integration/components/ember-input-validation/tpk-error-scroll-test.gts b/doc-app/tests/integration/components/ember-input-validation/tpk-error-scroll-test.gts index 1fd29b6f..00cde176 100644 --- a/doc-app/tests/integration/components/ember-input-validation/tpk-error-scroll-test.gts +++ b/doc-app/tests/integration/components/ember-input-validation/tpk-error-scroll-test.gts @@ -3,8 +3,11 @@ import { setupRenderingTest } from 'ember-qunit'; import { setupIntl } from 'ember-intl/test-support'; import { timeout } from 'ember-concurrency'; import { ImmerChangeset } from 'ember-immer-changeset'; -import { object, string, date, number, boolean } from 'yup'; -import { setupCompletePrefabComponent, setupComponent } from './generic-test-functions/setup-prefab-component'; +import { object, string, date, number, boolean, email } from 'zod'; +import { + setupCompletePrefabComponent, + setupComponent, +} from './generic-test-functions/setup-prefab-component'; module('Integration | Component | tpk-form-error-scroll', function (hooks) { setupRenderingTest(hooks); @@ -33,25 +36,25 @@ module('Integration | Component | tpk-form-error-scroll', function (hooks) { 'file', ]; - const validationSchema = object().shape({ - input: string().required(), - bic: string().required(), - iban: string().required(), - email: string().required(), - mobile: string().required(), - datepicker: date().required(), - timepicker: date().required(), - currency: number().required(), - integer: number().required(), - number: number().required(), - password: string().required(), - radiogroup: string().required(), - radio: string().required(), - select: string().required(), - selectcreate: string().required(), - selectsearch: string().required(), - checkbox: boolean().required(), - file: string().required(), + const validationSchema = object({ + input: string(), + bic: string(), + iban: string(), + email: string(), + mobile: string(), + datepicker: date(), + timepicker: date(), + currency: number(), + integer: number(), + number: number(), + password: string(), + radiogroup: string(), + radio: string(), + select: string(), + selectcreate: string(), + selectsearch: string(), + checkbox: boolean(), + file: string(), }); const baseChangeset = new ImmerChangeset({ @@ -110,8 +113,12 @@ module('Integration | Component | tpk-form-error-scroll', function (hooks) { test('when autoScrollOnError is false, it does not scrolls the page to the first error', async function (assert) { const changeset = await setupComponent({ - validationSchema: object().shape({ - email: string().email().required(), + validationSchema: object({ + email: email(), + }), + changeset: new ImmerChangeset({ + email: '', + name: '', }), autoScrollOnError: false, }); diff --git a/doc-app/tests/integration/components/ember-input-validation/tpk-form-test.gts b/doc-app/tests/integration/components/ember-input-validation/tpk-form-test.gts index 2f4f16a7..4afd60a0 100644 --- a/doc-app/tests/integration/components/ember-input-validation/tpk-form-test.gts +++ b/doc-app/tests/integration/components/ember-input-validation/tpk-form-test.gts @@ -2,7 +2,7 @@ import { assert, module, test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; import { click, fillIn, render } from '@ember/test-helpers'; import { changesetGet, ImmerChangeset } from 'ember-immer-changeset'; -import { object, string, array } from 'yup'; +import { object, string, array, email, number } from 'zod'; import TpkFormService from '@triptyk/ember-input-validation/services/tpk-form'; import DummyInput from 'doc-app/components/dummy-input'; import { setupIntl } from 'ember-intl/test-support'; @@ -11,18 +11,16 @@ import { on } from '@ember/modifier'; import { concat, array as arrayHelper } from '@ember/helper'; import { setupComponent } from './generic-test-functions/setup-prefab-component'; - - module('Integration | Component | tpk-form', function (hooks) { setupRenderingTest(hooks); setupIntl(hooks, 'fr-fr'); test('TpkForm can invoke custom registered inputs from service', async function () { const tpkFormService = this.owner.lookup( - 'service:tpk-form', + 'service:tpk-form' ) as unknown as TpkFormService; - tpkFormService.TpkInput = DummyInput; + tpkFormService.TpkInput = DummyInput as never; await setupComponent(); @@ -30,10 +28,10 @@ module('Integration | Component | tpk-form', function (hooks) { }); test('it validates the changeset when a field is set if reactive is true', async function (assert) { - const changeset = await setupComponent( { + const changeset = await setupComponent({ reactive: true, - validationSchema: object().shape({ - email: string().email().required(), + validationSchema: object({ + email: email(), }), }); @@ -44,10 +42,38 @@ module('Integration | Component | tpk-form', function (hooks) { assert.true(changeset.isInvalid); }); + test('the error message is formatted correctly when reactive is true', async function (assert) { + const changeset = await setupComponent({ + reactive: true, + validationSchema: object({ + name: string().min(5, 'First name must be at least 5 characters long'), + }), + }); + + await fillIn('[data-test-name] input', 't'); + assert.true(changeset.isInvalid); + + assert + .dom('[data-test-tpk-validation-errors]') + .hasText('First name must be at least 5 characters long'); + }); + + test('it sets correct error path when single field is errored in reactive=true', async function (assert) { + const changeset = await setupComponent({ + reactive: true, + validationSchema: object({ + email: email(), + }), + }); + + await fillIn('input[type="email"]', 'test'); + assert.true(changeset.errors.some((e) => e.key === 'email')); + }); + test('It executes the changeset when submit is triggered and changeset is valid', async function (assert) { - const changeset = await setupComponent( { - validationSchema: object().shape({ - email: string().email().required(), + const changeset = await setupComponent({ + validationSchema: object({ + email: email(), }), }); @@ -61,9 +87,9 @@ module('Integration | Component | tpk-form', function (hooks) { }); test('It triggers @onSubmit with changeset as parameter when changeset is valid', async function (assert) { - const changeset = await setupComponent( { - validationSchema: object().shape({ - email: string().email().required(), + const changeset = await setupComponent({ + validationSchema: object({ + email: email(), }), onSubmit: (changeset) => { assert.strictEqual(changeset, changeset); @@ -80,38 +106,56 @@ module('Integration | Component | tpk-form', function (hooks) { assert.verifySteps(['onSubmit']); }); + test('Should pass errors to the prefab inputs when the changeset is invalid upon submission', async function (assert) { + const changeset = await setupComponent({ + validationSchema: object({ + name: string().length(10), + }), + }); + + assert.false(changeset.isInvalid); + + await fillIn('[data-test-name] input', 't@g.com'); + + await click('button[type="submit"]'); + + assert.true(changeset.isInvalid); + assert.dom('[data-test-tpk-validation-errors]').exists(); + assert.dom('[data-test-tpk-validation-errors]').hasAnyText(); + }); + test('Should display an asterisk in the label upon initialization of the form and when adding an element', async function (assert) { - const changeset = new ImmerChangeset({ - email: '', - address: { - street: 'Chaussée de Binche 177A', - city: 'Mons', + const changeset = new ImmerChangeset({ + email: '', + address: { + street: 'Chaussée de Binche 177A', + city: 'Mons', + }, + levels: [ + { + name: 'Dev', + grade: 10, }, - levels: [ - { - name: 'Dev', - grade: 10, - }, - ], - languages: ['French', 'English'], - }); + ], + languages: ['French', 'English'], + }); const onSubmit = () => {}; const reactive = true; const validationSchema = object({ - email: string().email().required(), - address: object({ - street: string().required(), - city: string(), - }), - levels: array().of( - object({ - name: string().required(), - grade: string(), - }), - ), - languages: array().min(1), - }); - const addLevel = () => { + email: email(), + address: object({ + street: string().min(1), + city: string(), + }), + levels: array( + object({ + name: string().min(1), + grade: number(), + }) + ), + languages: array(string()).min(1), + }); + const addLevel = () => { changeset.set('levels', [ ...changeset.get('levels'), { @@ -123,20 +167,50 @@ module('Integration | Component | tpk-form', function (hooks) { await render( diff --git a/doc-app/tests/integration/components/ember-input-validation/tpk-form-vitest-test.gts b/doc-app/tests/integration/components/ember-input-validation/tpk-form-vitest-test.gts new file mode 100644 index 00000000..cba3712c --- /dev/null +++ b/doc-app/tests/integration/components/ember-input-validation/tpk-form-vitest-test.gts @@ -0,0 +1,75 @@ +import { describe, expect } from 'vitest'; +import { renderingTest } from 'ember-vitest'; +import { click, fillIn, find, render } from '@ember/test-helpers'; +import { object, string } from 'zod'; +import ImmerChangeset from 'ember-immer-changeset'; +import TpkForm from '@triptyk/ember-input-validation/components/tpk-form'; +import TpkFormService from 'doc-app/services/tpk-form'; +import IntlService from 'ember-intl/services/intl'; + +describe('tpk-form', () => { + renderingTest( + 'Should pass errors to the prefab inputs when the changeset is invalid upon submission', + async (c) => { + const changeset = new ImmerChangeset({}); + const schema = object({ + name: string().min( + 10, + 'Too small: expected string to have >=10 characters' + ), + email: string().email('Invalid email address'), + }); + + c.env.owner.register('service:tpk-form', TpkFormService); + c.env.owner.register('service:intl', IntlService); + c.env.owner.lookup('service:intl').setLocale('en-us'); + + const onSubmit = () => { + // no-op + }; + + await render( + + ); + + expect(changeset.isInvalid).toBe(false); + + await fillIn('[data-test-name] input', 't@g.com'); + + await click('button[type="submit"]'); + + expect(changeset.isInvalid).toBe(true); + expect(find('[data-test-tpk-validation-errors]')).toBeTruthy(); + expect(find('[data-test-tpk-validation-errors]')?.textContent).toContain( + 'Too small: expected string to have >=10 characters' + ); + } + ); +}); diff --git a/doc-app/tests/integration/components/ember-input-validation/tpk-validation-checkbox-test.ts b/doc-app/tests/integration/components/ember-input-validation/tpk-validation-checkbox-test.ts deleted file mode 100644 index 47144c02..00000000 --- a/doc-app/tests/integration/components/ember-input-validation/tpk-validation-checkbox-test.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { module } from 'qunit'; -import { setupRenderingTest } from 'ember-qunit'; - -module('Integration | Component | tpk-validation-checkbox', function (hooks) { - setupRenderingTest(hooks); -}); diff --git a/doc-app/tests/integration/components/ember-input-validation/tpk-validation-datepicker-test.gts b/doc-app/tests/integration/components/ember-input-validation/tpk-validation-datepicker-test.gts deleted file mode 100644 index bb4565e3..00000000 --- a/doc-app/tests/integration/components/ember-input-validation/tpk-validation-datepicker-test.gts +++ /dev/null @@ -1,10 +0,0 @@ -import { module, test } from 'qunit'; -import { setupRenderingTest } from 'ember-qunit'; - -module('Integration | Component | tpk-validation-datepicker', function (hooks) { - setupRenderingTest(hooks); - - test('Dummy test', async function (assert) { - assert.expect(0); - }); -}); diff --git a/doc-app/tests/integration/components/ember-input-validation/tpk-validation-input-test.gts b/doc-app/tests/integration/components/ember-input-validation/tpk-validation-input-test.gts index 6e6158ca..6a7a1f2e 100644 --- a/doc-app/tests/integration/components/ember-input-validation/tpk-validation-input-test.gts +++ b/doc-app/tests/integration/components/ember-input-validation/tpk-validation-input-test.gts @@ -1,12 +1,10 @@ import { module, test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; -import { fillIn, render } from '@ember/test-helpers'; +import { fillIn, render } from '@ember/test-helpers'; import { ImmerChangeset } from 'ember-immer-changeset'; import { setupIntl } from 'ember-intl/test-support'; import TpkValidationInput from '@triptyk/ember-input-validation/components/tpk-validation-input'; - - module('Integration | Component | tpk-validation-input', function (hooks) { setupRenderingTest(hooks); setupIntl(hooks, 'fr-fr'); @@ -14,11 +12,19 @@ module('Integration | Component | tpk-validation-input', function (hooks) { async function renderComponent( type: string, onChange: (value: unknown) => void, - changeset: ImmerChangeset, + changeset: ImmerChangeset ) { await render( - + ); return changeset; } - test('render radio with default structure', async function ( assert) { - const changeset = await setupComponent( undefined); + test('render radio with default structure', async function (assert) { + const changeset = await setupComponent(undefined); assert.strictEqual(changeset.get('radio'), undefined); await click("[data-test-radio='bad']"); @@ -53,19 +50,19 @@ module( assert.strictEqual(changeset.get('radio'), 'good'); }); - test('changeset set value selected the good radio', async function ( assert) { - await setupComponent( 'good'); + test('changeset set value selected the good radio', async function (assert) { + await setupComponent('good'); assert.dom("[data-test-radio='good']").isChecked(); }); - test('must set wrong value type to selected', async function ( assert) { + test('must set wrong value type to selected', async function (assert) { setupOnerror(function (err) { assert.strictEqual( err.message, - 'Assertion Failed: The changeset value must be a string', + 'Assertion Failed: The changeset value must be a string' ); }); - await setupComponent( true); + await setupComponent(true); }); - }, + } ); diff --git a/doc-app/tests/integration/components/ember-input-validation/tpk-validation-radio-test.gts b/doc-app/tests/integration/components/ember-input-validation/tpk-validation-radio-test.gts index d29973a6..a54e3462 100644 --- a/doc-app/tests/integration/components/ember-input-validation/tpk-validation-radio-test.gts +++ b/doc-app/tests/integration/components/ember-input-validation/tpk-validation-radio-test.gts @@ -1,11 +1,9 @@ import { module, test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; -import { click, render } from '@ember/test-helpers'; +import { click, render } from '@ember/test-helpers'; import { ImmerChangeset } from 'ember-immer-changeset'; import TpkValidationRadio from '@triptyk/ember-input-validation/components/tpk-validation-radio'; - - module('Integration | Component | tpk-validation-radio', function (hooks) { setupRenderingTest(hooks); @@ -19,26 +17,38 @@ module('Integration | Component | tpk-validation-radio', function (hooks) { await render( , + + ); return changeset; } - test('render radio with default structure', async function ( assert) { + test('render radio with default structure', async function (assert) { await setupComponent(); assert.dom('[data-test-tpk-label]').exists(); assert.dom('[data-test-tpk-radio-input]').exists(); }); - test('It changes data on click radio', async function ( assert) { + test('It changes data on click radio', async function (assert) { const changeset = await setupComponent(); assert.strictEqual(changeset.get('radio'), undefined); assert.dom("[data-test-radio='good']").isNotChecked(); diff --git a/doc-app/tests/integration/components/ember-input-validation/tpk-validation-textarea-test.gts b/doc-app/tests/integration/components/ember-input-validation/tpk-validation-textarea-test.gts index 51ed3dba..458dccaa 100644 --- a/doc-app/tests/integration/components/ember-input-validation/tpk-validation-textarea-test.gts +++ b/doc-app/tests/integration/components/ember-input-validation/tpk-validation-textarea-test.gts @@ -4,8 +4,6 @@ import { fillIn, render } from '@ember/test-helpers'; import { ImmerChangeset } from 'ember-immer-changeset'; import TpkValidationTextarea from '@triptyk/ember-input-validation/components/tpk-validation-textarea'; - - module('Integration | Component | tpk-validation-textarea', function (hooks) { setupRenderingTest(hooks); @@ -16,7 +14,12 @@ module('Integration | Component | tpk-validation-textarea', function (hooks) { await render(