diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000000..b1f04ad75d3 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,14 @@ +# Lines starting with '#' are comments. +# Each line is a file pattern followed by one or more owners. + +# More details are here: https://help.github.com/articles/about-codeowners/ + +# The '*' pattern is global owners. + +# Order is important. The last matching pattern has the most precedence. +# The folders are ordered as follows: + +# In each subsection folders are ordered first by depth, then alphabetically. +# This should make it easy to add new rules without breaking existing ones. + +* @ionic-team/framework diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 1a0efc743b7..00000000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -name: Bug report -about: Report a bug on the docs site -title: '' -labels: bug -assignees: '' - ---- - -**Describe the bug** -A clear and concise description of what the bug is. - -**To reproduce** -Steps to reproduce the behavior: -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**Screenshots** -If applicable, add screenshots to help explain your problem. - -**Browser and OS (please complete the following information)** - - OS: [e.g. iOS] - - Browser: [e.g. chrome, safari] - - Version: [e.g. 22] - -**Additional context** -Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 00000000000..3cae620736e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,43 @@ +name: 🐛 Bug Report +description: Report a bug on the docs site +labels: ["triage"] +title: "bug: " +body: + - type: textarea + attributes: + label: Describe the Bug + description: A clear description of what the bug is and how it manifests. + validations: + required: true + - type: textarea + attributes: + label: Expected Behavior + description: A clear description of what you expected to happen. + validations: + required: true + - type: textarea + attributes: + label: Steps to Reproduce + description: Please explain the steps required to duplicate this issue. + validations: + required: true + - type: textarea + attributes: + label: Screenshots + description: If applicable, add screenshots to help explain the problem. + - type: input + attributes: + label: Operating System + description: The operating system you are running (e.g. Windows) + - type: input + attributes: + label: Browser + description: The browser you are running (e.g. Chrome, Safari) + - type: input + attributes: + label: Version + description: The browser version you are running (e.g. 14) + - type: textarea + attributes: + label: Additional Information + description: List any other information that is relevant to your issue. diff --git a/.github/ISSUE_TEMPLATE/content-issue.md b/.github/ISSUE_TEMPLATE/content-issue.md deleted file mode 100644 index 58b864b751c..00000000000 --- a/.github/ISSUE_TEMPLATE/content-issue.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -name: Content issue -about: Report missing or inaccurate content on the docs -title: '' -labels: content -assignees: '' - ---- - -**URL** -The URL at which the content is missing or inaccurate - -**What is missing or inaccurate about the content on this page?** diff --git a/.github/ISSUE_TEMPLATE/content-issue.yml b/.github/ISSUE_TEMPLATE/content-issue.yml new file mode 100644 index 00000000000..404492e1736 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/content-issue.yml @@ -0,0 +1,17 @@ +name: 📕 Content Issue +description: Report missing or inaccurate content on the docs +labels: ["triage"] +title: "content: " +body: + - type: input + attributes: + label: URL + description: The URL at which the content is missing or inaccurate + validations: + required: true + - type: textarea + attributes: + label: Issue Description + description: What is missing or inaccurate about the content on this page? + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index d513e5c0428..00000000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -name: Feature request -about: Suggest a feature for the docs -title: '' -labels: feature -assignees: '' - ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 00000000000..5a964579982 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,23 @@ +name: 💡 Feature Request +description: Suggest a feature for the docs +labels: ["triage"] +title: "feat: " +body: + - type: textarea + attributes: + label: Describe Problem + description: A clear and concise description of what the problem is. Ex. I am always frustrated when [...] + validations: + required: true + - type: textarea + attributes: + label: Describe Preferred Solution + description: A clear and concise description of what you want to happen. + - type: textarea + attributes: + label: Describe Alternatives + description: A clear and concise description of any alternative solutions or features you have considered. + - type: textarea + attributes: + label: Additional Information + description: Add any other context or screenshots about the feature request here. \ No newline at end of file diff --git a/.github/ionic-issue-bot.yml b/.github/ionic-issue-bot.yml new file mode 100644 index 00000000000..f0da0d54073 --- /dev/null +++ b/.github/ionic-issue-bot.yml @@ -0,0 +1,86 @@ +triage: + label: triage + dryRun: false + +closeAndLock: + labels: + - label: 'ionitron: support' + message: > + Thanks for the issue! This issue appears to be a support request. We use this issue tracker exclusively for + content issues, bug reports and feature requests related to the documentation. Please use our + [forum](https://forum.ionicframework.com/) for help or questions about Ionic Framework. + + + Thank you for using Ionic! + - label: 'ionitron: missing template' + message: > + Thanks for the issue! It appears that you have not filled out the provided issue template. We use this issue + template in order to gather more information and further assist you. Please create a new issue and ensure the + template is fully filled out. + + + Thank you for using Ionic! + close: true + lock: true + dryRun: false + +comment: + labels: + - label: "help wanted" + message: > + This issue has been labeled as `help wanted`. This label is added to issues + that we believe would be good for contributors. + + + If you'd like to work on this issue, please comment here letting us know that + you would like to submit a pull request for it. This helps us to keep track of + the pull request and make sure there isn't duplicated effort. + + + For a guide on how to create a pull request and test this project locally to see + your changes, see our [contributing documentation](https://github.com/ionic-team/ionic-docs/blob/main/CONTRIBUTING.md). + + + Thank you! + - label: 'ionitron: needs reproduction' + message: > + Thanks for the issue! This issue has been labeled as `needs reproduction`. This label is added to issues that + we are not able to reproduce. + + + Please provide easy to follow steps for us to reproduce this issue. + dryRun: false + +noReply: + days: 14 + maxIssuesPerRun: 100 + label: "needs: reply" + responseLabel: triage + exemptProjects: true + exemptMilestones: true + message: > + Thanks for the issue! This issue is being closed due to the lack of a reply. If this is still an issue, + please create a new issue and ensure the template is fully filled out. + + + Thank you for using Ionic! + close: true + lock: true + dryRun: false + +noReproduction: + days: 14 + maxIssuesPerRun: 100 + label: "ionitron: needs reproduction" + responseLabel: triage + exemptProjects: true + exemptMilestones: true + message: > + Thanks for the issue! This issue is being closed due to the lack of a reproduction. If this is still an issue, + please create a new issue and ensure the template is fully filled out. + + + Thank you for using Ionic! + close: true + lock: true + dryRun: false diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 00000000000..750cea4b16e --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,34 @@ +# GitHub Actions docs +# https://help.github.com/en/articles/about-github-actions +# https://help.github.com/en/articles/workflow-syntax-for-github-actions + +name: Install Dependencies, Lint + +on: [pull_request] + +jobs: + test: + name: Test on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + node_version: [20] + os: [windows-latest, macOS-latest] + + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node_version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node_version }} + - name: Install Dependencies + run: npm ci --legacy-peer-deps + - name: Lint + run: npm run lint + - name: Spell Check + run: npm run spellcheck + # Lint and spell check changes should be pushed + # to the branch before the branch is merge eligible. + - name: Check Diff + run: git diff --exit-code + shell: bash diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000000..fef3fa51da8 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,43 @@ +name: Deploy +on: + push: + branches: [ main ] +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 20.x + cache: 'npm' + cache-dependency-path: package-lock.json + + - name: prepare code + run: git clone https://github.com/ionic-jp/community-site.git site + + # community-siteのビルド + - name: community-site build + run: | + npm install + npm run build.ci + working-directory: site + + # Docsのビルド + - name: npm install, build + run: | + npm ci --legacy-peer-deps + npm run prebuild + npm run build:ci + mv site/www/* www/ + + # デプロイ + - name: deploy + run: | + npx netlify-cli deploy \ + --site ${{ secrets.NETLIFY_SITE_ID }} \ + --dir www/ \ + --auth ${{ secrets.NETLIFY_TOKEN }} \ + --prod diff --git a/.gitignore b/.gitignore index 31aea381f0b..e34ae50b1dc 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ # Production /build +/www +/i18n # Generated files .docusaurus @@ -19,4 +21,6 @@ src/components/page/reference/ReleaseNotes/release-notes.json npm-debug.log* yarn-debug.log* -yarn-error.log* \ No newline at end of file +yarn-error.log* + +static/**/node_modules/ diff --git a/.npmrc b/.npmrc new file mode 100644 index 00000000000..860dc500f0d --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +node-options=--max_old_space_size=4096 diff --git a/.prettierignore b/.prettierignore index 85fee6b4234..c750d314e8a 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,13 +1,18 @@ src/theme/DocItem -src/theme/DocPage +src/theme/DocRoot legacy-stencil-components -node_modules scripts/bak -src/styles.bak -src/pages + docs/api docs/native +versioned_docs/version-v*/native docs/cli/commands +docs/reference/glossary.md + +static/code/stackblitz .docusaurus -.github \ No newline at end of file +.github +build +node_modules +src/translate diff --git a/.prettierrc.js b/.prettierrc.js deleted file mode 100644 index 4122fc68e28..00000000000 --- a/.prettierrc.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = { - ...require("@ionic/prettier-config"), - overrides: [ - { - files: "*.md", - options: { - "parser": "mdx" - } - } - ] -}; \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7184cf5f7d7..6452724858e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,6 +4,9 @@ Thanks for your interest in contributing to Ionic's documentation! :tada: Check - [Contributing Guide](#contributing-guide) - [Development Workflow](#development-workflow) + - [Previewing Changes](#previewing-changes) + - [Linting Documentation](#linting-documentation) + - [Spell Check](#spell-check) - [Using VS Code on Windows](#using-vs-code-on-windows) - [Project Structure](#project-structure) - [Directories](#directories) @@ -12,7 +15,6 @@ Thanks for your interest in contributing to Ionic's documentation! :tada: Check - [Translation](#translation) - [Reporting Issues](#reporting-issues) - [Pull Request Guidelines](#pull-request-guidelines) - - [Deploying](#deploying) - [License](#license) @@ -20,14 +22,67 @@ Thanks for your interest in contributing to Ionic's documentation! :tada: Check ## Development Workflow +### Previewing Changes + In order to run the documentation locally, install the dependencies and run the development server: ```sh -$ npm install -$ npm start +npm install +npm start +``` + +### Linting Documentation + +This repository uses [Prettier](https://prettier.io/), an opinionated code formatter, in order to keep consistent formatting throughout the documentation. Run the following command to automatically fix all formatting, and then push any changes: + +``` +npm run lint +``` + +### Spell Check + +This repository uses [cspell](https://cspell.org/), a spell checker for code, to automatically flag any spelling errors. Run the following command to see any spelling errors: + +``` +npm run spellcheck ``` -> **Note**: recent versions of npm (5+) and Node.js (10+) are required to run certain scripts. +> [!NOTE] +> Any spelling errors will need to be fixed manually. There are various ways to ignore words or sections that were flagged erroneously. These are listed below. + +#### Ignoring words + +**To ignore:** + +- A **specific word**, add it to the following file: `cspell-wordlist.txt` + - For example, `Ionicons` is flagged as an unknown word. Since this is the name of our software, it has been added to this file to be ignored. +- A **directory** or anything matching a **regular expression**, update the following file: `cspell.json` + - For example, we don't want to flag anything inside of code ticks (`) or code blocks (```), so there are regular expressions added to ignore anything inside of these. +- An **entire line**, add the following comment above it: + ```markdown + + ``` +- **Multiple lines**, add comments above and below the lines to be ignored: + + ```markdown + + +

Everything inside of these comments will be ignored by the spell checkr. Proofread your own words carefully.

+ + + ``` + +> [!IMPORTANT] +> You need to have line breaks between the `cspell` comments and any HTML elements, +> otherwise the build will error with `Module build failed`. + +#### Tips + +Before adding a word or section to be ignored, see if there is a way to make it pass the spell check. Technical terms that are part of an API may need to be wrapped in code formatting. For example, the word `keydown` is flagged as an unknown word by the spell checker, but this is a [Web API event](https://developer.mozilla.org/en-US/docs/Web/API/Element/keydown_event). We can wrap any mentions of `keydown` in two backticks (\`keydown\`) in order to avoid it being flagged by the spell checker. + +Comments disabling the next line or entire sections of documentation are useful for making the spell checker ignore people's names. + +In general, we should try to avoid ignoring words unless they are technical terms that are used throughout the documentation and wouldn't necessarily make sense formatted as code. --- @@ -54,8 +109,9 @@ Ionic's documentation is built using [Docusaurus](https://docusaurus.io/). The c - `components/` - styles split out into the components they target - `static/` - `demos/` - self-contained demos, optionally presented by pages via `demoUrl` YAML frontmatter + - `usage/` - playgrounds that can be created by running `npm run playground:new` [(docs)](_templates/README.md#new-playground-template) - `versioned_docs/` - versions of the docs created by the docusaurus versioning command -- `versioned_sitebars/` - versions of the docs sidebars created by the docusaurus versioning command +- `versioned_sidebars/` - versions of the docs sidebars created by the docusaurus versioning command ## Authoring Content @@ -84,7 +140,9 @@ The Ionic docs have been translated into Japanese and are in the process of bein We use Crowdin for our translation service. You can participate in the translation effort on the [Ionic Crowdin page](https://crowdin.com/project/ionic-docs). -_Please submit translation issues to the Crowdin page and not the Ionic Docs GitHub repo_ +_Please submit translation issues to the Crowdin page and not the Ionic Docs GitHub repo._ + + The Japanese translation of the docs were built by an independent team, lead by [rdlabo](https://github.com/rdlabo) and can be found and contributed to on the [ionic-jp group's `ionic-docs` project page](https://github.com/ionic-jp/ionic-docs). @@ -99,7 +157,8 @@ If the issue you're reporting is a bug, please be sure it is an issue with the I - OS and browser versions - If possible, a demo repo or CodePen/CodeSandbox -> **Note**: Some [reference content](#reference-content) is pulled from other Ionic repos. In that case, please submit your issue on the docs repo with a link to the repo where the content lives. +> [!NOTE] +> Some [reference content](#reference-content) is pulled from other Ionic repos. In that case, please submit your issue on the docs repo with a link to the repo where the content lives. --- @@ -109,20 +168,6 @@ When submitting pull requests, please keep the scope of your change contained to --- - - ## Deploying The Ionic documentation's `main` branch is deployed automatically and separately from the [Ionic site](https://github.com/ionic-team/ionic-site) itself. The Ionic site then uses a proxy for paths under `/docs` to request the deployed documentation. @@ -133,4 +178,4 @@ The Ionic documentation's `main` branch is deployed automatically and separately This repo is licensed and managed separately from Ionic itself. -By contributing to this repo, you agree to have your contributions licensed under the Apache 2.0 license. See [LICENSE](../LICENSE) for the full license text. +By contributing to this repo, you agree to have your contributions licensed under the Apache 2.0 license. See [LICENSE](LICENSE) for the full license text. diff --git a/_templates/README.md b/_templates/README.md new file mode 100644 index 00000000000..60a3ebef83d --- /dev/null +++ b/_templates/README.md @@ -0,0 +1,32 @@ +# Hygen templates + +The templates in this directory are intended to be used with [hygen](https://www.hygen.io/) to generate boilerplate files. Check out [the root package.json](../package.json) to see if there are any custom commands to use them (e.g. `npm run playground:new`). You can also run e.g. `hygen playground new` to use a generator. + +Some helpful docs links for updating/creating templates: + +- [enquirer](https://github.com/enquirer/enquirer#toggle-prompt) for building command line prompts +- [inflection](https://www.hygen.io/docs/templates#helpers-and-inflections) and [change case](https://www.hygen.io/docs/templates#change-case-helpers) for e.g. changing the case of variables submitted via the prompts + +# New playground template + +## Generation + +To create a new playground, run `npm run playground:new`. This will walk you through some prompts to decide what files for the generator to create for the playground, and what their paths should be. + +The path defaults to `basic`. If there is already a basic playground, you'll want to input a different path for the playground. + +The CSS option will add extra files if you need to include custom CSS in your playground. + +If you need a component for multiple versions of Ionic Framework, you (currently) need to run the generator once for each version. + +## Usage + +Once you've generated your playground, you need to add it to the main markdown file in the docs (e.g. [docs/api/button.md](../docs/api/button.md)) by doing something similar to the following example: + +``` +## Feature + +import Feature from '@site/static/usage/v8/button/feature/index.md'; + + +``` diff --git a/_templates/playground/new/angular_example_component_css.md.ejs.t b/_templates/playground/new/angular_example_component_css.md.ejs.t new file mode 100644 index 00000000000..e6aab594e42 --- /dev/null +++ b/_templates/playground/new/angular_example_component_css.md.ejs.t @@ -0,0 +1,9 @@ +--- +# this file only gets generated if `css` (from the command line prompt) is true +to: "<%= css ? `static/usage/v${version}/${name}/${path}/angular/example_component_css.md` : null %>" +--- +```css +<%= component %> { + /* styles go here */ +} +``` diff --git a/_templates/playground/new/angular_example_component_html.md.ejs.t b/_templates/playground/new/angular_example_component_html.md.ejs.t new file mode 100644 index 00000000000..98f48fde212 --- /dev/null +++ b/_templates/playground/new/angular_example_component_html.md.ejs.t @@ -0,0 +1,6 @@ +--- +to: "<%= `static/usage/v${version}/${name}/${path}/angular/example_component_html.md` %>" +--- +```html +<<%= component %>>> +``` diff --git a/_templates/playground/new/angular_example_component_ts.md.ejs.t b/_templates/playground/new/angular_example_component_ts.md.ejs.t new file mode 100644 index 00000000000..548a45dd57b --- /dev/null +++ b/_templates/playground/new/angular_example_component_ts.md.ejs.t @@ -0,0 +1,16 @@ +--- +arbitrary: <% pascalComponent = h.changeCase.pascal(component) %> +to: "<%= `static/usage/v${version}/${name}/${path}/angular/example_component_ts.md` %>" +--- +```ts +import { Component } from '@angular/core'; +import { <%= pascalComponent %> } from '@ionic/angular/standalone'; + +@Component({ + selector: 'app-example', + templateUrl: 'example.component.html', + styleUrls: ['./example.component.css'], + imports: [<%= pascalComponent %>], +}) +export class ExampleComponent {} +``` diff --git a/_templates/playground/new/demo.html.ejs.t b/_templates/playground/new/demo.html.ejs.t new file mode 100644 index 00000000000..3a6a9cadff9 --- /dev/null +++ b/_templates/playground/new/demo.html.ejs.t @@ -0,0 +1,32 @@ +--- +arbitrary: <% numberOfAncestors = (path.match(/\//g) || []).length; directoryChanges = '../'.repeat(numberOfAncestors) %> +to: "<%= `static/usage/v${version}/${name}/${path}/demo.html` %>" +--- + + + + + + <%= h.changeCase.titleCase(name) %> + + + + <% if (css){ %> + + <% } %> + + + + + +
+ <<%= component %>>> +
+
+
+ + diff --git a/_templates/playground/new/index.js b/_templates/playground/new/index.js new file mode 100644 index 00000000000..c6f9fb53b6c --- /dev/null +++ b/_templates/playground/new/index.js @@ -0,0 +1,82 @@ +const changeCase = require('change-case'); + +// see types of prompts: +// https://github.com/enquirer/enquirer/tree/master/examples +// +module.exports = { + prompt: ({ inquirer }) => { + return inquirer + .prompt([ + { + type: 'toggle', + name: 'is_component', + message: 'Is this playground for a component?', + initial: true, + }, + ]) + .then((answers) => { + return inquirer + .prompt([ + // ask a different question for components vs. other playgrounds + answers.is_component + ? { + type: 'input', + name: 'component', + message: 'Which component is this playground for?', + initial: 'ion-button', + validate(value) { + return value.match(/^ion-[a-z/-]*[a-z]+$/) + ? true + : "Component name must be kebab-case and begin with 'ion-'"; + }, + } + : { + type: 'input', + name: 'name', + message: 'Which guide section is this playground for?', + initial: 'animations', + validate(value) { + return value.match(/^[a-z/-]+$/) ? true : 'Section must be kebab-case'; + }, + }, + { + type: 'input', + name: 'path', + message: 'What should the playground path be?', + hint: 'e.g. `basic` or `theming/colors`', + validate(value) { + return value.match(/^[a-z]+[a-z/-]*[a-z]+$/) + ? true + : "Path should begin and end with a letter and only contain lowercase letters, '-', or '/'"; + }, + }, + { + type: 'select', + name: 'version', + message: 'Select the Ionic Framework version for the playground', + initial: '8', + choices: ['6', '7', '8'], + }, + { + type: 'toggle', + name: 'css', + message: 'Generate custom CSS files?', + }, + ]) + .then((answers) => { + answers.name = answers.name || answers.component.replace('ion-', ''); + + // if the playground is not for a component, + // include an ion-card in the playground + answers.component = answers.component || 'ion-card'; + + const playgroundName = changeCase.pascal(answers.path.split('/').pop()); + console.log( + `\nTo use this playground in a docs markdown file, include\nthe following:\n\n## ${playgroundName}\n\nimport ${playgroundName} from '@site/static/usage/v${answers.version}/${answers.name}/${answers.path}/index.md';\n\n<${playgroundName} />\n` + ); + + return answers; + }); + }); + }, +}; diff --git a/_templates/playground/new/index.md.ejs.t b/_templates/playground/new/index.md.ejs.t new file mode 100644 index 00000000000..148d3e85efe --- /dev/null +++ b/_templates/playground/new/index.md.ejs.t @@ -0,0 +1,48 @@ +--- +to: "<%= `static/usage/v${version}/${name}/${path}/index.md` %>" +--- +import Playground from '@site/src/components/global/Playground'; + +import javascript from './javascript.md'; +<% if (css){ %> +import react_main_tsx from './react/main_tsx.md'; +import react_main_css from './react/main_css.md'; + +<% } else { -%> +import react from './react.md'; +<% } -%> +import vue from './vue.md'; + +import angular_example_component_html from './angular/example_component_html.md'; +<% if (css){ -%> +import angular_example_component_css from './angular/example_component_css.md'; +<% } -%> +import angular_example_component_ts from './angular/example_component_ts.md'; + + + react: { + files: { + 'src/main.tsx': react_main_tsx, + 'src/main.css': react_main_css, + }, + }, +<% } else { -%> + react, +<% } -%> + vue, + angular: { + files: { + 'src/app/example.component.html': angular_example_component_html, +<% if (css){ -%> + 'src/app/example.component.css': angular_example_component_css, +<% } -%> + 'src/app/example.component.ts': angular_example_component_ts, + }, + }, + }} + src="usage/v<%= version %>/<%= name %>/<%= path %>/demo.html" +/> diff --git a/_templates/playground/new/javascript.md.ejs.t b/_templates/playground/new/javascript.md.ejs.t new file mode 100644 index 00000000000..1aa3e7f1f2e --- /dev/null +++ b/_templates/playground/new/javascript.md.ejs.t @@ -0,0 +1,14 @@ +--- +to: "<%= `static/usage/v${version}/${name}/${path}/javascript.md` %>" +--- +```html +<<%= component %>>> +<% if (css){ -%> + + +<% } -%> +``` diff --git a/_templates/playground/new/react.md.ejs.t b/_templates/playground/new/react.md.ejs.t new file mode 100644 index 00000000000..a8320a026ba --- /dev/null +++ b/_templates/playground/new/react.md.ejs.t @@ -0,0 +1,20 @@ +--- +arbitrary: <% pascalComponent = h.changeCase.pascal(component) %> +# this file's location depends on whether or not the css option is selected via the prompt +to: "<%= `static/usage/v${version}/${name}/${path}/${css ? 'react/main_tsx.md' : 'react.md'}` %>" +--- +```tsx +import React from 'react'; +import { <%= pascalComponent %> } from '@ionic/react';<% if (css){ %> + +import './main.css';<% } %> + +function Example() { + return ( + <> + <<%= pascalComponent %>>> + + ); +} +export default Example; +``` diff --git a/_templates/playground/new/react_main_css.md.ejs.t b/_templates/playground/new/react_main_css.md.ejs.t new file mode 100644 index 00000000000..1abbc16100c --- /dev/null +++ b/_templates/playground/new/react_main_css.md.ejs.t @@ -0,0 +1,9 @@ +--- +# this file only gets generated if `css` (from the command line prompt) is true +to: "<%= css ? `static/usage/v${version}/${name}/${path}/react/main_css.md` : null %>" +--- +```css +<%= component %> { + /* styles go here */ +} +``` diff --git a/_templates/playground/new/vue.md.ejs.t b/_templates/playground/new/vue.md.ejs.t new file mode 100644 index 00000000000..a22edd2b2b4 --- /dev/null +++ b/_templates/playground/new/vue.md.ejs.t @@ -0,0 +1,28 @@ +--- +arbitrary: <% pascalComponent = h.changeCase.pascal(component) %> +to: "<%= `static/usage/v${version}/${name}/${path}/vue.md` %>" +--- +```html + + + +<% if (css){ -%> + + +<% } -%> +``` diff --git a/crowdin.yml b/crowdin.yml index 33a536865ca..c237cf6e3bd 100644 --- a/crowdin.yml +++ b/crowdin.yml @@ -8,6 +8,5 @@ files: - source: /docs/**/* translation: /i18n/%two_letters_code%/docusaurus-plugin-content-docs/current/**/%original_file_name% ignore: - - /docs/api/**/* - /docs/cli/commands/**/* - /docs/native/**/* diff --git a/cspell-wordlist.txt b/cspell-wordlist.txt new file mode 100644 index 00000000000..54171a11bf4 --- /dev/null +++ b/cspell-wordlist.txt @@ -0,0 +1,85 @@ +Appflow +Codepen +Firestore +Genymotion +Hygen +Ionicon +Ionicons +Logcat +Maskito +Pluralsight +Swiper +Udemy +Vetur +Wistia +WCAG + +actionsheet +fabs +datetime +datetimes +datetimepicker +infinitescroll +searchbar +searchbars +sidemenu +textarea +textareas + +appstore +authed +autogrow +automations +autoplay +Callout +comparewith +composables +engageable +flexbox +frontmatter +fullscreen +geolocation +interactives +isopen +jank +janky +jarsigner +jsdelivr +keyframes +keytool +lifecycles +localstorage +mobileweb +phablet +playstore +preconfigured +preflighted +proxying +quickstart +retargeted +runtimes +scroller +subcomponent +subcomponents +swipeable +templating +transpiling +treeshaking +triaging +typeahead +unminified +unsanitized +viewports +webapps +webviews +xlarge +xsmall + +allowtransparency +mozallowfullscreen +msallowfullscreen +oallowfullscreen +webkitallowfullscreen + +ionicframework +browserslistrc diff --git a/cspell.json b/cspell.json new file mode 100644 index 00000000000..972166aa24f --- /dev/null +++ b/cspell.json @@ -0,0 +1,27 @@ +{ + "dictionaries": ["custom-words"], + "dictionaryDefinitions": [ + { + "name": "custom-words", + "path": "./cspell-wordlist.txt", + "addWords": true + } + ], + "ignoreRegExpList": [ + "/(```+)[\\s\\S]+?\\1/g", + "`([^`]*)`", + "/:[a-zA-Z0-9-_\\+]+:/g" + ], + "ignorePaths": [ + "docs/cli", + "docs/native", + "versioned_docs/**/api", + "versioned_docs/**/cli", + "versioned_docs/**/native", + "node_modules", + "src/translate" + ], + "flagWords": [ + "hte" + ] +} diff --git a/docs/README.md b/docs/README.md index 2da29748116..12005305278 100644 --- a/docs/README.md +++ b/docs/README.md @@ -4,7 +4,7 @@ The `/docs` folder houses all markdown files. The page structure loosely maps to ## Versioning -This folder can also contain components, assets, and whatever else is meant to be versioned when the docusaurus versioning script is run. For example, if there is a page component that is only relevant to the `layout` section in the current version of Ionic, it could be added to a `_components/` folder in `docs/layout/`. When the versioning script is run, the component will be copied to `versioned_docs/verion-{X}/layout/_components/` and there will now be a separate component in `docs/layout/_components/` that can be deleted or updated to the latest version. The same concept applies to images and other files. +This folder can also contain components, assets, and whatever else is meant to be versioned when the docusaurus versioning script is run. For example, if there is a page component that is only relevant to the `layout` section in the current version of Ionic, it could be added to a `_components/` folder in `docs/layout/`. When the versioning script is run, the component will be copied to `versioned_docs/version-{X}/layout/_components/` and there will now be a separate component in `docs/layout/_components/` that can be deleted or updated to the latest version. The same concept applies to images and other files. If components are meant to be shared across versions, they can be put in `src/components/`. If images and other served files are meant to be shared across versions they can be put in `static/`. diff --git a/docs/angular/build-options.md b/docs/angular/build-options.md new file mode 100644 index 00000000000..630864d1621 --- /dev/null +++ b/docs/angular/build-options.md @@ -0,0 +1,700 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +# Build Options + +Developers have two options for using Ionic components: Standalone or Modules. This guide covers both options as well as the benefits and downsides of each approach. + +While the Standalone approach is newer and makes use of more modern Angular APIs, the Modules approach will continue to be supported in Ionic. Most of the Angular examples on this documentation website use the Modules approach. + +## Standalone + +:::info +Ionic UI components as Angular standalone components is supported starting in Ionic v7.5. +::: + +### Overview + +Developers can use Ionic components as standalone components to take advantage of treeshaking and newer Angular features. This option involves importing specific Ionic components in the Angular components you want to use them in. Developers can use Ionic standalone components even if their Angular application is NgModule-based. + +See the [Standalone Migration Guide](#migrating-from-modules-to-standalone) for instructions on how to update your Ionic app to make use of Ionic standalone components. + +**Benefits** + +1. Enables treeshaking so the final build output only includes the code necessary to run your app which reduces overall build size. +2. Avoids the use of NgModules to streamline the development experience and make your code easier to understand. +3. Allows developers to also use newer Angular features such as [ESBuild](https://angular.io/guide/esbuild). + +**Drawbacks** + +1. Ionic components need to be imported into every Angular component they are used in which can be time consuming to set up. + +### Usage with Standalone-based Applications + +:::warning +All Ionic imports should be imported from the `@ionic/angular/standalone` submodule. This includes imports such as components, directives, providers, and types. Importing from `@ionic/angular` may pull in lazy loaded Ionic code which can interfere with treeshaking. +::: + +**Bootstrapping and Configuration** + +Ionic Angular needs to be configured when the Angular application calls `bootstrapApplication` using the `provideIonicAngular` function. Developers can pass any [IonicConfig](../developing/config#ionicconfig) values as an object in this function. Note that `provideIonicAngular` needs to be called even if no custom config is passed. + +```typescript title="main.ts" +import { enableProdMode, importProvidersFrom } from '@angular/core'; +import { bootstrapApplication } from '@angular/platform-browser'; +import { RouteReuseStrategy, provideRouter } from '@angular/router'; +import { provideIonicAngular, IonicRouteStrategy } from '@ionic/angular/standalone'; + +import { routes } from './app/app.routes'; +import { AppComponent } from './app/app.component'; + +bootstrapApplication(AppComponent, { + providers: [ + { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }, + provideIonicAngular({ mode: 'ios' }), + provideRouter(routes), + ], +}); +``` + +**Components** + +In the example below, we are importing `IonContent` and `IonButton` from `@ionic/angular/standalone` and passing them to `imports` for use in the component template. We would get a compiler error if these components were not imported and provided to the `imports` array. + +```typescript title="home.page.ts" +import { Component } from '@angular/core'; +import { IonButton, IonContent } from '@ionic/angular/standalone'; + +@Component({ + selector: 'app-home', + templateUrl: 'home.page.html', + styleUrls: ['home.page.scss'], + standalone: true, + imports: [IonButton, IonContent], +}) +export class HomePage { + constructor() {} +} +``` + +**Icons** + +The icon SVG data needs to be defined in the Angular component so it can be loaded correctly. Developers can use the `addIcons` function from `ionicons` to map the SVG data to a string name. Developers can then reference the icon by its string name using the `name` property on `IonIcon`. + +We recommend calling `addIcons` in the Angular component `constructor` so the data is only added if the Angular component is being used. + +For developers using Ionicons 7.2 or newer, passing only the SVG data will cause the string name to be automatically generated. + +```typescript title="home.page.ts" +import { Component } from '@angular/core'; +import { IonIcon } from '@ionic/angular/standalone'; +import { addIcons } from 'ionicons'; +import { logoIonic } from 'ionicons/icons'; + +@Component({ + selector: 'app-home', + templateUrl: 'home.page.html', + styleUrls: ['home.page.scss'], + standalone: true, + imports: [IonIcon], +}) +export class HomePage { + constructor() { + /** + * On Ionicons 7.2+ this icon + * gets mapped to a "logo-ionic" key. + * Alternatively, developers can do: + * addIcons({ 'logo-ionic': logoIonic }); + */ + addIcons({ logoIonic }); + } +} +``` + +Icons can also be registered in entry points such as `app.component.ts` to avoid the need to call `addIcons` multiple times. Developers should be aware that the initial application chunk may increase because the registered icons will need to be loaded at application start. However, if your application uses a small number of icons the impact of this may be minimal. + +```typescript title="app.component.ts" +import { Component } from '@angular/core'; +import { addIcons } from 'ionicons'; +import { logoIonic } from 'ionicons/icons'; + +@Component({ + selector: 'app-root', + templateUrl: 'app.component.html', + styleUrls: ['app.component.scss'], + standalone: true, +}) +export class AppComponent { + constructor() { + /** + * Any icons you want to use in your application + * can be registered in app.component.ts and then + * referenced by name anywhere in your application. + */ + addIcons({ logoIonic }); + } +} +``` + +Icons registered in an application entry point can then be referenced by name anywhere in the application. + +```html title="home.page.html" + + +``` + +**Routing** + +Developers who wish to use `routerLink`, `routerAction`, or `routerDirection` on Ionic components should import the `IonRouterLink` directive. Developers who wish to use these routing features on anchor (``) elements should import `IonRouterLinkWithHref` instead. + +```typescript title="home.page.ts" +import { Component } from '@angular/core'; +import { RouterLink } from '@angular/router'; +import { IonButton, IonRouterLink } from '@ionic/angular/standalone'; + +@Component({ + selector: 'app-home', + templateUrl: 'home.page.html', + styleUrls: ['home.page.scss'], + standalone: true, + imports: [ + IonButton, + RouterLink, // required to get base routerLink behavior for @angular/router + IonRouterLink, // use IonRouterLinkWithHref if you are using an element instead + ], +}) +export class HomePage {} +``` + +```html title="home.page.html" +Go to Foo Page +``` + +**Testing** + +Ionic Angular's standalone components use ES Modules. As a result, developers using Jest should ensure that ES Modules are transpiled to a format that Jest can use. Developers using Jest should add the following to their Jest config: + + + + +```json + +"transformIgnorePatterns": ["/node_modules/(?!(@ionic/angular|@ionic/core|ionicons|@stencil/core|@angular/*)/)"] +``` + + + + +```json + +"transformIgnorePatterns": ["/node_modules/.pnpm/(?!(@ionic/angular|@ionic/core|ionicons|@stencil/core|@angular/*)@)"] +``` + + + + +### Usage with NgModule-based Applications + +:::warning +All Ionic imports should be imported from the `@ionic/angular/standalone` submodule. This includes imports such as components, directives, providers, and types. Importing from `@ionic/angular` may pull in lazy loaded Ionic code which can interfere with treeshaking. +::: + +**Bootstrapping and Configuration** + +Ionic Angular needs to be configured in the `providers` array of `app.module.ts` using the `provideIonicAngular` function. Developers can pass any [IonicConfig](../developing/config#ionicconfig) values as an object in this function. Note that `provideIonicAngular` needs to be called even if no custom config is passed. + +```typescript title="app.module.ts" +import { NgModule } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { RouteReuseStrategy } from '@angular/router'; + +import { IonicRouteStrategy, provideIonicAngular } from '@ionic/angular/standalone'; + +import { AppComponent } from './app.component'; +import { AppRoutingModule } from './app-routing.module'; + +@NgModule({ + declarations: [AppComponent], + imports: [BrowserModule, AppRoutingModule], + providers: [provideIonicAngular(), { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }], + bootstrap: [AppComponent], +}) +export class AppModule {} +``` + +**Components** + +In the example below, we are importing `IonContent` and `IonButton` from `@ionic/angular/standalone` and passing them to `imports` array in the Angular component's NgModule for use in the component template. We would get a compiler error if these components were not imported and provided to the `imports` array. + +```typescript title="home.module.ts" +import { NgModule } from '@angular/core'; +import { IonButton, IonContent } from '@ionic/angular/standalone'; +import { HomePage } from './home.page'; + +import { HomePageRoutingModule } from './home-routing.module'; + +@NgModule({ + imports: [IonButton, IonContent, HomePageRoutingModule], + declarations: [HomePage], +}) +export class HomePageModule {} +``` + +**Icons** + +The icon SVG data needs to be defined in the Angular component so it can be loaded correctly. Developers can use the `addIcons` function from `ionicons` to map the SVG data to a string name. Developers can then reference the icon by its string name using the `name` property on `IonIcon`. The `IonIcon` component should be added in `app.module.ts` just like the other Ionic components. + +We recommend calling `addIcons` in the Angular component `constructor` so the data is only added if the Angular component is being used. + +For developers using Ionicons 7.2 or newer, passing only the SVG data will cause the string name to be automatically generated. + +```typescript title="home.page.ts" +import { Component } from '@angular/core'; +import { addIcons } from 'ionicons'; +import { logoIonic } from 'ionicons/icons'; + +@Component({ + selector: 'app-home', + templateUrl: 'home.page.html', + styleUrls: ['home.page.scss'], +}) +export class HomePage { + constructor() { + /** + * On Ionicons 7.2+ this icon + * gets mapped to a "logo-ionic" key. + * Alternatively, developers can do: + * addIcons({ 'logo-ionic': logoIonic }); + */ + addIcons({ logoIonic }); + } +} +``` + +Icons can also be registered in entry points such as `app.component.ts` to avoid the need to call `addIcons` multiple times. Developers should be aware that the initial application chunk may increase because the registered icons will need to be loaded at application start. However, if your application uses a small number of icons the impact of this may be minimal. + +```typescript title="app.component.ts" +import { Component } from '@angular/core'; +import { addIcons } from 'ionicons'; +import { logoIonic } from 'ionicons/icons'; + +@Component({ + selector: 'app-root', + templateUrl: 'app.component.html', + styleUrls: ['app.component.scss'], +}) +export class AppComponent { + constructor() { + /** + * Any icons you want to use in your application + * can be registered in app.component.ts and then + * referenced by name anywhere in your application. + */ + addIcons({ logoIonic }); + } +} +``` + +Icons registered in an application entry point can then be referenced by name anywhere in the application. + +```html title="home.page.html" + + +``` + +**Routing** + +Developers who wish to use `routerLink`, `routerAction`, or `routerDirection` on Ionic components should import the `IonRouterLink` directive. Developers who wish to use these routing features on anchor (``) elements should import `IonRouterLinkWithHref` instead. + +```typescript title="home.module.ts" +import { NgModule } from '@angular/core'; +import { RouterLink } from '@angular/router'; +import { IonButton, IonRouterLink } from '@ionic/angular/standalone'; +import { HomePage } from './home.page'; + +import { HomePageRoutingModule } from './home-routing.module'; + +@NgModule({ + imports: [ + IonButton, + RouterLink, // required to get base routerLink behavior for @angular/router + IonRouterLink, // use IonRouterLinkWithHref if you are using an element instead + HomePageRoutingModule, + ], + declarations: [HomePage], +}) +export class HomePageModule {} +``` + +```html title="home.page.html" +Go to Foo Page +``` + +**Testing** + +Ionic Angular's standalone components use ES Modules. As a result, developers using Jest should ensure that ES Modules are transpiled to a format that Jest can use. Developers using Jest should add the following to their Jest config: + + + + +```json + +"transformIgnorePatterns": ["/node_modules/(?!(@ionic/angular|@ionic/core|ionicons|@stencil/core|@angular/*)/)"] +``` + + + + +```json + +"transformIgnorePatterns": ["/node_modules/.pnpm/(?!(@ionic/angular|@ionic/core|ionicons|@stencil/core|@angular/*)@)"] +``` + + + + +## Modules + +### Overview + +Developers can also use the Modules approach by importing `IonicModule` and calling `IonicModule.forRoot()` in the `imports` array in `app.module.ts`. This registers a version of Ionic where Ionic components will be lazily loaded at runtime. + +**Benefits** + +1. Since components are lazily loaded as needed, developers do not need to spend time manually importing and registering each Ionic component. + +**Drawbacks** + +1. Lazily loading Ionic components means that the compiler does not know which components are needed at build time. This means your final application bundle may be much larger than it needs to be. +2. Developers are unable to use newer Angular features such as [ESBuild](https://angular.io/guide/esbuild). + +### Usage + +In the example below, we are using `IonicModule` to create a lazily loaded version of Ionic. We can then reference any Ionic component without needing to explicitly import it. + +```typescript +import { NgModule } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; + +import { IonicModule } from '@ionic/angular'; + +import { AppComponent } from './app.component'; + +@NgModule({ + declarations: [AppComponent], + imports: [BrowserModule, IonicModule.forRoot()], + bootstrap: [AppComponent], +}) +export class AppModule {} +``` + +## Migrating from Modules to Standalone + +:::tip +Try our automated utility for migrating to standalone! + +See https://github.com/ionic-team/ionic-angular-standalone-codemods for instructions on how to get started. All issues related to the migration utility should be filed on the linked repo. +::: + +The Standalone option is newer than the Modules option, so developers may wish to switch during the development of their application. This guide details the steps needed to migrate. + +Migrating to Ionic standalone components must be done all at the same time and cannot be done gradually. The Modules and Standalone approaches use two different build systems of Ionic that cannot be used at the same time. + +Developers are encouraged to try the [automated migration utility](https://github.com/ionic-team/ionic-angular-standalone-codemods), though they can also follow the steps below if they would like to manually migrate their applications. + +### Standalone-based Applications + +Follow these steps if your Angular application is already using the standalone architecture, and you want to use Ionic UI components as standalone components too. + +1. Run `npm install @ionic/angular@latest` to ensure you are running the latest version of Ionic. Ionic UI Standalone Components is supported in Ionic v7.5 or newer. + +2. Run `npm install ionicons@latest` to ensure you are running the latest version of Ionicons. Ionicons v7.2 brings usability improvements that reduce the code boilerplate needed to use icons with standalone components. + +3. Remove the `IonicModule` call in `main.ts` in favor of `provideIonicAngular` imported from `@ionic/angular/standalone`. Any config passed to `IonicModule.forRoot` can be passed as an object to this new function. + +```diff title="main.ts" +import { enableProdMode, importProvidersFrom } from '@angular/core'; +import { bootstrapApplication } from '@angular/platform-browser'; +import { RouteReuseStrategy, provideRouter } from '@angular/router'; +- import { IonicModule, IonicRouteStrategy } from '@ionic/angular'; ++ import { provideIonicAngular, IonicRouteStrategy } from '@ionic/angular/standalone'; + +import { routes } from './app/app.routes'; +import { AppComponent } from './app/app.component'; + +bootstrapApplication(AppComponent, { + providers: [ + { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }, + /** + * The custom config serves as an example + * of how to pass a config to provideIonicAngular. + * You do not need to set "mode: 'ios'" to + * use Ionic standalone components. + */ +- importProvidersFrom(IonicModule.forRoot({ mode: 'ios' })), ++ provideIonicAngular({ mode: 'ios' }), + provideRouter(routes), + ], +}); +``` + +4. Remove any references to `IonicModule` found elsewhere in your application. + +5. Update any existing imports from `@ionic/angular` to import from `@ionic/angular/standalone` instead. + +```diff +- import { Platform } from '@ionic/angular'; ++ import { Platform } from '@ionic/angular/standalone'; +``` + +6. Add imports for each Ionic component in the Angular component where they are used. Be sure to pass the imports to the `imports` array on your Angular component. + +```diff title="app.component.ts" +import { Component } from '@angular/core'; ++ import { IonApp, IonRouterOutlet } from '@ionic/angular/standalone'; + +@Component({ + selector: 'app-root', + templateUrl: 'app.component.html', + styleUrls: ['app.component.scss'], + standalone: true, ++ imports: [IonApp, IonRouterOutlet], +}) +export class AppComponent { + constructor() {} +} +``` + +7. If you are using Ionicons, define the icon SVG data used in each Angular component using `addIcons`. This allows you to continue referencing icons by string name in your component template. Note that you will need to do this for any additional icons added. + +```diff title="test.component.ts" +import { Component } from '@angular/core'; ++ import { IonIcon } from '@ionic/angular/standalone'; ++ import { addIcons } from 'ionicons'; ++ import { alarm, logoIonic } from 'ionicons/icons'; + +@Component({ + selector: 'app-root', + templateUrl: 'app.component.html', + styleUrls: ['app.component.scss'], + standalone: true, ++ imports: [IonIcon], +}) +export class TestComponent { + constructor() { ++ addIcons({ alarm, logoIonic }); + } +} +``` + +8. Remove the following code from your `angular.json` file if present. Note that it may appear multiple times. + +```diff title="angular.json" +- { +- "glob": "**/*.svg", +- "input": "node_modules/ionicons/dist/ionicons/svg", +- "output": "./svg" +- } +``` + +9. If you are using `routerLink`, `routerDirection`, or `routerAction` be sure to import the `IonRouterLink` directive for Ionic components or `IonRouterLinkWithHref` directive for `` elements. + +```diff title="test.component.ts" +import { Component } from '@angular/core'; +- import { IonButton } from '@ionic/angular/standalone'; ++ import { IonButton, IonRouterLink } from '@ionic/angular/standalone'; + +@Component({ + selector: 'app-root', + templateUrl: 'app.component.html', + styleUrls: ['app.component.scss'], + standalone: true, + imports: [ + IonButton, ++ IonRouterLink + ], +}) +export class TestComponent {} +``` + +10. If you are using VSCode it is recommended to ignore the `@ionic/angular/common` and `@ionic/angular` module specifiers for import recommendations. + +```json title=".vscode/settings.json" +{ + "typescript.preferences.autoImportFileExcludePatterns": ["@ionic/angular/common", "@ionic/angular"] +} +``` + +### NgModule-based Applications + +Follow these steps if your Angular application is still using the NgModule architecture, but you want to adopt Ionic UI components as standalone components now. + +1. Run `npm install @ionic/angular@latest` to ensure you are running the latest version of Ionic. Ionic UI Standalone Components is supported in Ionic v7.5 or newer. + +2. Run `npm install ionicons@latest` to ensure you are running the latest version of Ionicons. Ionicons v7.2 brings usability improvements that reduce the code boilerplate needed to use icons with standalone components. + +3. Remove the `IonicModule` call in `app.module.ts` in favor of `provideIonicAngular` imported from `@ionic/angular/standalone`. Any config passed to `IonicModule.forRoot` can be passed as an object to this new function. + +```diff title="app.module.ts" +import { enableProdMode, importProvidersFrom } from '@angular/core'; +import { bootstrapApplication } from '@angular/platform-browser'; +import { RouteReuseStrategy, provideRouter } from '@angular/router'; +- import { IonicModule, IonicRouteStrategy } from '@ionic/angular'; ++ import { provideIonicAngular, IonicRouteStrategy } from '@ionic/angular/standalone'; + +import { routes } from './app/app.routes'; +import { AppComponent } from './app/app.component'; + +@NgModule({ + declarations: [AppComponent], +- imports: [BrowserModule, IonicModule.forRoot({ mode: 'ios' }), AppRoutingModule], ++ imports: [BrowserModule, AppRoutingModule], + providers: [ + { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }, + /** + * The custom config serves as an example + * of how to pass a config to provideIonicAngular. + * You do not need to set "mode: 'ios'" to + * use Ionic standalone components. + */ ++ provideIonicAngular({ mode: 'ios' }), + ], + bootstrap: [AppComponent], +}) +export class AppModule {} +``` + +4. Remove any references to `IonicModule` found elsewhere in your application. + +5. Update any existing imports from `@ionic/angular` to import from `@ionic/angular/standalone` instead. + +```diff +- import { Platform } from '@ionic/angular'; ++ import { Platform } from '@ionic/angular/standalone'; +``` + +6. Add imports for each Ionic component in the NgModule for the Angular component where they are used. Be sure to pass the components to the `imports` array on the module. + +```diff title="app.module.ts" +import { enableProdMode, importProvidersFrom } from '@angular/core'; +import { bootstrapApplication } from '@angular/platform-browser'; +import { RouteReuseStrategy, provideRouter } from '@angular/router'; +- import { provideIonicAngular, IonicRouteStrategy } from '@ionic/angular/standalone'; ++ import { provideIonicAngular, IonicRouteStrategy, IonApp, IonRouterOutlet } from '@ionic/angular/standalone'; + +import { routes } from './app/app.routes'; +import { AppComponent } from './app/app.component'; + +@NgModule({ + declarations: [AppComponent], +- imports: [BrowserModule, AppRoutingModule], ++ imports: [BrowserModule, AppRoutingModule, IonApp, IonRouterOutlet], + providers: [ + { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }, + provideIonicAngular({ mode: 'ios' }) + ], + bootstrap: [AppComponent], +}) +export class AppModule {} +``` + +For example, all modules that are using Ionic components need to have the Ionic components imported in their component module. + +```diff title="home.module.ts" +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; +import { HomePage } from './home.page'; + +import { HomePageRoutingModule } from './home-routing.module'; + ++ import { IonContent, IonHeader, IonTitle, IonToolbar } from '@ionic/angular/standalone'; + +@NgModule({ + imports: [ + CommonModule, + FormsModule, + HomePageRoutingModule, ++ IonContent, ++ IonHeader, ++ IonTitle, ++ IonToolbar + ], + declarations: [HomePage] +}) +export class HomePageModule {} +``` + +7. If you are using Ionicons, define the icon SVG data used in each Angular component using `addIcons`. This allows you to continue referencing icons by string name in your component template. Note that you will need to do this for any additional icons added. The `IonIcon` component should still be provided in the NgModule. + +```diff title="test.component.ts" +import { Component } from '@angular/core'; ++ import { addIcons } from 'ionicons'; ++ import { alarm, logoIonic } from 'ionicons/icons'; + +@Component({ + selector: 'app-root', + templateUrl: 'app.component.html', + styleUrls: ['app.component.scss'], +}) +export class TestComponent { + constructor() { ++ addIcons({ alarm, logoIonic }); + } +} +``` + +```diff title="test.module.ts" +import { NgModule } from '@angular/core'; +import { TestComponent } from './test.component'; ++ import { IonIcon } from '@ionic/angular/standalone'; + +@NgModule({ + imports: [ ++ IonIcon, + ], + declarations: [TestComponent] +}) +export class TestComponentModule {} +``` + +8. Remove the following code from your `angular.json` file if present. Note that it may appear multiple times. + +```diff title="angular.json" +- { +- "glob": "**/*.svg", +- "input": "node_modules/ionicons/dist/ionicons/svg", +- "output": "./svg" +- } +``` + +9. If you are using `routerLink`, `routerDirection`, or `routerAction` be sure to import the `IonRouterLink` directive for Ionic components or `IonRouterLinkWithHref` directive for `` elements. + +```diff title="test.module.ts" +import { NgModule } from '@angular/core'; +import { TestComponent } from './test.component'; +- import { IonButton } from '@ionic/angular/standalone'; ++ import { IonButton, IonRouterLink } from '@ionic/angular/standalone'; + +@NgModule({ + imports: [ + IonButton, ++ IonRouterLink, + ], + declarations: [TestComponent] +}) +``` + +10. If you are using VSCode it is recommended to ignore the `@ionic/angular/common` and `@ionic/angular` module specifiers for import recommendations. + +```json title=".vscode/settings.json" +{ + "typescript.preferences.autoImportFileExcludePatterns": ["@ionic/angular/common", "@ionic/angular"] +} +``` diff --git a/docs/angular/config.md b/docs/angular/config.md deleted file mode 100644 index 9af23a5d02b..00000000000 --- a/docs/angular/config.md +++ /dev/null @@ -1,186 +0,0 @@ ---- -title: Config ---- - - - Config | Ionic Config to Change Component Properties Globally - - - -Ionic Config provides a way to change the properties of components globally across an app. It can set the app mode, tab button layout, animations, and more. - -## Global Config - -To override the initial Ionic config for the app, provide a config in `IonicModule.forRoot` in the `app.module.ts` file. - -```tsx -import { IonicModule } from '@ionic/angular'; - -@NgModule({ - ... - imports: [ - BrowserModule, - IonicModule.forRoot({ - rippleEffect: false, - mode: 'md' - }), - AppRoutingModule - ], - ... -}) -``` - -In the above example, we are disabling the Material Design ripple effect across the app, as well as forcing the mode to be Material Design. - -## Per-Component Config - -Ionic Config is not reactive, so it is recommended to use a component's properties when you want to override its default behavior rather than set its config globally. - -```tsx -import { IonicModule } from '@ionic/angular'; - -@NgModule({ - ... - imports: [ - BrowserModule, - IonicModule.forRoot({ - backButtonText: 'Go Back' - }), - AppRoutingModule - ], - ... -}) -``` - -This will set the default text for `ion-back-button` to `Go Back`. However, if you were to change the value of the `backButtonText` config to `Do Not Go Back`, the `ion-back-button` default text would still default to `Go Back` as the component has already been initialized and rendered. Instead, it is recommended to use the `text` property on `ion-back-button`. - -```html - -``` - -In this example we have used our `ion-back-button` in such a way that the text can be dynamically updated if there were to be a change that warranted it, such as a language or locale change. The `getBackButtonText` method would be responsible for returning the correct text. - -## Per-Platform Config - -Ionic Config can also be set on a per-platform basis. For example, this allows you to disable animations if the app is being run in a browser on a potentially slower device. Developers can take advantage of the Platform utilities to accomplish this. - -Since the config is set at runtime, you will not have access to the Platform Dependency Injection. Instead, you can use the underlying functions that the provider uses directly. - -In the following example, we are disabling all animations in our Ionic app only if the app is running in a mobile web browser. -The `isPlatform()` call returns `true` or `false` based upon the platform that is passed in. See the [Platform Documentation](platform.md#platforms) for a list of possible values. - -```tsx -import { isPlatform, IonicModule } from '@ionic/angular'; - -@NgModule({ - ... - imports: [ - BrowserModule, - IonicModule.forRoot({ - animated: !isPlatform('mobileweb') - }), - AppRoutingModule - ], - ... -}) -``` - -The next example allows you to set an entirely different configuration based upon the platform, falling back to a default config if no platforms match: - -```tsx -import { isPlatform, IonicModule } from '@ionic/angular'; - -const getConfig = () => { - if (isPlatform('hybrid')) { - return { - backButtonText: 'Previous', - tabButtonLayout: 'label-hide' - } - } - - return { - menuIcon: 'ellipsis-vertical' - } -} -@NgModule({ - ... - imports: [ - BrowserModule, - IonicModule.forRoot(getConfig()), - AppRoutingModule - ], - ... -}) -``` - -Finally, this example allows you to accumulate a config object based upon different platform requirements: - -```tsx -import { isPlatform, IonicModule } from '@ionic/angular'; - -const getConfig = () => { - let config = { - animated: false - }; - - if (isPlatform('iphone')) { - config = { - ...config, - backButtonText: 'Previous' - } - } - - return config; -} -@NgModule({ - ... - imports: [ - BrowserModule, - IonicModule.forRoot(getConfig()), - AppRoutingModule - ], - ... -}) -``` - -## Config Options - -Below is a list of config options that Ionic uses. - -| Config | Type | Description | -| ------------------------ | --------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -| `actionSheetEnter` | `AnimationBuilder` | Provides a custom enter animation for all `ion-action-sheet`, overriding the default "animation". | -| `actionSheetLeave` | `AnimationBuilder` | Provides a custom leave animation for all `ion-action-sheet`, overriding the default "animation". | -| `alertEnter` | `AnimationBuilder` | Provides a custom enter animation for all `ion-alert`, overriding the default "animation". | -| `alertLeave` | `AnimationBuilder` | Provides a custom leave animation for all `ion-alert`, overriding the default "animation". | -| `animated` | `boolean` | If `true`, Ionic will enable all animations and transitions across the app. | -| `backButtonIcon` | `string` | Overrides the default icon in all `` components. | -| `backButtonText` | `string` | Overrides the default text in all `` components. | -| `hardwareBackButton` | `boolean` | If `true`, Ionic will respond to the hardware back button in an Android device. | -| `infiniteLoadingSpinner` | `SpinnerTypes` | Overrides the default spinner type in all `` components. | -| `loadingEnter` | `AnimationBuilder` | Provides a custom enter animation for all `ion-loading`, overriding the default "animation". | -| `loadingLeave` | `AnimationBuilder` | Provides a custom leave animation for all `ion-loading`, overriding the default "animation". | -| `loadingSpinner` | `SpinnerTypes` | Overrides the default spinner for all `ion-loading` overlays. | -| `menuIcon` | `string` | Overrides the default icon in all `` components. | -| `menuType` | `string` | Overrides the default menu type for all `` components. | -| `modalEnter` | `AnimationBuilder` | Provides a custom enter animation for all `ion-modal`, overriding the default "animation". | -| `modalLeave` | `AnimationBuilder` | Provides a custom leave animation for all `ion-modal`, overriding the default "animation". | -| `mode` | `Mode` | The mode determines which platform styles to use for the whole application. | -| `navAnimation` | `AnimationBuilder` | Overrides the default "animation" of all `ion-nav` and `ion-router-outlet` across the whole application. | -| `pickerEnter` | `AnimationBuilder` | Provides a custom enter animation for all `ion-picker`, overriding the default "animation". | -| `pickerLeave` | `AnimationBuilder` | Provides a custom leave animation for all `ion-picker`, overriding the default "animation". | -| `platform` | [`PlatformConfig`](/docs/angular/platform#customizing-platform-detection-methods) | Overrides the default platform detection methods. | -| `popoverEnter` | `AnimationBuilder` | Provides a custom enter animation for all `ion-popover`, overriding the default "animation". | -| `popoverLeave` | `AnimationBuilder` | Provides a custom leave animation for all `ion-popover`, overriding the default "animation". | -| `refreshingIcon` | `string` | Overrides the default icon in all `` components. | -| `refreshingSpinner` | `SpinnerTypes` | Overrides the default spinner type in all `` components. | -| `sanitizerEnabled` | `boolean` | If `true`, Ionic will enable a basic DOM sanitizer on component properties that accept custom HTML. | -| `spinner` | `SpinnerTypes` | Overrides the default spinner in all `` components. | -| `statusTap` | `boolean` | If `true`, clicking or tapping the status bar will cause the content to scroll to the top. | -| `swipeBackEnabled` | `boolean` | If `true`, Ionic will enable the "swipe-to-go-back" gesture across the application. | -| `tabButtonLayout` | `TabButtonLayout` | Overrides the default "layout" of all `ion-bar-button` across the whole application. | -| `toastEnter` | `AnimationBuilder` | Provides a custom enter animation for all `ion-toast`, overriding the default "animation". | -| `toastLeave` | `AnimationBuilder` | Provides a custom leave animation for all `ion-toast`, overriding the default "animation". | diff --git a/docs/angular/lifecycle.md b/docs/angular/lifecycle.md index 09206bdf137..85a76955693 100644 --- a/docs/angular/lifecycle.md +++ b/docs/angular/lifecycle.md @@ -1,74 +1,76 @@ --- -title: Ionic Page Life Cycle -sidebar_label: Lifecycle +title: Ionic PageのLife Cycle +sidebar_label: ライフサイクル --- - Angular Page Component Life Cycle - App Events Documentation + AngularのページコンポーネントのLife Cycle - すべてのイベントのドキュメンテーション -This guide covers how the page life cycle works in an app built with Ionic and Angular. +このガイドでは、Ionic と Angular を使用して構築されたアプリでの Page Life Cycle のしくみについて説明します。(追記:Life Cycle とは、表示をはじめてから破棄するまでを指します。この間の特定のタイミングに設定されているイベントを Life Cycle Events といいます) -![Ionic life cycle events demo](/img/guides/lifecycle/ioniclifecycle.png) +![Flowchart illustrating the Ionic page life cycle events and their sequence.](/img/guides/lifecycle/ioniclifecycle.png 'Ionic Lifecycle Diagram') -## Angular Life Cycle Events +## Angular の Life Cycle Events -Ionic embraces the life cycle events provided by Angular. The two Angular events you will find using the most are: +Ionic は Angular が提供する Life Cycle Events を取り入れています。最もよく使う 2 つの Angular イベントは次のとおりです。 -| Event Name | Description | -| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `ngOnInit` | Fired once during component initialization. This event can be used to initialize local members and make calls into services that only need to be done once. | -| `ngOnDestroy` | Fired right before Angular destroys the view. Useful for cleanup like unsubscribing from observables. | +| Event Name | Description | +| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `ngOnInit` | コンポーネントの初期化中に発生します。このイベントを使用して、ローカルメンバーを初期化し、一度だけ実行する必要がある Service を呼び出すことができます。 | +| `ngOnDestroy` | Angular がビューを破棄する直前に発生します。 observables の unsubscribe などのクリーンアップに役立ちます。 | -For more info on the Angular Component Life Cycle events, visit their [component lifecycle docs](https://angular.io/guide/lifecycle-hooks). +Angular の Component Life Cycle イベントの詳細については、それらの [component lifecycle docs](https://angular.jp/guide/lifecycle-hooks) をご覧ください。 :::note -Components that use `ion-nav` or `ion-router-outlet` should not use the `OnPush` change detection strategy. Doing so will prevent lifecycle hooks such as `ngOnInit` from firing. Additionally, asynchronous state changes may not render properly. +`ion-nav` または `ion-router-outlet` を使用するコンポーネントは、 `OnPush` 変更検出方式を使用しないでください。そうすることで、 `ngOnInit` などのライフサイクル・フックが起動するのを防ぐことができます。また、非同期状態の変更は正しくレンダリングされない場合があります。 ::: -## Ionic Page Events +## Ionic の Page Events -In addition to the Angular life cycle events, Ionic Angular provides a few additional events that you can use: +Angular の Life Cycle Events に加えて、Ionic Angular には、使用可能ないくつかの追加イベントがあります: -| Event Name | Description | -| ------------------ | ------------------------------------------------------------------ | -| `ionViewWillEnter` | Fired when the component routing to is about to animate into view. | -| `ionViewDidEnter` | Fired when the component routing to has finished animating. | -| `ionViewWillLeave` | Fired when the component routing from is about to animate. | -| `ionViewDidLeave` | Fired when the component routing to has finished animating. | +| Event Name | Description | +| ------------------ | ------------------------------------------------------------------------ | +| `ionViewWillEnter` | コンポーネントが表示されるアニメーションがはじまる時に発火します。 | +| `ionViewDidEnter` | コンポーネントが表示されるアニメーションが **終了した時に** 発火します。 | +| `ionViewWillLeave` | コンポーネントを離脱するアニメーションが **はじまる時に** 発火します。 | +| `ionViewDidLeave` | コンポーネントを離脱するアニメーションが **終了した時に** 発火します。 | -The difference between `ionViewWillEnter` and `ionViewDidEnter` is when they fire. The former fires right after `ngOnInit` but before the page transition begins, and the latter directly after the transition ends. +これらのライフサイクルは、ルーターによって直接マッピングされたコンポーネントに対してのみ呼び出されます。つまり、`/pageOne`が`PageOneComponent`にマッピングされた場合、Ionic ライフサイクルは`PageOneComponent`で呼び出されますが、`PageOneComponent`がレンダリングする子コンポーネントでは呼び出されません。 -For `ionViewWillLeave` and `ionViewDidLeave`, `ionViewWillLeave` gets called directly before the transition away from the current page begins, and `ionViewDidLeave` does not get called until after the new page gets successfully transitioned into (after the new pages `ionViewDidEnter` fires). +`ionViewWillEnter`と`ionViewDidEnter`の違いは、いつ発火するかです。前者は `ngOnInit` の直後でページ遷移が始まる前に、後者は遷移が終わった後に直接呼び出されます。 -![Ionic life cycle events demo](/img/guides/lifecycle/ioniclifecycle.gif) +`ionViewWillLeave` と `ionViewDidLeave` についてですが、 `ionViewWillLeave` は現在のページから離脱する処理がはじまる前に呼び出されますが、 `ionViewDidLeave` は新しいページに遷移する処理が成功してから呼び出されます (新しいページの `ionViewDidEnter` が発火した後になります)。 -## How Ionic Handles the Life of a Page +![Animated GIF showing Ionic page life cycle events in a console log as a page transition occurs.](/img/guides/lifecycle/ioniclifecycle.gif 'Ionic Lifecycle Animation') -Ionic has its router outlet, called ``. This outlet extends Angular's `` with some additional functionality to enable better experiences for mobile devices. +## Ionic が Page の Life をどのように処理するか -When an app is wrapped in ``, Ionic treats navigation a bit differently. When you navigate to a new page, Ionic will keep the old page in the existing DOM, but hide it from your view and transition the new page. The reason we do this is two-fold: +Ionic は `` という router outlet を持っています。この outlet が Angular の `` を継承し、さらに拡張して、モバイルデバイスのためのより良い体験を可能にしました。 -1. We can maintain the state of the old page (data on the screen, scroll position, etc..) -2. We can provide a smoother transition back to the page since it is already there and doesn't need to be recreated. +`` にアプリがラップされることで、Ionic はナビゲーションの扱いを少し変更します。新しいページに遷移すると、Ionic は古いページを既存の DOM に残しますが、ビューから隠して新しいページに移行します。これを行う理由は 2 つあります: -Pages are only removed from the DOM when they are "popped", for instance, by pressing the back button in the UI or the browsers back button. +1. 古いページの状態を維持することができます(画面上のデータ、スクロール位置など)。 +2. ページがすでに存在しており作成し直す必要がないため、ページへの移行がスムーズになります。 -Because of this special handling, the `ngOnInit` and `ngOnDestroy` methods might not fire when you would usually think they should. +たとえば、UI の "戻る" ボタンまたはブラウザの "戻る" ボタンを押すことによってページが「Pop」されると、ページは DOM から削除されるだけとなります。 -`ngOnInit` will only fire each time the page is freshly created, but not when navigated back to the page. For instance, navigating between each page in a tabs interface will only call each page's `ngOnInit` method once, but not on subsequent visits. `ngOnDestroy` will only fire when a page "popped". +この特別な処理のために、`ngOnInit` と `ngOnDestroy` のメソッドは通常そうあるべきだと思うときには発火しないかもしれません。 -## Route Guards +`ngOnInit` はページが新しく作成されるたびに発火するだけなので、ページに戻ったときには発火されません。たとえば、タブのインタフェースで各ページ間を移動しても、各ページの `ngOnInit` メソッドは最初の 1 回だけ呼び出され、その後の表示では呼び出されません。`ngOnDestroy` はページが 「Pop」したときにのみ発生します。 -In Ionic 3, there were a couple of additional life cycle methods that were useful to control when a page could be entered (`ionViewCanEnter`) and left (`ionViewCanLeave`). These could be used to protect pages from unauthorized users and to keep a user on a page when you don't want them to leave (like during a form fill). +## ルートガード -These methods were removed in Ionic 4 in favor of using Angular's Route Guards. +Ionic 3 では、いつページにアクセスすることができるか( `ionViewCanEnter` )と離脱できるか(`ionViewCanLeave`)を制御するのに役立つ、いくつかの追加のライフサイクルメソッドがありました。これらは、許可されていないユーザーからページを保護したり、ユーザーがページを離れたくないときにユーザーをページ上に保持したりするために使用できます(フォーム入力中など)。 -A route guard helps determine if a particular action can be taken against a route. They are classes that implement a certain interface. The `CanActivate` and `CanDeactivate` interfaces can be used to implement the same type of logic that the removed events `ionViewCanEnter` and `ionViewCanLeave` did. +これらの方法は、Angular のルートガードを使用するために Ionic 4 で削除されました。 + +ルートガードは、ルートに対して特定のアクションを実行できるかどうかを判断するのに役立ちます。それらは特定のインターフェースを実装するクラスです。`CanActive` と `CanDeactivate` のインターフェイスは、`ionViewCanEnter` と `ionViewCanLeave` と同様のロジックでイベントを削除することができます。 ```tsx @Injectable() @@ -81,21 +83,21 @@ export class AuthGuard implements CanActivate { } ``` -To use this guard, add it to the appropriate param in the route definition: +このガードを使用するには、それをルート定義の適切なパラメータに追加します: ```tsx { path: 'settings', canActivate: [AuthGuard], loadChildren: '...', } ``` -For more info on how to use route guards, go to Angular's [router documentation](https://angular.io/guide/router). +ルートガードの使い方の詳細については、Angular の [router documentation](https://angular.jp/guide/router) を参照してください。 -## Guidance for Each Life Cycle Method +## Life Cycle メソッドのガイダンス -Below are some tips on use cases for each of the life cycle events. +以下は、life cycle events ごとのユースケースに関するヒントです。 -- `ngOnInit` - Initialize your component and load data from services that don't need refreshing on each subsequent visit. -- `ionViewWillEnter` - Since `ionViewWillEnter` is called every time the view is navigated to (regardless if initialized or not), it's a good method to load data from services. However, if your data comes back during the animation, it can start lots of DOM manipulation, which can cause some janky animations. -- `ionViewDidEnter` - If you see performance problems from using `ionViewWillEnter` when loading data, you can do your data calls in `ionViewDidEnter` instead. This event won't fire until after the page is visible by the user, however, so you might want to use either a loading indicator or a skeleton screen, so content doesn't flash in un-naturally after the transition is complete. -- `ionViewWillLeave` - Can be used for cleanup, like unsubscribing from observables. Since `ngOnDestroy` might not fire when you navigate from the current page, put your cleanup code here if you don't want it active while the screen is not in view. -- `ionViewDidLeave` - When this event fires, you know the new page has fully transitioned in, so any logic you might not normally do when the view is visible can go here. -- `ngOnDestroy` - Cleanup logic for your pages that you don't want to clean up in `ionViewWillLeave`. +- `ngOnInit` - コンポーネントを初期化し、Service からアクセスごとに更新する必要がないデータをロードします。 +- `ionViewWillEnter` - `ionViewWillEnter` は View がナビゲートされる度に呼び出されるので(初期化されているかどうかにかかわらず)、Service からデータをロードするのに適したメソッドです。ただし、アニメーション中にデータがを取得すると、大量の DOM 操作が開始される可能性があります。これにより、ぎこちないアニメーションが発生する可能性があります。 +- `ionViewDidEnter` - `ionViewWillEnter` を使ってデータを取得していてパフォーマンスに問題がある時は、`ionViewDidEnter` を代わりに使うことができます。ただし、Page がユーザーに表示されるまではこのイベントは発火しません。そのため、ロードインジケータまたはスケルトン画面を使用することをお勧めします。これにより、遷移が完了した後にコンテンツが不自然に点滅することはありません。 +- `ionViewWillLeave` - observables の unsubscribing のように、クリーンアップで利用します。 `ngOnDestroy` はあなたが現在のページから遷移する時には発火しない可能性がありますので、画面が表示されていない時にアクティブにしたくない場合はここでクリーンアップの処理を行います。 +- `ionViewDidLeave` - このイベントが発生すると、新しいページへと完全に遷移したことがわかります。そのため、ビューが表示されているときに通常は行わない可能性があるロジックはすべてここに移動できます。 +- `ngOnDestroy` - `ionViewWillLeave` でクリーンアップしたくないページのクリーンアップロジックはここにおいてください。 diff --git a/docs/angular/navigation.md b/docs/angular/navigation.md index 2b7b3635d44..96576a1b061 100644 --- a/docs/angular/navigation.md +++ b/docs/angular/navigation.md @@ -1,6 +1,6 @@ --- -title: Angular Navigation -sidebar_label: Navigation/Routing +title: Angular ナビゲーション +sidebar_label: ナビゲーション/ルーティング --- import useBaseUrl from '@docusaurus/useBaseUrl'; @@ -13,13 +13,13 @@ import useBaseUrl from '@docusaurus/useBaseUrl'; /> -This guide covers how routing works in an app built with Ionic and Angular. +このガイドでは、Ionic と Angular を使用して構築されたアプリでのルーティングのしくみについて説明します。 -The Angular Router is one of the most important libraries in an Angular application. Without it, apps would be single view/single context apps or would not be able to maintain their navigation state on browser reloads. With Angular Router, we can create rich apps that are linkable and have rich animations (when paired with Ionic of course). Let's look at the basics of the Angular Router and how we can configure it for Ionic apps. +Angular Router は、Angular アプリケーションで最も重要なライブラリの 1 つです。これがなければ、アプリはシングルビュー/シングルコンテキストアプリになるか、ブラウザのリロード時にナビゲーションのステートを維持できなくなります。Angular Router を使用すると、リンク可能でリッチなアニメーションを持つリッチなアプリを作成できます(もちろん、Ionic と組み合わせると!)。Angular Router の基本と、それを Ionic アプリケーション用に設定する方法を見てみましょう。 -## A simple Route +## シンプルな Route -For most apps, having some sort of route is often required. The most basic configuration looks a bit like this: +ほとんどのアプリでは、some sort of route を持つことがしばしば必要になります。最も基本的な設定はこのようになります: ```tsx @@ -36,11 +36,11 @@ import { RouterModule } from '@angular/router'; }) ``` -The simplest breakdown for what we have here is a path/component lookup. When our app loads, the router kicks things off by reading the URL the user is trying to load. In our sample, our route looks for `''`, which is essentially our index route. So for this, we load the `LoginComponent`. Fairly straight forward. This pattern of matching paths with a component continues for every entry we have in the router config. But what if we wanted to load a different path on our initial load? +URL path と Component の組み合わせを確認する最も簡単な方法は、ここをみるすることです。アプリがロードされると、ルーターはユーザーがロードしようとしている URL を読むことで動作を開始します。私たちのサンプルでは、Route は `''` を参照します。これは本質的に私たちのインデックスルートとなります。そうすると、一致するエントリを探し出して、 `LoginComponent` がロードされます。かなり簡単です。この処理は `path` が一致するまで、設定されているすべての Route のエントリを参照します。しかし、初期ロードと異なるパスをロードしたい場合はどうなりますか? -## Handling Redirects +## リダイレクトの処理 -For this we can use router redirects. Redirects work the same way that a typical route object does, but just includes a few different keys. +そういう場合には、ルーターリダイレクトを使用できます。リダイレクトは通常のルートオブジェクトと同じように書くことができますが、いくつかの異なるキーが含まれます。 ```tsx [ @@ -50,29 +50,29 @@ For this we can use router redirects. Redirects work the same way that a typical ]; ``` -In our redirect, we look for the index path of our app. Then if we load that, we redirect to the `login` route. The last key of `pathMatch` is required to tell the router how it should look up the path. +このリダイレクトでは、アプリのインデックス(`''`)を探しはじめると、`login` にリダイレクトします。最後の `pathMatch` キーは、ルータにパスの検索方法を指示するために必要です。 -Since we use `full`, we're telling the router that we should compare the full path, even if ends up being something like `/route1/route2/route3`. Meaning that if we have: +`full` を使用すると、たとえ最後まで `/route1/route2/route3` と一致する path がなかったとしても、フルパスを比較する必要があることをルータに伝えることができます。つまり、次のようになります。 ```tsx { path: '/route1/route2/route3', redirectTo: 'login', pathMatch: 'full' }, { path: 'login', component: LoginComponent }, ``` -And load `/route1/route2/route3` we'll redirect. But if we loaded `/route1/route2/route4`, we won't redirect, as the paths don't match fully. +このように書くと `/route1/route2/route3` をロードすると、リダイレクトを行います。けれど仮に `/route1/route2/route4` であれば、すべての path が一致しないのでリダイレクトを行いません。 -Alternatively, if we used: +あるいは、こういう書き方もできます: ```tsx { path: '/route1/route2', redirectTo: 'login', pathMatch: 'prefix' }, { path: 'login', component: LoginComponent }, ``` -Then load both `/route1/route2/route3` and `/route1/route2/route4`, we'll be redirected for both routes. This is because `pathMatch: 'prefix'` will match only part of the path. +`/route1/route2/route3` と `/route1/route2/route4` の両方を読み込んだとおき, どちらの場合もリダイレクトします。 `pathMatch: 'prefix'` によって、一部でも一致したら該当するからです。 -## Navigating to different routes +## routes へのナビゲーション -Talking about routes is good and all, but how does one actually navigate to said routes? For this, we can use the `routerLink` directive. Let's go back and take our simple router setup from earlier: +routes について説明してきましたが、それではどのようにしてそのルートにナビゲーションしたらいいのでしょうか。これには、 `routerLink` directive を利用します。先ほどの簡単な router 設定でこれを確認してみましょう: ```ts RouterModule.forRoot([ @@ -81,7 +81,7 @@ RouterModule.forRoot([ ]); ``` -Now from the `LoginComponent`, we can use the following HTML to navigate to the detail route. +わたしたちは、次の HTML を利用することで、`LoginComponent` から `detail` route に遷移することができます。 ```html @@ -95,9 +95,9 @@ Now from the `LoginComponent`, we can use the following HTML to navigate to the ``` -The important part here is the `ion-button` and `routerLink` directive. RouterLink works on a similar idea as typical `href`s, but instead of building out the URL as a string, it can be built as an array, which can provide more complicated paths. +ここで重要なのは`ion-button` と `routerLink` directive です。RouterLink は典型的な `href` と同様の考えで動作しますが、URL を文字列として構築する代わりに配列として構築することができ、それによってより複雑なパスを書くこともできます。 -We also can programmatically navigate in our app by using the router API. +Router API を使用して、プログラムで遷移することもできます。 ```tsx import { Component } from '@angular/core'; @@ -116,27 +116,23 @@ export class LoginComponent { } ``` -Both options provide the same navigation mechanism, just fitting different use cases. +どちらのオプションも同様のナビゲーションメカニズムを提供し、異なるユースケースで利用することができます。 -:::note -A note on navigation with relative URLs: Currently, to support multiple navigation stacks, relative URLs are something not supported -::: - -### Navigating using LocationStrategy.historyGo +### LocationStrategy.historyGo を使ったナビゲーション -Angular Router has a [LocationStrategy.historyGo](https://angular.io/api/common/LocationStrategy#historyGo) method that allows developers to move forward or backward through the application history. Let's take a look at an example. +Angular Router には [LocationStrategy.historyGo](https://angular.io/api/common/LocationStrategy#historyGo) メソッドがあり、アプリケーションの履歴を進んだり戻ったりすることができます。例を見てみましょう。 -Say you have the following application history: +次のようなアプリケーションの履歴があるとします: -`/pageA` --> `/pageB` --> `/pageC` +`/ページA` --> `/ページB` --> `/ページC`。 -If you were to call `LocationStrategy.historyGo(-2)` on `/pageC`, you would be brought back to `/pageA`. If you then called `LocationStrategy.historyGo(2)`, you would be brought to `/pageC`. +もし `/pageC` で `LocationStrategy.historyGo(-2)` を呼び出すと、 `/pageA` に戻る。その後、 `LocationStrategy.historyGo(2)` を呼び出すと、 `/pageC` に戻る。 -An key characteristic of `LocationStrategy.historyGo()` is that it expects your application history to be linear. This means that `LocationStrategy.historyGo()` should not be used in applications that make use of non-linear routing. See [Linear Routing versus Non-Linear Routing](#linear-routing-versus-non-linear-routing) for more information. +`LocationStrategy.historyGo()` の主な特徴は、アプリケーションの履歴が線形であることを想定していることです。つまり、`LocationStrategy.historyGo()` は非線形のルーティングを使用するアプリケーションでは使用すべきではありません。詳しくは [リニアルーティング対非リニアルーティング](#linear-routing-versus-non-linear-routing) を参照してください。 ## Lazy loading routes -Now the current way our routes are setup makes it so they are included in the same chunk as the root app.module, which is not ideal. Instead, the router has a setup that allows the components to be isolated to their own chunks. +現在のルート設定では、すべての Component が、ルートとなる `app.module` と同じ `chunk` に含まれているので理想的ではありません。代わりに、ルータにはコンポーネントを独自の `chunk` に分離できるように設定されています。 ```tsx @@ -154,7 +150,7 @@ import { RouterModule } from '@angular/router'; }) ``` -While similar, the `loadChildren` property is a way to reference a module by using native import instead of a component directly. In order to do this though, we need to create a module for each of the components. +`loadChildren` プロパティはコンポーネントの代わりにネイティブインポートを直接仕様してモジュールを参照する方法です。ただしこれを行うには、コンポーネントごとにモジュールを作成する必要があります。 ```tsx ... @@ -172,10 +168,36 @@ import { LoginComponent } from './login.component'; ``` :::note -We're excluding some additional content and only including the necessary parts. +一部のコードを省略して紹介しています ::: -Here, we have a typical Angular Module setup, along with a RouterModule import, but we're now using `forChild` and declaring the component in that setup. With this setup, when we run our build, we will produce separate chunks for both the app component, the login component, and the detail component. +ここでは、`RouterModule` のインポートとともに、典型的な `Angular Module` の設定がありますが、`RouterModule` では `forChild` によってコンポーネントを使用することを宣言しています。この設定では、ビルドを実行するときに、`App Component`(Root)、 `login Component` 、および `detail Component` において別々のチャンクを作成します。 + +## Standalone Components + +Standalone components allow developers to lazy load a component on a route without having to declare the component to an Angular module. + +Developers can use the existing syntax for standalone component routing from Angular: + +```ts +@NgModule({ + imports: [ + RouterModule.forRoot([ + { + path: 'standalone-route', + loadComponent: () => import('./path/to/my-component.component').then((c) => c.MyComponent), + }, + ]), + ], +}) +export class AppRoutingModule {} +``` + +:::tip +If you are using `routerLink`, `routerDirection`, or `routerAction` be sure to also import the `IonRouterLink` directive for Ionic components or the `IonRouterLinkWithHref` directive for `` elements. An example of this is available in the [Ionic Angular Build Options docs](./build-options.md#migrating-from-modules-to-standalone). +::: + +To get started with standalone components [visit Angular's official docs](https://angular.io/guide/standalone-components). ## Live Example @@ -191,11 +213,11 @@ The following is an example of linear routing in a mobile app: @@ -217,11 +239,11 @@ The following is an example of non-linear routing: @@ -303,7 +325,7 @@ There are very few use cases in which nested routes make sense in mobile applica ## Working with Tabs -With Tabs, the Angular Router provides Ionic the mechanism to know what components should be loaded, but the heavy lifting is actually done by the tabs component. Let's look at a simple example. +タブを使用すると、Angular Router にどのコンポーネントをロードする必要があるかを知るためのメカニズムを Ionic が提供しますが、タブコンポーネントでは複雑な作業が行われます。簡単な例を見てみましょう。 ```ts const routes: Routes = [ @@ -335,7 +357,7 @@ const routes: Routes = [ ]; ``` -Here we have a "tabs" path that we load. In this example we call the path "tabs", but the name of the paths can be changed. They can be called whatever fits your app. In that route object, we can define a child route as well. In this example, the top level child route "tab1" acts as our "outlet", and can load additional child routes. For this example, we have a single sub-child-route, which just loads a new component. The markup for the tab is as followed: +ここでは、 `tabs` パスを読み込んでいます。この例では、path を `tabs` としていますが、これは変更可能です。あなたのアプリに合った名前にすることができます。このルートオブジェクトでは、子ルートも定義することができます。この例では、トップレベルの子ルート「tab1」が「outlet」として機能し、さらに子ルートをロードすることができます。この例では、1 つの子ルートがあり、新しいコンポーネントをロードするだけです。Tabs のマークアップは、次のとおりです: ```html @@ -348,14 +370,14 @@ Here we have a "tabs" path that we load. In this example we call the path "tabs" ``` -If you've built apps with Ionic before, this should feel familiar. We create a `ion-tabs` component, and provide a `ion-tab-bar`. The `ion-tab-bar` provides a `ion-tab-button` with a `tab` property that is associated with the tab "outlet" in the router config. Note that the latest version of `@ionic/angular` no longer requires ``, but instead allows developers to fully customize the tab bar, and the single source of truth lives within the router configuration. +Ionic を使ってアプリを作成したことがあれば、このマークアップはおなじみのはずです。`ion-tabs` コンポーネントを作成し、`ion-tab-bar` を提供します。`ion-tab-bar` は、 `tab`と一緒に`ion-tab-button`を提供します。最新の `@ionic/angular` はもはや `` を必要とせず、開発者がタブバーを完全にカスタマイズできるようになり、すべての設定は Router の設定によって行えるようになりました。 ### How Tabs in Ionic Work Each tab in Ionic is treated as an individual navigation stack. This means if you have three tabs in your application, each tab has its own navigation stack. Within each stack you can navigate forwards (push a view) and backwards (pop a view). This behavior is important to note as it is different than most tab implementations that are found in other web based UI libraries. Other libraries typically manage tabs as one single history stack. - + Since Ionic is focused on helping developers build mobile apps, the tabs in Ionic are designed to match native mobile tabs as closely as possible. As a result, there may be certain behaviors in Ionic's tabs that differ from tabs implementations you have seen in other UI libraries. Read on to learn more about some of these differences. ### Child Routes within Tabs @@ -432,11 +454,11 @@ The example below shows how the iOS App Store app handles presenting an "Account @@ -448,6 +470,6 @@ Instead, we recommend having routes in each tab that reference the same componen The example below shows how the Spotify app reuses the same album component to show content in multiple tabs. Notice that each screenshot shows the same album but from a different tab. -| Home Tab | Search Tab | -| :------: | :--------: | +| Home Tab | Search Tab | +| :-------------------------------------------------: | :---------------------------------------------------: | | | | diff --git a/docs/angular/overview.md b/docs/angular/overview.md index ce6cd60c6be..5d29843b7e6 100644 --- a/docs/angular/overview.md +++ b/docs/angular/overview.md @@ -1,6 +1,6 @@ --- -title: 'Ionic Angular Overview' -sidebar_label: Overview +title: Ionic Angular の概要 +sidebar_label: 概要 --- @@ -11,12 +11,36 @@ sidebar_label: Overview /> -`@ionic/angular` combines the core Ionic experience with the tooling and APIs that are tailored to Angular Developers. +import DocsCard from '@components/global/DocsCard'; +import DocsCards from '@components/global/DocsCards'; -## Angular Version Support +`@ionic/angular` は core Ionic experience に、Angular 開発者向けにカスタマイズされたツールと API を組み合わせたものです。 -Ionic supports `Angular 6.0.0 and up`. As part of their upgrade strategy, Angular has built-in tooling to help automate upgrades and provide feedback to developers whenever changes to an API occurred. This reduces update friction and keeps the ecosystem in a evergreen state. +## Angular バージョンサポート + +Ionic v7 は Angular v14+をサポートしています。アップグレード戦略の一環として、Angular にはアップグレードを自動化するためのツールが組み込まれており、API に変更があった際には開発者にフィードバックを提供します。これにより、アップデートの手間を減らし、エコシステムを最新の状態に保つことができます。 ## Angular Tooling -With Ionic 4+, the official Angular stack for building an app and routing are used, so your app can fall in-line with the rest of the great Angular ecosystem. In cases where more opinionated features are needed, Ionic provides `@ionic/angular-toolkit`, which builds and integrates with the [official Angular CLI](https://angular.io/cli) and provides features that are specific to `@ionic/angular` apps. +Ionic4 以降では、アプリケーション構築とルーティングのために公式の Angular スタックが使用されているため、あなたのアプリケーションは Angular エコシステムと同じように利用できます。更に独自の機能が必要な場合には、Ionic は`@ionic/angular-toolkit`を提供します。、これは [official Angular CLI](https://angular.jp/cli) を構築して統合し、`@ionic/angular` アプリ固有の機能を提供します。 + +## Resources + + + +

Learn the fundamentals you need to know to start building amazing apps with Ionic Framework.

+
+ + +

Learn the basics of navigation inside your app with Ionic and Angular Router

+
+ + +

Learn about using Ionic lifecycle events in class components and with hooks

+
+ + +

Learn about using Modules or Standalone Components in Ionic.

+
+ +
diff --git a/docs/angular/performance.md b/docs/angular/performance.md index c19ee5d7b2c..d2c78341765 100644 --- a/docs/angular/performance.md +++ b/docs/angular/performance.md @@ -1,6 +1,6 @@ --- -title: Angular Performance -sidebar_label: Performance +title: Angularのパフォーマンス +sidebar_label: パフォーマンス --- @@ -56,6 +56,8 @@ For more information on how Angular manages change propagation with `ngFor` see ## From the Community + + [High Performance Animations in Ionic](https://www.joshmorony.com/high-performance-animations-in-ionic/) - Josh Morony [High Performance List Filtering in Ionic](https://www.joshmorony.com/high-performance-list-filtering-in-ionic-2/) - Josh Morony @@ -64,6 +66,8 @@ For more information on how Angular manages change propagation with `ngFor` see [Ionic Framework is Fast (But Your Code Might Not Be)](https://www.joshmorony.com/ionic-framework-is-fast-but-your-code-might-not-be/) - Josh Morony + + :::note Do you have a guide you'd like to share? Click the _Edit this page_ button below. ::: diff --git a/docs/angular/platform.md b/docs/angular/platform.md index 2f485ae2a3d..5cb3546fc72 100644 --- a/docs/angular/platform.md +++ b/docs/angular/platform.md @@ -1,8 +1,10 @@ --- title: Platform -toc_max_heading_level: 2 --- +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + Platform | Ionic Platform to Customize Apps to Fit Any Device -The Platform service can be used to get information about your current device. You can get all of the platforms associated with the device using the `platforms` method, including whether the app is being viewed from a tablet, if it's on a mobile device or browser, and the exact platform (iOS, Android, etc). You can also get the orientation of the device, if it uses right-to-left language direction, and much much more. With this information you can completely customize your app to fit any device. +プラットフォームサービスは、現在のデバイスに関する情報を取得するために使用できます。`platforms` メソッドを利用することでデバイスに関連付けられているすべてのプラットフォームを取得できます。例えば、アプリがタブレットから表示されているかどうか(モバイルデバイスまたはブラウザ上にある場合)、および正確なプラットフォーム(iOS、Android など)などです。右から左への言語の向きなどを使用すれば、デバイスの向きもわかります。この情報を使用して、あらゆるデバイスに合わせてアプリを完全にカスタマイズできます。 ## Usage + + + ```tsx import { Platform } from '@ionic/angular'; @@ -26,11 +38,31 @@ export class MyPage { } ``` + + + +```tsx +import { Platform } from '@ionic/angular/standalone'; + +@Component({...}) +export class MyPage { + constructor(public platform: Platform) { + + } +} +``` + + + + ## Methods -### `is(platformName: Platforms) => boolean` +### `is` -Depending on the platform the user is on, `is(platformName)` will return true or false. Note that the same app can return true for more than one platform name. For example, an app running from an iPad would return true for the platform names: `mobile`, `ios`, `ipad`, and `tablet`. Additionally, if the app was running from Cordova then `cordova` would be true. +| | | +| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **Description** | Depending on the platform the user is on, `is(platformName)` will return true or false. Note that the same app can return true for more than one platform name. For example, an app running from an iPad would return true for the platform names: `mobile`, `ios`, `ipad`, and `tablet`. Additionally, if the app was running from Cordova then `cordova` would be true. | +| **Signature** | `is(platformName: Platforms) => boolean` | #### Parameters @@ -40,7 +72,7 @@ Depending on the platform the user is on, `is(platformName)` will return true or #### Platforms -Below is a table listing all the possible platform values along with corresponding descriptions. +以下は、利用可能なすべての platform の値とそれに対応する説明をまとめた表です。 | Platform Name | Description | | ------------- | ---------------------------------------- | @@ -61,7 +93,7 @@ Below is a table listing all the possible platform values along with correspondi #### Customizing Platform Detection Functions -The function used to detect a specific platform can be overridden by providing an alternative function in the global [Ionic config](./config). Each function takes `window` as a parameter and returns a boolean. +The function used to detect a specific platform can be overridden by providing an alternative function in the global [Ionic config](../developing/config). Each function takes `window` as a parameter and returns a boolean. ```tsx import { IonicModule } from '@ionic/angular'; @@ -106,45 +138,70 @@ type PlatformConfig = { }; ``` -### `platforms() => string[]` +### `platforms` -Depending on what device you are on, `platforms` can return multiple values. Each possible value is a hierarchy of platforms. For example, on an iPhone, it would return `mobile`, `ios`, and `iphone`. +| | | +| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **Description** | Depending on what device you are on, `platforms` can return multiple values. Each possible value is a hierarchy of platforms. For example, on an iPhone, it would return `mobile`, `ios`, and `iphone`. | +| **Signature** | `platforms() => string[]` | -### `ready() => Promise` +### `ready` -Returns a promise when the platform is ready and native functionality can be called. If the app is running from within a web browser, then the promise will resolve when the DOM is ready. When the app is running from an application engine such as Cordova, then the promise will resolve when Cordova triggers the `deviceready` event. The resolved value is the `readySource`, which states the platform that was used. +| | | +| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **Description** | Returns a promise when the platform is ready and native functionality can be called. If the app is running from within a web browser, then the promise will resolve when the DOM is ready. When the app is running from an application engine such as Cordova, then the promise will resolve when Cordova triggers the `deviceready` event. The resolved value is the `readySource`, which states the platform that was used.

For example, when Cordova is ready, the resolved ready source is `cordova`. The default ready source value will be `dom`. The `readySource` is useful if different logic should run depending on the platform the app is running from. For example, only Capacitor and Cordova can execute the status bar plugin, so the web should not run status bar plugin logic. | +| **Signature** | `ready() => Promise` | -For example, when Cordova is ready, the resolved ready source is `cordova`. The default ready source value will be `dom`. The `readySource` is useful if different logic should run depending on the platform the app is running from. For example, only Capacitor and Cordova can execute the status bar plugin, so the web should not run status bar plugin logic. +### `isRTL` -### `isRTL() => boolean` +| | | +| --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **Description** | Returns if this app is using right-to-left language direction or not. We recommend the app's `index.html` file already has the correct `dir` attribute value set, such as `` or ``. [W3C: Structural markup and right-to-left text in HTML](http://www.w3.org/International/questions/qa-html-dir) | +| **Signature** | `isRTL() => boolean` | -Returns if this app is using right-to-left language direction or not. We recommend the app's `index.html` file already has the correct `dir` attribute value set, such as `` or ``. [W3C: Structural markup and right-to-left text in HTML](http://www.w3.org/International/questions/qa-html-dir) +### `isLandscape` -### `isLandscape() => boolean` +| | | +| --------------- | ----------------------------------------------- | +| **Description** | Returns `true` if the app is in landscape mode. | +| **Signature** | `isLandscape() => boolean` | -Returns `true` if the app is in landscape mode. +### `isPortrait` -### `isPortrait() => boolean` +| | | +| --------------- | ---------------------------------------------- | +| **Description** | Returns `true` if the app is in portrait mode. | +| **Signature** | `isPortrait() => boolean` | -Returns `true` if the app is in portrait mode. +### `width` -### `width() => number` +| | | +| --------------- | -------------------------------------------------------------------- | +| **Description** | Gets the width of the platform's viewport using `window.innerWidth`. | +| **Signature** | `width() => number` | -Gets the width of the platform's viewport using `window.innerWidth`. +### `height` -### `height() => number` +| | | +| --------------- | ---------------------------------------------------------------------- | +| **Description** | Gets the height of the platform's viewport using `window.innerHeight`. | +| **Signature** | `height() => number` | -Gets the height of the platform's viewport using `window.innerHeight`. +### `url` -### `url() => string` +| | | +| --------------- | -------------------- | +| **Description** | Get the current url. | +| **Signature** | `url() => string` | -Get the current url. +### `testUserAgent` -### `testUserAgent(expression: string) => boolean` +| | | +| --------------- | ---------------------------------------------------------------------- | +| **Description** | Returns `true` if the expression is included in the user agent string. | +| **Signature** | `testUserAgent(expression: string) => boolean` | -Returns `true` if the expression is included in the user agent string. - -### Parameters +#### Parameters | Name | Type | Description | | ---------- | ------ | ------------------------------------- | @@ -154,9 +211,9 @@ Returns `true` if the expression is included in the user agent string. ### `pause` -The `pause` event emits when the native platform puts the application into the background, typically when the user switches to a different application. This event emits when a Cordova/Capacitor app is put into the background but doesn't fire in a standard web browser. +`pause` イベントは、ネイティブ・プラットフォームがアプリケーションをバックグラウンドに置いたとき、通常はユーザーが別のアプリケーションに切り替えたときに発生します。このイベントは、Cordova/Capacitor アプリケーションがバックグラウンドに置かれたときに発生しますが、標準的な Web ブラウザでは発生しません。 -#### Usage +#### Examples ```tsx this.platform.pause.subscribe(async () => { @@ -166,9 +223,9 @@ this.platform.pause.subscribe(async () => { ### `resize` -The `resize` event emits when the browser window has changed dimensions. This could be from a browser window being physically resized, or from a device changing orientation. +`resize` イベントは、ブラウザウィンドウの寸法が変更されたときに発生します。これは、ブラウザーウィンドウが物理的にサイズ変更されている場合や、デバイスの向きが変わっている場合に発生します。 -#### Usage +#### Examples ```tsx this.platform.resize.subscribe(async () => { @@ -178,9 +235,9 @@ this.platform.resize.subscribe(async () => { ### `resume` -The `resume` event fires when the native platform pulls the application out from the background. This event emits when a Cordova/Capacitor app comes out from the background but doesn't fire in a standard web browser. +`resume` イベントは、ネイティブプラットフォームがバックグラウンドからアプリケーションを引き出したときに発生します。このイベントは、Cordova/Capacitor アプリがバックグラウンドから出てきても、標準的な Web ブラウザで起動しない場合に発生します。 -#### Usage +#### Examples ```tsx this.platform.resume.subscribe(async () => { diff --git a/docs/angular/pwa.md b/docs/angular/pwa.md index 8b90caf5d89..684c150c457 100644 --- a/docs/angular/pwa.md +++ b/docs/angular/pwa.md @@ -1,5 +1,5 @@ --- -title: Progressive Web Apps in Angular +title: AngularでのPWA sidebar_label: Progressive Web Apps --- @@ -82,19 +82,33 @@ If it's the first time you use firebase-tools, login to your Google account with With the Firebase CLI installed, run `firebase init` within your Ionic project. The CLI prompts: -**"Which Firebase CLI features do you want to set up for this folder?"** Choose "Hosting: Configure and deploy Firebase Hosting sites." +**"Which Firebase CLI features do you want to set up for this folder?"** Choose "Hosting: Configure files for Firebase Hosting and (optionally) set up GitHub Action deploys". + +Create a new Firebase project or select an existing one. **"Select a default Firebase project for this directory:"** Choose the project you created on the Firebase website. **"What do you want to use as your public directory?"** Enter "www". :::note -Answering these next two questions will ensure that routing, hard reload, and deep linking work in the app: +Answering this next question will ensure that routing, hard reload, and deep linking work in the app: ::: **Configure as a single-page app (rewrite all urls to /index.html)?"** Enter "Yes". -**"File www/index.html already exists. Overwrite?"** Enter "No". +**"File build/index.html already exists. Overwrite?"** Enter "No". + +**Set up automatic builds and deploys with Github?** Enter "Yes". + +**For which GitHub repository would you like to set up a Github Workflow?** Enter your project name. + +**Set up the workflow to run a build script before every deploy?** Enter "Yes". + +**What script should be run before every deploy?** Enter `npm ci && npm run build`. + +**Set up automatic deployment to your sites live channel when a PR is merged?** Enter "Yes". + +**What is the name of the get hooked branch associated with your sites live channel?** Enter your project's main branch name. A `firebase.json` config file is generated, configuring the app for deployment. diff --git a/docs/angular/slides.md b/docs/angular/slides.md index afeda06f317..836b717114a 100644 --- a/docs/angular/slides.md +++ b/docs/angular/slides.md @@ -1,7 +1,10 @@ --- -title: Slides +title: Migrating from ion-slides to Swiper.js --- +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + Set Up Swiper.js for Angular Slides [Example] | Ionic -We recommend
Swiper.js if you need a modern touch slider component. It powers our `ion-slides` component, but we now recommend that developers use Swiper for Angular directly. +:::warning Looking for `ion-slides`? +`ion-slides` was deprecated in v6.0.0 and removed in v7.0.0. We recommend using the Swiper.js library directly. The migration process is detailed below. +::: -This guide will go over how to get Swiper for Angular set up in your Ionic Framework application. It will also go over any migration information you may need to move from `ion-slides` to the official Swiper Angular integration. +We recommend Swiper.js if you need a modern touch slider component. Swiper 9 introduced Swiper Element as a replacement for its Angular component, so this guide will go over how to get Swiper Element set up in your Ionic Framework application. It will also go over any migration information you may need to move from `ion-slides` to Swiper Element. ## Getting Started @@ -25,223 +30,209 @@ npm install @ionic/angular@latest Once that is done, install the Swiper dependency in your project: ```shell -npm install swiper +npm install swiper@latest ``` -Once that is done, we need to import the `SwiperModule` module. This should be done in your component's module file: +Next, we need to add the `CUSTOM_ELEMENTS_SCHEMA`, which tells Angular that we will be using custom elements. This can be done in either `app.module.ts`, or the module file for the component where you will be using Swiper. ```typescript -// home.module.ts -import { SwiperModule } from 'swiper/angular'; +import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; @NgModule({ - imports: [..., SwiperModule] + schemas: [..., CUSTOM_ELEMENTS_SCHEMA] }); ... ``` -## Swiping with Style - -Next, we need to import the base Swiper styles. We are also going to import the styles that Ionic provides which will let us customize the Swiper styles using the same CSS Variables that we used with `ion-slides`. - -You can import these files in `global.scss`: - -```scss -// global.scss -@import '~swiper/scss'; -@import '~@ionic/angular/css/ionic-swiper'; -``` - -If you prefer to import these in the CSS file for your slides component, you will need to disable [ViewEncapsulation in Angular](https://angular.io/api/core/ViewEncapsulation), otherwise the styles will not apply: +Finally, we need to call Swiper's `register` function to globally register Swiper's custom elements. This should only be done once, so place it in `app.component.ts`. ```typescript -// home.page.ts -import { Component, ViewEncapsulation } from '@angular/core'; +import { register } from 'swiper/element/bundle'; + +register(); @Component({ - selector: 'app-home', - templateUrl: 'home.page.html', - styleUrls: ['home.page.scss'], - encapsulation: ViewEncapsulation.None -}) -export class HomePage { ... -} +}) +... ``` -```scss -// home.page.scss -@import '~swiper/scss'; -@import '~@ionic/angular/css/ionic-swiper'; +From there, we just have to replace `ion-slides` elements with `swiper-container` and `ion-slide` elements with `swiper-slide`. Note that these custom elements do not need to be imported, as calling `register` tells Angular about them on its own. + +```html + + Slide 1 + Slide 2 + Slide 3 + ``` -### Updating Selectors +## Bundled vs. Core Versions -Previously, we were able to target `ion-slides` and `ion-slide` to apply any custom styling. The contents of those style blocks remain the same, but we need to update the selectors. Below is a list of selector changes when going from `ion-slides` to Swiper Angular: +By default, make sure you import the `register` function from `swiper/element/bundle`. This uses the bundled version of Swiper, which automatically includes all modules and stylesheets needed to run Swiper's various features. -| ion-slides Selector | Swiper Selector | -| ------------------- | --------------- | -| `ion-slides` | `.swiper` | -| `ion-slide` | `.swiper-slide` | +If you would like to use the Core version instead, which does not include additional modules automatically, see https://swiperjs.com/element#core-version-and-modules. The rest of this migration guide will assume you are using the bundled version. -### Vanilla CSS (Optional) +## Swiping with Style -For developers not using a CSS pre-processor, Swiper also provides the styles bundled together. It is important to note that this will import styles for all modules as well. +To migrate over your CSS, first update your selectors to target the new custom elements instead: -```javascript -// slides.component.css -@import 'swiper/css'; -@import '@ionic/angular/css/ionic-swiper'; -``` +| ion-slides Selector | Swiper Selector | +| ------------------- | ------------------ | +| `ion-slides` | `swiper-container` | +| `ion-slide` | `swiper-slide` | -## Using Components +If you were using the CSS custom properties found on `ion-slides`, below is a list of corresponding properties used in Swiper. -Swiper Angular exports a `Swiper` component which is the equivalent of `ion-slides`. It also exports a `swiperSlide` directive which can be used on an `` for each slide: +| `ion-slides` CSS property | `swiper-container` CSS property | +| ---------------------------------- | ------------------------------------------- | +| `--bullet-background` | `--swiper-pagination-bullet-inactive-color` | +| `--bullet-background-active` | `--swiper-pagination-color` | +| `--progress-bar-background` | `--swiper-pagination-progressbar-bg-color` | +| `--progress-bar-background-active` | `--swiper-pagination-color` | +| `--scroll-bar-background` | `--swiper-scrollbar-bg-color` | +| `--scroll-bar-background-active` | `--swiper-scrollbar-drag-bg-color` | -```html - - - - Slide 1 - Slide 2 - Slide 3 - - -``` +For additional custom CSS, because Swiper Element uses Shadow DOM encapsulation, styles will need to be injected into the Shadow DOM scope. See https://swiperjs.com/element#injecting-styles for instructions. -## Using Modules +### Additional `ion-slides` Styles -By default, Swiper for Angular does not import any additional modules. To use modules such as Navigation or Pagination, you need to import them first. +The `ion-slides` component had additional styling that helped create a native look and feel. These styles are **not** required to use Swiper.js with Ionic, but if you would like to maintain the look of `ion-slides` as closely as possible, add the following CSS to your `global.scss`: -`ion-slides` automatically included the Pagination, Scrollbar, Autoplay, Keyboard, and Zoom modules. This part of the guide will show you how to install these modules. +```css +swiper-container { + --swiper-pagination-bullet-inactive-color: var(--ion-text-color-step-800, #cccccc); + --swiper-pagination-color: var(--ion-color-primary, #0054e9); + --swiper-pagination-progressbar-bg-color: rgba(var(--ion-text-color-rgb, 0, 0, 0), 0.25); + --swiper-scrollbar-bg-color: rgba(var(--ion-text-color-rgb, 0, 0, 0), 0.1); + --swiper-scrollbar-drag-bg-color: rgba(var(--ion-text-color-rgb, 0, 0, 0), 0.5); +} -To begin, we need to import the modules and provide them to Swiper: +swiper-slide { + display: flex; + position: relative; -```typescript -// home.page.ts -import { Component } from '@angular/core'; -import SwiperCore, { Autoplay, Keyboard, Pagination, Scrollbar, Zoom } from 'swiper'; + flex-direction: column; + flex-shrink: 0; + align-items: center; + justify-content: center; -SwiperCore.use([Autoplay, Keyboard, Pagination, Scrollbar, Zoom]); + width: 100%; + height: 100%; -@Component({ - selector: 'app-home', - templateUrl: 'home.page.html', - styleUrls: ['home.page.scss'] -}) -export class HomePage { - ... + font-size: 18px; + + text-align: center; + box-sizing: border-box; } -``` -Next, we need to import the stylesheets for each module: - -```scss -// global.scss -@import '~swiper/scss'; -@import '~swiper/scss/autoplay'; -@import '~swiper/scss/keyboard'; -@import '~swiper/scss/pagination'; -@import '~swiper/scss/scrollbar'; -@import '~swiper/scss/zoom'; -@import '~@ionic/angular/css/ionic-swiper'; +swiper-slide img { + width: auto; + max-width: 100%; + height: auto; + max-height: 100%; +} ``` -Finally, we can turn these features on by using the appropriate properties: - -```html - - - - Slide 1 - Slide 2 - Slide 3 - - -``` +## The IonicSlides Module -:::note -See https://swiperjs.com/angular#usage for a full list of modules. -::: +With `ion-slides`, Ionic automatically customized dozens of Swiper properties. This resulted in an experience that felt smooth when swiping on mobile devices. We recommend using the `IonicSlides` module to ensure that these properties are also set when using Swiper directly. However, using this module is **not** required to use Swiper.js in Ionic. -## The IonicSlides Module +It is recommended to review the [properties](https://github.com/ionic-team/ionic-framework/blob/main/core/src/components/slides/IonicSlides.ts) set by `IonicSlides` and determine which ones you would like to customize. -With `ion-slides`, Ionic automatically customized dozens of Swiper properties. This resulted in an experience that felt smooth when swiping on mobile devices. We recommend using the `IonicSlides` module to ensure that these properties are also set when using Swiper directly. +We can install the `IonicSlides` module by importing and passing it to the `modules` property of `swiper-container` as an array: -We can install the `IonicSlides` module by importing it from `@ionic/angular` and passing it in as the last item in the array provided in `SwiperCore.use`: + + -```javascript +```typescript // home.page.ts -import { Component } from '@angular/core'; -import SwiperCore, { Autoplay, Keyboard, Pagination, Scrollbar, Zoom } from 'swiper'; -import { IonicSlides } from '@ionic/angular'; -SwiperCore.use([Autoplay, Keyboard, Pagination, Scrollbar, Zoom, IonicSlides]); +import { IonicSlides } from '@ionic/angular'; @Component({ - selector: 'app-home', - templateUrl: 'home.page.html', - styleUrls: ['home.page.scss'] + ... }) export class HomePage { + swiperModules = [IonicSlides]; +} +``` + + + + +```typescript +// home.page.ts + +import { IonicSlides } from '@ionic/angular/standalone'; + +@Component({ ... +}) +export class HomePage { + swiperModules = [IonicSlides]; } ``` + + + +```html + + + ... +``` + :::note -The `IonicSlides` module must be the last module in the array. This will let it automatically customize the settings of modules such as Pagination, Scrollbar, Zoom, and more. +If you are using the Core version of Swiper and have installed additional modules, ensure that `IonicSlides` is the last module in the array. This will let it automatically customize the settings of modules such as Pagination, Scrollbar, Zoom, and more. ::: ## Properties -Swiper options can be provided as individual properties directly on the `` component or via the `config` property. +Swiper options should be provided as individual properties directly on the `` component. Let's say in an app with `ion-slides` we had the `slidesPerView` and `loop` options set: ```html - + Slide 1 Slide 3 Slide 3 ``` -To set these options as properties directly on `` we would do the following: - -```html - - Slide 1 - Slide 2 - Slide 3 - -``` - -To set these options using the `config` object, we would do: +To set these options as properties directly on `` we would do the following: ```html - - Slide 1 - Slide 3 - Slide 3 - + + Slide 1 + Slide 2 + Slide 3 + ``` -Below is a full list of property changes when going from `ion-slides` to Swiper Angular: +Below is a full list of property changes when going from `ion-slides` to Swiper Element: -| Name | Notes | -| --------- | --------------------------------------------------------------------------------------------------------------------- | -| options | Use the `config` property instead or set each option as a property directly on the `` component. | -| mode | For different styles based upon the mode, you can target the slides with `.ios .swiper` or `.md .swiper` in your CSS. | -| pager | Use the `pagination` property instead. Requires installation of the Pagination module. | -| scrollbar | You can continue to use the `scrollbar` property, just be sure to install the Scrollbar module first. | +| Name | Notes | +| ------- | --------------------------------------------------------------------------------------------------------------------------------------- | +| options | Set each option as a property directly on the `` component. | +| mode | For different styles based upon the mode, you can target the slides with `.ios swiper-container` or `.md swiper-container` in your CSS. | +| pager | Use the `pagination` property instead. | :::note -All properties available in Swiper Angular can be found at https://swiperjs.com/angular#swiper-component-props. +All properties available in Swiper Element can be found at https://swiperjs.com/swiper-api#parameters. ::: ## Events -Since the `Swiper` component is not provided by Ionic Framework, event names will not have an `ionSlide` prefix to them. +Since the `swiper-container` component is not provided by Ionic Framework, event names will not have an `ionSlide` prefix to them. Additionally, all event names should be lowercase instead of camelCase. Let's say in an app with `ion-slides` we used the `ionSlideDidChange` event: @@ -253,170 +244,108 @@ Let's say in an app with `ion-slides` we used the `ionSlideDidChange` event: ``` -To migrate, we would change the name of the event to `slideChange`: +To migrate, we would change the name of the event to `swiperslidechange`: ```html - - Slide 1 - Slide 2 - Slide 3 - + + Slide 1 + Slide 2 + Slide 3 + ``` Below is a full list of event name changes when going from `ion-slides` to Swiper Angular: -| ion-slides Event | Swiper Event | -| ----------------------- | -------------------------- | -| ionSlideWillChange | slideChangeTransitionStart | -| ionSlideDidChange | slideChangeTransitionEnd | -| ionSlideDoubleTap | doubleTap | -| ionSlideDrag | sliderMove | -| ionSlideNextStart | slideNextTransitionStart | -| ionSlideNextEnd | slideNextTransitionEnd | -| ionSlidePrevStart | slidePrevTransitionStart | -| ionSlidePrevEnd | slidePrevTransitionEnd | -| ionSlideReachStart | reachBeginning | -| ionSlideReachEnd | reachEnd | -| ionSlideTap | tap | -| ionSlideTouchStart | touchStart | -| ionSlideTouchEnd | touchEnd | -| ionSlideTransitionStart | transitionStart | -| ionSlideTransitionEnd | transitionEnd | -| ionSlidesDidLoad | init | +| ion-slides Event | Swiper Event | +| ------------------------- | ---------------------------------- | +| `ionSlideWillChange` | `swiperslidechangetransitionstart` | +| `ionSlideDidChange` | `swiperslidechange` | +| `ionSlideDoubleTap` | `swiperdoubletap` | +| `ionSlideDrag` | `swiperslidermove` | +| `ionSlideNextStart` | `swiperslidenexttransitionstart` | +| `ionSlideNextEnd` | `swiperslidenexttransitionend` | +| `ionSlidePrevStart` | `swiperslideprevtransitionstart` | +| `ionSlidePrevEnd` | `swiperslideprevtransitionend` | +| `ionSlideReachStart` | `swiperreachbeginning` | +| `ionSlideReachEnd` | `swiperreachend` | +| `ionSlideTap` | `swipertap` | +| `ionSlideTouchStart` | `swipertouchstart` | +| `ionSlideTouchEnd` | `swipertouchend` | +| `ionSlideTransitionStart` | `swipertransitionstart` | +| `ionSlideTransitionEnd` | `swipertransitionend` | +| `ionSlidesDidLoad` | `swiperinit` | :::note -All events available in Swiper Angular can be found at https://swiperjs.com/angular#swiper-component-events. +All events available in Swiper Element can be found at https://swiperjs.com/swiper-api#events and should be lowercased and prefixed with the word `swiper`. ::: ## Methods -Most methods have been removed in favor of accessing the `` props directly. - -Accessing these properties can be tricky as you want to access the properties on the Swiper instance itself, not your Angular component. To do this, we recommend getting a reference to the `Swiper` instance via `(swiper)`: +Most methods have been removed in favor of directly accessing the properties of the Swiper instance. To access the Swiper instance, first get a reference to the `` element (such as through `ViewChild`), then access its `swiper` prop: ```html - - Slide 1 - Slide 2 - Slide 3 - + + Slide 1 + Slide 2 + Slide 3 + ``` -```javascript +```typescript // slides.component.ts -import { Component } from '@angular/core'; + +import { ..., ElementRef, ViewChild } from '@angular/core'; @Component({ - selector: 'app-slides-example', - templateUrl: 'slides.component.html', - styleUrls: ['slides.component.scss'] + ... }) export class SlidesExample { - private slides: any; + @ViewChild('swiper') + swiperRef: ElementRef | undefined; - constructor() {} - setSwiperInstance(swiper: any) { - this.slides = swiper; + logActiveIndex() { + console.log(this.swiperRef?.nativeElement.swiper.activeIndex); } } ``` -From here, if you wanted to access a property on the Swiper instance you would access `this.slides`. For example, if you wanted to check the `isBeginning` property, you could do: `this.slides.isBeginning`. Make sure `this.slides` is defined first though! +Below is a full list of method changes when going from `ion-slides` to Swiper Element: + +| ion-slides Method | Notes | +| -------------------- | ------------------------------------------------------------------------------------ | +| `getActiveIndex()` | Use the `activeIndex` property instead. | +| `getPreviousIndex()` | Use the `previousIndex` property instead. | +| `getSwiper()` | Get a reference to the Swiper instance using the `swiper` prop. See example above. | +| `isBeginning()` | Use the `isBeginning` property instead. | +| `isEnd()` | Use the `isEnd` property instead. | +| `length()` | Use the `slides` property instead. (i.e swiper.slides.length) | +| `lockSwipeToNext()` | Use the `allowSlidesNext` property instead. | +| `lockSwipeToPrev()` | Use the `allowSlidePrev` property instead. | +| `lockSwipes()` | Use the `allowSlideNext`, `allowSlidePrev`, and `allowTouchMove` properties instead. | +| `startAutoplay()` | Use the `autoplay` property instead. | +| `stopAutoplay()` | Use the `autoplay` property instead. | -Below is a full list of method changes when going from `ion-slides` to Swiper Angular: - -| ion-slides Method | Notes | -| ------------------ | ------------------------------------------------------------------------------------ | -| getActiveIndex() | Use the `activeIndex` property instead. | -| getPreviousIndex() | Use the `previousIndex` property instead. | -| getSwiper() | Get a reference to the Swiper instance using `(swiper)`. See example above. | -| isBeginning() | Use the `isBeginning` property instead. | -| isEnd() | Use the `isEnd` property instead. | -| length() | Use the `slides` property instead. (i.e swiperRef.slides.length) | -| lockSwipeToNext() | Use the `allowSlidesNext` property instead. | -| lockSwipeToPrev() | Use the `allowSlidePrev` property instead. | -| lockSwipes() | Use the `allowSlideNext`, `allowSlidePrev`, and `allowTouchMove` properties instead. | -| startAutoplay() | Use the `autoplay` property instead. | -| stopAutoplay() | Use the `autoplay` property instead. | +:::note +All methods and properties available on the Swiper instance can be found at https://swiperjs.com/swiper-api#methods-and-properties. +::: ## Effects -If you are using effects such as Cube or Fade, you can install them just like we did with the other modules. In this example, we will use the fade effect. To start, we will import the `EffectFade` module and register it using `SwiperCore.use`: +Effects such as Cube or Fade can be used in Swiper Element with no additional imports, as long as you are using the bundled version of Swiper. For example, the below code will cause the slides to have a flip transition effect: ```html - - - - Slide 1 - Slide 2 - Slide 3 - -``` - -```javascript -// slides.component.ts -import { Component } from '@angular/core'; -import SwiperCore, { EffectFade } from 'swiper'; -import { IonicSlides } from '@ionic/angular'; - -SwiperCore.use([EffectFade, IonicSlides]); - -@Component({ - selector: 'app-slides-example', - templateUrl: 'slides.component.html', - styleUrls: ['slides.component.scss'], -}) -export class SlidesExample { - constructor() {} -} -``` - -Next, we need to import the stylesheet associated with the effect: - -```scss -// global.scss -@import '~swiper/scss/effect-fade'; -``` - -After that, we can activate it by setting the `effect` property on `swiper` to `"fade"`: - -```html - - - - Slide 1 - Slide 2 - Slide 3 - -``` - -```javascript -// slides.component.ts -import { Component } from '@angular/core'; -import SwiperCore, { EffectFade } from 'swiper'; -import { IonicSlides } from '@ionic/angular'; - -SwiperCore.use([EffectFade, IonicSlides]); - -@Component({ - selector: 'app-slides-example', - templateUrl: 'slides.component.html', - styleUrls: ['slides.component.scss'], -}) -export class SlidesExample { - constructor() {} -} + ... ``` :::note -For more information on effects in Swiper, please see https://swiperjs.com/angular#effects. +For more information on effects in Swiper, please see https://swiperjs.com/swiper-api#fade-effect. ::: ## Wrap Up -Now that you have Swiper installed, there is a whole set of new Swiper features for you to enjoy. We recommend starting with the Swiper Angular Introduction and then referencing the Swiper API docs. +Now that you have Swiper installed, there is a whole set of new Swiper features for you to enjoy. We recommend starting with the Swiper Element documentation and then referencing the Swiper API docs. ## FAQ diff --git a/docs/angular/storage.md b/docs/angular/storage.md index dad80e77f3a..23c365eb7d4 100644 --- a/docs/angular/storage.md +++ b/docs/angular/storage.md @@ -1,6 +1,6 @@ --- -title: Data Storage -sidebar_label: Storage +title: データストレージ +sidebar_label: ストレージ --- @@ -11,7 +11,7 @@ sidebar_label: Storage /> -There are variety of options available for storing data within an Ionic app. +Ionic アプリ内にデータを保存するためのさまざまなオプションを用意しています。 Here are two official Ionic options: diff --git a/docs/angular/testing.md b/docs/angular/testing.md index b8aedacd3fe..095c38c8061 100644 --- a/docs/angular/testing.md +++ b/docs/angular/testing.md @@ -1,5 +1,5 @@ --- -title: Testing +title: テスト --- @@ -10,53 +10,53 @@ title: Testing /> -When an `@ionic/angular` application is generated using the Ionic CLI, it is automatically set up for unit testing and end-to-end testing of the application. This is the same setup that is used by the Angular CLI. Refer to the Angular Testing Guide for detailed information on testing Angular applications. +Ionic CLI を使用して `@ionic/angular` アプリケーションを生成すると、アプリケーションのユニットテストとエンドツーエンドのテスト用に自動的に準備されます。これは Angular CLI で使われる設定と同じものです。Angular で作られたアプリケーションのテストについての詳細は Angular Testing Guide をご参照ください。 -## Testing Principles +## テストの原則 -When testing an application, it is best to keep in mind that testing can show if defects are present in a system. However, it is impossible to prove that any non-trivial system is completely free of defects. For this reason, the goal of testing is not to verify that the code is correct but to find problems within the code. This is a subtle but important distinction. +アプリケーションをテストするときは、テストによってシステムに欠陥があるかどうかを確認できる、ということを覚えておくことが一番です。しかし、どんなささいなシステムも完全に欠陥のないことを証明することは不可能です。このため、テストの目的はコードが正しいことを確認することではなく、コードの中の問題を見つけることです。これは微妙ですが、重要な違いです。 -If we set out to prove that the code is correct, we are more likely to stick to the happy path through the code. If we set out to find problems, we are more likely to more fully exercise the code and find the bugs that are lurking there. +もし私たちがコードが正しいことを証明しようとするのであれば、私たちはコードを通じて幸せな道を歩み続けようとするでしょう。もし私が問題の発見しようとするのであれば、コードをより完全に実行し、そこに潜むバグを発見する可能性が高くなります。 -It is also best to begin testing an application from the very start. This allows defects to be found early in the process when they are easier to fix. This also allows code to be refactored with confidence as new features are added to the system. +最初からアプリケーションのテストを開始することも最良です。これにより、修正が容易な段階で早期に欠陥を発見できます。またこれにより、システムに新しい機能が追加されたときに、コードを確実にリファクタリングすることもできます。 -## Unit Testing +## ユニットテスト -Unit tests exercise a single unit of code (component, page, service, pipe, etc) in isolation from the rest of the system. Isolation is achieved through the injection of mock objects in place of the code's dependencies. The mock objects allow the test to have fine-grained control of the outputs of the dependencies. The mocks also allow the test to determine which dependencies have been called and what has been passed to them. +ユニットテストでは、システムの他の部分から分離して、単一のコードユニット(Component、Page、Service、Pipe など)を実行します。分離は、コードの依存関係の代わりにモックオブジェクトを注入することによって実現されます。モックオブジェクトによって、テストは依存関係の切り出しをきめ細かく制御することができます。モックによって、どの依存関係が呼び出され、何が渡されたかをテストで判断することもできます。 -Well-written unit tests are structured such that the unit of code and the features it contains are described via `describe()` callbacks. The requirements for the unit of code and its features are tested via `it()` callbacks. When the descriptions for the `describe()` and `it()` callbacks are read, they make sense as a phrase. When the descriptions for nested `describe()`s and a final `it()` are concatenated together, they form a sentence that fully describes the test case. +適切に記述されたユニットテストは、コードの単位とそれに含まれる機能が `describe()` コールバックによって記述されるように構成されています。コード単位とその機能の要件は、`it()` コールバックによってテストされます。`describe()` コールバックと `it()` コールバックの説明を読むと、フレーズとして意味がわかります。ネストされた `describe()` と最後の `it()` の記述をつなげると、テストケースを完全に記述する文が形成されます。 -Since unit tests exercise the code in isolation, they are fast, robust, and allow for a high degree of code coverage. +ユニットテストはコードを分離して実行するため、高速で堅牢であり、高度なコードカバレッジが可能です。 -### Using Mocks +### モックの利用 -Unit tests exercise a code module in isolation. To facilitate this, we recommend using Jasmine (https://jasmine.github.io/). Jasmine creates mock objects (which Jasmine calls "spies") to take the place of dependencies while testing. When a mock object is used, the test can control the values returned by calls to that dependency, making the current test independent of changes made to the dependency. This also makes the test setup easier, allowing the test to only be concerned with the code within the module under test. +ユニットテストでは、コードをコードをモジュールで分離して実行します。これを簡単にするには、Jasmine(https://jasmine.github.io/) を使用することをお勧めします。Jasmine は、テスト実行中に依存関係の代わりにモックオブジェクト(Jasmine は 「スパイ」 と呼んでいます)を作成します。モックオブジェクトを使用すると、テストはその依存関係への呼び出しによって返される値を制御できるため、依存関係に加えられた変更から現在のテストを独立させることができます。これにより、テストのセットアップも簡単になり、テスト対象のモジュール内のコードだけをテストすることができます。 -Using mocks also allows the test to query the mock to determine if it was called and how it was called via the `toHaveBeenCalled*` set of functions. Tests should be as specific as possible with these functions, favoring calls to `toHaveBeenCalledTimes` over calls to `toHaveBeenCalled` when testing that a method has been called. That is `expect(mock.foo).toHaveBeenCalledTimes(1)` is better than `expect(mock.foo).toHaveBeenCalled()`. The opposite advice should be followed when testing that something has not been called (`expect(mock.foo).not.toHaveBeenCalled()`). +モックを使用すると、モックが呼び出されたかどうか、および `toHaveBeenCalled*` セットの関数を介してどのように呼び出されたかを判断するために、テストでモックを確認することもできます。これらの関数では、メソッドが呼び出されたことをテストするときに、`toHaveBeenCalled` メソッドの呼び出しよりも `toHaveBeenCalledTimes` の呼び出しを優先して、テストをできるだけ具体的に行う必要があります。つまり、`expect(mock.foo).toHaveBeenCalledTimes(1)` は `expect(mock.foo).toHaveBeenCalled()` よりも優れています。何かが呼ばれていないこと(`expect(mock.foo).not.toHaveBeenCalled()`)をテストする際は、逆のアドバイスに従うべきです。 -There are two common ways to create mock objects in Jasmine. Mock objects can be constructed from scratch using `jasmine.createSpy` and `jasmine.createSpyObj` or spies can be installed onto existing objects using `spyOn()` and `spyOnProperty()`. +Jasmine でモックオブジェクトを作成する一般的な方法は 2 つあります。モックオブジェクトは、`jasmine.createSpy` と`jasmine.createSpyObj` を使ってスクラッチで作成することも、`spyOn()` と `spyOnProperty()` を使って既存のオブジェクトにスパイをインストールすることもできます。 -#### Using `jasmine.createSpy` and `jasmine.createSpyObj` +### `jasmine.createSpy` と `jasmine.createSpyObj` の利用 -`jasmine.createSpyObj` creates a full mock object from scratch with a set of mock methods defined on creation. This is useful in that it is very simple. Nothing needs to be constructed or injected into the test. The disadvantage of using this function is that it allows the creation of objects that may not match the real objects. +`jasmine.createSpyObj` は、作成時に定義された一連のモックメソッドを使用して、完全なモックオブジェクトをスクラッチで作成します。これはとてもシンプルで便利です。テストのために何かを組み立てたり注入したりする必要はありません。この関数の使用する欠点は、実際のオブジェクトと一致しないオブジェクトを生成できることです。 -`jasmine.createSpy` is similar but it creates a stand-alone mock function. +`jasmine.createSpy` も似ていますが、スタンドアロンのモック関数を作成します。 -#### Using `spyOn()` and `spyOnProperty()` +#### `spyOn()` と `spyOnProperty()` の利用 -`spyOn()` installs the spy on an existing object. The advantage of using this technique is that if an attempt is made to spy on a method that does not exist on the object, an exception is raised. This prevents the test from mocking methods that do not exist. The disadvantage is that the test needs a fully formed object to begin with, which may increase the amount of test setup required. +`spyOn()` は、既存のオブジェクトにスパイをインストールします。この手法を使用する利点は、オブジェクト上に存在しないメソッドをスパイしようとすると、例外が発生することです。これにより、テストが存在しないメソッドをモックすることを防ぎます。欠点は、テストが最初から完全に整形されたオブジェクトを必要とすることであり、これはテストに必要なセットアップの量を増加させるかと思います。 -`spyOnProperty()` is similar with the difference being that it spies on a property and not a method. +`spyOnProperty()` は似ていますが、メソッドではなくプロパティに対してスパイするという点で異なります。 -### General Testing Structure +### 一般的なテストの構成 -Unit tests are contained in `spec` files with one `spec` file per entity (component, page, service, pipe, etc.). The `spec` files live side-by-side with and are named after the source that they are testing. For example, if the project has a service called WeatherService, the code for it is in a file named `weather.service.ts` with the tests in a file named `weather.service.spec.ts`. Both of those files are in the same folder. +ユニットテストは、エンティティ(Component、Page、Service、Pipe など)ごとに 1 つの `spec` ファイルを持つ `spec` ファイルに含まれています。`spec` ファイルは、テスト中のソースと一緒に存在し、かつその名前が付けられます。たとえば、プロジェクトに WeatherService という Service がある場合、そのコードは`weather.service.ts` という名前のファイルにあり、テストは `weather.service.spec.ts` という名前のファイルにあります。これらのファイルは両方とも同じフォルダにあります。 -The `spec` files themselves contain a single `describe` call that defines that overall test. Nested within it are other `describe` calls that define major areas of functionality. Each `describe` call can contain setup and teardown code (generally handled via `beforeEach` and `afterEach` calls), more `describe` calls forming a hierarchical breakdown of functionality, and `it` calls which define individual test cases. +`spec` ファイル自体には、そのテスト全体を定義するただ一つの `describe` コールが含まれています。その中には、主要な機能領域を定義する他の `describe` コールがネストされています。各 `describe` コールには、setup コードと teardown コード(一般的に `beforeEach` と `afterEach` コールによって処理される)、機能を階層的に分解した `describe` コール、また個々のテストケースを定義する `it` コールが含まれます。 -The `describe` and `it` calls also contain a descriptive text label. In well-formed tests, the `describe` and `it` calls combine with their labels to perform proper phrases and the full label for each test case, formed by combining the `describe` and `it` labels, creates a full sentence. +`describe` と `it` コールには、説明のテキストラベルも含まれます。適切な形式のテストでは、`describe` と `it` をコールすると、ラベルと組み合わせた適切なフレーズが実行され、各テストケースのすべてのラベルが `describe` と `it` ラベルを組み合わせて構成され、完全な文が作成されます。 -For example: +例: ```tsx describe('Calculation', () => { @@ -72,17 +72,17 @@ describe('Calculation', () => { }); ``` -The outer `describe` call states that the `Calculation` service is being tested, the inner `describe` calls state exactly what functionality is being tested, and the `it` calls state what the test cases are. When run the full label for each test case is a sentence that makes sense (Calculation divide cowardly refuses to divide by zero). +外側の `describe` コールは `Calculation` Service がテストされていることを示し、内側の `describe` コールはテストされている機能を正確に示し、そして `it` コールはテストケースが何であるかを示しています。各テストケースの完全なラベルを実行すると、意味のある文になります(卑劣な 0 での除算という計算を拒否しました)。 -### Pages and Components +### ページとコンポーネント -Pages are just Angular components. Thus, pages and components are both tested using Angular's Component Testing guidelines. +Pages は単なる Angular コンポーネントです。そのため、ページとコンポーネントは両方とも Angular のコンポーネントテストガイドライン を使ってテストされます。 -Since pages and components contain both TypeScript code and HTML template markup it is possible to perform both component class testing and component DOM testing. When a page is created, the template test that is generated looks like this: +ページとコンポーネントには TypeScript コードと HTML テンプレートマークアップの両方が含まれているため、コンポーネントクラスのテストとコンポーネント DOM のテストの両方を実行できます。ページが作成されると、生成されるテンプレートテストは次のようになります: ```tsx import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { TabsPage } from './tabs.page'; @@ -91,13 +91,11 @@ describe('TabsPage', () => { let fixture: ComponentFixture; beforeEach(async () => { - TestBed.configureTestingModule({ + await TestBed.configureTestingModule({ declarations: [TabsPage], schemas: [CUSTOM_ELEMENTS_SCHEMA], }).compileComponents(); - }); - beforeEach(() => { fixture = TestBed.createComponent(TabsPage); component = fixture.componentInstance; fixture.detectChanges(); @@ -109,17 +107,17 @@ describe('TabsPage', () => { }); ``` -When doing component class testing, the component object is accessed using the component object defined via `component = fixture.componentInstance;`. This is an instance of the component class. When doing DOM testing, the `fixture.nativeElement` property is used. This is the actual `HTMLElement` for the component, which allows the test to use standard HTML API methods such as `HTMLElement.querySelector` in order to examine the DOM. +コンポーネントクラスのテストを行う場合、コンポーネントオブジェクトは `component=fixture.componentInstance;` によって定義されたコンポーネントオブジェクトを使用してアクセスされます。これはコンポーネントクラスのインスタンスです。DOM テストを行う際には、`fixture.nativeElement` プロパティが使用されます。これはコンポーネントの実際の `HTMLElement`であり、テストで DOM を調べるために `HTMLElement.querySelector` などの標準の HTML API メソッドを使うことを可能にします。 -## Services +## Service -Services often fall into one of two broad categories: utility services that perform calculations and other operations, and data services that perform primarily HTTP operations and data manipulation. +Service は、多くの場合、計算やその他の操作を実行するユーティリティの service と、主に HTTP 操作やデータ操作を実行するデータの service の 2 つの大まかなカテゴリーのいずれかに分類されます。 -### Basic Service Testing +### 基本的な Service のテスト -The suggested way to test most services is to instantiate the service and manually inject mocks for any dependency the service has. This way, the code can be tested in isolation. +ほとんどの service をテストするために推奨する方法は、service をインスタンス化し、service が持つ依存関係のモックを手動で注入することです。こうすることで、コードを分離してテストすることができます。 -Let's say that there is a service with a method that takes an array of timecards and calculates net pay. Let's also assume that the tax calculations are handled via another service that the current service depends on. This payroll service could be tested as such: +たとえば、タイムカードの配列を取得して差引支給額を計算するメソッドを持つ service があるとします。また税金計算は、現在の service が依存しているもう一つの service を介して処理されるとします。この給与計算の service は、このようにテストすることができます: ```tsx import { PayrollService } from './payroll.service'; @@ -144,9 +142,9 @@ describe('PayrollService', () => { }); ``` -This allows the test to control the values returned by the various tax calculations via mock setup such as `taxServiceSpy.federalIncomeTax.and.returnValue(73.24)`. This allows the "net pay" tests to be independent of the tax calculation logic. When the tax codes change, only the tax service related code and tests need to change. The tests for the net pay can continue to operate as they are since these tests do not care how the tax is calculated, just that the value is applied properly. +これにより、テストでは `taxServiceSpy.federalIncomeTax.and.returnValue(73.24)` などのモックの設定を介して様々な税金計算から戻される値を制御できます。これにより、「差引支給額」のテストを税金計算ロジックから独立させることができます。税金のコードが変更された場合、修正する必要があるのは税金 service 関連のコードとテストのみです。差引支給額のテストは、税金がどのように計算されるかを考慮せず、値が適切に適用されるのみであるため、そのまま機能し続けることができます。 -The scaffolding that is used when a service is generated via `ionic g service name` uses Angular's testing utilities and sets up a testing module. Doing so is not strictly necessary. That code may be left in, however, allowing the service to be built manually or injected as such: +`ionic g service name` で service を生成するときに使われる scaffold は Angular のテストユーティリティを使ってテストモジュールをセットアップします。必ずしもそうする必要はありません。ただし、このコードを残しておくことで、手動でサービスを構築したり、次のように注入したりすることができます: ```tsx import { TestBed, inject } from '@angular/core/testing'; @@ -180,11 +178,11 @@ describe('PayrolService', () => { }); ``` -#### Testing HTTP Data Services +#### HTTP データ Service のテスト -Most services that perform HTTP operations will use Angular's HttpClient service in order to perform those operations. For such tests, it is suggested to use Angular's `HttpClientTestingModule`. For detailed documentation of this module, please see Angular's Angular's Testing HTTP requests guide. +HTTP 操作を実行するほとんどの service は、それらの操作を実行するために Angular の HttpClient service を使用します。そのようなテストには、Angular の `HttpClientTestingModule` を使うことが推奨されています。このモジュールの詳細なドキュメントは Angular の HTTP リクエストをテストする のガイドを参照してください。 -This basic setup for such a test looks like this: +このようなテストの基本的な設定は次のようになります: ```tsx import { HttpBackend, HttpClient } from '@angular/common/http'; @@ -231,11 +229,11 @@ describe('IssTrackingDataService', () => { }); ``` -### Pipes +### Pipe -A pipe is like a service with a specifically defined interface. It is a class that contains one public method, `transform`, which manipulates the input value (and other optional arguments) in order to create the output that is rendered on the page. To test a pipe: instantiate the pipe, call the transform method, and verify the results. +pipe は、特別に定義されたインタフェースを持つ service のようなものです。このクラスには、入力値(およびその他のオプションの引数)を操作してページにレンダリングされる出力を作成するための public メソッド `transform` が含まれています。パイプをテストするには、パイプをインスタンス化し、transform メソッドを呼び出して結果を検証します。 -As a simple example, let's look at a pipe that takes a `Person` object and formats the name. For the sake of simplicity, let's say a `Person` consists of an `id`, `firstName`, `lastName`, and `middleInitial`. The requirements for the pipe are to print the name as "Last, First M." handling situations where a first name, last name, or middle initial do not exist. Such a test might look like this: +簡単な例として、`Person` オブジェクトを受け取り、名前をフォーマットする pipe を見てみましょう。簡単にするために、`Person` は `id`、`firstName`、`lastName`、`middleInitial` で構成されるとします。パイプの要件は、名・姓・ミドルネームのいずれかが存在しない場合に、名前を「性、名 M(ミドルネーム)。」として出力することです。このようなテストは次のようになります: ```tsx import { NamePipe } from './name.pipe'; @@ -281,34 +279,34 @@ describe('NamePipe', () => { }); ``` -It is also beneficial to exercise the pipe via DOM testing in the components and pages that utilize the pipe. +また、pipe を利用するコンポーネントおよびページでの DOM テストを介して pipe を実行することも有益です。 -## End-to-end Testing +## エンドツーエンドテスト -End-to-end testing is used to verify that an application works as a whole and often includes a connection to live data. Whereas unit tests focus on code units in isolation and thus allow for low-level testing of the application logic, end-to-end tests focus on various user stories or usage scenarios, providing high-level testing of the overall flow of data through the application. Whereas unit tests try to uncover problems with an application's logic, end-to-end tests try to uncover problems that occur when those individual units are used together. End-to-end tests uncover problems with the overall architecture of the application. +エンドツーエンドのテストは、アプリケーションが全体として機能し、多くの場合、ライブデータへの接続を含むことを検証するために使用されます。一方で、ユニットテストは分離されたコードユニットに重点を置いているため、アプリケーションロジックの低レベルのテストが可能ですが、エンドツーエンドテストはさまざまなユーザーストーリーや使用・シナリオに重点を置いており、アプリケーション全体を通したデータフローの総合的な高レベルのテストを提供します。また一方で、ユニットテストではアプリケーションのロジックの問題を明らかにしようとしますが、エンドツーエンドテストでは、個々のユニットが一緒に使用される場合に発生する問題を明らかにしようとします。エンドツーエンドのテストにより、アプリケーションの全体的なアーキテクチャに関する問題が明らかになります。 -Since end-to-end tests exercise user stories and cover the application as a whole rather than individual code modules, end-to-end tests exist in their own application in the project apart from the code for the main application itself. Most end-to-end tests operate by automating common user interactions with the application and examining the DOM to determine the results of those interactions. +エンドツーエンドテストはユーザーストーリーを実行し、個々のコードモジュールではなくアプリケーション全体を対象とするため、エンドツーエンドテストは、メインアプリケーション自体のコードとは別に、プロジェクト内の独自のアプリケーションとして存在します。ほとんどのエンドツーエンドテストは、アプリケーションとの共通のユーザー対話を自動化し、それらの対話の結果を判別するために DOM を調査します。 -### Test Structure +### テストの構成 -When an `@ionic/angular` application is generated, a default end-to-end test application is generated in the `e2e` folder. This application uses Protractor to control the browser and Jasmine to structure and execute the tests. The application initially consists of four files: +`@ionic/angular` アプリケーションが作成されると、 デフォルトのエンドツーエンドのテストアプリケーションが `e2e` フォルダに生成されます。このアプリケーションは Protractor を使用してブラウザを制御し、Jasmine を使用してテストを構築し、実行します。アプリケーションは、初期時は次の 4 つのファイルで構成されています: -- `protractor.conf.js` - the Protractor configuration file -- `tsconfig.e2e.json` - specific TypeScript configuration for the testing application -- `src/app.po.ts` - a page object containing methods that navigate the application, query elements in the DOM, and maninpulate elements on the page -- `src/app.e2e-spec.ts` - a testing script +- `protractor.conf.js` - Protractor の設定ファイル +- `tsconfig.e2e.json` - テストアプリケーション用の特定の TypeScript の設定 +- `src/app.po.ts` - アプリケーションをナビゲートするメソッド、DOM 内の要素を照会するメソッド、ページ上の要素を操作するメソッドを含むページオブジェクト +- `src/app.e2e-spec.ts` - テスト用のスクリプト -#### Page Objects +#### ページオブジェクト -End-to-end tests operate by automating common user interactions with the application, waiting for the application to respond, and examining the DOM to determine the results of the interaction. This involves a lot of DOM manipulation and examination. If this were all done manually, the tests would be very brittle and difficult to read and maintain. +エンドツーエンドのテストは、アプリケーションとの共通のユーザー対話を自動化し、アプリケーションが応答するのを待ち、対話の結果を判別するために DOM を検査します。これには、多くの DOM 操作と試験が必要です。これらをすべて手作業で行うと、テストは非常に脆くなり、見て理解することや保守が困難になります。 -Page objects encapsulate the HTML for a single page in a TypeScript class, providing an API that the test scripts use to interact with the application. The encapsulation of the DOM manipulation logic in page objects makes the tests more readable and far easier to reason about, lowering the maintenance costs of the test. Creating well-crafted page objects is the key to creating high quality and maintainable end-to-end tests. +ページオブジェクトは、TypeScript クラスの単一ページの HTML をカプセル化し、テスト用のスクリプトがアプリケーションと対話するために使用する API を提供します。DOM 操作ロジックをページオブジェクト内にカプセル化することで、テストが読みやすくなり、かつ判断することがはるかに簡単になり、テストの保守コストが大幅に削減されます。洗練されたページオブジェクトを作成することは、高品質で保守しやすいエンドツーエンドのテストを作成するための鍵です。 -##### Base Page Object +##### ベースページオブジェクト -A lot of tests rely on actions such as waiting for a page to be visible, entering text into an input, and clicking a button. The methods used to do this remain consistent with only the CSS selectors used to get the appropriate DOM element changing. Therefore it makes sense to abstract this logic into a base class that can be used by the other page objects. +多くのテストは、ページが表示されるのを待ったり、input にテキストを入力したり、ボタンをクリックするなどのアクションに依存しています。これを行うために使用されるメソッドは、適切な DOM 要素の変更を取得するために使用される CSS セレクターのみと一貫性があります。したがって、このロジックを、他のページオブジェクトが使用できるベースクラスに抽象化することは理にかなっています。 -Here is an example that implements a few basic methods that all page objects will need to support. +すべてのページオブジェクトがサポートを必要とするいくつかのベースメソッドを実装する例を次に示します: ```tsx import { browser, by, element, ExpectedConditions } from 'protractor'; @@ -370,11 +368,11 @@ export class PageObjectBase { } ``` -##### Per-Page Abstractions +##### ページ毎の要約 -Each page in the application will have its own page object class that abstracts the elements on that page. If a base page object class is used, creating the page object involves mostly creating custom methods for elements that are specific to that page. Often, these custom elements take advantage of methods in the base class in order to perform the work that is required. +アプリケーションの各ページには、そのページの要素を抽象化する独自のページオブジェクトクラスがあります。ベースとなるページオブジェクトクラスを使用する場合、ページオブジェクトを作成するには、ほとんどの場合そのページに固有の要素のカスタムメソッドを作成する必要があります。多くの場合、これらのカスタム要素は、必要な作業を実行するためにベースクラスのメソッドの恩恵を受けます。 -Here is an example page object for a simple but typical login page. Notice that many of the methods, such as `enterEMail()`, call methods in the base class that perform the bulk of the work. +次に、単純ですが典型的なログインページのページオブジェクトの例を示します。`enterEMail()` のような多くのメソッドは、作業の大部分を行うベースクラスのメソッドを呼び出すことに注意してください。 ```tsx import { browser, by, element, ExpectedConditions } from 'protractor'; @@ -407,13 +405,13 @@ export class LoginPage extends PageObjectBase { } ``` -#### Testing Scripts +#### テストスクリプト -Similar to unit tests, end-to-end test scripts consist of nested `describe()` and `it()` functions. In the case of end-to-end tests, the `describe()` functions generally denote specific scenarios with the `it()` functions denoting specific behaviors that should be exhibited by the application as actions are performed within that scenario. +ユニットテストと同様に、エンドツーエンドのテストスクリプトはネストされた `describe()` と `it()` 関数で構成されています。エンドツーエンドのテストの場合、`describe()` 関数は一般に、特定のシナリオを、そのシナリオ内でアクションが実行されるときにアプリケーションによって表されるべき特定の振る舞いを示す `it()` 関数とともに示します。 -Also similar to unit tests, the labels used in the `describe()` and `it()` functions should make sense both with the "describe" or "it" and when concatenated together to form the complete test case. +また、ユニットテストと同様に、`describe()` および `it()` 関数で使用されるラベルは、"describe" または "it"と、完全なテストケースを形成するためにともに連結されるとき、両方とも意味をなします。 -Here is a sample end-to-end test script that exercises some typical login scenarios. +典型的なログインシナリオを実行するエンドツーエンドのテストスクリプトの簡単な例を次に示します。 ```tsx import { AppPage } from '../page-objects/pages/app.po'; @@ -501,17 +499,17 @@ describe('Login', () => { }); ``` -### Configuration +### 設定 -The default configuration uses the same `environment.ts` file that is used for development. In order to provide better control over the data used by the end-to-end tests, it is often useful to create a specific environment for testing and use that environment for the tests. This section shows one possible way to create this configuration. +デフォルトの設定では、開発に使用される同じ `environment.ts` ファイルを使います。エンドツーエンドのテストで使用するデータをより適切に制御するには、テスト用の特定の環境を用意し、テストにその環境を使用すると便利なことが多いです。このセクションでは、この設定を作成する 1 つの方法を示します。 -#### Testing Environment +#### テスト環境 -Setting up a testing environment involves creating a new environment file that uses a dedicated testing backend, updating the `angular.json` file to use that environment, and modifying the `e2e` script in the `package.json` to specify the `test` environment. +テスト環境を設定するには、テスト専用のバックエンドを使用する新しい環境ファイルを作成し、その環境を使うために `angular.json` ファイルを更新し、`package.json` 中の `e2e` スクリプトを `test` 環境を指定するように修正します。 -##### Create the `environment.e2e.ts` File +##### `environment.e2e.ts` ファイルを生成 -The Angular `environment.ts` and `environment.prod.ts` files are often used to store information such as the base URL for the application's backend data services. Create an `environment.e2e.ts` that provides the same information, only connecting to backend services that are dedicated to testing rather than the development or production backend services. Here is an example: +Angular の `environment.ts` と `environment.prod.ts` ファイルは、アプリケーションのバックエンドのデータサービスのベース URL などの情報を格納するために度々使用されます。また、同じ情報を提供する `environment.e2e.ts` を作成してください。これは、開発または本番のバックエンドサービスではなく、テスト専用のバックエンドサービスにのみ接続します。以下に例を示します: ```tsx export const environment = { @@ -521,11 +519,11 @@ export const environment = { }; ``` -##### Modify the `angular.json` File +##### `angular.json` ファイルを修正 -The `angular.json` file needs to be modified to use this file. This is a layered process. Follow the XPaths listed below to add the configuration that is required. +`angular.json` ファイルを使用するには、このファイルを修正する必要があります。これは階層化プロセスです。以下の XPath リストに従って、必要な設定を追加しましょう。 -Add a configuration at `/projects/app/architect/build/configurations` called `test` that does the file replacement: +`/projects/app/architect/build/configurations` にファイルの置換を行う `test` という名前の設定を追加します: ```json "test": { @@ -538,7 +536,7 @@ Add a configuration at `/projects/app/architect/build/configurations` called `te } ``` -Add a configuration at `/projects/app/architect/serve/configurations` called `test` that points the browser target at the `test` build configuration that was defined above. +`/projects/app/architect/serve/configurations` に、上記で定義した `test` というビルドの設定をブラウザターゲットに指定する `test` という名前の設定を追加します。 ```json "test": { @@ -546,7 +544,7 @@ Add a configuration at `/projects/app/architect/serve/configurations` called `te } ``` -Add a configuration at `/projects/app-e2e/architect/e2e/configurations` called `test` that does points the dev server target at the `test` serve configuration defined above. +`/projects/app-e2e/architect/e2e/configurations` に、上記で定義した `test` という起動設定で開発サーバーターゲットを指定する `test` という名前の設定を追加します。 ```json "test": { @@ -554,9 +552,9 @@ Add a configuration at `/projects/app-e2e/architect/e2e/configurations` called ` } ``` -##### Modify the `package.json` File +##### `package.json` ファイルを修正 -Modify the `package.json` file so that `npm run e2e` uses the `test` configuration. +`npm run e2e` が `test` の設定を使うように `package.json` ファイルを修正します。 ```json "scripts": { @@ -570,14 +568,14 @@ Modify the `package.json` file so that `npm run e2e` uses the `test` configurati }, ``` -#### Test Cleanup +#### テストクリーンアップ -If the end-to-end tests modify data in any way it is helpful to reset the data to a known state once the test completes. One way to do that is to: +エンドツーエンドテストが何らかの方法でデータを変更する場合は、テストが完了したらデータを既知の状態に一度リセットすると便利です。そのための 1 つの方法は: -1. Create an endpoint that performs the cleanup. -1. Add a `onCleanUp()` function to the `config` object exported by the `protractor.conf.js` file. +1. クリーンアップを実行するエンドポイントを生成する。 +1. `protractor.conf.js` ファイルによってエクスポートされる `config` オブジェクトに `onCleanUp()` 関数を追加する -Here is an example: +次に例を示します: ```javascript onCleanUp() { diff --git a/docs/angular/virtual-scroll.md b/docs/angular/virtual-scroll.md index 0150d810162..3e239956e27 100644 --- a/docs/angular/virtual-scroll.md +++ b/docs/angular/virtual-scroll.md @@ -1,8 +1,12 @@ -# Virtual Scroll +# 仮想スクロール -In the past, we have provided an `ion-virtual-scroll` component in Ionic Framework to help with list virtualization. At the time this was not available in Angular, but recently Angular has provided its own solution via the `@angular/cdk` package. +:::warning Looking for `ion-virtual-scroll`? -## Setup +`ion-virtual-scroll` was deprecated in v6.0.0 and removed in v7.0.0. We recommend using the `@angular/cdk` package detailed below. + +::: + +## Installation To setup the CDK Scroller, first install `@angular/cdk`: diff --git a/docs/angular/your-first-app.md b/docs/angular/your-first-app.md index 753dbefb5a5..22a9b47a603 100644 --- a/docs/angular/your-first-app.md +++ b/docs/angular/your-first-app.md @@ -1,6 +1,6 @@ --- -title: 'Your First Ionic App: Angular' -sidebar_label: Build Your First App +title: 'はじめてのIonicアプリ: Angular' +sidebar_label: はじめてのアプリ --- @@ -11,7 +11,7 @@ sidebar_label: Build Your First App /> -The great thing about Ionic is that with one codebase, you can build for any platform using just HTML, CSS, and JavaScript. Follow along as we learn the fundamentals of Ionic app development by creating a realistic app step by step. +Ionic の素晴らしいところは、1 つのコードベースで、使い慣れた Web ツールと言語を使用して任意のプラットフォーム用にビルドできることです。 Follow along as we learn the fundamentals of Ionic app development by creating a realistic app step by step. Here’s the finished app running on all 3 platforms: @@ -19,9 +19,9 @@ Here’s the finished app running on all 3 platforms: width="560" height="315" src="https://www.youtube.com/embed/0ASQ13Y1Rk4" - frameborder="0" + frameBorder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" - allowfullscreen + allowFullScreen > :::note @@ -35,8 +35,8 @@ We'll create a Photo Gallery app that offers the ability to take photos with you Highlights include: - One Angular-based codebase that runs on the web, iOS, and Android using Ionic Framework [UI components](https://ionicframework.com/docs/components). -- Deployed as a native iOS and Android mobile app using [Capacitor](https://capacitor.ionicframework.com), Ionic's official native app runtime. -- Photo Gallery functionality powered by the Capacitor [Camera](https://capacitor.ionicframework.com/docs/apis/camera), [Filesystem](https://capacitor.ionicframework.com/docs/apis/filesystem), and [Storage](https://capacitor.ionicframework.com/docs/apis/storage) APIs. +- Deployed as a native iOS and Android mobile app using [Capacitor](https://capacitorjs.com), Ionic's official native app runtime. +- Photo Gallery functionality powered by the Capacitor [Camera](https://capacitorjs.com/docs/apis/camera), [Filesystem](https://capacitorjs.com/docs/apis/filesystem), and [Preferences](https://capacitorjs.com/docs/apis/preferences) APIs. Find the complete app code referenced in this guide [on GitHub](https://github.com/ionic-team/photo-gallery-capacitor-ng). @@ -69,17 +69,23 @@ The `-g` option means _install globally_. When packages are installed globally, Consider setting up npm to operate globally without elevated permissions. See [Resolving Permission Errors](../developing/tips.md#resolving-permission-errors) for more information. ::: -## Create an App +## アプリの作成 -Next, create an Ionic Angular app that uses the “Tabs” starter template and adds Capacitor for native functionality: +次に、"Tabs" というアプリテンプレートを使用して Ionic Angular アプリを生成し、Native 機能を使うために Capacitor を追加します。 ```shell ionic start photo-gallery tabs --type=angular --capacitor ``` -This starter project comes complete with three pre-built pages and best practices for Ionic development. With common building blocks already in place, we can add more features easily! +:::note + +`NgModules` と `Standalone` のどちらかを選択するプロンプトが表示されたら、このチュートリアルは `NgModules` のアプローチに従っているので、`NgModules` を選択する。 + +::: + +このスタータープロジェクトには、Ionic 開発のために事前に構成された 3 つのページとベストプラクティスが用意されています。共通の構成要素がすでに配置されているため、機能を簡単に追加できます! -Next, change into the app folder: +次に、アプリのフォルダに移動します: ```shell cd photo-gallery @@ -88,7 +94,7 @@ cd photo-gallery Next we'll need to install the necessary Capacitor plugins to make the app's native functionality work: ```shell -npm install @capacitor/camera @capacitor/storage @capacitor/filesystem +npm install @capacitor/camera @capacitor/preferences @capacitor/filesystem ``` ### PWA Elements @@ -106,15 +112,15 @@ Next, import `@ionic/pwa-elements` by editing `src/main.ts`. ```tsx import { defineCustomElements } from '@ionic/pwa-elements/loader'; -// Call the element loader after the platform has been bootstrapped +// Call the element loader before the bootstrapModule/bootstrapApplication call defineCustomElements(window); ``` That’s it! Now for the fun part - let’s see the app in action. -## Run the App +## アプリを起動 -Run this command next: +次のコマンドを実行してください: ```shell ionic serve @@ -126,7 +132,7 @@ And voilà! Your Ionic app is now running in a web browser. Most of your app can There are three tabs. Click on the Tab2 tab. It’s a blank canvas, aka the perfect spot to transform into a Photo Gallery. The Ionic CLI features Live Reload, so when you make changes and save them, the app is updated immediately! -![Before and after going through this tutorial](/img/guides/first-app-cap-ng/email-photogallery.gif) +![Animated GIF showing the live reload feature in an Ionic app, with changes in code immediately updating the app in a web browser.](/img/guides/first-app-cap-ng/email-photogallery.gif 'Live Reload Feature in Ionic App') Open the photo-gallery app folder in your code editor of choice, then navigate to `/src/app/tab2/tab2.page.html`. We see: diff --git a/docs/angular/your-first-app/2-taking-photos.md b/docs/angular/your-first-app/2-taking-photos.md index 33064cd1140..efaa4f38961 100644 --- a/docs/angular/your-first-app/2-taking-photos.md +++ b/docs/angular/your-first-app/2-taking-photos.md @@ -1,6 +1,6 @@ --- title: Taking Photos with the Camera -sidebar_label: Taking Photos +sidebar_label: カメラ撮影 --- @@ -11,7 +11,7 @@ sidebar_label: Taking Photos /> -Now for the fun part - adding the ability to take photos with the device’s camera using the Capacitor [Camera API](https://capacitor.ionicframework.com/docs/apis/camera). We’ll begin with building it for the web, then make some small tweaks to make it work on mobile (iOS and Android). +Now for the fun part - adding the ability to take photos with the device’s camera using the Capacitor [Camera API](https://capacitorjs.com/docs/apis/camera). We’ll begin with building it for the web, then make some small tweaks to make it work on mobile (iOS and Android). ## Photo Service @@ -26,7 +26,7 @@ Open the new `services/photo.service.ts` file, and let’s add the logic that wi ```tsx import { Camera, CameraResultType, CameraSource, Photo } from '@capacitor/camera'; import { Filesystem, Directory } from '@capacitor/filesystem'; -import { Storage } from '@capacitor/storage'; +import { Preferences } from '@capacitor/preferences'; ``` Next, define a new class method, `addNewToGallery`, that will contain the core logic to take a device photo and save it to the filesystem. Let’s start by opening the device camera: @@ -70,7 +70,7 @@ Then, open `tab2.page.html` and call the `addPhotoToGallery()` function when the Save the file, and if it's not running already, restart the development server in your browser by running `ionic serve`. On the Photo Gallery tab, click the Camera button. If your computer has a webcam of any sort, a modal window appears. Take a selfie! -![Camera API on the web](/img/guides/first-app-cap-ng/camera-web.png) +![A photo gallery app displaying a webcam selfie.](/img/guides/first-app-cap-ng/camera-web.png 'Webcam Selfie in Photo Gallery') _(Your selfie is probably much better than mine)_ @@ -83,7 +83,7 @@ Outside of the `PhotoService` class definition (the very bottom of the file), cr ```tsx export interface UserPhoto { filepath: string; - webviewPath: string; + webviewPath?: string; } ``` @@ -108,7 +108,7 @@ Over in the `addNewToGallery` function, add the newly captured photo to the begi this.photos.unshift({ filepath: "soon...", - webviewPath: capturedPhoto.webPath + webviewPath: capturedPhoto.webPath! }); } ``` diff --git a/docs/angular/your-first-app/3-saving-photos.md b/docs/angular/your-first-app/3-saving-photos.md index 051e5fb3808..cf9b948c221 100644 --- a/docs/angular/your-first-app/3-saving-photos.md +++ b/docs/angular/your-first-app/3-saving-photos.md @@ -1,5 +1,5 @@ --- -sidebar_label: Saving Photos +sidebar_label: 写真の保存 --- # Saving Photos to the Filesystem @@ -31,7 +31,7 @@ public async addNewToGallery() { } ``` -We’ll use the Capacitor [Filesystem API](https://capacitor.ionicframework.com/docs/apis/filesystem) to save the photo to the filesystem. To start, convert the photo to base64 format, then feed the data to the Filesystem’s `writeFile` function. As you’ll recall, we display each photo on the screen by setting each image’s source path (`src` attribute) in `tab2.page.html` to the webviewPath property. So, set it then return the new Photo object. +We’ll use the Capacitor [Filesystem API](https://capacitorjs.com/docs/apis/filesystem) to save the photo to the filesystem. To start, convert the photo to base64 format, then feed the data to the Filesystem’s `writeFile` function. As you’ll recall, we display each photo on the screen by setting each image’s source path (`src` attribute) in `tab2.page.html` to the webviewPath property. So, set it then return the new Photo object. ```tsx private async savePicture(photo: Photo) { @@ -39,7 +39,7 @@ private async savePicture(photo: Photo) { const base64Data = await this.readAsBase64(photo); // Write the file to the data directory - const fileName = new Date().getTime() + '.jpeg'; + const fileName = Date.now() + '.jpeg'; const savedFile = await Filesystem.writeFile({ path: fileName, data: base64Data, diff --git a/docs/angular/your-first-app/4-loading-photos.md b/docs/angular/your-first-app/4-loading-photos.md index 15aa6ec926a..f2fc61b1fd1 100644 --- a/docs/angular/your-first-app/4-loading-photos.md +++ b/docs/angular/your-first-app/4-loading-photos.md @@ -1,14 +1,14 @@ --- -sidebar_label: Loading Photos +sidebar_label: 写真の読み込み --- # Loading Photos from the Filesystem We’ve implemented photo taking and saving to the filesystem. There’s one last piece of functionality missing: the photos are stored in the filesystem, but we need a way to save pointers to each file so that they can be displayed again in the photo gallery. -Fortunately, this is easy: we’ll leverage the Capacitor [Storage API](https://capacitor.ionicframework.com/docs/apis/storage) to store our array of Photos in a key-value store. +Fortunately, this is easy: we’ll leverage the Capacitor [Preferences API](https://capacitorjs.com/docs/apis/preferences) to store our array of Photos in a key-value store. -## Storage API +## Preferences API Begin by defining a constant variable that will act as the key for the store: @@ -21,10 +21,10 @@ export class PhotoService { } ``` -Next, at the end of the `addNewToGallery` function, add a call to `Storage.set()` to save the Photos array. By adding it here, the Photos array is stored each time a new photo is taken. This way, it doesn’t matter when the app user closes or switches to a different app - all photo data is saved. +Next, at the end of the `addNewToGallery` function, add a call to `Preferences.set()` to save the Photos array. By adding it here, the Photos array is stored each time a new photo is taken. This way, it doesn’t matter when the app user closes or switches to a different app - all photo data is saved. ```tsx -Storage.set({ +Preferences.set({ key: this.PHOTO_STORAGE, value: JSON.stringify(this.photos), }); @@ -35,8 +35,8 @@ With the photo array data saved, create a function called `loadSaved()` that can ```tsx public async loadSaved() { // Retrieve cached photo array data - const photoList = await Storage.get({ key: this.PHOTO_STORAGE }); - this.photos = JSON.parse(photoList.value) || []; + const { value } = await Preferences.get({ key: this.PHOTO_STORAGE }); + this.photos = (value ? JSON.parse(value) : []) as UserPhoto[]; // more to come... } diff --git a/docs/angular/your-first-app/5-adding-mobile.md b/docs/angular/your-first-app/5-adding-mobile.md index 913d4d582e6..16235a008a4 100644 --- a/docs/angular/your-first-app/5-adding-mobile.md +++ b/docs/angular/your-first-app/5-adding-mobile.md @@ -2,7 +2,7 @@ strip_number_prefixes: false --- -# Adding Mobile +# モバイルデバイス機能の追加 Our photo gallery app won’t be complete until it runs on iOS, Android, and the web - all using one codebase. All it takes is some small logic changes to support mobile platforms, installing some native tooling, then running the app on a device. Let’s go! @@ -38,14 +38,14 @@ private async readAsBase64(photo: Photo) { if (this.platform.is('hybrid')) { // Read the file into base64 format const file = await Filesystem.readFile({ - path: photo.path + path: photo.path! }); return file.data; } else { // Fetch the photo, read as a blob, then convert to base64 format - const response = await fetch(photo.webPath); + const response = await fetch(photo.webPath!); const blob = await response.blob(); return await this.convertBlobToBase64(blob) as string; @@ -57,35 +57,35 @@ Next, update the `savePicture()` method. When running on mobile, set `filepath` ```tsx // Save picture to file on device - private async savePicture(photo: Photo) { - // Convert photo to base64 format, required by Filesystem API to save - const base64Data = await this.readAsBase64(photo); - - // Write the file to the data directory - const fileName = new Date().getTime() + '.jpeg'; - const savedFile = await Filesystem.writeFile({ - path: fileName, - data: base64Data, - directory: Directory.Data - }); +private async savePicture(photo: Photo) { + // Convert photo to base64 format, required by Filesystem API to save + const base64Data = await this.readAsBase64(photo); + + // Write the file to the data directory + const fileName = Date.now() + '.jpeg'; + const savedFile = await Filesystem.writeFile({ + path: fileName, + data: base64Data, + directory: Directory.Data + }); - if (this.platform.is('hybrid')) { - // Display the new image by rewriting the 'file://' path to HTTP - // Details: https://ionicframework.com/docs/building/webview#file-protocol - return { - filepath: savedFile.uri, - webviewPath: Capacitor.convertFileSrc(savedFile.uri), - }; - } - else { - // Use webPath to display the new image instead of base64 since it's - // already loaded into memory - return { - filepath: fileName, - webviewPath: photo.webPath - }; - } + if (this.platform.is('hybrid')) { + // Display the new image by rewriting the 'file://' path to HTTP + // Details: https://ionicframework.com/docs/building/webview#file-protocol + return { + filepath: savedFile.uri, + webviewPath: Capacitor.convertFileSrc(savedFile.uri), + }; } + else { + // Use webPath to display the new image instead of base64 since it's + // already loaded into memory + return { + filepath: fileName, + webviewPath: photo.webPath + }; + } +} ``` Next, head back over to the `loadSaved()` function we implemented for the web earlier. On mobile, we can directly set the source of an image tag - `` - to each photo file on the Filesystem, displaying them automatically. Thus, only the web requires reading each image from the Filesystem into base64 format. Update this function to add an _if statement_ around the Filesystem code: @@ -93,8 +93,8 @@ Next, head back over to the `loadSaved()` function we implemented for the web ea ```tsx public async loadSaved() { // Retrieve cached photo array data - const photoList = await Storage.get({ key: this.PHOTO_STORAGE }); - this.photos = JSON.parse(photoList.value) || []; + const { value } = await Preferences.get({ key: this.PHOTO_STORAGE }); + this.photos = (value ? JSON.parse(value) : []) as UserPhoto[]; // Easiest way to detect when running on the web: // “when the platform is NOT hybrid, do this” diff --git a/docs/angular/your-first-app/6-deploying-mobile.md b/docs/angular/your-first-app/6-deploying-mobile.md index 9b6d503d51b..06ae7100d8f 100644 --- a/docs/angular/your-first-app/6-deploying-mobile.md +++ b/docs/angular/your-first-app/6-deploying-mobile.md @@ -1,6 +1,6 @@ --- title: Deploying to iOS and Android -sidebar_label: Deploying Mobile +sidebar_label: モバイルへのデプロイ --- @@ -15,7 +15,7 @@ Since we added Capacitor to our project when it was first created, there’s onl ## Capacitor Setup -Capacitor is Ionic’s official app runtime that makes it easy to deploy web apps to native platforms like iOS, Android, and more. If you’ve used Cordova in the past, consider reading more about the differences [here](https://capacitor.ionicframework.com/docs/cordova#differences-between-capacitor-and-cordova). +Capacitor is Ionic’s official app runtime that makes it easy to deploy web apps to native platforms like iOS, Android, and more. If you’ve used Cordova in the past, consider reading more about the differences [here](https://capacitorjs.com/docs/cordova#differences-between-capacitor-and-cordova). If you’re still running `ionic serve` in the terminal, cancel it. Complete a fresh build of your Ionic project, fixing any errors that it reports: @@ -58,9 +58,9 @@ First, run the Capacitor `open` command, which opens the native iOS project in X ionic cap open ios ``` -In order for some native plugins to work, user permissions must be configured. In our photo gallery app, this includes the Camera plugin: iOS displays a modal dialog automatically after the first time that `Camera.getPhoto()` is called, prompting the user to allow the app to use the Camera. The permission that drives this is labeled “Privacy - Camera Usage.” To set it, the `Info.plist` file must be modified ([more details here](https://capacitor.ionicframework.com/docs/ios/configuration)). To access it, click "Info," then expand "Custom iOS Target Properties." +In order for some native plugins to work, user permissions must be configured. In our photo gallery app, this includes the Camera plugin: iOS displays a modal dialog automatically after the first time that `Camera.getPhoto()` is called, prompting the user to allow the app to use the Camera. The permission that drives this is labeled “Privacy - Camera Usage.” To set it, the `Info.plist` file must be modified ([more details here](https://capacitorjs.com/docs/ios/configuration)). To access it, click "Info," then expand "Custom iOS Target Properties." -![Xcode Custom iOS Target Properties](/img/guides/first-app-cap-ng/xcode-info-plist.png) +![The Info.plist file in Xcode showing the NSCameraUsageDescription key added for camera access.](/img/guides/first-app-cap-ng/xcode-info-plist.png 'Xcode Info.plist Configuration') Each setting in `Info.plist` has a low-level parameter name and a high-level name. By default, the property list editor shows the high-level names, but it's often useful to switch to showing the raw, low-level names. To do this, right-click anywhere in the property list editor and toggle "Raw Keys/Values." @@ -70,15 +70,15 @@ Follow the same process to add the other two Keys required of the Camera plugin: Next, click on `App` in the Project Navigator on the left-hand side, then within the `Signing & Capabilities` section, select your Development Team. -![Xcode - Selecting Development Team](/img/guides/first-app-cap-ng/xcode-signing.png) +![The Xcode interface displaying the Signing and Capabilities tab for an iOS app project.](/img/guides/first-app-cap-ng/xcode-signing.png 'Xcode Signing & Capabilities') With permissions in place and Development Team selected, we are ready to try out the app on a real device! Connect an iOS device to your Mac computer, select it (`App -> Matthew’s iPhone` for me) then click the "Build" button to build, install, and launch the app on your device: -![Xcode build button](/img/guides/first-app-cap-ng/xcode-build-button.png) +![Xcode toolbar highlighting the Build button used to compile and run an iOS app.](/img/guides/first-app-cap-ng/xcode-build-button.png 'Xcode Build Button') Upon tapping the Camera button on the Photo Gallery tab, the permission prompt will display. Tap OK, then take a picture with the Camera. Afterward, the photo shows in the app! -![iOS Camera permissions](/img/guides/first-app-cap-ng/ios-permissions-photo.png) +![Two iPhones side by side, one showing the camera permission prompt and the other displaying a photo taken with the app.](/img/guides/first-app-cap-ng/ios-permissions-photo.png 'iOS Camera Permission Prompt and Photo Result') ## Android Deployment @@ -92,7 +92,7 @@ ionic cap open android Similar to iOS, we must enable the correct permissions to use the Camera. Configure these in the `AndroidManifest.xml` file. Android Studio will likely open this file automatically, but in case it doesn't, locate it under `android/app/src/main/`. -![Android Manifest location](/img/guides/first-app-cap-ng/android-manifest.png) +![Android Studio editor showing the AndroidManifest.xml file with camera permissions.](/img/guides/first-app-cap-ng/android-manifest.png 'Android Manifest Permissions') Scroll to the `Permissions` section and ensure these entries are included: @@ -103,11 +103,11 @@ Scroll to the `Permissions` section and ensure these entries are included: Save the file. With permissions in place, we are ready to try out the app on a real device! Connect an Android device to your computer. Within Android Studio, click the "Run" button, select the attached Android device, then click OK to build, install, and launch the app on your device. -![Launching app on Android](/img/guides/first-app-cap-ng/android-device.png) +![The Android Studio interface with arrows pointing to the Run button and the connected device.](/img/guides/first-app-cap-ng/android-device.png 'Android Studio Run Configuration') Once again, upon tapping the Camera button on the Photo Gallery tab, the permission prompt should be displayed. Tap OK, then take a picture with the Camera. Afterward, the photo should appear in the app. -![Android Camera permissions](/img/guides/first-app-cap-ng/android-permissions-photo.png) +![Two Android phones side by side, one showing the camera permission prompt and the other displaying a photo taken with the app.](/img/guides/first-app-cap-ng/android-permissions-photo.png 'Android Permissions and Photo Capture') Our Photo Gallery app has just been deployed to Android and iOS devices. 🎉 diff --git a/docs/angular/your-first-app/7-live-reload.md b/docs/angular/your-first-app/7-live-reload.md index c560be55767..484feddcc0f 100644 --- a/docs/angular/your-first-app/7-live-reload.md +++ b/docs/angular/your-first-app/7-live-reload.md @@ -1,6 +1,6 @@ --- -title: Rapid App Development with Live Reload -sidebar_label: Live Reload +title: アプリ開発を高速化するためのライブリロード +sidebar_label: ライブリロード --- @@ -91,7 +91,7 @@ public async deletePicture(photo: UserPhoto, position: number) { this.photos.splice(position, 1); // Update photos array cache by overwriting the existing photo array - Storage.set({ + Preferences.set({ key: this.PHOTO_STORAGE, value: JSON.stringify(this.photos) }); @@ -107,7 +107,7 @@ public async deletePicture(photo: UserPhoto, position: number) { } ``` -The selected photo is removed from the Photos array first. Then, we use the Capacitor Storage API to update the cached version of the Photos array. Finally, we delete the actual photo file itself using the Filesystem API. +The selected photo is removed from the Photos array first. Then, we use the Capacitor Preferences API to update the cached version of the Photos array. Finally, we delete the actual photo file itself using the Filesystem API. Save this file, then tap on a photo again and choose the “Delete” option. This time, the photo is deleted! Implemented much faster using Live Reload. 💪 diff --git a/docs/angular/your-first-app/8-distribute.md b/docs/angular/your-first-app/8-distribute.md index 72f54278489..65ef475f6be 100644 --- a/docs/angular/your-first-app/8-distribute.md +++ b/docs/angular/your-first-app/8-distribute.md @@ -18,7 +18,7 @@ For more on connecting your code repository to Appflow, checkout the [Connect yo The Appflow SDK (also known as Ionic Deploy plugin) will allow you to take advantage of arguably two of the best Appflow features: deploying live updates to your app and bypassing the app stores. Ionic Appflow's Live Update feature is shipped with Appflow SDK and features the capabilities of detecting and syncing the updates for your app that you have pushed to your identified channels within the dashboard. -To get the Appflow SDK plugin added to your project, you can follow the install instructions within the Appflow Dashboard by clicking on "Install Instructions" inside of the `Deploy > Destinations` section. Alternatively, you can install the plugin manually by excuting the following command in your app's root directory: +To get the Appflow SDK plugin added to your project, you can follow the install instructions within the Appflow Dashboard by clicking on "Install Instructions" inside of the `Deploy > Destinations` section. Alternatively, you can install the plugin manually by executing the following command in your app's root directory: ```shell ionic deploy add \ @@ -55,7 +55,7 @@ To receive this live update, you will need to run the app on a device or an emul ionic [cordova | cap] run [ios | android] [options] ``` -Assuming the app is configured correctly to listen to the channel you deployed too, the app should immediately update on startup if you have chosen the auto update method during setup. If the background update method was chosen, be sure to stay in the app for about 30 seconds to ensure the update was downloaded. Then, close the application, reopen it, and you will see the updates applied! +Assuming the app is configured correctly to listen to the channel you deployed to, the app should immediately update on startup if you have chosen the auto update method during setup. If the background update method was chosen, be sure to stay in the app for about 30 seconds to ensure the update was downloaded. Then, close the application, reopen it, and you will see the updates applied! To dive into more details on the steps to deploy a live update, as well as additional information such as disabling deploy for development, check out the [Deploy a Live Update](https://ionic.io/docs/appflow/quickstart/deploy) section inside the Appflow docs. @@ -75,7 +75,7 @@ For more information, visit the [Create an Automation](https://ionic.io/docs/app ## Create an Environment -[Package builds](https://ionic.io/docs/appflow/package/builds) and [Deploy builds](https://ionic.io/docs/appflow/deploy/builds) can be futher customized via [Environments](https://ionic.io/docs/appflow/automation/environments). This powerful feature allows you to create different configurations based on the environment variables passed in at build time. When combined with the [Automation](https://ionic.io/docs/appflow/automation/intro) feature, development teams can easily configure development, staging, and production build configurations, allowing them to embrace DevOps best practices and ship better quality updates faster than ever. +[Package builds](https://ionic.io/docs/appflow/package/builds) and [Deploy builds](https://ionic.io/docs/appflow/deploy/builds) can be further customized via [Environments](https://ionic.io/docs/appflow/automation/environments). This powerful feature allows you to create different configurations based on the environment variables passed in at build time. When combined with the [Automation](https://ionic.io/docs/appflow/automation/intro) feature, development teams can easily configure development, staging, and production build configurations, allowing them to embrace DevOps best practices and ship better quality updates faster than ever. Creating an Environment is available for those on our [Basic plans](https://ionic.io/pricing) and above. More information on this can be found in the [Create an Environment](https://ionic.io/docs/appflow/quickstart/environment) section within the Appflow docs. @@ -95,6 +95,6 @@ For access to the ability to create a Native Configuration, you will need to be Congratulations! You developed a complete cross-platform Photo Gallery app that runs on the web, iOS, and Android. Not only that, you have also then built the app and deployed it to your users devices! -There are many paths to follow from here. Try adding another [Ionic UI component](https://ionicframework.com/docs/components) to the app, or more [native functionality](https://capacitor.ionicframework.com/docs/apis). The sky’s the limit. Once you have added another feature, run the the build and deploy process again through Appflow to get it out to your users. +There are many paths to follow from here. Try adding another [Ionic UI component](https://ionicframework.com/docs/components) to the app, or more [native functionality](https://capacitorjs.com/docs/apis). The sky’s the limit. Once you have added another feature, run the build and deploy process again through Appflow to get it out to your users. Happy app building! 💙 diff --git a/docs/api.md b/docs/api.md index 45e4c1d8d19..01b482ea210 100644 --- a/docs/api.md +++ b/docs/api.md @@ -1,17 +1,17 @@ --- -title: API Index +title: APIインデックス --- import APIList from '@components/page/api/APIList'; - API Index | Ionic Docs API Index for all API Custom Elements + API Index | API カスタム要素の Ionic Docs API Index -Each Ionic [component](/docs/components) consists of one or more [custom elements](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements). Each custom element, in turn, may expose properties, methods, events, and CSS custom properties. +各 Ionic の [コンポーネント](/docs/components) は、1 つ以上の [カスタム要素](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements) から構成されます。各カスタム要素は順番に、プロパティ、メソッド、イベント、および CSS カスタムプロパティを公開できます。 diff --git a/docs/api/accordion-group.md b/docs/api/accordion-group.md index aa3020206b8..be0d80eba1b 100644 --- a/docs/api/accordion-group.md +++ b/docs/api/accordion-group.md @@ -1,37 +1,21 @@ --- title: "ion-accordion-group" -hide_table_of_contents: true --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - -import Props from '@site/static/auto-generated/accordion-group/props.md'; -import Events from '@site/static/auto-generated/accordion-group/events.md'; -import Methods from '@site/static/auto-generated/accordion-group/methods.md'; -import Parts from '@site/static/auto-generated/accordion-group/parts.md'; -import CustomProps from '@site/static/auto-generated/accordion-group/custom-props.md'; -import Slots from '@site/static/auto-generated/accordion-group/slots.md'; - - +import Props from '@ionic-internal/component-api/v8/accordion-group/props.md'; +import Events from '@ionic-internal/component-api/v8/accordion-group/events.md'; +import Methods from '@ionic-internal/component-api/v8/accordion-group/methods.md'; +import Parts from '@ionic-internal/component-api/v8/accordion-group/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/accordion-group/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/accordion-group/slots.md'; import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; -

Contents

- - - - +アコーディオン・グループは、アコーディオンインスタンスのためのコンテナです。これは、アコーディオンの状態を管理し、キーボードナビゲーションを提供します。 -Accordion group is a container for accordion instances. It manages the state of the accordions and provides keyboard navigation. +より詳細な情報や使用方法については、 [Accordion](./accordion) を参照ください。 -For more information as well as usage, see the [Accordion Documentation](./accordion) ## Interfaces @@ -45,7 +29,7 @@ interface AccordionGroupChangeEventDetail { ### AccordionGroupCustomEvent -While not required, this interface can be used in place of the `CustomEvent` interface for stronger typing with Ionic events emitted from this component. +必須ではありませんが、このコンポーネントから発行される Ionic イベントでより強く型付けを行うために、`CustomEvent` インターフェースの代わりにこのインターフェースを使用することが可能です。 ```typescript interface AccordionGroupCustomEvent extends CustomEvent { @@ -56,20 +40,20 @@ interface AccordionGroupCustomEvent extends CustomEvent { -## Properties +## プロパティ -## Events +## イベント -## Methods +## メソッド ## CSS Shadow Parts -## CSS Custom Properties +## CSSカスタムプロパティ ## Slots - \ No newline at end of file + diff --git a/docs/api/accordion.md b/docs/api/accordion.md index 87380efebdf..a60f352a68b 100644 --- a/docs/api/accordion.md +++ b/docs/api/accordion.md @@ -1,133 +1,133 @@ --- title: "ion-accordion" --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - -import Props from '@site/static/auto-generated/accordion/props.md'; -import Events from '@site/static/auto-generated/accordion/events.md'; -import Methods from '@site/static/auto-generated/accordion/methods.md'; -import Parts from '@site/static/auto-generated/accordion/parts.md'; -import CustomProps from '@site/static/auto-generated/accordion/custom-props.md'; -import Slots from '@site/static/auto-generated/accordion/slots.md'; +import Props from '@ionic-internal/component-api/v8/accordion/props.md'; +import Events from '@ionic-internal/component-api/v8/accordion/events.md'; +import Methods from '@ionic-internal/component-api/v8/accordion/methods.md'; +import Parts from '@ionic-internal/component-api/v8/accordion/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/accordion/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/accordion/slots.md'; - Ion-Accordion Components: How to Build & Examples | Ionic - + ion-accordion: Accordion Components: How to Build & Examples + import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; -

Contents

- -Accordions provide collapsible sections in your content to reduce vertical space while providing a way of organizing and grouping information. All `ion-accordion` components should be grouped inside `ion-accordion-group` components. +アコーディオンは、情報を整理してグループ化する方法を提供しながら、垂直方向のスペースを減らすために、コンテンツに折り畳み可能なセクションを提供します。すべての `ion-accordion` コンポーネントは `ion-accordion-group` コンポーネントの中にグループ化されている必要があります。 -## Basic Usage +## 基本的な使い方 -import Basic from '@site/static/usage/accordion/basic/index.md'; +import Basic from '@site/static/usage/v8/accordion/basic/index.md'; -## Toggle Accordions +## アコーディオンをトグルする方法 -Which accordion is open is controlled by setting the `value` property on `ion-accordion-group`. Setting this property allows developers to programmatically expand or collapse certain accordions. +どのアコーディオンを開くかは、`ion-accordion-group` の `value` プロパティを設定することで制御できます。このプロパティを設定することで、開発者はプログラムによって特定のアコーディオンを展開したり折りたたんだりすることができます。 -import Toggle from '@site/static/usage/accordion/toggle/index.md'; +import Toggle from '@site/static/usage/v8/accordion/toggle/index.md'; -## Listen for Accordion State Changes +## アコーディオンの状態変化を監視 + +:::caution +[Input](./input) や [Textarea](./textarea) などの他のコンポーネントが発する `ionChange` イベントのほとんどはバブル化されます。その結果、アコーディオンの中で関連コンポーネントが使用されている場合、これらのイベントはバブルアップし、アコーディオングループの `ionChange` リスナーを発火させます。 + +アコーディオンの内部で `ionChange` を発する他のコンポーネントを使用する場合は、アコーディオングループの `ionChange` コールバックに、コールバックに渡されたイベントの `target` キーをチェックさせ、`ionChange` がアコーディオングループからのものであり、子孫からのものでないことを確認することをお勧めします。 +::: -Developers can listen for the `ionChange` event to be notified when accordions expand or collapse. +開発者は `ionChange` イベントをリッスンして、アコーディオンが展開または折りたたまれたときに通知を受けることができます。 -import ListenChanges from '@site/static/usage/accordion/listen-changes/index.md'; +import ListenChanges from '@site/static/usage/v8/accordion/listen-changes/index.md'; -## Multiple Accordions +## 複数のアコーディオン -Developers can allow multiple accordions to be open at once with the `multiple` property. +開発者は `multiple` プロパティを使用して、複数のアコーディオンを一度に開くことができるようにすることができます。 -import Multiple from '@site/static/usage/accordion/multiple/index.md'; +import Multiple from '@site/static/usage/v8/accordion/multiple/index.md'; -## Disabling Accordions +## アコーディオンの無効化 -### Individual Accordion +### アコーディオンを無効にする -Individual accordions can be disabled with the `disabled` property on `ion-accordion`. +個々のアコーディオンは、`ion-accordion` の `disabled` プロパティで無効にできます。 -import DisableIndividual from '@site/static/usage/accordion/disable/individual/index.md'; +import DisableIndividual from '@site/static/usage/v8/accordion/disable/individual/index.md'; -### Accordion Group +### アコーディオングループ -The accordion group can be disabled with the `disabled` property on `ion-accordion-group`. +アコーディオングループは、`ion-accordion-group` の `disabled` プロパティで無効にすることができます。 -import DisableGroup from '@site/static/usage/accordion/disable/group/index.md'; +import DisableGroup from '@site/static/usage/v8/accordion/disable/group/index.md'; -## Readonly Accordions +## 読み込み可能なアコーディオン -### Individual Accordion +### 個別アコーディオン -Individual accordions can be disabled with the `readonly` property on `ion-accordion`. +個々のアコーディオンは、`ion-accordion` の `readonly` プロパティで無効にできます。 -import ReadonlyIndividual from '@site/static/usage/accordion/readonly/individual/index.md'; +import ReadonlyIndividual from '@site/static/usage/v8/accordion/readonly/individual/index.md'; -### Accordion Group +### アコーディオングループ -The accordion group can be disabled with the `readonly` property on `ion-accordion-group`. +アコーディオングループは、`ion-accordion-group` の `readonly` プロパティで無効にできます。 -import ReadonlyGroup from '@site/static/usage/accordion/readonly/group/index.md'; +import ReadonlyGroup from '@site/static/usage/v8/accordion/readonly/group/index.md'; -## Anatomy +## 構造 -### Header +## ヘッダー -The `header` slot is used as the toggle that will expand or collapse your accordion. We recommend you use an `ion-item` here to take advantage of the accessibility and theming functionalities. +`header` slotは、アコーディオンを展開または折りたたむためのトグルとして使用されます。アクセシビリティとテーマ機能を利用するために、ここでは `ion-item` を使用することをお勧めします。 -When using `ion-item` in the `header` slot, the `ion-item`'s `button` prop is set to `true` and the `detail` prop is set to `false`. In addition, we will also automatically add a toggle icon to the `ion-item`. This icon will automatically be rotated when you expand or collapse the accordion. See [Customizing Icons](#icons) for more information. +`header` slotに `ion-item` を使用する場合、 `ion-item` の `button` プロパティは `true` に、 `detail` プロパティは `false` に設定されます。さらに、`ion-item` にはトグルアイコンも自動的に追加されます。このアイコンは、アコーディオンを展開したり折りたたんだりすると、自動的に回転するようになります。詳しくは、 [アイコンのカスタマイズ](#icons) を参照してください。 -### Content +### コンテンツ -The `content` slot is used as the part of the accordion that is revealed or hidden depending on the state of your accordion. You can place anything here except for another `ion-content` instance as only one instance of `ion-content` should be added per page. +`content` slotは、アコーディオンの状態に応じて表示/非表示される部分として使用されます。1ページに1つだけ `ion-content` インスタンスを追加する必要があるため、ここには他の `ion-content` インスタンスを除いて何でも置くことができます。 -## Customization +## カスタマイズ -### Expansion Styles +### 拡張スタイル -There are two built in expansion styles: `compact` and `inset`. This expansion style is set via the `expand` property on `ion-accordion-group`. +組み込みの拡張スタイルには、`compact` と `inset` の 2 種類があります。この拡張スタイルは `ion-accordion-group` の `expand` プロパティによって設定されます。 -When `expand="inset"`, the accordion group is given a border radius. On `md` mode, the entire accordion will shift down when it is opened. +`expand="inset"` の場合、アコーディオングループにはborder radiusが与えられます。 `md` モードでは、アコーディオン全体を開くと下に移動します。 -import ExpansionStyles from '@site/static/usage/accordion/customization/expansion-styles/index.md'; +import ExpansionStyles from '@site/static/usage/v8/accordion/customization/expansion-styles/index.md'; -### Advanced Expansion Styles +### 高度な拡張スタイル -You can customize the expansion behavior by styling based on the accordion's state. There are four state classes applied to `ion-accordion`. Styling using these classes can allow you to create advanced state transitions: +アコーディオンの状態に応じてスタイルを設定することで、展開の動作をカスタマイズすることができます。 `ion-accordion` には4つのステートクラスが適用されています。これらのクラスを使ってスタイリングすることで、高度な状態遷移を作成することができます。 -| Class Name | Description | -| ---------- | ----------- | -| `.accordion-expanding` | Applied when the accordion is actively expanding | -| `.accordion-expanded` | Applied when the accordion is fully expanded | -| `.accordion-collapsing` | Applied when the accordion is actively collapsing | -| `.accordion-collapsed` | Applied when the accordion is fully collapsed | +| Class Name | Description | +| ---------- |-----------------------------------| +| `.accordion-expanding` | アコーディオンがアクティブに展開しているときに適用されます。 | +| `.accordion-expanded` | アコーディオンが完全に展開されたときに適用されます。 | +| `.accordion-collapsing` | アコーディオンがアクティブに折りたたまれているときに適用されます。 | +| `.accordion-collapsed` | アコーディオンが完全に折りたたまれているときに適用されます。 | -If you need to target specific pieces of the accordion, we recommend targeting the element directly. For example, if you want to customize the ion-item in your header slot when the accordion is expanded, you can use the following selector: +アコーディオンの特定の部分をターゲットにする必要がある場合、要素を直接ターゲットにすることをお勧めします。例えば、アコーディオンが展開されたときに `header` slot の ion-item をカスタマイズしたい場合、以下のセレクタを使用することができます。 ```css ion-accordion.accordion-expanding ion-item[slot="header"], @@ -136,81 +136,81 @@ ion-accordion.accordion-expanded ion-item[slot="header"] { } ``` -import AdvancedExpansionStyles from '@site/static/usage/accordion/customization/advanced-expansion-styles/index.md'; +import AdvancedExpansionStyles from '@site/static/usage/v8/accordion/customization/advanced-expansion-styles/index.md'; -### Icons +### アイコン -When using an `ion-item` in the `header` slot, we automatically add an `ion-icon`. The type of icon used can be controlled by the `toggleIcon` property, and the slot it is added to can be controlled with the `toggleIconSlot` property. +`header` slot に `ion-item` を使用する場合、自動的に `ion-icon` が追加されます。使用するアイコンの種類は `toggleIcon` プロパティで制御でき、追加するスロットも `toggleIconSlot` プロパティで制御することができます。 -If you would like to manage the icon yourself or use an icon that is not an `ion-icon`, you can add the `ion-accordion-toggle-icon` class to the icon element. +アイコンを自分で管理したい場合や、`ion-icon` 以外のアイコンを使用したい場合は、icon 要素に `ion-accordion-toggle-icon` クラスを追加することができます。 -Regardless of which option you choose, the icon will automatically be rotated when you expand or collapse the accordion. +どのオプションを選択しても、アコーディオンを展開または折りたたむと、アイコンは自動的に回転します。 -import Icons from '@site/static/usage/accordion/customization/icons/index.md'; +import Icons from '@site/static/usage/v8/accordion/customization/icons/index.md'; -### Theming +### テーマ -Since `ion-accordion` acts as a shell around the header and content elements, you can easily theme the accordion however you would like. You can theme the header by targeting the slotted `ion-item`. Since you are using `ion-item`, you also have access to all of the [ion-item CSS Variables](./item#css-custom-properties) and [ion-item Shadow Parts](./item#css-shadow-parts). Theming the content is also easily achieved by targeting the element that is in the `content` slot. +`ion-accordion` はヘッダーとコンテンツ要素を囲むシェルとして機能するので、アコーディオンを簡単に好きなようにテーマ化することができます。ヘッダーのテーマは、スロットの `ion-item` をターゲットにすることで行うことができます。 `ion-item` を使用しているので、 [ion-item CSS Variables](./item#css-custom-properties) と [ion-item Shadow Parts](./item#css-shadow-parts) にもすべてアクセスすることができます。コンテンツのテイムも、`content` slotにある要素をターゲットにすることで簡単に実現できます。 -import Theming from '@site/static/usage/accordion/customization/theming/index.md'; +import Theming from '@site/static/usage/v8/accordion/customization/theming/index.md'; -## Accessibility +## アクセシビリティ -### Animations +### アニメーション -By default, animations are enabled when expanding or collapsing an accordion item. Animations will be automatically disabled when the `prefers-reduced-motion` media query is supported and set to `reduce`. For browsers that do not support this, animations can be disabled by setting the `animated` config in your Ionic Framework app. +デフォルトでは、アコーディオン・アイテムを展開したり折りたたんだりする際にアニメーションが有効になります。アニメーションは `prefers-reduced-motion` メディアクエリがサポートされ、`reduce` に設定されると自動的に無効化されます。対応していないブラウザでは、Ionic Frameworkアプリで `animated` を設定することで、アニメーションを無効にすることができます。 -import AccessibilityAnimations from '@site/static/usage/accordion/accessibility/animations/index.md'; +import AccessibilityAnimations from '@site/static/usage/v8/accordion/accessibility/animations/index.md'; -### Keyboard Navigation +### キーボードインタラクション -When used inside an `ion-accordion-group`, `ion-accordion` has full keyboard support for interacting with the component. The following table details what each key does: +`ion-accordion-group` の中で使用する場合、`ion-accordion` はキーボードによる操作を完全にサポートしています。次の表は、それぞれのキーが何をするのかの詳細です。 -| Key | Function | -| ------------------ | ------------------------------------------------------------ | -| `Space` or `Enter` | When focus is on the accordion header, the accordion will collapse or expand depending on the state of the component. | -| `Tab` | Moves focus to the next focusable element. | -| `Shift` + `Tab` | Moves focus to the previous focusable element. | -| `Down Arrow` | - When focus is on an accordion header, moves focus to the next accordion header.
- When focus is on the last accordion header, moves focus to the first accordion header. | -| `Up Arrow` | - When focus is on an accordion header, moves focus to the previous accordion header.
- When focus is on the first accordion header, moves focus to the last accordion header. | -| `Home` | When focus is on an accordion header, moves focus to the first accordion header. | -| `End` | When focus is on an accordion header, moves focus to the last accordion header. | +| Key | Description | +| ------------------------------------ | ------------------------------------------------------------ | +| Space or Enter | When focus is on the accordion header, the accordion will collapse or expand depending on the state of the component. | +| Tab | Moves focus to the next focusable element. | +| Shift + Tab | Moves focus to the previous focusable element. | +| Down Arrow | - When focus is on an accordion header, moves focus to the next accordion header.
- When focus is on the last accordion header, moves focus to the first accordion header. | +| Up Arrow | - When focus is on an accordion header, moves focus to the previous accordion header.
- When focus is on the first accordion header, moves focus to the last accordion header. | +| Home | When focus is on an accordion header, moves focus to the first accordion header. | +| End | When focus is on an accordion header, moves focus to the last accordion header. | -## Performance +## パフォーマンス -### Animations +### アニメーション -The accordion animation works by knowing the height of the `content` slot when the animation starts. The accordion expects that this height will remain consistent throughout the animation. As a result, developers should avoid performing any operation that may change the height of the content during the animation. +アコーディオンアニメーションは、アニメーションを開始するときに `content` slotの高さを知ることによって動作します。アコーディオンは、この高さがアニメーションの間、一貫して保たれることを期待します。そのため、開発者はアニメーション中にコンテンツの高さを変更するような操作を行わないようにしなければなりません。 -For example, using [ion-img](./img) may cause layout shifts as it lazily loads images. This means that as the animation plays, `ion-img` will load the image data, and the dimensions of `ion-img` will change to account for the loaded image data. This can result in the height of the `content` slot changing. Developers have a few options for avoiding this: +例えば、[ion-img](./img) を使用すると、画像を遅延ロードするため、レイアウトのずれが生じることがあります。つまり、アニメーションを再生すると、 `ion-img` が画像データをロードし、ロードされた画像データを考慮して `ion-img` の寸法が変更されることになります。その結果、 `content` slotの高さが変化してしまうことがあります。これを避けるために、開発者にはいくつかのオプションがあります。 -1. Use an `img` element without any lazy loading. `ion-img` always uses lazy loading, but `img` does not use lazy loading by default. This is the simplest option and works well if you have small images that do not significantly benefit from lazy loading. +1. 遅延読み込みを行わない `img` 要素を使用します。`ion-img` は常に遅延読み込みを使用しますが、`img` はデフォルトでは遅延読み込みを使用しません。これは最も単純なオプションで、遅延読み込みの恩恵をあまり受けない小さな画像を使用する場合に有効です。 -2. Set a minimum width and height on `ion-img`. If you need to use lazy loading and know the dimensions of the images ahead of time (such as if you are loading icons of the same size), you can set the `ion-img` to have a minimum width or height using CSS. This gives developers the benefit of lazy loading while avoiding layout shifts. This works when using an `img` element with `loading="lazy"` too! +2. `ion-img` に最小の幅と高さを設定します。遅延読み込みを使用する必要があり、前もって画像の寸法がわかっている場合(同じサイズのアイコンを読み込む場合など)、CSS を使用して `ion-img` に最小限の幅または高さを設定することができます。これにより、開発者はレイアウトの崩れを防ぎつつ、遅延ロードの恩恵を受けることができます。これは、 `img` 要素を `loading="lazy"` と共に使用する場合にも有効です! -3. If neither of these options are applicable, developers may want to consider disabling animations altogether by using the `animated` property on [ion-accordion-group](./accordion-group). +3. これらの解決方法を選択できない場合、開発者は [ion-accordion-group](./accordion-group) の `animated` プロパティを使用してアニメーションを完全に無効にすることを検討することができます。 -## Properties +## プロパティ -## Events +## イベント -## Methods +## メソッド ## CSS Shadow Parts -## CSS Custom Properties +## CSSカスタムプロパティ ## Slots diff --git a/docs/api/action-sheet.md b/docs/api/action-sheet.md index 42113201f7a..441cda46e30 100644 --- a/docs/api/action-sheet.md +++ b/docs/api/action-sheet.md @@ -1,52 +1,75 @@ --- title: "ion-action-sheet" -hide_table_of_contents: true -demoUrl: "/docs/demos/api/action-sheet/index.html" -demoSourceUrl: "https://github.com/ionic-team/ionic-docs/tree/main/static/demos/api/action-sheet/index.html" --- import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -import Props from '@site/static/auto-generated/action-sheet/props.md'; -import Events from '@site/static/auto-generated/action-sheet/events.md'; -import Methods from '@site/static/auto-generated/action-sheet/methods.md'; -import Parts from '@site/static/auto-generated/action-sheet/parts.md'; -import CustomProps from '@site/static/auto-generated/action-sheet/custom-props.md'; -import Slots from '@site/static/auto-generated/action-sheet/slots.md'; +import Props from '@ionic-internal/component-api/v8/action-sheet/props.md'; +import Events from '@ionic-internal/component-api/v8/action-sheet/events.md'; +import Methods from '@ionic-internal/component-api/v8/action-sheet/methods.md'; +import Parts from '@ionic-internal/component-api/v8/action-sheet/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/action-sheet/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/action-sheet/slots.md'; - ion-action-sheet | Action Sheet Dialog for iOS and Android Apps - + ion-action-sheet: Action Sheet Dialog for iOS and Android + import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; -

Contents

- +Action Sheetは複数の選択肢を表示するダイアログです。アプリのコンテンツ上に表示され、ユーザが手動で破棄しないとアプリの利用を再開することはできません。`ios` modeでは、破壊的な選択肢は明示されます(コンテンツの削除などは赤字などでわかりやすく表示されます)。Action Sheetを破棄するには、背景をタップする、デスクトップのパソコンの場合はエスケープキーを押すなど、複数の選択肢があります。 +## インラインアクションシート (推奨) +`ion-action-sheet` は、テンプレートに直接コンポーネントを記述することで使用することができます。これにより、アクションシートを表示するために配線する必要があるハンドラの数を減らすことができます。 -An Action Sheet is a dialog that displays a set of options. It appears on top of the app's content, and must be manually dismissed by the user before they can resume interaction with the app. Destructive options are made obvious in `ios` mode. There are multiple ways to dismiss the action sheet, including tapping the backdrop or hitting the escape key on desktop. +import Trigger from '@site/static/usage/v8/action-sheet/inline/trigger/index.md'; + + + +### `isOpen` を使う + +`ion-action-sheet` の `isOpen` プロパティは、開発者がアプリケーションの状態からアクションシートの表示状態を制御することを可能にします。つまり、`isOpen`が`true`に設定されるとアクションシートが表示され、`isOpen`が`false`に設定されるとアクションシートは解除されます。 + +`isOpen` は一方通行のデータバインディングを使用しているため、アクションシートが終了したときに自動的に `false` に設定されることはありません。開発者は `ionActionSheetDidDismiss` または `didDismiss` イベントをリッスンして `isOpen` を `false` に設定する必要があります。この理由は、`ion-action-sheet` の内部がアプリケーションの状態と密接に結合するのを防ぐためです。一方通行のデータバインディングでは、アクションシートはリアクティブ変数が提供するブーリアン値だけを気にすればよい。一方通行のデータバインディングでは、アクションシートは、ブーリアン値とリアクティブ変数の存在の両方に関心を持つ必要があります。これは、非決定的な動作につながり、アプリケーションのデバッグを困難にします。 + +import IsOpen from '@site/static/usage/v8/action-sheet/inline/isOpen/index.md'; + + + +## Controller アクションシート + +アクションシートの表示・非表示をより細かく制御したい場合は、`actionSheetController`を使用することができます。 + +import Controller from '@site/static/usage/v8/action-sheet/controller/index.md'; + + ## Buttons -A button's `role` property can either be `destructive` or `cancel`. Buttons without a role property will have the default look for the platform. Buttons with the `cancel` role will always load as the bottom button, no matter where they are in the array. All other buttons will be displayed in the order they have been added to the `buttons` array. Note: We recommend that `destructive` buttons are always the first button in the array, making them the top button. Additionally, if the action sheet is dismissed by tapping the backdrop, then it will fire the handler from the button with the cancel role. +Buttonの `role` プロパティは、 `destructive` か `cancel` のどちらかを利用できます。 roleプロパティがない場合は、プラットフォームに応じたデフォルトの外観となります。`cancel` role を持つButtonは、配列 `buttons` のどこに配置してもアクションシートの最下部に表示されます。 Note: `destructive` roleをつけるButtonは、一番上のButtonとして配置することをおすすめします。また、背景をタップしてアクションシートを破棄した場合、cancel role に設定されているhandlerが実行されます。 -A button can also be passed data via the `data` property on `ActionSheetButton`. This will populate the `data` field in the return value of the `onDidDismiss` method. +Buttonは `ActionSheetButton` の `data` プロパティを介してデータを渡すこともできます。これは `onDidDismiss` メソッドの戻り値にある `data` フィールドにデータを入力します。 -## Customization +## Collecting Role Information on Dismiss -Action Sheet uses scoped encapsulation, which means it will automatically scope its CSS by appending each of the styles with an additional class at runtime. Overriding scoped selectors in CSS requires a [higher specificity](https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity) selector. +`didDismiss` イベントが発生すると、イベント詳細の `data` と `role` フィールドを使用して、アクションシートがどのように却下されたかについての情報を収集することができます。 -We recommend passing a custom class to `cssClass` in the `create` method and using that to add custom styles to the host and inner elements. This property can also accept multiple classes separated by spaces. View the [Usage](#usage) section for an example of how to pass a class using `cssClass`. +import RoleInfo from '@site/static/usage/v8/action-sheet/role-info-on-dismiss/index.md'; + + + +## テーマ + +アクションシートはscopedによるカプセル化を採用しており、実行時に各スタイルにクラスを追加することで、自動的にCSSをスコープ化します。CSSでscopedセレクタをオーバーライドするには、[higher specificity](https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity) セレクタが必要です。 + +### スタイリング + +私たちは、 `create` メソッドで `cssClass` にカスタムクラスを渡し、それを使ってホストと内部要素にカスタムスタイルを追加することをお勧めします。このプロパティは、スペースで区切られた複数のクラスを受け付けることもできます。 ```css /* DOES NOT WORK - not specific enough */ @@ -60,566 +83,216 @@ We recommend passing a custom class to `cssClass` in the `create` method and usi } ``` -Any of the defined [CSS Custom Properties](#css-custom-properties) can be used to style the Action Sheet without needing to target individual elements: +import Styling from '@site/static/usage/v8/action-sheet/theming/styling/index.md'; -```css -.my-custom-class { - --background: #e5e5e5; -} -``` + -:::note - If you are building an Ionic Angular app, the styles need to be added to a global stylesheet file. Read [Style Placement](#style-placement) in the Angular section below for more information. -::: +## CSSカスタムプロパティ +[CSSカスタムプロパティ](#css-custom-properties-1) は、個々の要素を対象とすることなく、アクションシートのスタイルに使用することができます。 -## Interfaces +import CssCustomProperties from '@site/static/usage/v8/action-sheet/theming/css-properties/index.md'; -### ActionSheetButton + -```typescript -interface ActionSheetButton { - text?: string; - role?: 'cancel' | 'destructive' | 'selected' | string; - icon?: string; - cssClass?: string | string[]; - handler?: () => boolean | void | Promise; - data?: T; -} -``` +## アクセシビリティ -### ActionSheetOptions +### Screen Readers -```typescript -interface ActionSheetOptions { - header?: string; - subHeader?: string; - cssClass?: string | string[]; - buttons: (ActionSheetButton | string)[]; - backdropDismiss?: boolean; - translucent?: boolean; - animated?: boolean; - mode?: Mode; - keyboardClose?: boolean; - id?: string; - htmlAttributes?: { [key: string]: any }; +アクションシートは、スクリーンリーダーにとって [アクセシブル](../reference/glossary#a11y) であるためにariaプロパティを設定しますが、これらのプロパティは、十分な説明になっていなかったり、アクションシートがアプリでどのように使用されているかに合っていなかったりする場合、オーバーライドすることができます。 - enterAnimation?: AnimationBuilder; - leaveAnimation?: AnimationBuilder; -} -``` +#### Role +アクションシートには `role` として [`dialog`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/dialog_role) が設定されます。ARIA仕様に合わせるためには、`aria-label`属性か`aria-labelledby`属性のどちらかを設定しなければなりません。 +#### Action Sheet の概要 -## Usage +Ionicは自動的にヘッダー要素を指すように `aria-labelledby` を設定するので、すべてのアクションシートには `header` プロパティを定義することを強く推奨します。しかし、`header`を含めない場合は、`htmlAttributes`プロパティを使って、説明的な`aria-label`を指定するか、カスタムの`aria-labelledby`値を設定することもできます。 - + -```typescript -import { Component } from '@angular/core'; -import { ActionSheetController } from '@ionic/angular'; - -@Component({ - selector: 'action-sheet-example', - templateUrl: 'action-sheet-example.html', - styleUrls: ['./action-sheet-example.css'], -}) -export class ActionSheetExample { - - constructor(public actionSheetController: ActionSheetController) {} - - async presentActionSheet() { - const actionSheet = await this.actionSheetController.create({ - header: 'Albums', - cssClass: 'my-custom-class', - buttons: [{ - text: 'Delete', - role: 'destructive', - icon: 'trash', - id: 'delete-button', - data: { - type: 'delete' - }, - handler: () => { - console.log('Delete clicked'); - } - }, { - text: 'Share', - icon: 'share', - data: 10, - handler: () => { - console.log('Share clicked'); - } - }, { - text: 'Play (open modal)', - icon: 'caret-forward-circle', - data: 'Data value', - handler: () => { - console.log('Play clicked'); - } - }, { - text: 'Favorite', - icon: 'heart', - handler: () => { - console.log('Favorite clicked'); - } - }, { - text: 'Cancel', - icon: 'close', - role: 'cancel', - handler: () => { - console.log('Cancel clicked'); - } - }] - }); - await actionSheet.present(); - - const { role, data } = await actionSheet.onDidDismiss(); - console.log('onDidDismiss resolved with role and data', role, data); - } - -} +```javascript +const actionSheet = await this.actionSheetController.create({ + htmlAttributes: { + 'aria-label': 'action sheet dialog', + }, +}); ``` + -### Style Placement - -In Angular, the CSS of a specific page is scoped only to elements of that page. Even though the Action Sheet can be presented from within a page, the `ion-action-sheet` element is appended outside of the current page. This means that any custom styles need to go in a global stylesheet file. In an Ionic Angular starter this can be the `src/global.scss` file or you can register a new global style file by [adding to the `styles` build option in `angular.json`](https://angular.io/guide/workspace-config#style-script-config). + +```javascript +const actionSheet = await this.actionSheetController.create({ + htmlAttributes: { + 'aria-label': 'action sheet dialog', + }, +}); +``` - - + ```javascript -async function presentActionSheet() { - const actionSheet = document.createElement('ion-action-sheet'); - - actionSheet.header = 'Albums'; - actionSheet.cssClass = 'my-custom-class'; - actionSheet.buttons = [{ - text: 'Delete', - role: 'destructive', - icon: 'trash', - id: 'delete-button', - data: { - type: 'delete' - }, - handler: () => { - console.log('Delete clicked'); - } - }, { - text: 'Share', - icon: 'share', - data: 10, - handler: () => { - console.log('Share clicked'); - } - }, { - text: 'Play (open modal)', - icon: 'caret-forward-circle', - data: 'Data value', - handler: () => { - console.log('Play clicked'); - } - }, { - text: 'Favorite', - icon: 'heart', - handler: () => { - console.log('Favorite clicked'); - } - }, { - text: 'Cancel', - icon: 'close', - role: 'cancel', - handler: () => { - console.log('Cancel clicked'); - } - }]; - document.body.appendChild(actionSheet); - await actionSheet.present(); - - const { role, data } = await actionSheet.onDidDismiss(); - console.log('onDidDismiss resolved with role and data', role, data); -} +useIonActionSheet({ + htmlAttributes: { + 'aria-label': 'action sheet dialog', + }, +}); ``` + + + + +```javascript +const actionSheet = await actionSheetController.create({ + htmlAttributes: { + 'aria-label': 'action sheet dialog', + }, +}); +``` + - +#### Action Sheet Buttons の概要 -```tsx -/* Using with useIonActionSheet Hook */ - -import React from 'react'; -import { - IonButton, - IonContent, - IonPage, - useIonActionSheet, -} from '@ionic/react'; - -const ActionSheetExample: React.FC = () => { - const [present, dismiss] = useIonActionSheet(); - - return ( - - - - present({ - buttons: [{ text: 'Ok' }, { text: 'Cancel' }], - header: 'Action Sheet' - }) - } - > - Show ActionSheet - - - present([{ text: 'Ok' }, { text: 'Cancel' }], 'Action Sheet') - } - > - Show ActionSheet using params - - { - present([{ text: 'Ok' }, { text: 'Cancel' }], 'Action Sheet'); - setTimeout(dismiss, 3000); - }} - > - Show ActionSheet, hide after 3 seconds - - - - ); -}; -``` +テキストを含むボタンはスクリーンリーダーによって読み取られる。ボタンがアイコンのみを含んでいる場合や、既存のテキスト以外の説明が必要な場合は、ボタンの `htmlAttributes` プロパティに `aria-label` を渡して、ラベルをボタンに割り当てる必要があります。 -```tsx -/* Using with IonActionSheet Component */ - -import React, { useState } from 'react'; -import { IonActionSheet, IonContent, IonButton } from '@ionic/react'; -import { trash, share, caretForwardCircle, heart, close } from 'ionicons/icons'; - -export const ActionSheetExample: React.FC = () => { - const [showActionSheet, setShowActionSheet] = useState(false); - - return ( - - setShowActionSheet(true)} expand="block"> - Show Action Sheet - - setShowActionSheet(false)} - cssClass='my-custom-class' - buttons={[{ - text: 'Delete', - role: 'destructive', - icon: trash, - id: 'delete-button', - data: { - type: 'delete' - }, - handler: () => { - console.log('Delete clicked'); - } - }, { - text: 'Share', - icon: share, - data: 10, - handler: () => { - console.log('Share clicked'); - } - }, { - text: 'Play (open modal)', - icon: caretForwardCircle, - data: 'Data value', - handler: () => { - console.log('Play clicked'); - } - }, { - text: 'Favorite', - icon: heart, - handler: () => { - console.log('Favorite clicked'); - } - }, { - text: 'Cancel', - icon: close, - role: 'cancel', - handler: () => { - console.log('Cancel clicked'); - } - }]} - > - - - ); -} -``` + + + +```javascript +const actionSheet = await this.actionSheetController.create({ + header: 'Header', + buttons: [ + { + icon: 'close', + htmlAttributes: { + 'aria-label': 'close', + }, + }, + ], +}); +``` + - - -```tsx -import { Component, h } from '@stencil/core'; - -import { actionSheetController } from '@ionic/core'; - -@Component({ - tag: 'action-sheet-example', - styleUrl: 'action-sheet-example.css' -}) -export class ActionSheetExample { - async presentActionSheet() { - const actionSheet = await actionSheetController.create({ - header: 'Albums', - cssClass: 'my-custom-class', - buttons: [{ - text: 'Delete', - role: 'destructive', - icon: 'trash', - id: 'delete-button', - data: { - type: 'delete' - }, - handler: () => { - console.log('Delete clicked'); - } - }, { - text: 'Share', - icon: 'share', - data: 10, - handler: () => { - console.log('Share clicked'); - } - }, { - text: 'Play (open modal)', - icon: 'caret-forward-circle', - data: 'Data value', - handler: () => { - console.log('Play clicked'); - } - }, { - text: 'Favorite', - icon: 'heart', - handler: () => { - console.log('Favorite clicked'); - } - }, { - text: 'Cancel', - icon: 'close', - role: 'cancel', - handler: () => { - console.log('Cancel clicked'); - } - }] - }); - await actionSheet.present(); - - const { role, data } = await actionSheet.onDidDismiss(); - console.log('onDidDismiss resolved with role and data', role, data); - } - - render() { - return [ - - this.presentActionSheet()}>Present Action Sheet - - ]; - } -} +```javascript +const actionSheet = await this.actionSheetController.create({ + header: 'Header', + buttons: [ + { + icon: 'close', + htmlAttributes: { + 'aria-label': 'close', + }, + }, + ], +}); ``` - + - - -```html - - - ``` -Developers can also use this component directly in their template: - -```html - - - ``` - -## Properties +## Interfaces + +### ActionSheetButton + +```typescript +interface ActionSheetButton { + text?: string; + role?: 'cancel' | 'destructive' | 'selected' | string; + icon?: string; + cssClass?: string | string[]; + id?: string; + htmlAttributes?: { [key: string]: any }; + handler?: () => boolean | void | Promise; + data?: T; +} +``` + +### ActionSheetOptions + +```typescript +interface ActionSheetOptions { + header?: string; + subHeader?: string; + cssClass?: string | string[]; + buttons: (ActionSheetButton | string)[]; + backdropDismiss?: boolean; + translucent?: boolean; + animated?: boolean; + mode?: Mode; + keyboardClose?: boolean; + id?: string; + htmlAttributes?: { [key: string]: any }; + + enterAnimation?: AnimationBuilder; + leaveAnimation?: AnimationBuilder; +} +``` + +## プロパティ -## Events +## イベント -## Methods +## メソッド ## CSS Shadow Parts -## CSS Custom Properties +## CSSカスタムプロパティ ## Slots - \ No newline at end of file + diff --git a/docs/api/alert.md b/docs/api/alert.md index 7004abbf2bb..f313ff8c8bf 100644 --- a/docs/api/alert.md +++ b/docs/api/alert.md @@ -4,134 +4,82 @@ title: "ion-alert" import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -import Props from '@site/static/auto-generated/alert/props.md'; -import Events from '@site/static/auto-generated/alert/events.md'; -import Methods from '@site/static/auto-generated/alert/methods.md'; -import Parts from '@site/static/auto-generated/alert/parts.md'; -import CustomProps from '@site/static/auto-generated/alert/custom-props.md'; -import Slots from '@site/static/auto-generated/alert/slots.md'; +import Props from '@ionic-internal/component-api/v8/alert/props.md'; +import Events from '@ionic-internal/component-api/v8/alert/events.md'; +import Methods from '@ionic-internal/component-api/v8/alert/methods.md'; +import Parts from '@ionic-internal/component-api/v8/alert/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/alert/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/alert/slots.md'; - ion-alert: Ionic API Alert Buttons with Custom Message Prompts - + ion-alert: Ionic Alert Buttons with Custom Message Prompts + import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; +アラートは、ユーザーに情報を提示したり、Inputを使ってユーザーから情報を収集したりするダイアログである。アラートはアプリのコンテンツの上に表示され、アプリとの対話を再開する前に、ユーザーが手動で解除する必要があります。また、オプションで `header`、`subHeader`、`message` を持つことができます。 +## インラインアラート(推奨) -An Alert is a dialog that presents users with information or collects information from the user using inputs. An alert appears on top of the app's content, and must be manually dismissed by the user before they can resume interaction with the app. It can also optionally have a `header`, `subHeader` and `message`. +`ion-alert` は、テンプレートに直接コンポーネントを記述して使用することができます。これにより、アラートを表示するために必要なハンドラの数を減らすことができます。 -## Presenting +import Trigger from '@site/static/usage/v8/alert/presenting/trigger/index.md'; -### Controller + -import Controller from '@site/static/usage/alert/presenting/controller/index.md'; +### `isOpen` を使う - +`ion-alert` の `isOpen` プロパティは、開発者がアプリケーションの状態からアラートの表示状態を制御することを可能にします。つまり、`isOpen` を `true` に設定するとアラートが表示され、`isOpen` を `false` に設定するとアラートは解除されます。 -### Inline +`isOpen` は一方通行のデータバインディングを使用しているため、アラートが解除されたときに自動的に `false` に設定されることはありません。開発者は `ionAlertDidDismiss` または `didDismiss` イベントを待ち、`isOpen` を `false` に設定する必要があります。この理由は、`ion-alert` の内部がアプリケーションの状態と密接に結合するのを防ぐためである。一方通行のデータバインディングでは、アラートはリアクティブ変数が提供するブーリアン値だけを気にすればよい。双方向のデータバインディングでは、アラートはブーリアン値とリアクティブ変数の存在の両方に関心を持つ必要があります。これは、非決定的な動作につながり、アプリケーションのデバッグを困難にする可能性があります。 -When using Ionic with React or Vue, `ion-alert` can also be placed directly in the template through use of the `isOpen` property. Note that `isOpen` must be set to `false` manually when the alert is dismissed; it will not be updated automatically. +import IsOpen from '@site/static/usage/v8/alert/presenting/isOpen/index.md'; - - + -```tsx -import React, { useState } from 'react'; -import { IonAlert, IonButton, IonContent } from '@ionic/react'; - -function Example() { - const [showAlert, setShowAlert] = useState(false); - - return ( - - setShowAlert(true)}>Click Me - setShowAlert(false)} - header="Alert" - subHeader="Important message" - message="This is an alert!" - buttons={['OK']} - /> - - ); -} -``` +## Controller Alerts - - +`alertController`は、アラートを表示するタイミングや解除するタイミングをより細かく制御する必要がある場合に使用することができる。 -```html - - - -``` +import Controller from '@site/static/usage/v8/alert/presenting/controller/index.md'; - - + ## Buttons -In the array of `buttons`, each button includes properties for its `text`, and optionally a `handler`. If a handler returns `false` then the alert will not automatically be dismissed when the button is clicked. All buttons will show up in the order they have been added to the `buttons` array from left to right. Note: The right most button (the last one in the array) is the main button. +`buttons` の配列には、各buttonの `text` のプロパティと、オプションで `handler` を利用することができます。 `handler` が `false` を返した場合、buttonがクリックされてもAlertは自動的に解除されません。すべての `buttons` は、左から右にボタン配列に追加された順序で表示されます。 Note: 一番右のボタン(配列の最後の1つ)がメインボタンです。 -Optionally, a `role` property can be added to a button, such as `cancel`. If a `cancel` role is on one of the buttons, then if the alert is dismissed by tapping the backdrop, then it will fire the handler from the button with a cancel role. +オプションで、`cancel`のような `role` プロパティをボタンに追加することができます。もし `cancel` ロールがボタンのいずれかに設定されている場合、バックドロップをタップしてアラートが解除されると、キャンセルロールを持つボタンから handler が起動されます。 -import Buttons from '@site/static/usage/alert/buttons/index.md'; +import Buttons from '@site/static/usage/v8/alert/buttons/index.md'; ## Inputs -Alerts can also include several different inputs whose data can be passed back to the app. Inputs can be used as a simple way to prompt users for information. Radios, checkboxes and text inputs are all accepted, but they cannot be mixed. For example, an alert could have all radio button inputs, or all checkbox inputs, but the same alert cannot mix radio and checkbox inputs. Do note however, different types of "text" inputs can be mixed, such as `url`, `email`, `text`, `textarea` etc. If you require a complex form UI which doesn't fit within the guidelines of an alert then we recommend building the form within a modal instead. +Alertには、複数の異なるInputを含めることもでき、そのデータをアプリで受け取ることができます。 Inputはユーザーに情報の入力を促す簡単な方法として使用できます。Radios, checkboxes と text inputs textarea はすべて利用できますが、これらを混ぜて利用することはできません。例えば、Alertはすべてbutton Inputであったり、すべてcheckboxでのInputを持つことはできますが、同一のAlertにradioとcheckbox Inputを混ぜることはできません。ただし、"text" Inputでは、 `url`, `email`, `text` などの複数のtypeを混ぜて利用することはできます。アラートのガイドラインに収まらない複雑なForm UIが必要な場合は、代わりにModal内でFormを構築することをお勧めします。 ### Text Inputs Example -import TextInputs from '@site/static/usage/alert/inputs/text-inputs/index.md'; +import TextInputs from '@site/static/usage/v8/alert/inputs/text-inputs/index.md'; ### Radio Example -import Radios from '@site/static/usage/alert/inputs/radios/index.md'; +import Radios from '@site/static/usage/v8/alert/inputs/radios/index.md'; -## Customization +## カスタマイズ -Alert uses scoped encapsulation, which means it will automatically scope its CSS by appending each of the styles with an additional class at runtime. Overriding scoped selectors in CSS requires a [higher specificity](https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity) selector. +Alertはscopedによるカプセル化を使用しており、実行時に各スタイルにクラスを追加することで自動的にCSSをスコープします。CSSでscopedセレクタをオーバーライドするには、[higher specificity](https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity) セレクタが必要です。 -We recommend passing a custom class to `cssClass` in the `create` method and using that to add custom styles to the host and inner elements. This property can also accept multiple classes separated by spaces. +`create` メソッドで `cssClass` にカスタムクラスを渡し、それを使ってホストと内部要素にカスタムスタイルを追加することをお勧めします。このプロパティは、スペースで区切られた複数のクラスを受け付けることもできます。 ```css /* DOES NOT WORK - not specific enough */ @@ -145,7 +93,7 @@ We recommend passing a custom class to `cssClass` in the `create` method and usi } ``` -Any of the defined [CSS Custom Properties](#css-custom-properties) can be used to style the Alert without needing to target individual elements: +[CSSカスタムプロパティ](#css-custom-properties) は、個々の要素をターゲットにすることなく、アラートのスタイルに使用することができます。 ```css .my-custom-class { @@ -153,25 +101,183 @@ Any of the defined [CSS Custom Properties](#css-custom-properties) can be used t } ``` -import Customization from '@site/static/usage/alert/customization/index.md'; +import Customization from '@site/static/usage/v8/alert/customization/index.md'; :::note - If you are building an Ionic Angular app, the styles need to be added to a global stylesheet file. +IonicのAngularアプリを構築する場合、スタイルはグローバルなスタイルシートファイルに追加する必要があります。 ::: +## アクセシビリティ + +### Screen Readers + +アラートは、スクリーンリーダーにとって[アクセシブル](../reference/glossary#a11y)であるために、ariaプロパティを設定しますが、これらのプロパティは、十分な説明がない場合、またはアラートがアプリでどのように使用されているかと一致しない場合は、オーバーライドすることができます。 + +#### Role + +Ionicは自動的にアラートの`role`を、入力やボタンがある場合は[`alertdialog`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/alertdialog_role)に、何もない場合は[`alert`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/alert_role)に設定します。 + +#### Alert の概要 + +アラートに `header` プロパティが定義されている場合、`aria-labelledby` 属性は自動的にヘッダの ID に設定されます。 `header` が定義されていない場合、`subHeader` 要素がフォールバックとして使用されます。同様に、 `aria-describedby` 属性が定義されている場合は、自動的に `message` 要素の ID が設定されます。 + +ARIAの仕様に合わせるために、アラートには `message` と `header` または `subHeader` を含めることを強くお勧めします。もし `header` や `subHeader` を含めない場合は、`htmlAttributes` プロパティを使用して、説明的な `aria-label` を指定することができます。 + + + + + +```javascript +const alert = await this.alertController.create({ + message: 'This is an alert with custom aria attributes.', + htmlAttributes: { + 'aria-label': 'alert dialog', + }, +}); +``` + + + + + +```javascript +const alert = await this.alertController.create({ + message: 'This is an alert with custom aria attributes.', + htmlAttributes: { + 'aria-label': 'alert dialog', + }, +}); +``` + + + + + +```javascript +useIonAlert({ + message: 'This is an alert with custom aria attributes.', + htmlAttributes: { + 'aria-label': 'alert dialog', + }, +}); +``` + + + + + +```javascript +const alert = await alertController.create({ + message: 'This is an alert with custom aria attributes.', + htmlAttributes: { + 'aria-label': 'alert dialog', + }, +}); +``` + + + + + + +すべてのARIA属性は、アラートの`htmlAttributes`プロパティにカスタム値を定義することで、手動で上書きすることができます。 + +#### Alert Buttons の概要 + +Buttons containing text will be read by a screen reader. If a description other than the existing text is desired, a label can be set on the button by passing `aria-label` to the `htmlAttributes` property on the button. + + + + + +```javascript +const alert = await this.alertController.create({ + header: 'Header', + buttons: [ + { + text: 'Exit', + htmlAttributes: { + 'aria-label': 'close', + }, + }, + ], +}); +``` + + + + + +```javascript +const alert = await this.alertController.create({ + header: 'Header', + buttons: [ + { + text: 'Exit', + htmlAttributes: { + 'aria-label': 'close', + }, + }, + ], +}); +``` + + + + + +```javascript +useIonAlert({ + header: 'Header', + buttons: [ + { + text: 'Exit', + htmlAttributes: { + 'aria-label': 'close', + }, + }, + ], +}); +``` + + + + + +```javascript +const alert = await alertController.create({ + header: 'Header', + buttons: [ + { + text: 'Exit', + htmlAttributes: { + 'aria-label': 'close', + }, + }, + ], +}); +``` + + + + ## Interfaces ### AlertButton ```typescript +type AlertButtonOverlayHandler = boolean | void | { [key: string]: any }; + interface AlertButton { text: string; role?: 'cancel' | 'destructive' | string; cssClass?: string | string[]; - handler?: (value: any) => boolean | void | {[key: string]: any}; + id?: string; + htmlAttributes?: { [key: string]: any }; + handler?: (value: any) => AlertButtonOverlayHandler | Promise; } ``` @@ -184,6 +290,9 @@ interface AlertInput { name?: string; placeholder?: string; value?: any; + /** + * The label text to display next to the input, if the input type is `radio` or `checkbox`. + */ label?: string; checked?: boolean; disabled?: boolean; @@ -222,20 +331,20 @@ interface AlertOptions { } ``` -## Properties +## プロパティ -## Events +## イベント -## Methods +## メソッド ## CSS Shadow Parts -## CSS Custom Properties +## CSSカスタムプロパティ ## Slots - \ No newline at end of file + diff --git a/docs/api/app.md b/docs/api/app.md index 2e0645a063d..32602254b86 100644 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -1,55 +1,53 @@ --- title: "ion-app" -hide_table_of_contents: true --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - -import Props from '@site/static/auto-generated/app/props.md'; -import Events from '@site/static/auto-generated/app/events.md'; -import Methods from '@site/static/auto-generated/app/methods.md'; -import Parts from '@site/static/auto-generated/app/parts.md'; -import CustomProps from '@site/static/auto-generated/app/custom-props.md'; -import Slots from '@site/static/auto-generated/app/slots.md'; +import Props from '@ionic-internal/component-api/v8/app/props.md'; +import Events from '@ionic-internal/component-api/v8/app/events.md'; +import Methods from '@ionic-internal/component-api/v8/app/methods.md'; +import Parts from '@ionic-internal/component-api/v8/app/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/app/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/app/slots.md'; ion-app: Container Element for an Ionic Application - + import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; - - -

Contents

+AppはIonicアプリケーションのコンテナ要素です。1つのプロジェクトにつき``要素は1つだけです。アプリはメニュー、ヘッダー、コンテンツ、フッターなど多くのIonicコンポーネントを持つことができます。オーバーレイコンポーネントは表示時に `` に追加されます。 - +`ion-app`を使用すると、以下の動作が可能になります。 +* [キーボードライフサイクルイベント](../developing/keyboard#keyboard-lifecycle-events) は、ネイティブプラグインを必要なくなります。 +* Android 端末のハードウェアバックボタンの動作をカスタマイズするための [Hardware Back Button Listeners](../developing/hardware-back-button) を使えます +* Capacitor や Cordova でステータスバーをサポートし、ステータスバーをタップすることでビューの最上部にスクロールできるようになります。 +* テキスト入力が画面上のキーボードにかからないように、コンテンツをスクロールさせるスクロールアシストユーティリティが使えます。 +* Material Design モードでのボタン操作時の[Ripple effect](./リップルエフェクト) が使えます。 +* Ionicアプリの使用感をよりネイティブなものにする、その他のタップやフォーカスのユーティリティが使えます。 +## Programmatic Focus -App is a container element for an Ionic application. There should only be one `` element per project. An app can have many Ionic components including menus, headers, content, and footers. The overlay components get appended to the `` when they are presented. +Ionic offers focus utilities for components with the `ion-focusable` class. These utilities automatically manage focus for components when certain keyboard keys, like Tab, are pressed. Components can also be programmatically focused in response to user actions using the `setFocus` method from `ion-app`. +import SetFocus from '@site/static/usage/v8/app/set-focus/index.md'; + -## Properties +## プロパティ -## Events +## イベント -## Methods +## メソッド ## CSS Shadow Parts -## CSS Custom Properties +## CSSカスタムプロパティ ## Slots - \ No newline at end of file + diff --git a/docs/api/avatar.md b/docs/api/avatar.md index 86fb904812a..9a3577b416b 100644 --- a/docs/api/avatar.md +++ b/docs/api/avatar.md @@ -1,220 +1,67 @@ --- title: "ion-avatar" -hide_table_of_contents: true -demoUrl: "/docs/demos/api/avatar/index.html" -demoSourceUrl: "https://github.com/ionic-team/ionic-docs/tree/main/static/demos/api/avatar/index.html" --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; -import Props from '@site/static/auto-generated/avatar/props.md'; -import Events from '@site/static/auto-generated/avatar/events.md'; -import Methods from '@site/static/auto-generated/avatar/methods.md'; -import Parts from '@site/static/auto-generated/avatar/parts.md'; -import CustomProps from '@site/static/auto-generated/avatar/custom-props.md'; -import Slots from '@site/static/auto-generated/avatar/slots.md'; +import Props from '@ionic-internal/component-api/v8/avatar/props.md'; +import Events from '@ionic-internal/component-api/v8/avatar/events.md'; +import Methods from '@ionic-internal/component-api/v8/avatar/methods.md'; +import Parts from '@ionic-internal/component-api/v8/avatar/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/avatar/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/avatar/slots.md'; ion-avatar: Circular Application Avatar Icon Component - + import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; -

Contents

+Avatarは通常、写真やアイコンをラップする円形のコンポーネントです。これらは、人またはオブジェクトを表示するために使用できます。 - +Avatarは、単独で使用することも、任意の要素の内部で使用することもできます。`ion-chip` または `ion-item` の内部に配置すると、Avatarは親コンポーネントに合わせてサイズ変更します。Avatarをitemの左側または右側に配置するには、`slot` を `start` か `end` に設定します。 +## 基本的な使い方 +import Basic from '@site/static/usage/v8/avatar/basic/index.md'; -Avatars are circular components that usually wrap an image or icon. They can be used to represent a person or an object. + -Avatars can be used by themselves or inside of any element. If placed inside of an `ion-chip` or `ion-item`, the avatar will resize to fit the parent component. To position an avatar on the left or right side of an item, set the slot to `start` or `end`, respectively. +## Chip Avatar +import Chip from '@site/static/usage/v8/avatar/chip/index.md'; + +## Item Avatar -## Usage +import Item from '@site/static/usage/v8/avatar/item/index.md'; - + - +## テーマ -```html - - - +## CSSカスタムプロパティ - - - - - Chip Avatar - +import CSSProps from '@site/static/usage/v8/avatar/theming/css-properties/index.md'; - - - - - Item Avatar - -``` + - - - - - -```html - - - - - - - - - Chip Avatar - - - - - - - Item Avatar - -``` - - - - - - -```tsx -import React from 'react'; -import { IonAvatar, IonChip, IonItem, IonLabel, IonContent } from '@ionic/react'; - -export const AvatarExample: React.FC = () => ( - - - - - - - - - - Chip Avatar - - - - - - - Item Avatar - - -); -``` - - - - - - -```tsx -import { Component, h } from '@stencil/core'; - -@Component({ - tag: 'avatar-example', - styleUrl: 'avatar-example.css' -}) -export class AvatarExample { - render() { - return [ - - - , - - - - - - Chip Avatar - , - - - - - - Item Avatar - - ]; - } -} -``` - - - - - - -```html - - - -``` - - - - - -## Properties +## プロパティ -## Events +## イベント -## Methods +## メソッド ## CSS Shadow Parts -## CSS Custom Properties +## CSSカスタムプロパティ ## Slots - \ No newline at end of file + diff --git a/docs/api/back-button.md b/docs/api/back-button.md index 615a04c61ee..a3b9e954761 100644 --- a/docs/api/back-button.md +++ b/docs/api/back-button.md @@ -1,372 +1,57 @@ --- title: "ion-back-button" -hide_table_of_contents: true -demoUrl: "/docs/demos/api/back-button/index.html" -demoSourceUrl: "https://github.com/ionic-team/ionic-docs/tree/main/static/demos/api/back-button/index.html" --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - -import Props from '@site/static/auto-generated/back-button/props.md'; -import Events from '@site/static/auto-generated/back-button/events.md'; -import Methods from '@site/static/auto-generated/back-button/methods.md'; -import Parts from '@site/static/auto-generated/back-button/parts.md'; -import CustomProps from '@site/static/auto-generated/back-button/custom-props.md'; -import Slots from '@site/static/auto-generated/back-button/slots.md'; +import Props from '@ionic-internal/component-api/v8/back-button/props.md'; +import Events from '@ionic-internal/component-api/v8/back-button/events.md'; +import Methods from '@ionic-internal/component-api/v8/back-button/methods.md'; +import Parts from '@ionic-internal/component-api/v8/back-button/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/back-button/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/back-button/slots.md'; - Back Button | ion-back-button: Custom Menu Icon for Applications - + ion-back-button: Custom Menu Back Button for Applications + import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; -

Contents

- - - - - -The back button navigates back in the app's history upon click. It is smart enough to know what to render based on the mode and when to show based on the navigation stack. - -To change what is displayed in the back button, use the `text` and `icon` properties. - - - - -## Usage - - - - - -```html - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -``` - - - - - - -```html - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -``` - - - - - - -```tsx -import React from 'react'; -import { IonBackButton, IonHeader, IonToolbar, IonButtons, IonMenuButton, IonContent } from '@ionic/react'; - -export const BackButtonExample: React.FC = () => ( - - {/*-- Default back button --*/} - - - - - - - - - {/*-- Back button with a default href --*/} - - - - - - - - - {/*-- Back button with custom text and icon --*/} - - - - - - - - - {/*-- Back button with no text and custom icon --*/} - - - - - - - - - {/*-- Danger back button next to a menu button --*/} - - - - - - - - - -); -``` - - - - - - -```tsx -import { Component, h } from '@stencil/core'; - -@Component({ - tag: 'back-button-example', - styleUrl: 'back-button-example.css' -}) -export class BackButtonExample { - render() { - const buttonText = "Custom"; - const buttonIcon = "add"; - - return [ - // Default back button - - - - - - - , - - // Back button with a default href - - - - - - - , - - // Back button with custom text and icon - - - - - - - - , - - // Back button with no text and custom icon - - - - - - - , - - // Danger back button next to a menu button - - - - - - - - - ]; - } -} -``` - - - - +Back Buttonは、クリックされるとアプリの履歴に戻るようにナビゲートします。このボタンは、ナビゲーションスタックに履歴があるときのみ表示されます。ただし、 [`defaultHref`](#default-back-history) が設定されている場合は除きます。戻るボタンはモードに応じて異なるテキストとアイコンを表示しますが、これはカスタマイズすることができます。 -```html - +デフォルトでは、Back Buttonはテキスト `"Back"` と共に、`ios` では `"chevron-back"` アイコン、`md` では `"arrow-back-sharp"` アイコンを表示します。これは、`icon`または`text`プロパティを設定することで、戻るボタンコンポーネントごとにカスタマイズすることができます。また、グローバル設定の `backButtonIcon` または `backButtonText` プロパティを使用して、グローバルに設定することもできます。詳しくは、[Config docs](../developing/config) を参照してください。 - -``` + - +## デフォルトのBack履歴 - +時折、アプリが履歴がないときに戻るボタンを表示し、ナビゲートする必要がある場合があります。この場合、戻るボタンの `defaultHref` をパスに設定することで実現できます。 `defaultHref` を使用するには、アプリにパスが設定されたルーターが含まれている必要があります。 -## Properties +## プロパティ -## Events +## イベント -## Methods +## メソッド ## CSS Shadow Parts -## CSS Custom Properties +## CSSカスタムプロパティ ## Slots - \ No newline at end of file + diff --git a/docs/api/backdrop.md b/docs/api/backdrop.md index 177cd990b0d..3ac77c97296 100644 --- a/docs/api/backdrop.md +++ b/docs/api/backdrop.md @@ -1,245 +1,50 @@ --- title: "ion-backdrop" -hide_table_of_contents: true -demoUrl: "/docs/demos/api/backdrop/index.html" -demoSourceUrl: "https://github.com/ionic-team/ionic-docs/tree/main/static/demos/api/backdrop/index.html" --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - -import Props from '@site/static/auto-generated/backdrop/props.md'; -import Events from '@site/static/auto-generated/backdrop/events.md'; -import Methods from '@site/static/auto-generated/backdrop/methods.md'; -import Parts from '@site/static/auto-generated/backdrop/parts.md'; -import CustomProps from '@site/static/auto-generated/backdrop/custom-props.md'; -import Slots from '@site/static/auto-generated/backdrop/slots.md'; - - +import Props from '@ionic-internal/component-api/v8/backdrop/props.md'; +import Events from '@ionic-internal/component-api/v8/backdrop/events.md'; +import Methods from '@ionic-internal/component-api/v8/backdrop/methods.md'; +import Parts from '@ionic-internal/component-api/v8/backdrop/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/backdrop/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/backdrop/slots.md'; import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; -

Contents

- - - - - -Backdrops are full screen components that overlay other components. They are useful behind components that transition in on top of other content and can be used to dismiss that component. - - - - -## Usage - - - - - -```html - - - - - - - - - - - - - - - -``` - -```typescript -import { Component } from '@angular/core'; - -@Component({ - selector: 'backdrop-example', - templateUrl: 'backdrop-example.html', - styleUrls: ['./backdrop-example.css'], -}) -export class BackdropExample { - enableBackdropDismiss = false; - showBackdrop = false; - shouldPropagate = false; -} -``` - - - - - - - -```html - - - - - - - - - - - - - - -``` - -```javascript -var backdrop = document.getElementById('customBackdrop'); -backdrop.visible = false; -backdrop.tappable = false; -backdrop.stopPropagation = false; -``` - - - - - - -```tsx -import React from 'react'; -import { IonBackdrop, IonContent } from '@ionic/react'; - -export const BackdropExample: React.FC = () => ( - - {/*-- Default backdrop --*/} - - - {/*-- Backdrop that is not tappable --*/} - - - {/*-- Backdrop that is not visible --*/} - - - {/*-- Backdrop with propagation --*/} - - - - -); -``` - - - - - - - -```tsx -import { Component, h } from '@stencil/core'; - -@Component({ - tag: 'backdrop-example', - styleUrl: 'backdrop-example.css' -}) -export class BackdropExample { - render() { - const enableBackdropDismiss = false; - const showBackdrop = false; - const shouldPropagate = false; - - return [ - // Default backdrop - , - - // Backdrop that is not tappable - , - - // Backdrop that is not visible - , - - // Backdrop with propagation - , - - // Backdrop that sets dynamic properties - - - ]; - } -} -``` - - - - - +Backdropは、他のコンポーネントをオーバーレイするためフルスクリーンのコンポーネントです。これらは、他のコンテンツの上に遷移するコンポーネントのバックグラウンドで役立ち、そのコンポーネントを削除するために使用できます。 -```html - +## スタイリング - -``` +コンテンツに `z-index` を設定し、背景よりも高い位置に表示させることができます(デフォルトは `2` です)。 - +import Styling from '@site/static/usage/v8/backdrop/styling/index.md'; - + -## Properties +## プロパティ -## Events +## イベント -## Methods +## メソッド ## CSS Shadow Parts -## CSS Custom Properties +## CSSカスタムプロパティ ## Slots diff --git a/docs/api/badge.md b/docs/api/badge.md index ae0de884003..c7682a087a3 100644 --- a/docs/api/badge.md +++ b/docs/api/badge.md @@ -1,234 +1,70 @@ --- title: "ion-badge" -hide_table_of_contents: true -demoUrl: "/docs/demos/api/badge/index.html" -demoSourceUrl: "https://github.com/ionic-team/ionic-docs/tree/main/static/demos/api/badge/index.html" --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - -import Props from '@site/static/auto-generated/badge/props.md'; -import Events from '@site/static/auto-generated/badge/events.md'; -import Methods from '@site/static/auto-generated/badge/methods.md'; -import Parts from '@site/static/auto-generated/badge/parts.md'; -import CustomProps from '@site/static/auto-generated/badge/custom-props.md'; -import Slots from '@site/static/auto-generated/badge/slots.md'; +import Props from '@ionic-internal/component-api/v8/badge/props.md'; +import Events from '@ionic-internal/component-api/v8/badge/events.md'; +import Methods from '@ionic-internal/component-api/v8/badge/methods.md'; +import Parts from '@ionic-internal/component-api/v8/badge/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/badge/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/badge/slots.md'; - Badges | ion-badge: iOS & Android App Notification Badge Icons - + ion-badge: iOS & Android App Notification Badge Icons + import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; -

Contents

+バッジはインラインブロック要素で、通常は他の要素の近くに表示されます。通常、数字やその他の文字が含まれています。バッジは、ある要素に関連する追加項目があることを知らせたり、その項目の数を示したりするために使用されます。バッジは、コンテンツが渡されないと非表示になります。 + +## 基本的な使い方 + +import Basic from '@site/static/usage/v8/badge/basic/index.md'; - + +## Tabボタン内のバッジ +バッジはTabボタン内に追加することができ、多くの場合、通知を示したり、要素に関連する追加項目を強調するために使用されます。 -Badges are inline block elements that usually appear near another element. Typically they contain a number or other characters. They can be used as a notification that there are additional items associated with an element and indicate how many items there are. +:::info +Empty badges are only available for `md` mode. +::: +import InsideTabBar from '@site/static/usage/v8/badge/inside-tab-bar/index.md'; + +## テーマ -## Usage +### Colors - +import Colors from '@site/static/usage/v8/badge/theming/colors/index.md'; - + -```html - -99 +### CSS Properties - -11 -22 -33 -44 -55 -66 -77 -88 -99 +import CSSProps from '@site/static/usage/v8/badge/theming/css-properties/index.md'; - - - 11 - My Item - 22 - -``` - - - - - - -```html - -99 + - -11 -22 -33 -44 -55 -66 -77 -88 -99 - - - - 11 - My Item - 22 - -``` - - - - - - -```tsx -import React from 'react'; -import { IonBadge, IonItem, IonLabel, IonContent } from '@ionic/react'; - -export const BadgeExample: React.FC = () => ( - - {/*-- Default --*/} - 99 - - {/*-- Colors --*/} - 11 - 22 - 33 - 44 - 55 - 66 - 77 - 88 - 99 - - {/*-- Item with badge on left and right --*/} - - 11 - My Item - 22 - - -); -``` - - - - - - - -```tsx -import { Component, h } from '@stencil/core'; - -@Component({ - tag: 'badge-example', - styleUrl: 'badge-example.css' -}) -export class BadgeExample { - render() { - return [ - // Default - 99, - - // Colors - 11, - 22, - 33, - 44, - 55, - 66, - 77, - 88, - 99, - - // Item with badge on left and right - - 11 - My Item - 22 - - ]; - } -} -``` - - - - - - -```html - - - -``` - - - - - -## Properties +## プロパティ -## Events +## イベント -## Methods +## メソッド ## CSS Shadow Parts -## CSS Custom Properties +## CSSカスタムプロパティ ## Slots - \ No newline at end of file + diff --git a/docs/api/breadcrumb.md b/docs/api/breadcrumb.md index 799cc91a3e7..e0e8c137690 100644 --- a/docs/api/breadcrumb.md +++ b/docs/api/breadcrumb.md @@ -1,37 +1,21 @@ --- title: "ion-breadcrumb" -hide_table_of_contents: true --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - -import Props from '@site/static/auto-generated/breadcrumb/props.md'; -import Events from '@site/static/auto-generated/breadcrumb/events.md'; -import Methods from '@site/static/auto-generated/breadcrumb/methods.md'; -import Parts from '@site/static/auto-generated/breadcrumb/parts.md'; -import CustomProps from '@site/static/auto-generated/breadcrumb/custom-props.md'; -import Slots from '@site/static/auto-generated/breadcrumb/slots.md'; - - +import Props from '@ionic-internal/component-api/v8/breadcrumb/props.md'; +import Events from '@ionic-internal/component-api/v8/breadcrumb/events.md'; +import Methods from '@ionic-internal/component-api/v8/breadcrumb/methods.md'; +import Parts from '@ionic-internal/component-api/v8/breadcrumb/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/breadcrumb/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/breadcrumb/slots.md'; import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; -

Contents

- - - - -A Breadcrumb is a single navigation item that is a child of the Breadcrumbs component. A breadcrumb can link elsewhere in an app or it can be plain text. Each breadcrumb has a separator between it and the next breadcrumb and can optionally contain an icon. +Breadcrumbは、Breadcrumbsコンポーネントの子であり、単一のナビゲーションアイテムです。Breadcrumbは、アプリ内の他の場所にリンクすることも、プレーンテキストにすることもできます。Breadcrumbsは、次のBreadcrumbとの間にセパレータを持ち、オプションでアイコンを含むことができます。 -For usage examples, see the [Breadcrumbs](/docs/api/breadcrumbs) documentation. +詳しい説明は [Breadcrumbs](./breadcrumbs) を参照ください。 ## Interfaces @@ -45,7 +29,7 @@ interface BreadcrumbCollapsedClickEventDetail { ### BreadcrumbCustomEvent -While not required, this interface can be used in place of the `CustomEvent` interface for stronger typing . +必須ではありませんが、より強い型付けのために、このインターフェースを `CustomEvent` インターフェースの代わりに使用することができます。 ```typescript interface BreadcrumbCustomEvent extends CustomEvent { @@ -57,20 +41,20 @@ interface BreadcrumbCustomEvent extends CustomEvent { -## Properties +## プロパティ -## Events +## イベント -## Methods +## メソッド ## CSS Shadow Parts -## CSS Custom Properties +## CSSカスタムプロパティ ## Slots - \ No newline at end of file + diff --git a/docs/api/breadcrumbs.md b/docs/api/breadcrumbs.md index aad5436ff2e..b00f98cd337 100644 --- a/docs/api/breadcrumbs.md +++ b/docs/api/breadcrumbs.md @@ -1,42 +1,38 @@ --- title: "ion-breadcrumbs" --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - -import Props from '@site/static/auto-generated/breadcrumbs/props.md'; -import Events from '@site/static/auto-generated/breadcrumbs/events.md'; -import Methods from '@site/static/auto-generated/breadcrumbs/methods.md'; -import Parts from '@site/static/auto-generated/breadcrumbs/parts.md'; -import CustomProps from '@site/static/auto-generated/breadcrumbs/custom-props.md'; -import Slots from '@site/static/auto-generated/breadcrumbs/slots.md'; +import Props from '@ionic-internal/component-api/v8/breadcrumbs/props.md'; +import Events from '@ionic-internal/component-api/v8/breadcrumbs/events.md'; +import Methods from '@ionic-internal/component-api/v8/breadcrumbs/methods.md'; +import Parts from '@ionic-internal/component-api/v8/breadcrumbs/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/breadcrumbs/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/breadcrumbs/slots.md'; import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; -Breadcrumbs are navigation items that are used to indicate where a user is on an app or site. They should be used for large sites and apps with hierarchically arranged pages. Breadcrumbs can be collapsed based on the maximum number that can show, and the collapsed indicator can be clicked on to present a popover with more information or expand the collapsed breadcrumbs. +Breadcrumbsは、ユーザーがアプリやサイトのどこにいるのかを示すために使用されるナビゲーションアイテムです。大規模なサイトや、階層的に配置されたページを持つアプリで使用する必要があります。Breadcrumbsは、表示可能な最大数に応じて折りたたむことができ、折りたたんだインジケータをクリックすると、詳細情報を示すポップオーバーが表示され、折りたたんだBreadcrumbを展開することができます。 -## Basic Usage +## 基本的な使い方 -import Basic from '@site/static/usage/breadcrumbs/basic/index.md'; +import Basic from '@site/static/usage/v8/breadcrumbs/basic/index.md'; ## Using Icons -### Icons on Items +### アイテムでのアイコン -import IconsOnItems from '@site/static/usage/breadcrumbs/icons/icons-on-items/index.md'; +import IconsOnItems from '@site/static/usage/v8/breadcrumbs/icons/icons-on-items/index.md'; ### Custom Separators -import CustomSeparators from '@site/static/usage/breadcrumbs/icons/custom-separators/index.md'; +import CustomSeparators from '@site/static/usage/v8/breadcrumbs/icons/custom-separators/index.md'; @@ -44,65 +40,65 @@ import CustomSeparators from '@site/static/usage/breadcrumbs/icons/custom-separa ### Max Items -If there are more items than the value of `maxItems`, the breadcrumbs will be collapsed. By default, only the first and last items will be shown. +`maxItems` の値よりも多くのアイテムがある場合、breadcrumbsは折りたたまれます。デフォルトでは、最初と最後のアイテムのみが表示されます。 -import MaxItems from '@site/static/usage/breadcrumbs/collapsing-items/max-items/index.md'; +import MaxItems from '@site/static/usage/v8/breadcrumbs/collapsing-items/max-items/index.md'; ### Items Before or After Collapse -Once the items are collapsed, the number of items to show can be controlled by the `itemsBeforeCollapse` and `itemsAfterCollapse` properties. +アイテムが折りたたまれた後、表示するアイテムの数は `itemsBeforeCollapse` と `itemsAfterCollapse` プロパティで制御することができます。 -import ItemsBeforeAfter from '@site/static/usage/breadcrumbs/collapsing-items/items-before-after/index.md'; +import ItemsBeforeAfter from '@site/static/usage/v8/breadcrumbs/collapsing-items/items-before-after/index.md'; ### Collapsed Indicator Click -- Expand Breadcrumbs -Clicking the collapsed indicator will fire the `ionCollapsedClick` event. This can be used to, for example, expand the breadcrumbs. +インジケータをクリックすると、`ionCollapsedClick` イベントが発生します。これは、例えば、breadcrumbsを展開するために使うことができます。 -import ExpandOnClick from '@site/static/usage/breadcrumbs/collapsing-items/expand-on-click/index.md'; +import ExpandOnClick from '@site/static/usage/v8/breadcrumbs/collapsing-items/expand-on-click/index.md'; ### Collapsed Indicator Click -- Present Popover -The `ionCollapsedClick` event can also be used to present an overlay (in this case, an `ion-popover`) showing the hidden breadcrumbs. +また、`ionCollapsedClick` イベントは、隠されたパンくずを表示するオーバーレイ(この場合は `ion-popover` )を提示するために使用することができます。 -import PopoverOnClick from '@site/static/usage/breadcrumbs/collapsing-items/popover-on-click/index.md'; +import PopoverOnClick from '@site/static/usage/v8/breadcrumbs/collapsing-items/popover-on-click/index.md'; -## Styling +## テーマ -## Color Property +### Colors -import ColorProp from '@site/static/usage/breadcrumbs/styling/color/index.md'; +import Colors from '@site/static/usage/v8/breadcrumbs/theming/colors/index.md'; - + -## CSS Properties +## CSSカスタムプロパティ -import CSSProps from '@site/static/usage/breadcrumbs/styling/css-props/index.md'; +import CSSProps from '@site/static/usage/v8/breadcrumbs/theming/css-properties/index.md'; -## Properties +## プロパティ -## Events +## イベント -## Methods +## メソッド ## CSS Shadow Parts -## CSS Custom Properties +## CSSカスタムプロパティ ## Slots - \ No newline at end of file + diff --git a/docs/api/button.md b/docs/api/button.md index 2831df0f112..5490dc07c4c 100644 --- a/docs/api/button.md +++ b/docs/api/button.md @@ -1,411 +1,115 @@ --- title: "ion-button" -hide_table_of_contents: true -demoUrl: "/docs/demos/api/button/index.html" -demoSourceUrl: "https://github.com/ionic-team/ionic-docs/tree/main/static/demos/api/button/index.html" --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - -import Props from '@site/static/auto-generated/button/props.md'; -import Events from '@site/static/auto-generated/button/events.md'; -import Methods from '@site/static/auto-generated/button/methods.md'; -import Parts from '@site/static/auto-generated/button/parts.md'; -import CustomProps from '@site/static/auto-generated/button/custom-props.md'; -import Slots from '@site/static/auto-generated/button/slots.md'; +import Props from '@ionic-internal/component-api/v8/button/props.md'; +import Events from '@ionic-internal/component-api/v8/button/events.md'; +import Methods from '@ionic-internal/component-api/v8/button/methods.md'; +import Parts from '@ionic-internal/component-api/v8/button/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/button/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/button/slots.md'; - ion-button: Design and Style Buttons with Custom CSS Properties - + ion-button: Style Buttons with Custom CSS Properties + import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; -

Contents

- - +Buttonはクリック可能な要素を提供し、Form内や、標準の単機能なButton機能を必要とする任意の場所で使用できます。text、icon、またはその両方を表示できます。Buttonは、いくつかの属性を利用して特定の外観になるようにスタイル設定できます。 +## 基本的な使い方 +import Basic from '@site/static/usage/v8/button/basic/index.md'; -Buttons provide a clickable element, which can be used in forms, or anywhere that needs simple, standard button functionality. They may display text, icons, or both. Buttons can be styled with several attributes to look a specific way. + ## Expand -This attribute lets you specify how wide the button should be. By default, buttons are inline blocks, but setting this attribute will change the button to a full-width block element. +このプロパティでは、ボタンの幅を指定することができます。デフォルトでは、ボタンは `display: inline-block` を持ちますが、このプロパティを設定すると、ボタンは `display: block` を持つ全角要素に変更されます。 -| Value | Details | -|----------------|------------------------------------------------------------------------------| -| `block` | Full-width button with rounded corners. | -| `full` | Full-width button with square corners and no border on the left or right. | - -## Fill +import Expand from '@site/static/usage/v8/button/expand/index.md'; -This attribute determines the background and border color of the button. By default, buttons have a solid background unless the button is inside of a toolbar, in which case it has a transparent background. - -| Value | Details | -|----------------|------------------------------------------------------------------------------| -| `clear` | Button with a transparent background that resembles a flat button. | -| `outline` | Button with a transparent background and a visible border. | -| `solid` | Button with a filled background. Useful for buttons in a toolbar. | - -## Size + -This attribute specifies the size of the button. Setting this attribute will change the height and padding of a button. +## Shape -| Value | Details | -|----------------|------------------------------------------------------------------------------| -| `small` | Button with less height and padding. Default for buttons in an item. | -| `default` | Button with the default height and padding. Useful for buttons in an item. | -| `large` | Button with more height and padding. | +このプロパティは、ボタンの形状を指定することができます。デフォルトでは、ボタンは小さなボーダー半径を持つ長方形ですが、これを `"round"` に設定すると、ボタンは丸みを帯びた要素に変更されます。 +import Shape from '@site/static/usage/v8/button/shape/index.md'; + -## Usage - - - - - - -```html - -Default +## Fill - -Anchor +この属性は、Buttonのbackgroundとborder-colorを設定します。デフォルトでは、Buttonはtoolbar内にない限り、backgroundは塗りつぶされます。toolbar内にある場合は、backgroundは透明になります。 - -Primary -Secondary -Tertiary -Success -Warning -Danger -Light -Medium -Dark +import Fill from '@site/static/usage/v8/button/fill/index.md'; - -Full Button -Block Button + - -Round Button +## Size - -Outline + Full -Outline + Block -Outline + Round +この属性は、Buttonのサイズを指定します。この属性を設定すると、Buttonの高さとpaddingが変更されます - - - - Left Icon - +import Size from '@site/static/usage/v8/button/size/index.md'; - - Right Icon - - + - - - +## Icons - -Large -Default -Small -``` +import Icons from '@site/static/usage/v8/button/icons/index.md'; + - +## テーマ +### Colors - +import Colors from '@site/static/usage/v8/button/theming/colors/index.md'; + -```html - -Default +## CSSカスタムプロパティ - -Anchor +import CSSProps from '@site/static/usage/v8/button/theming/css-properties/index.md'; - -Primary -Secondary -Tertiary -Success -Warning -Danger -Light -Medium -Dark + - -Full Button -Block Button +## アクセシビリティ - -Round Button +ボタンはアクセスしやすいように作られていますが、その内容によっては調整が必要な場合があります。ボタンコンポーネントは、ネイティブの[button element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button)をレンダリングし、ネイティブのボタンが提供する機能を利用できるようにします。 - -Outline + Full -Outline + Block -Outline + Round +### Overflowing Text Content - - - - Left Icon - +ボタンのテキスト・コンテンツがコンテナからはみ出す場合が多々あります。このような場合、すべてのテキストがまだ読めるように、ボタンの内側にテキストを折り返すことをお勧めします。ボタンコンポーネントは、テキストの余分な行を収容するために、その高さを自動的に調整します。 - - Right Icon - - +テキストが長すぎて収まらない場合、ボタンテキストは自動的に次の行に折り返されません。テキストを折り返すには、`ion-text-wrap`クラスを追加して、`white-space`プロパティを`"normal"`に設定します。これは将来のメジャーリリースでデフォルトになる予定である。 - - - - - -Large -Default -Small -``` - - - - - - - -```tsx -import React from 'react'; +:::info +max-width`スタイルは、デモのためだけに下のボタンに設定されています。テキストラッピングは動的なボタン幅で動作します。 +::: -import { IonButton, IonIcon, IonContent } from '@ionic/react'; -import { star } from 'ionicons/icons'; +import TextWrapping from '@site/static/usage/v8/button/text-wrapping/index.md'; -export const ButtonExample: React.FC = () => ( - - {/*-- Default --*/} - Default - - {/*-- Anchor --*/} - Anchor - - {/*-- Colors --*/} - Primary - Secondary - Tertiary - Success - Warning - Danger - Light - Medium - Dark - - {/*-- Expand --*/} - Full Button - Block Button - - {/*-- Round --*/} - Round Button - - {/*-- Fill --*/} - Outline + Full - Outline + Block - Outline + Round + - {/*-- Icons --*/} - - - Left Icon - - - - Right Icon - - - - - - - - {/*-- Sizes --*/} - Large - Default - Small - -); - -``` - - - - - - - -```tsx -import { Component, h } from '@stencil/core'; - -@Component({ - tag: 'button-example', - styleUrl: 'button-example.css' -}) -export class ButtonExample { - render() { - return [ - // Default - Default, - - // Anchor - Anchor, - - // Colors - Primary, - Secondary, - Tertiary, - Success, - Warning, - Danger, - Light, - Medium, - Dark, - - // Expand - Full Button, - Block Button, - - // Round - Round Button, - - // Fill - Outline + Full, - Outline + Block, - Outline + Round, - - // Icons - - - Left Icon - , - - - Right Icon - - , - - - - , - - // Sizes - Large, - Default, - Small - ]; - } -} -``` - - - - - - -```html - - - -``` - - - - - - -## Properties +## プロパティ -## Events +## イベント -## Methods +## メソッド ## CSS Shadow Parts -## CSS Custom Properties +## CSSカスタムプロパティ ## Slots - \ No newline at end of file + diff --git a/docs/api/buttons.md b/docs/api/buttons.md index 7e247b828ec..d9698da934e 100644 --- a/docs/api/buttons.md +++ b/docs/api/buttons.md @@ -1,377 +1,87 @@ --- title: "ion-buttons" -hide_table_of_contents: true --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - -import Props from '@site/static/auto-generated/buttons/props.md'; -import Events from '@site/static/auto-generated/buttons/events.md'; -import Methods from '@site/static/auto-generated/buttons/methods.md'; -import Parts from '@site/static/auto-generated/buttons/parts.md'; -import CustomProps from '@site/static/auto-generated/buttons/custom-props.md'; -import Slots from '@site/static/auto-generated/buttons/slots.md'; +import Props from '@ionic-internal/component-api/v8/buttons/props.md'; +import Events from '@ionic-internal/component-api/v8/buttons/events.md'; +import Methods from '@ionic-internal/component-api/v8/buttons/methods.md'; +import Parts from '@ionic-internal/component-api/v8/buttons/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/buttons/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/buttons/slots.md'; ion-buttons: Toolbar Element with Named Slots for Buttons - + import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; -

Contents

- +Buttonsコンポーネントは、コンテナ要素です。 [ツールバー](./toolbar) の内部で使用し、標準の[ボタン](./button)、[メニューボタン](./menu-button)、[戻るボタン](./back-button)を含むいくつかのタイプのボタンを含めることができる。 + +## 基本的な使い方 + +import Basic from '@site/static/usage/v8/buttons/basic/index.md'; + -The Buttons component is a container element. Buttons placed in a toolbar should be placed inside of the `` element. +## Buttons Placement -The `` element can be positioned inside of the toolbar using a named slot. The below chart has a description of each slot. +ツールバー内のボタンは、スロットという名前を使って配置することができます。下図は各スロットの説明です。 | Slot | Description | |--------------|----------------------------------------------------------------------------------------------------------| -| `secondary` | Positions element to the `left` of the content in `ios` mode, and directly to the `right` in `md` mode. | -| `primary` | Positions element to the `right` of the content in `ios` mode, and to the far `right` in `md` mode. | | `start` | Positions to the `left` of the content in LTR, and to the `right` in RTL. | | `end` | Positions to the `right` of the content in LTR, and to the `left` in RTL. | +| `secondary` | Positions element to the `left` of the content in `ios` mode, and directly to the `right` in `md` mode. | +| `primary` | Positions element to the `right` of the content in `ios` mode, and to the far `right` in `md` mode. | + +import Placement from '@site/static/usage/v8/buttons/placement/index.md'; + + + + +## Buttonsのタイプ + +ツールバーのボタンは、デフォルトでは透明ですが、ボタンの [`fill`](./button#fill) プロパティで変更することが可能です。この例で [バックボタン](./back-button) と [メニューボタン](./menu-button) に含まれるプロパティは表示目的であり、正しい使用方法はそれぞれのドキュメントをご覧ください。 + +import Types from '@site/static/usage/v8/buttons/types/index.md'; + + + + +## Collapsible Buttons + +ボタンに `collapse` プロパティを設定すると、ヘッダーが折りたたまれたときにボタンが折りたたまれます。これは通常、[collapsible large titles](./title#collapsible-large-titles) と共に使用します。 + +:::info + +この機能はiOS modeでのみ有効です。 + +::: + +import CollapsibleLargeTitleButtons from '@site/static/usage/v8/title/collapsible-large-title/buttons/index.md'; + -## Usage - - - - - -```html - - - - - Back Button - - - - - - - - - - - - Default Buttons - - - - - - - - - - - - - - Right side menu toggle - - - - - - - - - - - - Collapsible Buttons - -``` - - - - - - -```html - - - - - Back Button - - - - - - - - - - - - Default Buttons - - - - - - - - - - - - - - Right side menu toggle - - - - - - - - - - - - - - - - Collapsible Buttons - -``` - - - - - - -```tsx -import React from 'react'; -import { IonButtons, IonToolbar, IonBackButton, IonTitle, IonButton, IonIcon, IonMenuButton, IonContent } from '@ionic/react'; -import { personCircle, search, star, ellipsisHorizontal, ellipsisVertical } from 'ionicons/icons'; - -export const ButtonsExample: React.FC = () => ( - - - - - - Back Button - - - - - - - - - - - - Default Buttons - - - - - - - - - - {}}> - - - - Right side menu toggle - - - - - - - - - - - - Collapsible Buttons - - -); -``` - - - - - - -```tsx -import { Component, h } from '@stencil/core'; - -@Component({ - tag: 'buttons-example', - styleUrl: 'buttons-example.css' -}) -export class ButtonsExample { - - clickedStar() { - console.log("Clicked star button"); - } - - render() { - return [ - - - - - Back Button - , - - - - - - - - - - - Default Buttons - - - - - - , - - - - this.clickedStar()}> - - - - Right side menu toggle - - - - , - - - - - - - - Collapsible Buttons - - ]; - } -} -``` - - - - - - -```html - - - -``` - - - - - -## Properties +## プロパティ -## Events +## イベント -## Methods +## メソッド ## CSS Shadow Parts -## CSS Custom Properties +## CSSカスタムプロパティ ## Slots - \ No newline at end of file + diff --git a/docs/api/card-content.md b/docs/api/card-content.md index 75d361f515b..dc7e3181313 100644 --- a/docs/api/card-content.md +++ b/docs/api/card-content.md @@ -1,54 +1,35 @@ --- title: "ion-card-content" -hide_table_of_contents: true --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - -import Props from '@site/static/auto-generated/card-content/props.md'; -import Events from '@site/static/auto-generated/card-content/events.md'; -import Methods from '@site/static/auto-generated/card-content/methods.md'; -import Parts from '@site/static/auto-generated/card-content/parts.md'; -import CustomProps from '@site/static/auto-generated/card-content/custom-props.md'; -import Slots from '@site/static/auto-generated/card-content/slots.md'; - - +import Props from '@ionic-internal/component-api/v8/card-content/props.md'; +import Events from '@ionic-internal/component-api/v8/card-content/events.md'; +import Methods from '@ionic-internal/component-api/v8/card-content/methods.md'; +import Parts from '@ionic-internal/component-api/v8/card-content/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/card-content/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/card-content/slots.md'; import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; - - - -

Contents

- - - - -`ion-card-content` is child component of `ion-card` that adds some content padding. -It is recommended that any text content for a card should be placed in an `ion-card-content`. +カードコンテンツは、カードの子コンポーネントで、そのコンテンツの周りにパディングを追加します。カードのテキストコンテンツは、カードコンテンツの中に配置することが推奨されます。 +詳しくは、[Card](./card)のドキュメントを参照してください。 -## Properties +## プロパティ -## Events +## イベント -## Methods +## メソッド ## CSS Shadow Parts -## CSS Custom Properties +## CSSカスタムプロパティ ## Slots - \ No newline at end of file + diff --git a/docs/api/card-header.md b/docs/api/card-header.md index 88dceee3cb7..90768d9116d 100644 --- a/docs/api/card-header.md +++ b/docs/api/card-header.md @@ -1,53 +1,37 @@ --- title: "ion-card-header" -hide_table_of_contents: true --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - -import Props from '@site/static/auto-generated/card-header/props.md'; -import Events from '@site/static/auto-generated/card-header/events.md'; -import Methods from '@site/static/auto-generated/card-header/methods.md'; -import Parts from '@site/static/auto-generated/card-header/parts.md'; -import CustomProps from '@site/static/auto-generated/card-header/custom-props.md'; -import Slots from '@site/static/auto-generated/card-header/slots.md'; - - +import Props from '@ionic-internal/component-api/v8/card-header/props.md'; +import Events from '@ionic-internal/component-api/v8/card-header/events.md'; +import Methods from '@ionic-internal/component-api/v8/card-header/methods.md'; +import Parts from '@ionic-internal/component-api/v8/card-header/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/card-header/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/card-header/slots.md'; import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; -

Contents

- - - - - -`ion-card-header` is a header component for `ion-card`. +カードヘッダは、カードの子コンポーネントで、カードコンテンツの前に配置する必要があります。カードタイトル](./card-title)と[カードサブタイトル](./card-subtitle)を含むことができます。 +詳しくは、[Card](./card)のドキュメントを参照してください。 -## Properties +## プロパティ -## Events +## イベント -## Methods +## メソッド ## CSS Shadow Parts -## CSS Custom Properties +## CSSカスタムプロパティ ## Slots - \ No newline at end of file + diff --git a/docs/api/card-subtitle.md b/docs/api/card-subtitle.md index 11fbe3a3e77..d22b0bd85b0 100644 --- a/docs/api/card-subtitle.md +++ b/docs/api/card-subtitle.md @@ -1,52 +1,37 @@ --- title: "ion-card-subtitle" -hide_table_of_contents: true --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - -import Props from '@site/static/auto-generated/card-subtitle/props.md'; -import Events from '@site/static/auto-generated/card-subtitle/events.md'; -import Methods from '@site/static/auto-generated/card-subtitle/methods.md'; -import Parts from '@site/static/auto-generated/card-subtitle/parts.md'; -import CustomProps from '@site/static/auto-generated/card-subtitle/custom-props.md'; -import Slots from '@site/static/auto-generated/card-subtitle/slots.md'; - - +import Props from '@ionic-internal/component-api/v8/card-subtitle/props.md'; +import Events from '@ionic-internal/component-api/v8/card-subtitle/events.md'; +import Methods from '@ionic-internal/component-api/v8/card-subtitle/methods.md'; +import Parts from '@ionic-internal/component-api/v8/card-subtitle/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/card-subtitle/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/card-subtitle/slots.md'; import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; -

Contents

- - - - -`ion-card-subtitle` is a child component of `ion-card` +カードサブタイトルは、[カードヘッダ](./card-header)の内側に配置されるべき、cardの子コンポーネントです。 +詳しくは、[Card](./card)のドキュメントを参照してください。 -## Properties +## プロパティ -## Events +## イベント -## Methods +## メソッド ## CSS Shadow Parts -## CSS Custom Properties +## CSSカスタムプロパティ ## Slots - \ No newline at end of file + diff --git a/docs/api/card-title.md b/docs/api/card-title.md index 096a7a7219a..2f78daca981 100644 --- a/docs/api/card-title.md +++ b/docs/api/card-title.md @@ -1,56 +1,42 @@ --- title: "ion-card-title" -hide_table_of_contents: true --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; +import Props from '@ionic-internal/component-api/v8/card-title/props.md'; +import Events from '@ionic-internal/component-api/v8/card-title/events.md'; +import Methods from '@ionic-internal/component-api/v8/card-title/methods.md'; +import Parts from '@ionic-internal/component-api/v8/card-title/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/card-title/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/card-title/slots.md'; -import Props from '@site/static/auto-generated/card-title/props.md'; -import Events from '@site/static/auto-generated/card-title/events.md'; -import Methods from '@site/static/auto-generated/card-title/methods.md'; -import Parts from '@site/static/auto-generated/card-title/parts.md'; -import CustomProps from '@site/static/auto-generated/card-title/custom-props.md'; -import Slots from '@site/static/auto-generated/card-title/slots.md'; +import EncapsulationPill from '@components/page/api/EncapsulationPill'; - ion-card-title | Ionic App Card Title Component and Properties - + ion-card-title: Ionic App Card Title Component + -import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; - -

Contents

- - - - - -`ion-card-title` is a child component of `ion-card` +Card titleはcardの子コンポーネントで、[card header](./card-header)の内側に配置する必要があります。 +詳しくは、[Card](./card)のドキュメントを参照してください。 -## Properties +## プロパティ -## Events +## イベント -## Methods +## メソッド ## CSS Shadow Parts -## CSS Custom Properties +## CSSカスタムプロパティ ## Slots - \ No newline at end of file + diff --git a/docs/api/card.md b/docs/api/card.md index 48afa83b762..aa14648067b 100644 --- a/docs/api/card.md +++ b/docs/api/card.md @@ -1,381 +1,87 @@ --- title: "ion-card" -hide_table_of_contents: true -demoUrl: "/docs/demos/api/card/index.html" -demoSourceUrl: "https://github.com/ionic-team/ionic-docs/tree/main/static/demos/api/card/index.html" --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; +import Props from '@ionic-internal/component-api/v8/card/props.md'; +import Events from '@ionic-internal/component-api/v8/card/events.md'; +import Methods from '@ionic-internal/component-api/v8/card/methods.md'; +import Parts from '@ionic-internal/component-api/v8/card/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/card/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/card/slots.md'; -import Props from '@site/static/auto-generated/card/props.md'; -import Events from '@site/static/auto-generated/card/events.md'; -import Methods from '@site/static/auto-generated/card/methods.md'; -import Parts from '@site/static/auto-generated/card/parts.md'; -import CustomProps from '@site/static/auto-generated/card/custom-props.md'; -import Slots from '@site/static/auto-generated/card/slots.md'; +import EncapsulationPill from '@components/page/api/EncapsulationPill'; ion-card: Card UI Components for Ionic Framework API - + -import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; - -

Contents

- - - +カードは、テキスト、画像、ボタン、リストなどのコンテンツを表示するためのコンテナです。 +カードは1つのコンポーネントで構成することもできますが、 +多くの場合、ヘッダー、タイトル、サブタイトル、コンテンツで構成されます。 +カードはこの構造に対応するため、いくつかのコンポーネントに分割されます。 +[カードヘッダ](./card-header)、[カードタイトル](./card-title)、[カードサブタイトル](./card-subtitle)、[カードコンテンツ](./card-content)。 + + +## 基本的な使い方 + +import Basic from '@site/static/usage/v8/card/basic/index.md'; + + + + +## Media Cards + +import Media from '@site/static/usage/v8/card/media/index.md'; + + + + +## Card Buttons + +import Buttons from '@site/static/usage/v8/card/buttons/index.md'; + + + + +## List Card + +import List from '@site/static/usage/v8/card/list/index.md'; + + + + +## テーマ + +### Colors + +import Colors from '@site/static/usage/v8/card/theming/colors/index.md'; + + + +## CSSカスタムプロパティ + +import CSSProps from '@site/static/usage/v8/card/theming/css-properties/index.md'; + + -Cards are a standard piece of UI that serves as an entry point to more detailed -information. A card can be a single component, but is often made up of some -header, title, subtitle, and content. `ion-card` is broken up into several -sub-components to reflect this. Please see `ion-card-content`, -`ion-card-header`, `ion-card-title`, `ion-card-subtitle`. - - - -## Usage - - - - - -```html - - - Card Subtitle - Card Title - - - - Keep close to Nature's heart... and break clear away, once in awhile, - and climb a mountain or spend a week in the woods. Wash your spirit clean. - - - - - - ion-item in a card, icon left, button right - View - - - - This is content, without any paragraph or header tags, - within an ion-card-content element. - - - - - - - Card Link Item 1 activated - - - - - Card Link Item 2 - - - - - Card Button Item 1 activated - - - - - Card Button Item 2 - - -``` - - - - - - -```html - - - Card Subtitle - Card Title - - - - Keep close to Nature's heart... and break clear away, once in awhile, - and climb a mountain or spend a week in the woods. Wash your spirit clean. - - - - - - - ion-item in a card, icon left, button right - View - - - - This is content, without any paragraph or header tags, - within an ion-card-content element. - - - - - - - Card Link Item 1 activated - - - - - Card Link Item 2 - - - - - Card Button Item 1 activated - - - - - Card Button Item 2 - - -``` - - - - - - -```tsx -import React from 'react'; -import { IonContent, IonHeader, IonPage, IonTitle, IonToolbar, IonCard, IonCardHeader, IonCardSubtitle, IonCardTitle, IonCardContent, IonItem, IonIcon, IonLabel, IonButton } from '@ionic/react'; -import { pin, wifi, wine, warning, walk } from 'ionicons/icons'; - -export const CardExamples: React.FC = () => { - return ( - - - - CardExamples - - - - - - Card Subtitle - Card Title - - - - Keep close to Nature's heart... and break clear away, once in awhile, - and climb a mountain or spend a week in the woods. Wash your spirit clean. - - - - - - - ion-item in a card, icon left, button right - View - - - - This is content, without any paragraph or header tags, - within an ion-cardContent element. - - - - - - - Card Link Item 1 activated - - - - - Card Link Item 2 - - - - - Card Button Item 1 activated - - - - - Card Button Item 2 - - - - - ); -}; - -``` - - - - - - -```tsx -import { Component, h } from '@stencil/core'; - -@Component({ - tag: 'card-example', - styleUrl: 'card-example.css' -}) -export class CardExample { - render() { - return [ - - - Card Subtitle - Card Title - - - - Keep close to Nature's heart... and break clear away, once in awhile, - and climb a mountain or spend a week in the woods. Wash your spirit clean. - - , - - - - - ion-item in a card, icon left, button right - View - - - - This is content, without any paragraph or header tags, - within an ion-card-content element. - - , - - - - - Card Link Item 1 activated - - - - - Card Link Item 2 - - - - - Card Button Item 1 activated - - - - - Card Button Item 2 - - - ]; - } -} -``` - - - - - - -```html - - - -``` - - - - - -## Properties +## プロパティ -## Events +## イベント -## Methods +## メソッド ## CSS Shadow Parts -## CSS Custom Properties +## CSSカスタムプロパティ ## Slots - \ No newline at end of file + diff --git a/docs/api/checkbox.md b/docs/api/checkbox.md index 93e5fedeeed..153e5a58566 100644 --- a/docs/api/checkbox.md +++ b/docs/api/checkbox.md @@ -1,343 +1,157 @@ --- title: "ion-checkbox" -hide_table_of_contents: true -demoUrl: "/docs/demos/api/checkbox/index.html" -demoSourceUrl: "https://github.com/ionic-team/ionic-docs/tree/main/static/demos/api/checkbox/index.html" --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; -import Props from '@site/static/auto-generated/checkbox/props.md'; -import Events from '@site/static/auto-generated/checkbox/events.md'; -import Methods from '@site/static/auto-generated/checkbox/methods.md'; -import Parts from '@site/static/auto-generated/checkbox/parts.md'; -import CustomProps from '@site/static/auto-generated/checkbox/custom-props.md'; -import Slots from '@site/static/auto-generated/checkbox/slots.md'; +import Props from '@ionic-internal/component-api/v8/checkbox/props.md'; +import Events from '@ionic-internal/component-api/v8/checkbox/events.md'; +import Methods from '@ionic-internal/component-api/v8/checkbox/methods.md'; +import Parts from '@ionic-internal/component-api/v8/checkbox/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/checkbox/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/checkbox/slots.md'; - ion-checkboxes: Ionic App Component to Select Multiple Options - + ion-checkbox: Ionic App Checkbox to Select Multiple Options + import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; -

Contents

- +Checkboxを使用すると、一連のオプションから複数のオプションを選択できます。選択すると、チェックマークが付いた状態(checked)で表示されます。checkboxをクリックすると、 `checked` プロパティーが切り替わります。`checked` プロパティを設定して、プログラムで `checked` を切り替えることもできます。 +## 基本的な使い方 +import Basic from '@site/static/usage/v8/checkbox/basic/index.md'; -Checkboxes allow the selection of multiple options from a set of options. They appear as checked (ticked) when activated. Clicking on a checkbox will toggle the `checked` property. They can also be checked programmatically by setting the `checked` property. + -## Interfaces +## Label Placement -### CheckboxChangeEventDetail +開発者は `labelPlacement` プロパティを使用して、ラベルをコントロールに対してどのように配置するかを制御できます。このプロパティはフレックスボックスの `flex-direction` プロパティを反映しています。 -```typescript -interface CheckboxChangeEventDetail { - value: T; - checked: boolean; -} -``` +import LabelPlacement from '@site/static/usage/v8/checkbox/label-placement/index.md'; -### CheckboxCustomEvent + -While not required, this interface can be used in place of the `CustomEvent` interface for stronger typing with Ionic events emitted from this component. +## Alignment -```typescript -interface CheckboxCustomEvent extends CustomEvent { - detail: CheckboxChangeEventDetail; - target: HTMLIonCheckboxElement; -} -``` +Developers can use the `alignment` property to control how the label and control are aligned on the cross axis. This property mirrors the flexbox `align-items` property. +:::note +Stacked checkboxes can be aligned using the `alignment` property. This can be useful when the label and control need to be centered horizontally. +::: +import Alignment from '@site/static/usage/v8/checkbox/alignment/index.md'; + -## Usage +## Justification - +開発者は `justify` プロパティを使用して、ラベルとコントロールの行の詰め方を制御することができます。このプロパティはフレックスボックスの `justify-content` プロパティを反映しています。 - +import Justify from '@site/static/usage/v8/checkbox/justify/index.md'; -```html - - + - - - - +:::note +`ion-item`は、 `justify` がどのように機能するかを強調するためにデモで使用されているだけです。 `justify` が正しく機能するために必須ではありません。 +::: - - - - - - +## Indeterminate Checkboxes - - - - {{entry.val}} - - - -``` +import Indeterminate from '@site/static/usage/v8/checkbox/indeterminate/index.md'; -```typescript -import { Component } from '@angular/core'; - -@Component({ - selector: 'app-page-home', - templateUrl: 'home.page.html', - styleUrls: ['home.page.scss'] -}) -export class HomePage { - public form = [ - { val: 'Pepperoni', isChecked: true }, - { val: 'Sausage', isChecked: false }, - { val: 'Mushroom', isChecked: false } - ]; -} -``` + + +## Links inside of Labels +Checkbox labels can sometimes be accompanied with links. These links can provide more information related to the checkbox. However, clicking the link should not check the checkbox. To achieve this, we can use [stopPropagation](https://developer.mozilla.org/en-US/docs/Web/API/Event/stopPropagation) to prevent the click event from bubbling. When using this approach, the rest of the label still remains clickable. - +import LabelLink from '@site/static/usage/v8/checkbox/label-link/index.md'; + - +## Helper & Error Text -```html - - +Helper and error text can be used inside of a checkbox with the `helperText` and `errorText` property. The error text will not be displayed unless the `ion-invalid` and `ion-touched` classes are added to the `ion-checkbox`. This ensures errors are not shown before the user has a chance to enter data. - - +In Angular, this is done automatically through form validation. In JavaScript, React and Vue, the class needs to be manually added based on your own validation. - - +import HelperError from '@site/static/usage/v8/checkbox/helper-error/index.md'; - - - - - - + - - - - Pepperoni - - +## Theming - - Sausage - - +## CSSカスタムプロパティ - - Mushrooms - - - -``` +import CSSProps from '@site/static/usage/v8/checkbox/theming/css-properties/index.md'; + - - - - - -```tsx -import React, { useState } from 'react'; -import { IonContent, IonHeader, IonPage, IonTitle, IonToolbar, IonCheckbox, IonList, IonItem, IonLabel, IonItemDivider } from '@ionic/react'; - -const checkboxList = [ - { val: 'Pepperoni', isChecked: true }, - { val: 'Sausage', isChecked: false }, - { val: 'Mushroom', isChecked: false } -]; - -export const CheckboxExamples: React.FC = () => { - - const [checked, setChecked] = useState(false); - - return ( - - - - CheckboxExamples - - - - - Default Checkbox - - Checked: {JSON.stringify(checked)} - setChecked(e.detail.checked)} /> - - - Disabled Checkbox - - - Checkbox Colors - - - - - - - - Checkboxes in a List - - {checkboxList.map(({ val, isChecked }, i) => ( - - {val} - - - ))} - - - - ); -}; -``` +## Interfaces - - - - - -```tsx -import { Component, h } from '@stencil/core'; - -@Component({ - tag: 'checkbox-example', - styleUrl: 'checkbox-example.css' -}) -export class CheckboxExample { - private form = [ - { val: 'Pepperoni', isChecked: true }, - { val: 'Sausage', isChecked: false }, - { val: 'Mushroom', isChecked: false } - ]; - - render() { - return [ - // Default Checkbox - , - - // Disabled Checkbox - , - - // Checked Checkbox - , - - // Checkbox Colors - , - , - , - , - , - - // Checkboxes in a List - - {this.form.map(entry => - - {entry.val} - - - )} - - ]; - } +### CheckboxChangeEventDetail + +```typescript +interface CheckboxChangeEventDetail { + value: T; + checked: boolean; } ``` +### CheckboxCustomEvent + +必須ではありませんが、このコンポーネントから発行される Ionic イベントでより強く型付けを行うために、`CustomEvent` インターフェースの代わりにこのインターフェースを使用することが可能です。 - - - - - -```html - - - +```typescript +interface CheckboxCustomEvent extends CustomEvent { + detail: CheckboxChangeEventDetail; + target: HTMLIonCheckboxElement; +} ``` - +## レガシーなチェックボックス構文からのマイグレーション + +Ionic 7.0では、よりシンプルなチェックボックス構文が導入されました。この新しい構文は、チェックボックスの設定に必要な定型文を減らし、アクセシビリティの問題を解決し、開発者のエクスペリエンスを向上させます。 + +開発者は、この移行を一度に1つのチェックボックスずつ実行することができます。開発者はレガシー構文を使い続けることができますが、できるだけ早く移行することをお勧めします。 + +### 最新の構文の使い方 + +最新の構文を使用するには、`ion-label` を削除して、 `ion-checkbox` の中に直接ラベルを渡す必要があります。ラベルの配置は `ion-checkbox` の `labelPlacement` プロパティを使用して設定することができる。ラベルとコントロールの行の詰め方は、`ion-checkbox` の `justify` プロパティを使用して制御することができます。 + +import Migration from '@site/static/usage/v8/checkbox/migration/index.md'; + + + + +:::note +Ionic の過去のバージョンでは、`ion-checkbox` が正しく機能するために `ion-item` が必要でした。Ionic 7.0 からは、`ion-checkbox` は `ion-item` の中で、そのアイテムが `ion-list` に配置される場合にのみ使用されます。また、`ion-checkbox`が正しく機能するためには、`ion-item`はもはや必須ではありません。 +::: + +### レガシーな構文の使い方 + +Ionicは、アプリが最新のチェックボックス構文を使用しているかどうかをヒューリスティックに検出します。場合によっては、レガシーな構文を使い続けることが望ましい場合もあります。開発者は `ion-checkbox` の `legacy` プロパティを `true` に設定することで、そのチェックボックスのインスタンスがレガシー構文を使用するように強制できます。 - -## Properties +## プロパティ -## Events +## イベント -## Methods +## メソッド ## CSS Shadow Parts -## CSS Custom Properties +## CSSカスタムプロパティ ## Slots - \ No newline at end of file + diff --git a/docs/api/chip.md b/docs/api/chip.md index 4e10449fd00..43f9f6b7726 100644 --- a/docs/api/chip.md +++ b/docs/api/chip.md @@ -1,368 +1,64 @@ --- title: "ion-chip" -hide_table_of_contents: true -demoUrl: "/docs/demos/api/chip/index.html" -demoSourceUrl: "https://github.com/ionic-team/ionic-docs/tree/main/static/demos/api/chip/index.html" --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - -import Props from '@site/static/auto-generated/chip/props.md'; -import Events from '@site/static/auto-generated/chip/events.md'; -import Methods from '@site/static/auto-generated/chip/methods.md'; -import Parts from '@site/static/auto-generated/chip/parts.md'; -import CustomProps from '@site/static/auto-generated/chip/custom-props.md'; -import Slots from '@site/static/auto-generated/chip/slots.md'; +import Props from '@ionic-internal/component-api/v8/chip/props.md'; +import Events from '@ionic-internal/component-api/v8/chip/events.md'; +import Methods from '@ionic-internal/component-api/v8/chip/methods.md'; +import Parts from '@ionic-internal/component-api/v8/chip/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/chip/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/chip/slots.md'; - ion-chip: Name, Text, Icon and Avatar for Ionic Framework Apps - + ion-chip: Text, Icon and Avatar for Ionic Framework Apps + import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; -

Contents

- - - - - -Chips represent complex entities in small blocks, such as a contact. A chip can contain several different elements such as avatars, text, and icons. - - - -## Usage - - - - - -```html - - Default - - - - Secondary Label - - - - Secondary w/ Dark label - - - - Disabled Chip - - - - - Default - - - - - Default - - - - Button Chip - - - - - - Icon Chip - - - - - - - - Avatar Chip - - -``` - - - - - - - -```html - - Default - - - - Secondary Label - - - - Secondary w/ Dark label - - - - Disabled Chip - - - - - Default - - - - - Default - - - - Button Chip - - - - - - Icon Chip - - - - - - - - Avatar Chip - - -``` - - - - - - - -```tsx -import React from 'react'; -import { IonContent, IonHeader, IonPage, IonTitle, IonToolbar, IonChip, IonLabel, IonIcon, IonAvatar } from '@ionic/react'; -import { pin, heart, closeCircle, close } from 'ionicons/icons'; - -export const ChipExamples: React.FC = () => { - return ( - - - - ChipExamples - - - - - Default - - - - Secondary Label - - - - Secondary w/ Dark label - - - - Disabled Chip - - - - - Default - - - - - Default - - - - Button Chip - - - - - - Icon Chip - - - - - - - - Avatar Chip - - - - - ); -}; - -``` - - - - - - - -```tsx -import { Component, h } from '@stencil/core'; - -@Component({ - tag: 'chip-example', - styleUrl: 'chip-example.css' -}) -export class ChipExample { - render() { - return [ - - Default - , - - - Secondary Label - , - - - Secondary w/ Dark label - , - - - - Default - , - - - - Default - , - - - Button Chip - - , - - - - Icon Chip - - , - - - - - - Avatar Chip - - - ]; - } -} -``` - - - - - - -```html - +## テーマ - -``` + +## CSSカスタムプロパティ - +import CSSProps from '@site/static/usage/v8/chip/theming/css-properties/index.md'; - + -## Properties +## プロパティ -## Events +## イベント -## Methods +## メソッド ## CSS Shadow Parts -## CSS Custom Properties +## CSSカスタムプロパティ ## Slots - \ No newline at end of file + diff --git a/docs/api/col.md b/docs/api/col.md index 7b990adf3fc..9254ce927e0 100644 --- a/docs/api/col.md +++ b/docs/api/col.md @@ -1,64 +1,49 @@ --- title: "ion-col" -hide_table_of_contents: true --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - -import Props from '@site/static/auto-generated/col/props.md'; -import Events from '@site/static/auto-generated/col/events.md'; -import Methods from '@site/static/auto-generated/col/methods.md'; -import Parts from '@site/static/auto-generated/col/parts.md'; -import CustomProps from '@site/static/auto-generated/col/custom-props.md'; -import Slots from '@site/static/auto-generated/col/slots.md'; +import Props from '@ionic-internal/component-api/v8/col/props.md'; +import Events from '@ionic-internal/component-api/v8/col/events.md'; +import Methods from '@ionic-internal/component-api/v8/col/methods.md'; +import Parts from '@ionic-internal/component-api/v8/col/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/col/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/col/slots.md'; - ion-col: Column Component Padding, Size and Other Properties - + ion-col: Column Component Padding and Other Properties + import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; -

Contents

- - - - -Columns are cellular components of the [grid](grid.md) system and go inside of a [row](row.md). -They will expand to fill their row. All content within a grid should go inside of a column. +Columnは、[Grid](./grid) システムのセルラーコンポーネントで、[row](./row)の内部に配置されます。列は行を埋めるように拡張されます。グリッド内のすべてのコンテンツは、カラムの内部に配置する必要があります。 -See [Grid Layout](/docs/layout/grid) for more information. +詳しくは、[grid](./grid)のドキュメントを参照してください。 ## Column Alignment -By default, columns will stretch to fill the entire height of the row. Columns are [flex items](https://developer.mozilla.org/en-US/docs/Glossary/Flex_Item), so there are several [CSS classes](/docs/layout/css-utilities#flex-item-properties) that can be applied to a column to customize this behavior. +デフォルトでは、カラムは行の高さ全体を埋めるように引き伸ばされます。カラムは[フレックスアイテム](https://developer.mozilla.org/en-US/docs/Glossary/Flex_Item)なので、この動作をカスタマイズするために、カラムに適用できるいくつかの[CSSクラス](/docs/layout/css-utilities#flex-item-properties) があります。 -## Properties +## プロパティ -## Events +## イベント -## Methods +## メソッド ## CSS Shadow Parts -## CSS Custom Properties +## CSSカスタムプロパティ ## Slots - \ No newline at end of file + diff --git a/docs/api/content.md b/docs/api/content.md index ee2c258044c..6782dfcce50 100644 --- a/docs/api/content.md +++ b/docs/api/content.md @@ -1,259 +1,183 @@ --- title: "ion-content" -hide_table_of_contents: true -demoUrl: "/docs/demos/api/content/index.html" -demoSourceUrl: "https://github.com/ionic-team/ionic-docs/tree/main/static/demos/api/content/index.html" --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - -import Props from '@site/static/auto-generated/content/props.md'; -import Events from '@site/static/auto-generated/content/events.md'; -import Methods from '@site/static/auto-generated/content/methods.md'; -import Parts from '@site/static/auto-generated/content/parts.md'; -import CustomProps from '@site/static/auto-generated/content/custom-props.md'; -import Slots from '@site/static/auto-generated/content/slots.md'; +import Props from '@ionic-internal/component-api/v8/content/props.md'; +import Events from '@ionic-internal/component-api/v8/content/events.md'; +import Methods from '@ionic-internal/component-api/v8/content/methods.md'; +import Parts from '@ionic-internal/component-api/v8/content/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/content/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/content/slots.md'; - ion-content: Scrollable CSS Component for Ionic App Content Areas - + ion-content: Scrollable Component for Ionic App Content + import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; -

Contents

- +Contentコンポーネントは、スクロール可能領域を制御するいくつかの便利なメソッドを備えた、 +使いやすいコンテンツ領域を提供します。 +1つのビューに表示できるコンテンツは1つだけです。 +Contentは、他の多くのIonicコンポーネントと同様に、 [CSS Utilities](/docs/layout/css-utilities) で提供されるグローバルスタイルを使用するか、CSSおよび使用可能な [CSS Custom Properties](#css-custom-properties) を使用して個別にスタイル設定することによって、`padding` や `margin` などを変更するようにカスタマイズできます。 -The content component provides an easy to use content area with some useful methods -to control the scrollable area. There should only be one content in a single -view. +## 基本的な使い方 -Content, along with many other Ionic components, can be customized to modify its padding, margin, and more using the global styles provided in the [CSS Utilities](/docs/layout/css-utilities) or by individually styling it using CSS and the available [CSS Custom Properties](#css-custom-properties). +import Basic from '@site/static/usage/v8/content/basic/index.md'; + -## Fixed Content -In order to place elements outside of the scrollable area, `slot="fixed"` can be added to the element. This will absolutely position the element placing it in the top left. In order to place the element in a different position, style it using [top, right, bottom, and left](https://developer.mozilla.org/en-US/docs/Web/CSS/position). +## Header & Footer -## Interfaces +コンテンツは、ページ内の唯一のトップレベル・コンポーネントとすることも、[ヘッダー](./header)、[フッター](./footer)、またはその両方と一緒に使用することも可能です。ヘッダーやフッターと一緒に使用すると、残りの高さを埋めるようにサイズが調整されます。 -### ScrollBaseDetail +import HeaderFooter from '@site/static/usage/v8/content/header-footer/index.md'; -```typescript -interface ScrollBaseDetail { - isScrolling: boolean; -} -``` + -### ScrollDetail -```typescript -interface ScrollDetail extends GestureDetail, ScrollBaseDetail { - scrollTop: number; - scrollLeft: number; -} -``` +## Fullscreen Content -### ScrollBaseCustomEvent +デフォルトでは、コンテンツは [ヘッダー](./header)と [フッター](./footer)の間のスペースを埋めますが、それらの背景にまわることはありません。例えば、ヘッダーとフッターのどちらかに `translucent` プロパティを設定した場合や、ツールバーに `opacity` を設定した場合など、特定のケースでは、コンテンツをヘッダーとフッターの後ろにスクロールさせることが望まれるかもしれない。これは、コンテンツの `fullscreen` プロパティを `true` に設定することで実現することができます。 -While not required, this interface can be used in place of the `CustomEvent` interface for stronger typing on the `ionScrollStart` and `ionScrollEnd` events. +import Fullscreen from '@site/static/usage/v8/content/fullscreen/index.md'; -```typescript -interface ScrollBaseCustomEvent extends CustomEvent { - detail: ScrollBaseDetail; - target: HTMLIonContentElement; -} -``` + -### ScrollCustomEvent -While not required, this interface can be used in place of the `CustomEvent` interface for stronger typing on the `ionScroll` event. +## コンテンツの固定 -```typescript -interface ScrollCustomEvent extends ScrollBaseCustomEvent { - detail: ScrollDetail; -} -``` +スクロール可能な領域の外側に要素を配置するには、`fixed`スロットに割り当てます。そうすることで、その要素はコンテンツの左上に[絶対位置](https://developer.mozilla.org/en-US/docs/Web/CSS/position#absolute_positioning)されます。要素の位置を変えるには、CSSの[top, right, bottom, left](https://developer.mozilla.org/en-US/docs/Web/CSS/position)プロパティを使ってスタイルを設定することができます。 +The `fixedSlotPlacement` property is used to determine if content in the `fixed` slot is placed before or after the main content in the DOM. When set to `before`, fixed slot content will be placed before the main content and will therefore receive keyboard focus before the main content receives keyboard focus. This can be useful when the main content contains an infinitely-scrolling list, preventing a [FAB](./fab) or other fixed content from being reachable by pressing the tab key. +import Fixed from '@site/static/usage/v8/content/fixed/index.md'; + -## Usage +## スクロールメソッド - +コンテンツには [メソッド](#methods) が用意されており、これを呼び出すことでコンテンツを下、上、または特定のポイントにスクロールさせることができます。これらのメソッドには `duration` を渡すことができ、瞬時に位置を変更するのではなく、スムーズに移行することができます。 - +import ScrollMethods from '@site/static/usage/v8/content/scroll-methods/index.md'; -```html - -

Main Content

+ -
-

Fixed Content

-
-
-``` +## Scroll Events +スクロールイベントは、パフォーマンス上、コンテンツに対してデフォルトで無効化されています。しかし、`scrollEvents` を `true` に設定することで、有効にすることができます。これは、 スクロール [イベント](#events) を聞く前に必要です。 +import ScrollEvents from '@site/static/usage/v8/content/scroll-events/index.md'; -
+ +Scroll events are disabled by default for content due to performance. However, they can be enabled by setting `scrollEvents` to `true`. This is necessary before listening to any of the scroll [events](#events). - +## テーマ -```html - -

Main Content

+### Colors -
-

Fixed Content

-
-
-``` +import Colors from '@site/static/usage/v8/content/theming/colors/index.md'; -```javascript -var content = document.querySelector('ion-content'); -content.scrollEvents = true; -content.addEventListener('ionScrollStart', () => console.log('scroll start')); -content.addEventListener('ionScroll', (ev) => console.log('scroll', ev.detail)); -content.addEventListener('ionScrollEnd', () => console.log('scroll end')); -``` + +### CSS Shadow Parts -
+import CSSParts from '@site/static/usage/v8/content/theming/css-shadow-parts/index.md'; + - +## CSSカスタムプロパティ -```tsx -import React from 'react'; -import { IonContent } from '@ionic/react'; +import CSSProps from '@site/static/usage/v8/content/theming/css-properties/index.md'; -const ContentExample: React.FC = () => ( - {}} - onIonScroll={() => {}} - onIonScrollEnd={() => {}}> -

Main Content

+ -
-

Fixed Content

-
-
-); -``` +### Safe Area Padding +The content component will not automatically apply padding to any of its sides to account for the [safe area](/docs/theming/advanced#safe-area-padding). This is because the content component is often used in conjunction with other components that apply their own padding, such as [headers](./header) and [footers](./footer). However, if the content component is being used on its own, it may be desired to apply padding to the safe area. This can be done through CSS by using the `--ion-safe-area-(dir)` variables described in [Application Variables](../theming/advanced.md#application-variables). -
+The most common use case for this is to apply padding to the top of the content to account for the status bar. This can be done by setting the `padding-top` property to the value of the `--ion-safe-area-top` variable. +```css +ion-content::part(scroll) { + padding-top: var(--ion-safe-area-top, 0); +} +``` - +Another common use case is to apply padding to the left side of the content to account for the notch when the device is in landscape mode and the notch is on the left side. This can be done by setting the `padding-left` property to the value of the `--ion-safe-area-left` variable. -```tsx -import { Component, h } from '@stencil/core'; +```css +ion-content::part(scroll) { + padding-left: var(--ion-safe-area-left, 0); +} +``` -@Component({ - tag: 'content-example', - styleUrl: 'content-example.css' -}) -export class ContentExample { - logScrollStart() { - console.log('Scroll start'); - } +import SafeArea from '@site/static/usage/v8/content/theming/safe-area/index.md'; - logScrolling(ev) { - console.log('Scrolling', ev); - } + - logScrollEnd() { - console.log('Scroll end'); - } +## Interfaces - render() { - return [ - this.logScrollStart()} - onIonScroll={(ev) => this.logScrolling(ev)} - onIonScrollEnd={() => this.logScrollEnd()}> -

Main Content

+### ScrollBaseDetail -
-

Fixed Content

-
-
- ]; - } +```typescript +interface ScrollBaseDetail { + isScrolling: boolean; } ``` +### ScrollDetail -
- - - - -```html - +```typescript +interface ScrollDetail extends GestureDetail, ScrollBaseDetail { + scrollTop: number; + scrollLeft: number; +} +``` - +必須ではありませんが、`ionScrollStart` と `ionScrollEnd` イベントをより強く型付けするために、`CustomEvent` インターフェースの代わりにこのインターフェースを利用することが可能です。 +```typescript +interface ScrollBaseCustomEvent extends CustomEvent { + detail: ScrollBaseDetail; + target: HTMLIonContentElement; +} ``` +### ScrollCustomEvent +必須ではありませんが、`ionScroll` イベントをより強く型付けするために、`CustomEvent` インターフェースの代わりにこのインターフェースを利用することが可能です。 - +```typescript +interface ScrollCustomEvent extends ScrollBaseCustomEvent { + detail: ScrollDetail; +} +``` -
+### ScrollCustomEvent -## Properties +## プロパティ -## Events +## イベント -## Methods +## メソッド ## CSS Shadow Parts -## CSS Custom Properties +## CSSカスタムプロパティ ## Slots - \ No newline at end of file + diff --git a/docs/api/datetime-button.md b/docs/api/datetime-button.md new file mode 100644 index 00000000000..a9fcb17433c --- /dev/null +++ b/docs/api/datetime-button.md @@ -0,0 +1,80 @@ +--- +title: "ion-datetime-button" +--- +import Props from '@ionic-internal/component-api/v8/datetime-button/props.md'; +import Events from '@ionic-internal/component-api/v8/datetime-button/events.md'; +import Methods from '@ionic-internal/component-api/v8/datetime-button/methods.md'; +import Parts from '@ionic-internal/component-api/v8/datetime-button/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/datetime-button/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/datetime-button/slots.md'; + + + ion-datetime-button: Ionic Input for Datetime Picker + + + +import EncapsulationPill from '@components/page/api/EncapsulationPill'; + + + +Datetimeボタンは、[Datetime](./datetime) コンポーネントとリンクし、フォーマットされた日付と時刻を表示します。また、モーダルやポップオーバーなどで日時を表示するためのボタンも用意されています。 + +## 概要 + +Datetimeボタンは、スペースに制約がある場合に使用する必要があります。このコンポーネントは、現在の日付と時刻の値を表示するボタンを表示します。ボタンがタップされると、日付や時刻のピッカーがオーバーレイで表示されます。 + +Angular、React、VueなどのJavaScriptフレームワークでDatetime Buttonを使用する場合は、 [ion-modalのkeepContentsMountedプロパティ](./modal#keepcontentsmounted) または [ion-popover](./popover#keepcontentsmounted) を使用していることを確認してください。これにより、オーバーレイがまだ表示されていない場合でも、リンクされたdatetimeインスタンスがマウントされるようになります。 + +## 基本的な使い方 + +import Basic from '@site/static/usage/v8/datetime-button/basic/index.md'; + + + +## ローカライゼーション + +`ion-datetime-button` のローカライズされたテキストは、関連する `ion-datetime` インスタンスの `locale` プロパティによって決まります。詳しくは、[Datetime Localization](./datetime#localization) を参照してください。 + +## Format Options + +Datetimeインスタンスに`formatOptions`を指定することで、Datetime Buttonの日付と時刻の書式をカスタマイズすることができます。詳細は[Datetime Format Options](./datetime#format-options)を参照してください。 + +import FormatOptions from '@site/static/usage/v8/datetime-button/format-options/index.md'; + + + +## モーダルやポップオーバーと使う + +`ion-datetime-button` は、マウントされた `ion-datetime` インスタンスと関連付ける必要があります。そのため、[Inline Modals](./modal#inline-modals-recommended) と [Inline Popovers](./popover#inline-popovers) は `keepContentsMounted` プロパティを `true` に設定して使用しなければなりません。 + + + +## プロパティ + + +## イベント + + +## メソッド + + +## CSS Shadow Parts + + +## CSS カスタムプロパティ + + +## Slots + diff --git a/docs/api/datetime.md b/docs/api/datetime.md index 9770cef8b7e..af3f8671ebe 100644 --- a/docs/api/datetime.md +++ b/docs/api/datetime.md @@ -1,147 +1,160 @@ --- title: "ion-datetime" --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; +import Props from '@ionic-internal/component-api/v8/datetime/props.md'; +import Events from '@ionic-internal/component-api/v8/datetime/events.md'; +import Methods from '@ionic-internal/component-api/v8/datetime/methods.md'; +import Parts from '@ionic-internal/component-api/v8/datetime/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/datetime/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/datetime/slots.md'; -import Props from '@site/static/auto-generated/datetime/props.md'; -import Events from '@site/static/auto-generated/datetime/events.md'; -import Methods from '@site/static/auto-generated/datetime/methods.md'; -import Parts from '@site/static/auto-generated/datetime/parts.md'; -import CustomProps from '@site/static/auto-generated/datetime/custom-props.md'; -import Slots from '@site/static/auto-generated/datetime/slots.md'; +import Basic from '@site/static/usage/v8/datetime/basic/index.md'; -import Basic from '@site/static/usage/datetime/basic/index.md'; +import MaxMin from '@site/static/usage/v8/datetime/date-constraints/max-min/index.md'; +import Values from '@site/static/usage/v8/datetime/date-constraints/values/index.md'; +import Advanced from '@site/static/usage/v8/datetime/date-constraints/advanced/index.md'; -import MaxMin from '@site/static/usage/datetime/date-constraints/max-min/index.md'; -import Values from '@site/static/usage/datetime/date-constraints/values/index.md'; -import Advanced from '@site/static/usage/datetime/date-constraints/advanced/index.md'; +import FormatOptions from '@site/static/usage/v8/datetime/format-options/index.md'; -import CustomLocale from '@site/static/usage/datetime/localization/custom-locale/index.md'; -import HourCycle from '@site/static/usage/datetime/localization/hour-cycle/index.md'; -import FirstDayOfWeek from '@site/static/usage/datetime/localization/first-day-of-week/index.md'; -import LocaleExtensionTags from '@site/static/usage/datetime/localization/locale-extension-tags/index.md'; -import TimeLabel from '@site/static/usage/datetime/localization/time-label/index.md'; +import CustomLocale from '@site/static/usage/v8/datetime/localization/custom-locale/index.md'; +import HourCycle from '@site/static/usage/v8/datetime/localization/hour-cycle/index.md'; +import FirstDayOfWeek from '@site/static/usage/v8/datetime/localization/first-day-of-week/index.md'; +import LocaleExtensionTags from '@site/static/usage/v8/datetime/localization/locale-extension-tags/index.md'; +import TimeLabel from '@site/static/usage/v8/datetime/localization/time-label/index.md'; -import MonthAndYear from '@site/static/usage/datetime/presentation/month-and-year/index.md'; -import Time from '@site/static/usage/datetime/presentation/time/index.md'; -import Date from '@site/static/usage/datetime/presentation/date/index.md'; +import MonthAndYear from '@site/static/usage/v8/datetime/presentation/month-and-year/index.md'; +import Time from '@site/static/usage/v8/datetime/presentation/time/index.md'; +import Date from '@site/static/usage/v8/datetime/presentation/date/index.md'; -import ShowingDefaultTitle from '@site/static/usage/datetime/title/showing-default-title/index.md'; -import CustomizingTitle from '@site/static/usage/datetime/title/customizing-title/index.md'; +import ShowingDefaultTitle from '@site/static/usage/v8/datetime/title/showing-default-title/index.md'; +import CustomizingTitle from '@site/static/usage/v8/datetime/title/customizing-title/index.md'; -import ShowingConfirmationButtons from '@site/static/usage/datetime/buttons/showing-confirmation-buttons/index.md'; -import CustomizingButtons from '@site/static/usage/datetime/buttons/customizing-buttons/index.md'; -import CustomizingButtonTexts from '@site/static/usage/datetime/buttons/customizing-button-texts/index.md'; +import ShowingConfirmationButtons from '@site/static/usage/v8/datetime/buttons/showing-confirmation-buttons/index.md'; +import CustomizingButtons from '@site/static/usage/v8/datetime/buttons/customizing-buttons/index.md'; +import CustomizingButtonTexts from '@site/static/usage/v8/datetime/buttons/customizing-button-texts/index.md'; -import MultipleDateSelection from '@site/static/usage/datetime/multiple/index.md'; +import HighlightedDatesArray from '@site/static/usage/v8/datetime/highlightedDates/array/index.md'; +import HighlightedDatesCallback from '@site/static/usage/v8/datetime/highlightedDates/callback/index.md'; -import Theming from '@site/static/usage/datetime/theming/index.md'; +import ShowAdjacentDays from '@site/static/usage/v8/datetime/show-adjacent-days/index.md'; + +import MultipleDateSelection from '@site/static/usage/v8/datetime/multiple/index.md'; + +import GlobalTheming from '@site/static/usage/v8/datetime/styling/global-theming/index.md'; +import CalendarDaysStyling from '@site/static/usage/v8/datetime/styling/calendar-days/index.md'; +import WheelStyling from '@site/static/usage/v8/datetime/styling/wheel-styling/index.md'; ion-datetime: Ionic API Input for Datetime Format Picker - + import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; -Datetimes present a calendar interface and time wheel, making it easy for users to select dates and times. Datetimes are similar to the native `input` elements of `datetime-local`, however, Ionic Framework's Datetime component makes it easy to display the date and time in the preferred format, and manage the datetime values. +Datetimeはカレンダーとタイムホイールのインターフェイスを表示し、ユーザーが簡単に日付と時刻を選択できるようにします。Datetimeはネイティブの `datetime-local` の `input` 要素と似ていますが、Ionic FrameworkのDatetimeコンポーネントを使用すると、好みのフォーマットで日付と時刻を表示したり、datetimeの値を管理することが簡単にできます。 -## Overview +## 概要 -Historically, handling datetime values within JavaScript, or even within HTML -inputs, has always been a challenge. Specifically, JavaScript's `Date` object is -notoriously difficult to correctly parse apart datetime strings or to format -datetime values. Even worse is how different browsers and JavaScript versions -parse various datetime strings differently, especially per locale. +これまで、JavaScriptやHTMLの入力でdatetimeの値を扱うことは、常に困難でした。 +入力でさえも、常に課題でした。 +特に、JavaScriptの `Date` オブジェクトは、datetime文字列を正しく解析したり、datetime値をフォーマットしたりするのが難しいことで有名です。 +さらに悪いことに、ブラウザやJavaScriptのバージョンによって、 +特にロケールごとに様々なdatetime文字列の解析が異なるのです。 -Fortunately, Ionic Framework's datetime input has been designed so developers can avoid -the common pitfalls, allowing developers to easily manipulate datetime values and give the user a simple datetime picker for a great user experience. +Ionic Frameworkのdatetimeは、開発者が一般的な落とし穴を回避できるように設計されており、 +開発者は簡単にdatetime値を操作し、ユーザーにシンプルなdatetimeピッカーを提供し、素晴らしいユーザーエクスペリエンスを提供することができます。 -### ISO 8601 Datetime Format: YYYY-MM-DDTHH:mmZ +### ISO 8601 Datetime Format: `YYYY-MM-DDTHH:mmZ` -Ionic Framework uses the [ISO 8601 datetime format](https://www.w3.org/TR/NOTE-datetime) -for its value. The value is simply a string, rather than using JavaScript's -`Date` object. Using the ISO datetime format makes it easy to serialize -and parse within JSON objects and databases. +Ionic Frameworkでは、[ISO 8601 datetime format](https://www.w3.org/TR/NOTE-datetime) を値として使用します。 +この値は、JavaScriptの `Date` オブジェクトを使用するのではなく、単純に文字列として使用されます。 +ISO datetimeフォーマットを使用することで、 +JSONオブジェクトやデータベース内でのシリアライズやパースが容易になります。 -Below are some examples of ISO 8601 formats that can be used with `ion-datetime`: +以下は、 `ion-datetime` で使用できる ISO 8601 フォーマットの例です: -| Description | Format | Datetime Value Example | -| -------------------- | ---------------------- | ---------------------------- | -| Year | YYYY | 1994 | -| Year and Month | YYYY-MM | 1994-12 | -| Complete Date | YYYY-MM-DD | 1994-12-15 | -| Date and Time | YYYY-MM-DDTHH:mm | 1994-12-15T13:47 | -| UTC Timezone | YYYY-MM-DDTHH:mm:ssZ | 1994-12-15T13:47:20Z | -| Timezone Offset | YYYY-MM-DDTHH:mm:ssTZD | 1994-12-15T13:47:20+05:00 | -| Hour and Minute | HH:mm | 13:47 | +| Description | Format | Datetime Value Example | +| -------------------- | ------------------------ | ------------------------------ | +| Year | `YYYY` | `1994` | +| Year and Month | `YYYY-MM` | `1994-12` | +| Complete Date | `YYYY-MM-DD` | `1994-12-15` | +| Date and Time | `YYYY-MM-DDTHH:mm` | `1994-12-15T13:47` | +| UTC Timezone | `YYYY-MM-DDTHH:mm:ssZ` | `1994-12-15T13:47:20Z` | +| Timezone Offset | `YYYY-MM-DDTHH:mm:ssTZD` | `1994-12-15T13:47:20+05:00` | +| Hour and Minute | `HH:mm` | `13:47` | -Note that the year is always four-digits, milliseconds (if it's added) is always -three-digits, and all others are always two-digits. So the number representing -January always has a leading zero, such as `01`. Additionally, the hour is -always in the 24-hour format, so `00` is `12am` on a 12-hour clock, `13` means -`1pm`, and `23` means `11pm`. +年号は常に4桁、ミリ秒は(加算される場合は)常に3桁、その他は常に2桁であることに注意してください。 +ミリ秒は3桁、その他は2桁である。 +ですから、1月を表す数字には 1月を表す数字には常に先頭のゼロ、例えば`01`が付きます。 +また、時刻は常に24時間表示で、 +12時間表示の時計では「00」は「午前12時」、「13」は「午後1時」、「23」は「午後3時」を意味します。 :::note -While seconds and milliseconds can be specified using the ISO 8601 datetime format, `ion-datetime` does not provide an interface for second and millisecond selection. Any second or millisecond values provided will be ignored. +秒、ミリ秒、タイムゾーンは ISO 8601 datetime フォーマットで指定できますが、 `ion-datetime` は秒、ミリ秒、タイムゾーンを選択するためのインターフェイスを提供しません。秒、ミリ秒、タイムゾーンの値を指定しても無視されます。 ::: -## Basic Usage +## 基本的な使い方 -## Date Constraints +## 日付ボタンと使う + +モーダルやポップオーバーなどのオーバーレイで日付時刻を表示する必要がある場合は、 [ion-datetime-button](./datetime-button) を使用することをお勧めします。スペースに制約がある場合は、 `ion-datetime-button` を使用する必要があります。このコンポーネントは、現在の日付と時刻の値を表示するボタンを表示します。ボタンがタップされると、日付と時刻のピッカーがオーバーレイで表示されます。 + +## 非同期に値を設定する + +すでにdatetimeが作成された後にプログラムで`value`が更新されると、datetimeは自動的に新しい日付にジャンプします。しかし、ユーザーがdatetimeを操作しているときに、この方法で`value`を更新することは避けることをお勧めします。例えば、datetimeの`value`が非同期処理で読み込まれる場合、値の更新が終わるまでCSSでdatetimeを非表示にすることをお勧めします。 + +## 日付コンテナ -### Max and Min Dates +### 日付の最小値と最大値 -To customize the minimum and maximum datetime values, the `min` and `max` component properties can be provided which may make more sense for the app's use-case. Following the same IS0 8601 format listed in the table above, each component can restrict which dates can be selected by the user. +日付の最小値と最大値をカスタマイズするには、 `min` と `max` コンポーネントプロパティを使用します。上の表にあるのと同じ IS0 8601 フォーマットに従って、各コンポーネントはユーザーが選択できる日付を制限することができます。 -The following example restricts date selection to March 2022 through May 2022 only. +以下の例では、日付の選択を2022年3月から2022年5月のみに制限しています。 -### Selecting Specific Values +### 特定の値を選択する -While the `min` and `max` properties allow you to restrict date selection to a certain range, the `monthValues`, `dayValues`, `yearValues`, `hourValues`, and `minuteValues` properties allow you choose specific days and times that users can select. +`min` と `max` プロパティでは、日付の選択をある範囲に制限することができますが、 `monthValues`, `dayValues`, `yearValues`, `hourValues`, `minuteValues` プロパティでは、ユーザーが選択できる特定の日や時刻を選択することが可能です。 -The following example allows minutes to be selected in increments of 15. It also allows for days to be selected in increments of 5. +次の例では、15分単位で分を選択することができます。また、日付を5刻みで選択することができます。 -### Advanced Date Constraints +### 高度な日付制限 -With the `isDateEnabled` property, developers can customize the `ion-datetime` to disable a specific day, range of dates, weekends or any custom rule using an ISO 8601 date string. -The `isDateEnabled` property accepts a function returning a boolean, indicating if a date is enabled. The function is called for each rendered calendar day, for the previous, current and next month. Custom implementations should be optimized for performance to avoid jank. +`isDateEnabled` プロパティを使用すると、開発者は `ion-datetime` をカスタマイズして、ISO 8601 の日付文字列を使用して、特定の日、日付の範囲、週末、または任意のカスタムルールを無効にすることができる。 +isDateEnabled` プロパティは、日付が有効かどうかを示すブール値を返す関数を受け付ける。この関数は、レンダリングされた各日付、前月、当月、翌月に対して呼び出されます。カスタムの実装では、ジャンクを避けるためにパフォーマンスを最適化する必要があります。 -The following example shows how to disable all weekend dates. For more advanced date manipulation, we recommend using a date utility such as `date-fns`. +次の例では、週末の日付をすべて無効にする方法を示しています。より高度な日付操作を行うには、 `date-fns` のような日付ユーティリティを使用することをお勧めします。 -## Localization +## ローカライゼーション -Ionic Framework makes use of the [Intl.DatetimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DatetimeFormat) Web API which allows us to automatically localize the month and day names according to the language and region set on the user's device. +Ionic Frameworkでは、[Intl.DatetimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DatetimeFormat) Web APIを利用して、ユーザーの端末に設定されている言語や地域に応じて、月名と曜日名を自動的にローカライズすることが可能です。 -### Custom Locale +### カスタムロケール -For instances where you need a specific locale, you can use the `locale` property to set it. The locale controls both the language and the date and time formats that are displayed. +特定のロケールが必要な場合、 `locale` プロパティを使用して設定することができます。ロケールは、表示される言語と日付・時刻のフォーマットの両方を制御します。 -The following example shows how to set the locale to Spanish (Spain). +次の例では、ロケールをスペイン語(Spanish)に設定する方法を示しています。 :::note -The time label is not automatically localized. See [Time Label](#time-label) for more information. +時刻の表記は、自動的にローカライズされません。詳しくは [Time Label](#time-label) を参照してください。 ::: -### Hour Cycle +### 時間サイクル -`ion-datetime` will use the hour cycle that is specified by the `locale` property by default. For example, if `locale` is set to `en-US`, then `ion-datetime` will use a 12 hour cycle. +`ion-datetime` は、デフォルトで `locale` プロパティで指定された時間サイクルを使用します。例えば、 `locale` が `en-US` に設定されている場合、 `ion-datetime` は12時間のサイクルを使用します。 -There are 4 primary hour cycle types: +時間サイクルには4つのタイプがあります。 | Hour cycle type | Description | | --------------- | ------------------------------------------------------------ | @@ -151,77 +164,77 @@ There are 4 primary hour cycle types: | `'h24'` | Hour system using 1–24; corresponds to 'k' in pattern. The 24 hour clock, with midnight starting at 24:00. | :::note - Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/hourCycle + ソース: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/hourCycle ::: -There may be scenarios where you need to have more control over which hour cycle is used. This is where the `hourCycle` property can help. +どの時間のサイクルを使用するか、もっとコントロールする必要があるシナリオがあるかもしれません。このような場合には、 `hourCycle` プロパティが役に立ちます。 -In the following example, we can use the `hourCycle` property to force `ion-datetime` to use the 12 hour cycle even though the locale is `en-GB`, which uses a 24 hour cycle by default: +次の例では、 `hourCycle` プロパティを使用して、ロケールが `en-GB` であるにもかかわらず、 `ion-datetime` に12時間周期を使用するように強制することができます。 -### First Day of the Week +### 週初めの日 -For `ion-datetime`, the default first day of the week is Sunday. As of 2022, there is no browser API that lets Ionic automatically determine the first day of the week based on a device's locale, though there is on-going work regarding this (see: [TC39 GitHub](https://github.com/tc39/ecma402/issues/6)). +`ion-datetime`の場合、週初めの曜日はデフォルトで日曜日です。2022年現在、Ionicがデバイスのロケールに基づいて自動的に週の最初の曜日を決定するためのブラウザAPIはありませんが、これに関する作業は進行中です(参照: [TC39 GitHub](https://github.com/tc39/ecma402/issues/6) ). -### Time Label +### 時刻表記 -The time label is not automatically localized. Fortunately, Ionic makes it easy to provide custom localizations with the `time-label` slot. +時刻表記は自動的にローカライズされるわけではありません。幸いなことに、Ionicでは `time-label` スロットで簡単にカスタムのローカライズを提供することができます。 -### Locale Extension Tags +### ロケールエクステンションタグ -`ion-datetime` also supports [locale extension tags](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale) as part of the `Intl.Locale` API. These tags let you encode information about the locale in the locale string itself. Developers may prefer to use the extension tag approach if they are using the [Intl.Locale API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale) in their apps. +`ion-datetime` は、 `Intl.Locale` API の一部として [locale extension tags](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale) もサポートしています。これらのタグを使用すると、ロケールに関する情報をロケール文字列自体にエンコードすることができます。開発者は、アプリの中で [Intl.Locale API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale) を使っている場合、拡張タグのアプローチを使うことを好むかもしれません。 -For example, if you wanted to use a 12 hour cycle with the `en-GB` locale, you could provide extension tags instead of using both the `locale` and `hourCycle` properties: +たとえば、 `en-GB` ロケールで 12 時間周期を使用したい場合は、 `locale` と `hourCycle` の両方のプロパティを使用するのではなく、拡張タグを使用します。 :::note -Be sure to check the [Browser Compatibility Chart](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale#browser_compatibility) for `Intl.Locale` before using it in your app. +アプリで使用する前に、 `Intl.Locale` の [Browser Compatibility Chart](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale#browser_compatibility) を必ず確認してください。 ::: -## Presentation +## プレゼンテーション -By default, `ion-datetime` allows users to select both date and time. In addition, users have access to selecting the specific month, year, hour, and minute. +デフォルトでは、 `ion-datetime` は日付と時刻の両方を選択することができる。さらに、ユーザは特定の月、年、時間、分を選択することができます。 -Some use cases may call for only date selection or only time selection. The `presentation` property allows you to specify which pickers to show and the order to show them in. For example, setting `date-time` will have the calendar picker appear before the time picker. Setting `time-date` will have the calendar picker appear after the time picker. +ユースケースによっては、日付だけを選択したり、時間だけを選択したりすることもできます。 `presentation` プロパティでは、表示するピッカーとその順番を指定することができます。例えば、 `date-time` を設定すると、カレンダーピッカーがタイムピッカーよりも先に表示されます。 `time-date` を設定すると、カレンダーピッカーはtimeピッカーの後に表示されます。 -### Month and Year Selection +### 月と年の選択 -Month and year selection is available by passing `month-year`, `year-month`, `month`, or `year` to the `presentation` property. +月と年の選択は、 `presentation` プロパティに `month-year` , `month` , または `year` を渡すことで行うことができます。 -This example shows a datetime with the `month-year` configuration. +この例では、 `month-year` を設定した datetime を示しています。 -### Time Selection +### 時刻の選択 -Time selection is available by passing `date-time`, `time-date`, or `time` to the `presentation` property. +時刻の選択は、 `presentation` プロパティに `date-time`, `time-date`, `time` を渡すことで行うことができます。 -This example shows a datetime with the `time` configuration. +この例では、`time`の設定で datetime を表示しています。
-``` - -```css -.ripple-parent { - position: relative; - overflow: hidden; -} -``` - -
- - - - -```html - - -
- A plain div with a bounded ripple effect - -
- - - -
- A plain div with an unbounded ripple effect - -
- - -
-
-``` - -```css -.ripple-parent { - position: relative; - overflow: hidden; -} -``` - -
- - - - -```tsx -import React from 'react'; -import { IonApp, IonContent, IonRippleEffect } from '@ionic/react'; -import './RippleEffectExample.css'; - -export const RippleExample: React.FC = () => ( - - -
- A plain div with a bounded ripple effect - -
- - - -
- A plain div with an unbounded ripple effect - -
- - -
-
-); -``` - -```css -.ripple-parent { - position: relative; - overflow: hidden; -} -``` - -
- - - - -```tsx -import { Component, h } from '@stencil/core'; -@Component({ - tag: 'ripple-effect-example', - styleUrl: 'ripple-effect-example.css' -}) -export class RippleEffectExample { - render() { - return [ - - -
- A plain div with a bounded ripple effect - -
+ripple effectコンポーネントは、[Material Design ink ripple interaction effect](https://material.io/develop/web/supporting/ripple)を追加します。このコンポーネントは `` の内部でのみ使用でき、任意の要素の内部に追加できます。 - +親要素に [relative position](https://developer.mozilla.org/en-US/docs/Web/CSS/position) を設定することが重要です。波紋エフェクトはabsolute positionであり、相対位置決めされた最も近い親要素をカバーするからです。また、親要素には `ion-activatable` クラスを設定します。これは、波及効果にその要素がクリック可能であることを伝えるものです。波紋がコンテナからはみ出す場合は、親要素に `overflow: hidden` を追加することを推奨します。 -
- A plain div with an unbounded ripple effect - -
- -
-
- ]; - } -} -``` +## 基本的な使い方 -```css -.ripple-parent { - position: relative; - overflow: hidden; -} -``` +import Basic from '@site/static/usage/v8/ripple-effect/basic/index.md'; -
+ - +## タイプ -```html - - +## カスタマイズ - -``` +import Customizing from '@site/static/usage/v8/ripple-effect/customizing/index.md'; - + -
-## Properties +## プロパティ -## Events +## イベント -## Methods +## メソッド ## CSS Shadow Parts -## CSS Custom Properties +## CSSカスタムプロパティ ## Slots - \ No newline at end of file + diff --git a/docs/api/route-redirect.md b/docs/api/route-redirect.md index beff634f922..c70ffa3d00e 100644 --- a/docs/api/route-redirect.md +++ b/docs/api/route-redirect.md @@ -1,58 +1,43 @@ --- title: "ion-route-redirect" -hide_table_of_contents: true --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; -import Props from '@site/static/auto-generated/route-redirect/props.md'; -import Events from '@site/static/auto-generated/route-redirect/events.md'; -import Methods from '@site/static/auto-generated/route-redirect/methods.md'; -import Parts from '@site/static/auto-generated/route-redirect/parts.md'; -import CustomProps from '@site/static/auto-generated/route-redirect/custom-props.md'; -import Slots from '@site/static/auto-generated/route-redirect/slots.md'; +import Props from '@ionic-internal/component-api/v8/route-redirect/props.md'; +import Events from '@ionic-internal/component-api/v8/route-redirect/events.md'; +import Methods from '@ionic-internal/component-api/v8/route-redirect/methods.md'; +import Parts from '@ionic-internal/component-api/v8/route-redirect/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/route-redirect/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/route-redirect/slots.md'; - ion-route-redirect Plugin: Redirect 'from' a URL 'to' Another URL - + ion-route-redirect: Redirect 'from' a URL 'to' Another URL + import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; - -

Contents

- - - - - -A route redirect can only be used with an `ion-router` as a direct child of it. +ルートリダイレクトは `ion-router` を直接の子としてのみ使うことができます。 :::note - Note: this component should only be used with vanilla and Stencil JavaScript projects. For Angular projects, use [`ion-router-outlet`](router-outlet.md) and the Angular router. + Note: このコンポーネントは、vanilla と Stencil での JavaScriptプロジェクトでのみ使用してください。Angularプロジェクトでは、[`ion-router-outlet`](router-outlet.md) と Angularルータを使用してください。 ::: -The route redirect has two configurable properties: - - `from` - - `to` +ルートリダイレクトには、2つの設定可能なプロパティがあります。 +- `from` +- `to` -It redirects "from" a URL "to" another URL. When the defined `ion-route-redirect` rule matches, the router will redirect from the path specified in the `from` property to the path in the `to` property. In order for a redirect to occur the `from` path needs to be an exact match to the navigated URL. +これは、ある URL から別の URL へとリダイレクトします。定義された `ion-route-redirect` ルールがマッチすると、ルータは `from` プロパティで指定されたパスから `to` プロパティで指定されたパスへリダイレクトします。リダイレクトを行うには、`from` のパスがナビゲートされる URL と完全に一致する必要があります。 -## Multiple Route Redirects +## 複数ルートのリダイレクト -An arbitrary number of redirect routes can be defined inside an `ion-router`, but only one can match. +任意の数のリダイレクトルートを `ion-router` の内部で定義することができますが、合致するのは1つだけです。 -A route redirect will never call another redirect after its own redirect, since this could lead to infinite loops. +ルートリダイレクトは、それ自身のリダイレクトの後に別のリダイレクトを呼び出すことはありません。 -Take the following two redirects: +次の2つのリダイレクトを考えてみましょう。 ```html @@ -61,12 +46,12 @@ Take the following two redirects: ``` -If the user navigates to `/admin` the router will redirect to `/login` and stop there. It will never evaluate more than one redirect. +ユーザーが `/admin` に移動した場合、ルーターは `/login` にリダイレクトし、そこで停止します。複数のリダイレクトを評価することはありません。 -## Usage +## 使い方 ```html ``` -### Route Redirects as Guards +### ルートリダイレクトのガード -Redirection routes can work as guards to prevent users from navigating to certain areas of an application based on a given condition, such as if the user is authenticated or not. +リダイレクトルートは、ユーザーが認証されているかどうかなど、与えられた条件に基づいて、ユーザーがアプリケーションの特定の領域に移動するのを防ぐためのガードとして機能することができます。 -A route redirect can be added and removed dynamically to redirect (or guard) some routes from being accessed. In the following example, all urls `*` will be redirected to the `/login` url if `isLoggedIn` is `false`. +ルートリダイレクトは動的に追加・削除することができ、一部のルートをアクセスできないようにリダイレクト(ガード)することができます。次の例では、 `isLoggedIn` が `false` の場合、すべての URL `*` は `/login` にリダイレクトされます。 ```tsx const isLoggedIn = false; @@ -97,7 +82,7 @@ if (!isLoggedIn) { } ``` -Alternatively, the value of `to` can be modified based on a condition. In the following example, the route redirect will check if the user is logged in and redirect to the `/login` url if not. +また、`to`の値は条件に基づいて変更することもできます。次の例では、ルートリダイレクトはユーザーがログインしているかどうかをチェックし、ログインしていない場合は `/login` url にリダイレクトします。 ```html @@ -110,19 +95,19 @@ const routeRedirect = document.querySelector('#tutorialRedirect'); routeRedirect.setAttribute('to', isLoggedIn ? undefined : '/login'); ``` -## Properties +## プロパティ -## Events +## イベント -## Methods +## メソッド ## CSS Shadow Parts -## CSS Custom Properties +## CSSカスタムプロパティ ## Slots diff --git a/docs/api/route.md b/docs/api/route.md index 3c8764727ab..b84642e2be1 100644 --- a/docs/api/route.md +++ b/docs/api/route.md @@ -1,47 +1,34 @@ --- title: "ion-route" -hide_table_of_contents: true --- import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -import Props from '@site/static/auto-generated/route/props.md'; -import Events from '@site/static/auto-generated/route/events.md'; -import Methods from '@site/static/auto-generated/route/methods.md'; -import Parts from '@site/static/auto-generated/route/parts.md'; -import CustomProps from '@site/static/auto-generated/route/custom-props.md'; -import Slots from '@site/static/auto-generated/route/slots.md'; +import Props from '@ionic-internal/component-api/v8/route/props.md'; +import Events from '@ionic-internal/component-api/v8/route/events.md'; +import Methods from '@ionic-internal/component-api/v8/route/methods.md'; +import Parts from '@ionic-internal/component-api/v8/route/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/route/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/route/slots.md'; ion-route: API Route Component for Ionic Framework Apps - + import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; - -

Contents

- - - - - -The route component takes a component and renders it when the Browser URL matches the url property. +ルートコンポーネントはコンポーネントを受け取り、ブラウザの URL が url プロパティと一致したときに、そのコンポーネントをレンダリングします。 :::note - Note: this component should only be used with vanilla and Stencil JavaScript projects. For Angular projects, use [`ion-router-outlet`](router-outlet.md) and the Angular router. + Note: このコンポーネントは、vanilla と Stencil での JavaScriptプロジェクトでのみ使用してください。Angularプロジェクトでは、[`ion-router-outlet`](router-outlet.md) と Angularルータを使用してください。 ::: -## Navigation Hooks +## ナビゲーションフック -Navigation hooks can be used to perform tasks or act as navigation guards. Hooks are used by providing functions to the `beforeEnter` and `beforeLeave` properties on each `ion-route`. Returning `true` allows navigation to proceed, while returning `false` causes it to be cancelled. Returning an object of type `NavigationHookOptions` allows you to redirect navigation to another page. +ナビゲーションフックは、タスクを実行したり、ナビゲーションガードとして動作させるために使用することができます。フックは、各 `ion-route` の `beforeEnter` と `beforeLeave` プロパティに関数を提供することで使用します。`true` を返すとナビゲーションを進めることができ、`false` を返すとナビゲーションがキャンセルされる。NavigationHookOptions` 型のオブジェクトを返すと、ナビゲーションを別のページにリダイレクトすることができます。 ## Interfaces @@ -57,7 +44,7 @@ interface NavigationHookOptions { -## Usage +## 使い方 @@ -263,19 +250,19 @@ const confirmDiscardChanges = async () => { -## Properties +## プロパティ -## Events +## イベント -## Methods +## メソッド ## CSS Shadow Parts -## CSS Custom Properties +## CSSカスタムプロパティ ## Slots diff --git a/docs/api/router-link.md b/docs/api/router-link.md index ac7b3786de1..cd340172388 100644 --- a/docs/api/router-link.md +++ b/docs/api/router-link.md @@ -1,61 +1,44 @@ --- title: "ion-router-link" -hide_table_of_contents: true -demoUrl: "/docs/demos/api/router-link/index.html" -demoSourceUrl: "https://github.com/ionic-team/ionic-docs/tree/main/static/demos/api/router-link/index.html" --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; -import Props from '@site/static/auto-generated/router-link/props.md'; -import Events from '@site/static/auto-generated/router-link/events.md'; -import Methods from '@site/static/auto-generated/router-link/methods.md'; -import Parts from '@site/static/auto-generated/router-link/parts.md'; -import CustomProps from '@site/static/auto-generated/router-link/custom-props.md'; -import Slots from '@site/static/auto-generated/router-link/slots.md'; +import Props from '@ionic-internal/component-api/v8/router-link/props.md'; +import Events from '@ionic-internal/component-api/v8/router-link/events.md'; +import Methods from '@ionic-internal/component-api/v8/router-link/methods.md'; +import Parts from '@ionic-internal/component-api/v8/router-link/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/router-link/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/router-link/slots.md'; - Router Link | Navigating The ion-router-link Component - + ion-router-link: Navigate To a Specified Link + import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; -

Contents

- - - - - -The router link component is used for navigating to a specified link. Similar to the browser's anchor tag, it can accept a href for the location, and a direction for the transition animation. +router linkコンポーネントは、指定されたリンクに移動するために使用します。ブラウザのアンカータグと同様に、hrefで場所を、directionで遷移のアニメーションを指定することができます。 :::note - Note: this component should only be used with vanilla and Stencil JavaScript projects. For Angular projects, use an `
` and `routerLink` with the Angular router. + Note: このコンポーネントは、vanilla と Stencil での JavaScriptプロジェクトでのみ使用してください。Angularプロジェクトでは、[`ion-router-outlet`](router-outlet.md) と Angularルータを使用してください。 ::: +See the [Router](./router) documentation for more information. - - -## Properties +## プロパティ -## Events +## イベント -## Methods +## メソッド ## CSS Shadow Parts -## CSS Custom Properties +## CSSカスタムプロパティ ## Slots diff --git a/docs/api/router-outlet.md b/docs/api/router-outlet.md index 7f4438819bd..b266dc40f27 100644 --- a/docs/api/router-outlet.md +++ b/docs/api/router-outlet.md @@ -1,71 +1,58 @@ --- title: "ion-router-outlet" -hide_table_of_contents: true --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; -import Props from '@site/static/auto-generated/router-outlet/props.md'; -import Events from '@site/static/auto-generated/router-outlet/events.md'; -import Methods from '@site/static/auto-generated/router-outlet/methods.md'; -import Parts from '@site/static/auto-generated/router-outlet/parts.md'; -import CustomProps from '@site/static/auto-generated/router-outlet/custom-props.md'; -import Slots from '@site/static/auto-generated/router-outlet/slots.md'; +import Props from '@ionic-internal/component-api/v8/router-outlet/props.md'; +import Events from '@ionic-internal/component-api/v8/router-outlet/events.md'; +import Methods from '@ionic-internal/component-api/v8/router-outlet/methods.md'; +import Parts from '@ionic-internal/component-api/v8/router-outlet/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/router-outlet/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/router-outlet/slots.md'; import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; -

Contents

- +router outletはAngularの組み込みrouter outletコンポーネントやVueのルーター・ビューコンポーネントと同様の振る舞いをしますが、スタック式のナビゲーションを提供し、ビューをアニメーションで出し入れするためのロジックを含んでいます。 +router outlet はナビゲーション用のメソッドを備えていますが、フレームワークのルーターにあるナビゲーションメソッドを使用することをお勧めします。 +## ライフサイクルHook -The router outlet behaves in a similar way to Angular's built-in router outlet component and Vue's router view component, but contains the logic for providing a stacked navigation, and animating views in and out. +Router OutletでRoutesがレンダリングされた時、アニメーションに関連付けられた特定のIonicイベントにアクセスできます。 -Although router outlet has methods for navigating around, it's recommended to use the navigation methods in your framework's router. -## Life Cycle Hooks +| Event Name | Description | +|--------------------|------------------------------------------------------------------| +| `ionViewWillEnter` | コンポーネントが表示されるアニメーションがはじまる時に発火します。 | +| `ionViewDidEnter` | コンポーネントが表示されるアニメーションが終了した時に発火します。 | +| `ionViewWillLeave` | コンポーネントを離脱するアニメーションがはじまる時に発火します。 | +| `ionViewDidLeave` | コンポーネントを離脱するアニメーションが終了した時に発火します。 | -Routes rendered in a Router Outlet have access to specific Ionic events that are wired up to animations +これらのイベントはIonicのアニメーションシステムと連携し、コンポーネントがアニメーションを完成させたときにアプリの挙動を調整するのに使用できる。これらのイベントはフレームワーク独自のイベントシステムに代わるものではなく、追加されたものです。 -| Event Name | Trigger | -|--------------------|--------------------------------------------------------------------| -| `ionViewWillEnter` | Fired when the component routing to is about to animate into view. | -| `ionViewDidEnter` | Fired when the component routing to has finished animating. | -| `ionViewWillLeave` | Fired when the component routing from is about to animate. | -| `ionViewDidLeave` | Fired when the component routing to has finished animating. | +Router Guardsを扱うために、以前の`ionViewCanEnter` と `ionViewCanLeave`は、フレームワーク特有の同等のものに置き換えられました。Angularには[Router Guards](https://angular.jp/guide/router#milestone-5-route-guards)があります。 -These event tie into Ionic's animation system and can be used to coordinate parts of your app when a Components is done with its animation. These events are not a replacement for your framework's own event system, but an addition. -For handling Router Guards, the older `ionViewCanEnter` and `ionViewCanLeave` have been replaced with their framework specific equivalent. For Angular, there are [Router Guards](https://angular.io/guide/router#milestone-5-route-guards). - - - -## Properties +## プロパティ -## Events +## イベント -## Methods +## メソッド ## CSS Shadow Parts -## CSS Custom Properties +## CSSカスタムプロパティ ## Slots diff --git a/docs/api/router.md b/docs/api/router.md index cadfea87581..2af688b5b1d 100644 --- a/docs/api/router.md +++ b/docs/api/router.md @@ -1,52 +1,44 @@ --- title: "ion-router" -hide_table_of_contents: true --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; -import Props from '@site/static/auto-generated/router/props.md'; -import Events from '@site/static/auto-generated/router/events.md'; -import Methods from '@site/static/auto-generated/router/methods.md'; -import Parts from '@site/static/auto-generated/router/parts.md'; -import CustomProps from '@site/static/auto-generated/router/custom-props.md'; -import Slots from '@site/static/auto-generated/router/slots.md'; +import Props from '@ionic-internal/component-api/v8/router/props.md'; +import Events from '@ionic-internal/component-api/v8/router/events.md'; +import Methods from '@ionic-internal/component-api/v8/router/methods.md'; +import Parts from '@ionic-internal/component-api/v8/router/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/router/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/router/slots.md'; ion-router: Router Component to Coordinate URL Navigation - + import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; -

Contents

- - +ルーターは、vanilla と Stencil での JavaScriptプロジェクト内でルーティングを処理するためのコンポーネントです。 +:::note +注意: このコンポーネントは、vanilla と Stencil での JavaScriptプロジェクトでのみ使用してください。フレームワーク固有のルーティングソリューションについては、[Angular](../angular/navigation)、[React](../react/navigation)、[Vue](../vue/navigation)のルーティングガイドを参照してください。 +::: -The router is a component for handling routing inside vanilla and Stencil JavaScript projects. +アプリケーションはコードベースに単一の `ion-router` コンポーネントを持たなければなりません。 +このコンポーネントは、ブラウザの履歴とのすべての対話を制御し、イベント・システムを介して更新を集約します。 -:::note - Note: this component should only be used with vanilla and Stencil JavaScript projects. For Angular projects, use [`ion-router-outlet`](router-outlet.md) and the Angular router. -::: +`ion-router` は、`ion-nav` と `ion-tabs` 、 `ion-router-outlet` というIonicのナビゲーション機能のURL調整機能に過ぎません。 +つまり、 `ion-router` はDOMにアクセスすることはなく、コンポーネントを表示することも、何らかのライフサイクルイベントを発行することもなく、ブラウザのURLに基づいて、`ion-nav` と `ion-tabs` 、 `ion-router-outlet` に何をいつ「show」すべきかを指示するだけです。 -Apps should have a single `ion-router` component in the codebase. -This component controls all interactions with the browser history and it aggregates updates through an event system. +コンポーネント(ロード/選択)とURLの間の関係を設定するために、`ion-router` はJSX/HTMLを使ってルートのツリーを定義する宣言的な構文を利用します。 -`ion-router` is just a URL coordinator for the navigation outlets of ionic: `ion-nav`, `ion-tabs`, and `ion-router-outlet`. +## 基本的な使い方 -That means the `ion-router` never touches the DOM, it does NOT show the components or emit any kind of lifecycle events, it just tells `ion-nav`, `ion-tabs`, and `ion-router-outlet` what and when to "show" based on the browser's URL. +import BasicExample from '@site/static/usage/v8/router/basic/index.md'; -In order to configure this relationship between components (to load/select) and URLs, `ion-router` uses a declarative syntax using JSX/HTML to define a tree of routes. + ## Interfaces @@ -62,7 +54,7 @@ interface RouterEventDetail { ### RouterCustomEvent -While not required, this interface can be used in place of the `CustomEvent` interface for stronger typing with Ionic events emitted from this component. +必須ではありませんが、このコンポーネントから発行される Ionic イベントでより強く型付けを行うために、`CustomEvent` インターフェースの代わりにこのインターフェースを使用することが可能です。 ```typescript interface RouterCustomEvent extends CustomEvent { @@ -73,7 +65,7 @@ interface RouterCustomEvent extends CustomEvent { -## Usage +## 使い方 ```html @@ -103,19 +95,19 @@ interface RouterCustomEvent extends CustomEvent { ``` -## Properties +## プロパティ -## Events +## イベント -## Methods +## メソッド ## CSS Shadow Parts -## CSS Custom Properties +## CSSカスタムプロパティ ## Slots diff --git a/docs/api/row.md b/docs/api/row.md index 4642f474f28..1362477e3bd 100644 --- a/docs/api/row.md +++ b/docs/api/row.md @@ -1,64 +1,49 @@ --- title: "ion-row" -hide_table_of_contents: true --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - -import Props from '@site/static/auto-generated/row/props.md'; -import Events from '@site/static/auto-generated/row/events.md'; -import Methods from '@site/static/auto-generated/row/methods.md'; -import Parts from '@site/static/auto-generated/row/parts.md'; -import CustomProps from '@site/static/auto-generated/row/custom-props.md'; -import Slots from '@site/static/auto-generated/row/slots.md'; +import Props from '@ionic-internal/component-api/v8/row/props.md'; +import Events from '@ionic-internal/component-api/v8/row/events.md'; +import Methods from '@ionic-internal/component-api/v8/row/methods.md'; +import Parts from '@ionic-internal/component-api/v8/row/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/row/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/row/slots.md'; - ion-row: Horizontal Row Components and Alignment | Ionic API Docs - + ion-row: Horizontal Row Components of the Grid System + import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; -

Contents

- - - - - -Rows are horizontal components of the [grid](grid.md) system and contain varying numbers of -[columns](col.md). They ensure the columns are positioned properly. +Rowは[Grid](./grid)システムの水平方向の構成要素で、さまざまな数の +[columns](./col)を含む。列が適切に配置されるようにします。 -See [Grid Layout](/docs/layout/grid) for more information. +詳しくは[grid](./grid)のドキュメントを参照してください。 ## Row Alignment -By default, columns will stretch to fill the entire height of the row and wrap when necessary. Rows are [flex containers](https://developer.mozilla.org/en-US/docs/Glossary/Flex_Container), so there are several [CSS classes](/docs/layout/css-utilities#flex-container-properties) that can be applied to a row to customize this behavior. +デフォルトでは、列は行の高さ全体を埋めるように伸縮し、必要に応じて折り返されます。行は [Flexコンテナ](https://developer.mozilla.org/en-US/docs/Glossary/Flex_Container) なので、この動作をカスタマイズするために、行に適用できるいくつかの [CSS クラス](/docs/layout/css-utilities#flex-container-properties) が用意されています。 -## Properties +## プロパティ -## Events +## イベント -## Methods +## メソッド ## CSS Shadow Parts -## CSS Custom Properties +## CSSカスタムプロパティ ## Slots - \ No newline at end of file + diff --git a/docs/api/searchbar.md b/docs/api/searchbar.md index 9461f424ce6..91f0db1d5d6 100644 --- a/docs/api/searchbar.md +++ b/docs/api/searchbar.md @@ -1,394 +1,141 @@ --- title: "ion-searchbar" -hide_table_of_contents: true -demoUrl: "/docs/demos/api/searchbar/index.html" -demoSourceUrl: "https://github.com/ionic-team/ionic-docs/tree/main/static/demos/api/searchbar/index.html" --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - -import Props from '@site/static/auto-generated/searchbar/props.md'; -import Events from '@site/static/auto-generated/searchbar/events.md'; -import Methods from '@site/static/auto-generated/searchbar/methods.md'; -import Parts from '@site/static/auto-generated/searchbar/parts.md'; -import CustomProps from '@site/static/auto-generated/searchbar/custom-props.md'; -import Slots from '@site/static/auto-generated/searchbar/slots.md'; +import Props from '@ionic-internal/component-api/v8/searchbar/props.md'; +import Events from '@ionic-internal/component-api/v8/searchbar/events.md'; +import Methods from '@ionic-internal/component-api/v8/searchbar/methods.md'; +import Parts from '@ionic-internal/component-api/v8/searchbar/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/searchbar/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/searchbar/slots.md'; - Search Bar Icon for Keyboard Text Display | Ion-Search Bar - + ion-searchbar: Search Bar for Searching a Collection + import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; -

Contents

- - - - - -Searchbars represent a text field that can be used to search through a collection. They can be displayed inside of a toolbar or the main content. - -A Searchbar should be used instead of an input to search lists. A clear button is displayed upon entering input in the searchbar's text field. Clicking on the clear button will erase the text field and the input will remain focused. A cancel button can be enabled which will clear the input and lose the focus upon click. - -## Keyboard Display - -### Android - -By default, tapping the input will cause the keyboard to appear with a magnifying glass icon on the submit button. You can optionally set the `inputmode` property to `"search"`, which will change the icon from a magnifying glass to a carriage return. - -### iOS - -By default, tapping the input will cause the keyboard to appear with the text "return" on a gray submit button. You can optionally set the `inputmode` property to `"search"`, which will change the text from "return" to "go", and change the button color from gray to blue. Alternatively, you can wrap the `ion-searchbar` in a `form` element with an `action` property. This will cause the keyboard to appear with a blue submit button that says "search". - -## Interfaces - -### SearchbarChangeEventDetail - -```typescript -interface SearchbarChangeEventDetail { - value?: string; -} -``` - -### SearchbarCustomEvent - -While not required, this interface can be used in place of the `CustomEvent` interface for stronger typing with Ionic events emitted from this component. - -```typescript -interface SearchbarCustomEvent extends CustomEvent { - detail: SearchbarChangeEventDetail; - target: HTMLIonSearchbarElement; -} -``` - - - -## Usage - - - - - -```html - - - - - - - - - - - - - - - - - - - - - - - +検索バーは、コレクションを検索するために使用できるテキストフィールドを表します。ツールバーやメインコンテンツの中に表示することができます。検索バーは、検索リストへの入力の代わりに使用する必要があります。 - - - - +## 基本的な使い方 - - +import Basic from '@site/static/usage/v8/searchbar/basic/index.md'; - - + - - - - - - -``` - - - - - - -```html - - - - - +## 検索アイコン - - +検索バーのInputフィールドの左に表示される検索アイコンです。任意の [Ionicon](https://ionic.io/ionicons/) にカスタマイズすることが可能です。 - - +import SearchIcon from '@site/static/usage/v8/searchbar/search-icon/index.md'; - - + - - - - +## クリアボタン - - +検索バーに値があるとき、または検索バーのテキストフィールドに入力があったときに、クリアボタンが表示されます。クリアボタンをクリックすると、テキストフィールドは消去され、入力はフォーカスされたままになります。デフォルトでは、クリアボタンは検索バーをフォーカスしたときに表示されるように設定されていますが、常に表示する、または全く表示しないように設定することができます。また、クリアボタン内のアイコンは、任意の[Ionicon](https://ionic.io/ionicons/)にカスタマイズすることができます。 - - +import ClearButton from '@site/static/usage/v8/searchbar/clear-button/index.md'; - - + - - - - +## キャンセルボタン - - - - - - - -``` - - +キャンセルボタンを有効にすると、クリックすると入力がクリアされ、フォーカスが失われます。デフォルトでは、キャンセルボタンは表示されないように設定されていますが、常に表示するように設定したり、検索バーにフォーカスが当たったときのみ表示するように設定したりすることができます。キャンセルボタンは `ios` モードではテキストとして、`md` モードではアイコンとして表示されます。テキストとアイコンはそれぞれ別のプロパティでカスタマイズでき、アイコンは任意の[Ionicon](https://ionic.io/ionicons/)を使用することができます。 +import CancelButton from '@site/static/usage/v8/searchbar/cancel-button/index.md'; - + -```tsx -import React, { useState } from 'react'; -import { IonContent, IonHeader, IonPage, IonTitle, IonToolbar, IonSearchbar, IonFooter } from '@ionic/react'; -export const SearchBarExamples: React.FC = () => { - const [searchText, setSearchText] = useState(''); - return ( - - - - IonSearchBar Examples - - - -

Default Searchbar

- setSearchText(e.detail.value!)}> +## ツールバーの中に配置した検索バー -

Searchbar with cancel button always shown

- setSearchText(e.detail.value!)} showCancelButton="always"> +検索バーは、ツールバーの中に配置されたときにネイティブに見えるようにスタイルされています。iOSでは、検索バーは、ページタイトルを含むツールバーの下にある、独自のツールバーに配置されるべきです。Material Designでは、検索バーは、独自のツールバーに永続的に表示されるか、ページタイトルを含むツールバーの上に展開されるかのいずれかです。 -

Searchbar with cancel button never shown

- setSearchText(e.detail.value!)} showCancelButton="never"> + +import Toolbar from '@site/static/usage/v8/toolbar/searchbars/index.md'; -

Searchbar with cancel button shown on focus

- setSearchText(e.detail.value!)} showCancelButton="focus"> + -

Searchbar with danger color

- setSearchText(e.detail.value!)} color="danger"> -

Searchbar with telephone type

- setSearchText(e.detail.value!)} type="tel"> +## Debounce -

Searchbar with numeric inputmode

- setSearchText(e.detail.value!)} inputmode="numeric"> +検索バーにDebounceを設定して、`ionInput`イベントのトリガーを遅延させることができます。これは、入力に文字が入力されるたびにデータを要求するのではなく、要求を出すのを待つために使うことができるので、データを問い合わせるときに便利です。 -

Searchbar disabled

- setSearchText(e.detail.value!)} disabled={true}> +import Debounce from '@site/static/usage/v8/searchbar/debounce/index.md'; -

Searchbar with a cancel button and custom cancel button text

- setSearchText(e.detail.value!)} showCancelButton="focus" cancelButtonText="Custom Cancel"> + -

Searchbar with a custom debounce - Note: debounce only works on onIonChange event

- setSearchText(e.detail.value!)} debounce={1000}> -

Animated Searchbar

- setSearchText(e.detail.value!)} animated> +## テーマ -

Searchbar with a placeholder

- setSearchText(e.detail.value!)} placeholder="Filter Schedules"> - -

Searchbar in a Toolbar

- - setSearchText(e.detail.value!)}> - - -
- - - Search Text: {searchText ?? '(none)'} - - -
- ); -}; -``` +### Colors -
+import Colors from '@site/static/usage/v8/searchbar/theming/colors/index.md'; + - +## CSSカスタムプロパティ -```tsx -import { Component, h } from '@stencil/core'; +検索バーは、スコープをつけてカプセル化されています。これは、実行時に各スタイルに追加のクラスを付加することで、CSSを自動的にスコープ化することを意味します。CSSでscopedセレクタを上書きするには、[higher specificity](https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity) セレクタが必要です。そのため、クラスを追加してカスタマイズすることをお勧めします。 -@Component({ - tag: 'searchbar-example', - styleUrl: 'searchbar-example.css' -}) -export class SearchbarExample { - render() { - return [ - // Default Searchbar - , +import CSSProps from '@site/static/usage/v8/searchbar/theming/css-properties/index.md'; - // Searchbar with cancel button always shown - , + - // Searchbar with cancel button never shown - , - // Searchbar with cancel button shown on focus - , +## キーボード表示 - // Searchbar with danger color - , - - // Searchbar with value - , - - // Searchbar with telephone type - , - - // Searchbar with numeric inputmode - , +### Android - // Searchbar disabled - , +デフォルトでは、Inputをタップするとキーボードが表示され、サブミットボタンに虫眼鏡のアイコンが表示されます。オプションで `inputmode` プロパティを `"search"` に設定すると、アイコンが虫眼鏡からcarriage returnに変更されます。 - // Searchbar with a cancel button and custom cancel button text - , +### iOS - // Searchbar with a custom debounce - , +デフォルトでは、Inputをタップするとキーボードが表示され、グレーのSubmitボタンに「return」のテキストが表示されます。オプションで `inputmode` プロパティを `"search"` に設定すると、テキストが "return" から "go" に変わり、ボタンの色もグレーから青に変わります。また、`ion-searchbar` を `form` 要素でラップして、 `action` プロパティを設定することもできます。これにより、キーボードが表示され、"search "という青いSubmitボタンが表示されるようになります。 - // Animated Searchbar - , +## Interfaces - // Searchbar with a placeholder - , +### SearchbarChangeEventDetail - // Searchbar in a Toolbar - - - - ]; - } +```typescript +interface SearchbarChangeEventDetail { + value?: string; } ``` +### SearchbarCustomEvent - - - - - -```html - - - +```typescript +interface SearchbarCustomEvent extends CustomEvent { + detail: SearchbarChangeEventDetail; + target: HTMLIonSearchbarElement; +} ``` - - -
-## Properties +## プロパティ -## Events +## イベント -## Methods +## メソッド ## CSS Shadow Parts -## CSS Custom Properties +## CSSカスタムプロパティ ## Slots - \ No newline at end of file + diff --git a/docs/api/segment-button.md b/docs/api/segment-button.md index cc89dddc90b..16a31b30629 100644 --- a/docs/api/segment-button.md +++ b/docs/api/segment-button.md @@ -1,860 +1,71 @@ --- title: "ion-segment-button" -hide_table_of_contents: true --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - -import Props from '@site/static/auto-generated/segment-button/props.md'; -import Events from '@site/static/auto-generated/segment-button/events.md'; -import Methods from '@site/static/auto-generated/segment-button/methods.md'; -import Parts from '@site/static/auto-generated/segment-button/parts.md'; -import CustomProps from '@site/static/auto-generated/segment-button/custom-props.md'; -import Slots from '@site/static/auto-generated/segment-button/slots.md'; +import Props from '@ionic-internal/component-api/v8/segment-button/props.md'; +import Events from '@ionic-internal/component-api/v8/segment-button/events.md'; +import Methods from '@ionic-internal/component-api/v8/segment-button/methods.md'; +import Parts from '@ionic-internal/component-api/v8/segment-button/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/segment-button/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/segment-button/slots.md'; ion-segment-button | Segment Button Icon and Segment Value - + import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; -

Contents

- - - - - -Segment buttons are groups of related buttons inside of a [Segment](segment.md). They are displayed in a horizontal row. A segment button can be checked by default by setting the `value` of the segment to the `value` of the segment button. Only one segment button can be selected at a time. - - - - -## Usage - - - - - -```html - - - - Friends - - - Enemies - - - - - - - Paid - - - Free - - - Top - - - - - - - - - - - - - - - - - Bookmarks - - - Reading List - - - Shared Links - - - - - - - Item One - - - Item Two - - - Item Three - - - - - - - - - - - - - - - - - - - - Item One - - - - Item Two - - - - Item Three - - - - - - - - - Item One - - - - Item Two - - - - Item Three - - - - - - - Item One - - - - Item Two - - - - Item Three - - - - - - - - - Item One - - - - Item Two - - - - Item Three - - -``` - -```typescript -import { Component } from '@angular/core'; - -@Component({ - selector: 'segment-button-example', - templateUrl: 'segment-button-example.html', - styleUrls: ['./segment-button-example.css'], -}) -export class SegmentButtonExample { - segmentChanged(ev: any) { - console.log('Segment changed', ev); - } -} -``` - - - - - - -```html - - - - Friends - - - Enemies - - - - - - - Paid - - - Free - - - Top - - - - - - - - - - - - - - - - - Bookmarks - - - Reading List - - - Shared Links - - - - - - - Item One - - - Item Two - - - Item Three - - - - - - - - - - - - - - - - - - - - Item One - - - - Item Two - - - - Item Three - - - - - - - - - Item One - - - - Item Two - - - - Item Three - - - - - - - Item One - - - - Item Two - - - - Item Three - - - - - - - - - Item One - - - - Item Two - - - - Item Three - - -``` - -```javascript -// Listen for ionChange on segment -const segment = document.querySelector('ion-segment'); -segment.addEventListener('ionChange', (ev) => { - console.log('Segment changed', ev); -}) -``` - - - - - - -```tsx -import React from 'react'; -import { IonContent, IonHeader, IonPage, IonTitle, IonToolbar, IonSegment, IonSegmentButton, IonLabel, IonIcon } from '@ionic/react'; -import { call, camera, bookmark, heart, pin } from 'ionicons/icons'; - -export const SegmentButtonExamples: React.FC = () => { - return ( - - - - SegmentButton - - - - {/*-- Segment buttons with text and click listener --*/} - console.log(`${e.detail.value} segment selected`)}> - - Friends - - - Enemies - - - - {/*-- Segment buttons with the first checked and the last disabled --*/} - - - Paid - - - Free - - - Top - - - - {/*-- Segment buttons with values and icons --*/} - - - - - - - - - - {/*-- Segment with a value that checks the last button --*/} - - - Bookmarks - - - Reading List - - - Shared Links - - - - {/*-- Label only --*/} - - - Item One - - - Item Two - - - Item Three - - - - {/*-- Icon only --*/} - - - - - - - - - - - - - {/*-- Icon top --*/} - - - Item One - - - - Item Two - - - - Item Three - - - - - {/*-- Icon bottom --*/} - - - - Item One - - - - Item Two - - - - Item Three - - - - {/*-- Icon start --*/} - - - Item One - - - - Item Two - - - - Item Three - - - - - {/*-- Icon end --*/} - - - - Item One - - - - Item Two - - - - Item Three - - - - - ); -}; -``` - - - - - - - -```tsx -import { Component, h } from '@stencil/core'; - -@Component({ - tag: 'segment-button-example', - styleUrl: 'segment-button-example.css' -}) -export class SegmentButtonExample { - segmentChanged(ev: any) { - console.log('Segment changed', ev); - } - - render() { - return [ - // Segment buttons with text and click listener - this.segmentChanged(ev)}> - - Friends - - - Enemies - - , - - // Segment buttons with the first checked and the last disabled - - - Paid - - - Free - - - Top - - , - - // Segment buttons with values and icons - - - - - - - - , - // Segment with a value that checks the last button - - - Bookmarks - - - Reading List - - - Shared Links - - , +セグメントボタンは、[segment](segment.md)の中にある、関連するボタンのグループです。それらは横一列に表示されます。セグメントの `value` をセグメントボタンの `value` に設定することで、デフォルトでセグメントボタンを選択することができます。一度に選択できるセグメントボタンは1つだけです。 - // Label only - - - Item One - - - Item Two - - - Item Three - - , - // Icon only - - - - - - - - - - - , +## 基本的な使い方 - // Icon top - - - Item One - - - - Item Two - - - - Item Three - - - , +import Basic from '@site/static/usage/v8/segment-button/basic/index.md'; - // Icon bottom - - - - Item One - - - - Item Two - - - - Item Three - - , + - // Icon start - - - Item One - - - - Item Two - - - - Item Three - - - , - // Icon end - - - - Item One - - - - Item Two - - - - Item Three - - - ]; - } -} -``` +## Layout - +`layout`プロパティは、デフォルトで `"icon-top"` に設定されています。セグメントボタンにアイコンとラベルの両方がある場合、アイコンはラベルの上に表示されます。この動作は `layout` プロパティを `"icon-bottom"`, `"icon-start"`, `"icon-end"` に設定することで変更可能で、それぞれアイコンをラベルの下、ラベルの先頭(LTRでは左、RTLでは右)、ラベルの末尾(LTRでは右、RTLでは左)に表示することができます。 +import Layout from '@site/static/usage/v8/segment-button/layout/index.md'; - + -```html - + - -``` +## CSSカスタムプロパティ +import CSSProps from '@site/static/usage/v8/segment-button/theming/css-properties/index.md'; - + - -## Properties +## プロパティ -## Events +## イベント -## Methods +## メソッド ## CSS Shadow Parts -## CSS Custom Properties +## CSSカスタムプロパティ ## Slots - \ No newline at end of file + diff --git a/docs/api/segment-content.md b/docs/api/segment-content.md new file mode 100644 index 00000000000..3c17b07eceb --- /dev/null +++ b/docs/api/segment-content.md @@ -0,0 +1,52 @@ +--- +title: "ion-segment-content" +--- + +import Props from '@ionic-internal/component-api/v8/segment-content/props.md'; +import Events from '@ionic-internal/component-api/v8/segment-content/events.md'; +import Methods from '@ionic-internal/component-api/v8/segment-content/methods.md'; +import Parts from '@ionic-internal/component-api/v8/segment-content/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/segment-content/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/segment-content/slots.md'; + + + ion-segment-content: Display control element for swipeable segments + + + +import EncapsulationPill from '@components/page/api/EncapsulationPill'; + + + +Segment content is a wrapper element used to control the display of child elements when using swipeable segments. Segment content elements are children of a single +[segment view](./segment-view.md) instance that is linked to a [segment](./segment.md). See our [swipeable segments](./segment.md#swipeable-segments) documentation +for more information on how to use segment contents. + +## Usage + +Each `ion-segment-content` needs a unique `id` attribute. This will be used to link the segment content to a segment button via the button's +[contentId property](./segment-button.md#properties). + + + +import Swipeable from '@site/static/usage/v8/segment/swipeable/index.md'; + + + +## Properties + + +## Events + + +## Methods + + +## CSS Shadow Parts + + +## CSS Custom Properties + + +## Slots + \ No newline at end of file diff --git a/docs/api/segment-view.md b/docs/api/segment-view.md new file mode 100644 index 00000000000..5d0054c4ff8 --- /dev/null +++ b/docs/api/segment-view.md @@ -0,0 +1,40 @@ +--- +title: "ion-segment-view" +--- + +import Props from '@ionic-internal/component-api/v8/segment-view/props.md'; +import Events from '@ionic-internal/component-api/v8/segment-view/events.md'; +import Methods from '@ionic-internal/component-api/v8/segment-view/methods.md'; +import Parts from '@ionic-internal/component-api/v8/segment-view/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/segment-view/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/segment-view/slots.md'; + + + ion-segment-view: Controller element for swipeable segments + + + +import EncapsulationPill from '@components/page/api/EncapsulationPill'; + + + +Segment view is a wrapper element that links a group of [segment contents](./segment-content.md) to a [segment](./segment.md) when using swipeable segments. +See our [swipeable segments](./segment.md#swipeable-segments) documentation for more information on how to use segment views. + +## Properties + + +## Events + + +## Methods + + +## CSS Shadow Parts + + +## CSS Custom Properties + + +## Slots + \ No newline at end of file diff --git a/docs/api/segment.md b/docs/api/segment.md index 75c47759916..9be86bcbb6a 100644 --- a/docs/api/segment.md +++ b/docs/api/segment.md @@ -1,665 +1,134 @@ --- title: "ion-segment" -hide_table_of_contents: true -demoUrl: "/docs/demos/api/segment/index.html" -demoSourceUrl: "https://github.com/ionic-team/ionic-docs/tree/main/static/demos/api/segment/index.html" --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - -import Props from '@site/static/auto-generated/segment/props.md'; -import Events from '@site/static/auto-generated/segment/events.md'; -import Methods from '@site/static/auto-generated/segment/methods.md'; -import Parts from '@site/static/auto-generated/segment/parts.md'; -import CustomProps from '@site/static/auto-generated/segment/custom-props.md'; -import Slots from '@site/static/auto-generated/segment/slots.md'; +import Props from '@ionic-internal/component-api/v8/segment/props.md'; +import Events from '@ionic-internal/component-api/v8/segment/events.md'; +import Methods from '@ionic-internal/component-api/v8/segment/methods.md'; +import Parts from '@ionic-internal/component-api/v8/segment/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/segment/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/segment/slots.md'; ion-segment: API Documentation for Segmented Controls - + import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; -

Contents

- +Segmentsは、関連するボタンのグループを水平方向の行に表示することができ、segmented controlsとも呼ばれます。これらは、toolbarまたはメインコンテンツの内部に表示できます。 + +これらの機能は、1つを選択すると他のすべてが選択解除されるTabsと似ています。Segmentsは、コンテンツ内の異なるビューを切り替える場合に便利です。クリックしてページ間の遷移をコントロールする場合は、Segmentsの代わりにTabsを使用してください。 + +## 基本的な使い方 +セグメントは[セグメントボタン](./segment-button)からなり、各ボタンには`value`プロパティが設定されています。セグメントの `value` プロパティをボタンの値と一致させることで、そのボタンを選択することができます。また、セグメントを無効にすることで、ユーザがセグメントと対話できないようにすることができます。 -Segments display a group of related buttons, sometimes known as segmented controls, in a horizontal row. They can be displayed inside of a toolbar or the main content. +import Basic from '@site/static/usage/v8/segment/basic/index.md'; + + -Their functionality is similar to tabs, where selecting one will deselect all others. Segments are useful for toggling between different views inside of the content. Tabs should be used instead of a segment when clicking on a control should navigate between pages. ## Scrollable Segments -Segments are not scrollable by default. Each segment button has a fixed width, and the width is determined by dividing the number of segment buttons by the screen width. This ensures that each segment button can be displayed on the screen without having to scroll. As a result, some segment buttons with longer labels may get cut off. To avoid this we recommend either using a shorter label or switching to a scrollable segment by setting the `scrollable` property to `true`. This will cause the segment to scroll horizontally, but will allow each segment button to have a variable width. +デフォルトでは、セグメントはスクロールできません。各セグメントボタンの幅は固定で、セグメントボタンの数を画面幅で割って幅を決定します。これにより、各セグメントボタンがスクロールすることなく画面に表示されることが保証されます。そのため、ラベルが長いセグメントボタンは、一部が切れてしまうことがあります。これを避けるために、短いラベルを使用するか、`scrollable` プロパティを `true` に設定してスクロール可能なセグメントに変更することをお勧めします。これはセグメントを水平方向にスクロールさせますが、各セグメントボタンの幅を変更することができます。 -## Accessibility +import Scrollable from '@site/static/usage/v8/segment/scrollable/index.md'; -### Keyboard Navigation + -The component has full keyboard support for navigating between and selecting `ion-segment-button` elements. By default, keyboard navigation will only focus `ion-segment-button` elements, but you can use the `selectOnFocus` property to ensure that they get selected on focus as well. The following table details what each key does: -| Key | Function | -| ------------------ | -------------------------------------------------------------- | -| `ArrowRight` | Focuses the next focusable element. | -| `ArrowLeft` | Focuses the previous focusable element. | -| `Home` | Focuses the first focusable element. | -| `End` | Focuses the last focusable element. | -| `Space` or `Enter` | Selects the element that is currently focused. | +## Segments in Toolbars -## Interfaces + +import Toolbar from '@site/static/usage/v8/toolbar/segments/index.md'; -### SegmentChangeEventDetail + -```typescript -interface SegmentChangeEventDetail { - value?: string; -} -``` -### SegmentCustomEvent +## スワイプ可能なセグメント -While not required, this interface can be used in place of the `CustomEvent` interface for stronger typing with Ionic events emitted from this component. +それぞれの [セグメントボタン](./segment-button.md) は、セグメントがアクティブになったときに表示される [セグメントコンテンツ](./segment-content.md) 要素と関連付けることができます。 +要素に関連付けることができます。この方法では、各セグメントをスワイプまたはスクロールすることで、セグメントの内容が更新されます。 -```typescript -interface SegmentCustomEvent extends CustomEvent { - target: HTMLIonSegmentElement; - detail: SegmentChangeEventDetail; -} -``` +:::warning +スワイプ可能なセグメントを使用しているときに `ion-segment` に初期値 `value` が割り当てられていない場合、セグメントのデフォルトは最初のセグメントボタンの値になります。 +スワイプ可能なセグメントを使用する場合、セグメントボタンを無効にすることはできません。 +::: +import Swipeable from '@site/static/usage/v8/segment/swipeable/index.md'; -## Usage - - - - - -```html - - - - Friends - - - Enemies - - - - - - - Sunny - - - Rainy - - - - - - - Dogs - - - Cats - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Standard - - - Hybrid - - - Satellite - - - - - - - - - - - - - - - - - - - Python - - - Javascript - - -``` + -```typescript -import { Component } from '@angular/core'; - -@Component({ - selector: 'segment-example', - templateUrl: 'segment-example.html', - styleUrls: ['./segment-example.css'], -}) -export class SegmentExample { - segmentChanged(ev: any) { - console.log('Segment changed', ev); - } -} -``` +## Theming +### Colors - - - - - -```html - - - - Friends - - - Enemies - - - - - - - Sunny - - - Rainy - - - - - - - Dogs - - - Cats - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Standard - - - Hybrid - - - Satellite - - - - - - - - - - - - - - - - - - - Python - - - Javascript - - -``` +import Colors from '@site/static/usage/v8/segment/theming/colors/index.md'; -```javascript -// Listen for ionChange on all segments -const segments = document.querySelectorAll('ion-segment') -for (let i = 0; i < segments.length; i++) { - segments[i].addEventListener('ionChange', (ev) => { - console.log('Segment changed', ev); - }) -} -``` + - - - - - -```tsx -import React from 'react'; -import { IonContent, IonHeader, IonPage, IonTitle, IonToolbar, IonSegment, IonSegmentButton, IonLabel, IonIcon } from '@ionic/react'; -import { call, home, heart, pin, star, globe, basket, camera, bookmark } from 'ionicons/icons'; - -export const SegmentExamples: React.FC = () => { - return ( - - - - SegmentExamples - - - - {/*-- Default Segment --*/} - console.log('Segment selected', e.detail.value)}> - - Friends - - - Enemies - - - - {/*-- Disabled Segment --*/} - console.log('Segment selected', e.detail.value)} disabled value="sunny"> - - Sunny - - - Rainy - - - - {/*-- Segment with anchors --*/} - console.log('Segment selected', e.detail.value)}> - - Dogs - - - Cats - - - - {/*-- Scrollable Segment --*/} - - - - - - - - - - - - - - - - - - - - - - - - - {/*-- Segment with secondary color --*/} - console.log('Segment selected', e.detail.value)} color="secondary"> - - Standard - - - Hybrid - - - Satellite - - - - {/*-- Segment in a toolbar --*/} - - console.log('Segment selected', e.detail.value)}> - - - - - - - - - - {/*-- Segment with default selection --*/} - console.log('Segment selected', e.detail.value)} value="javascript"> - - Python - - - Javascript - - - - - ); -}; +## CSSカスタムプロパティ -``` +import CSSProps from '@site/static/usage/v8/segment/theming/css-properties/index.md'; + + + + +## アクセシビリティ + +### キーボードインタラクション + +このコンポーネントは、`ion-segment-button`要素間のナビゲーションと選択について、フルキーボードサポートを備えています。デフォルトでは、キーボードナビゲーションは `ion-segment-button` 要素にのみフォーカスしますが、`selectOnFocus` プロパティを使用すると、フォーカスされた要素も確実に選択されるようになります。次の表は、それぞれのキーが何をするのかの詳細です。 + +| Key | Description | +| ------------------------------------ | ---------------------------------------------- | +| ArrowRight | Focuses the next focusable element. | +| ArrowLeft | Focuses the previous focusable element. | +| Home | Focuses the first focusable element. | +| End | Focuses the last focusable element. | +| Space or Enter | Selects the element that is currently focused. | + +## Interfaces + +### SegmentChangeEventDetail - - - - - -```tsx -import { Component, h } from '@stencil/core'; - -@Component({ - tag: 'segment-example', - styleUrl: 'segment-example.css' -}) -export class SegmentExample { - segmentChanged(ev: any) { - console.log('Segment changed', ev); - } - - render() { - return [ - // Default Segment - this.segmentChanged(ev)}> - - Friends - - - Enemies - - , - - // Disabled Segment - this.segmentChanged(ev)} disabled={true} value="sunny"> - - Sunny - - - Rainy - - , - - // Segment with anchors - this.segmentChanged(ev)}> - - Dogs - - - Cats - - , - - // Scrollable Segment - - - - - - - - - - - - - - - - - - - - - - - , - - // Segment with secondary color - this.segmentChanged(ev)} color="secondary"> - - Standard - - - Hybrid - - - Satellite - - , - - // Segment in a toolbar - - this.segmentChanged(ev)}> - - - - - - - - , - - // Segment with default selection - this.segmentChanged(ev)} value="javascript"> - - Python - - - Javascript - - - ]; - } +```typescript +interface SegmentChangeEventDetail { + value?: string; } ``` - - - - - -```html - - - -``` +### SegmentCustomEvent +必須ではありませんが、このコンポーネントから発行される Ionic イベントでより強く型付けを行うために、`CustomEvent` インターフェースの代わりにこのインターフェースを使用することが可能です。 - +```typescript +interface SegmentCustomEvent extends CustomEvent { + target: HTMLIonSegmentElement; + detail: SegmentChangeEventDetail; +} +``` - -## Properties +## プロパティ -## Events +## イベント -## Methods +## メソッド ## CSS Shadow Parts -## CSS Custom Properties +## CSSカスタムプロパティ ## Slots - \ No newline at end of file + diff --git a/docs/api/select-option.md b/docs/api/select-option.md index f26ce97edab..f5852382a7c 100644 --- a/docs/api/select-option.md +++ b/docs/api/select-option.md @@ -1,733 +1,41 @@ --- title: "ion-select-option" -hide_table_of_contents: true --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - -import Props from '@site/static/auto-generated/select-option/props.md'; -import Events from '@site/static/auto-generated/select-option/events.md'; -import Methods from '@site/static/auto-generated/select-option/methods.md'; -import Parts from '@site/static/auto-generated/select-option/parts.md'; -import CustomProps from '@site/static/auto-generated/select-option/custom-props.md'; -import Slots from '@site/static/auto-generated/select-option/slots.md'; +import Props from '@ionic-internal/component-api/v8/select-option/props.md'; +import Events from '@ionic-internal/component-api/v8/select-option/events.md'; +import Methods from '@ionic-internal/component-api/v8/select-option/methods.md'; +import Parts from '@ionic-internal/component-api/v8/select-option/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/select-option/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/select-option/slots.md'; - Select Option | What Is An Option Select on Ionic Framework Apps - + ion-select-option: Option For a Select Dialog + import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; -

Contents

- - - - - -Select Options are components that are child elements of a Select. Each option defined is passed and displayed in the Select dialog. For more information, see the [Select docs](select.md). - -## Customization - -Each `ion-select-option` component that is added as a child of an `ion-select` is passed to the interface to display it in the dialog. It's important to note that the `ion-select-option` element itself is hidden from the view. This means that attempting to style it will not have any effect on the option in the dialog: - -```css -/* DOES NOT work */ -ion-select-option { - color: red; -} -``` - -Instead, each interface option has the class `.select-interface-option` which can be styled. Keep in mind that due to the overlays being scoped components the selector by itself will not work and a custom `cssClass` is recommended to be passed to the interface. - -```css -/* This will NOT work on its own */ -.select-interface-option { - color: red; -} - -/* - * "my-custom-interface" needs to be passed in through - * the cssClass of the interface options for this to work - */ -.my-custom-interface .select-interface-option { - color: red; -} -``` - -:::note - Note: Some interfaces require more in depth styling due to how the options are rendered. See usage for expanded information on this. -::: - - -The options can be styled individually by adding your own class on the `ion-select-option` which gets passed to the interface option. See the [Usage](#usage) section below for examples of styling and setting individual classes on options. - - - - -## Usage - - - - - -```html - - Select - - Brown - Blonde - Black - Red - - -``` - -### Customizing Options - -```html - - Select: Alert Interface - - Brown - Blonde - Black - Red - - - - - Select: Alert Interface (Multiple Selection) - - Brown - Blonde - Black - Red - - - - - Select: Popover Interface - - Brown - Blonde - Black - Red - - - - - Select: Action Sheet Interface - - Brown - Blonde - Black - Red - - -``` - -```css -/* Popover Interface: set color for the popover using Item's CSS variables */ -.my-custom-interface .select-interface-option { - --color: #971e49; - --color-hover: #79193b; -} - -/* Action Sheet Interface: set color for the action sheet using its button CSS variables */ -.my-custom-interface .select-interface-option { - --button-color: #971e49; - --button-color-hover: #79193b; -} - -/* Alert Interface: set color for alert options (single selection) */ -.my-custom-interface .select-interface-option .alert-radio-label { - color: #971e49; -} - -/* Alert Interface: set color for alert options (multiple selection) */ -.my-custom-interface .select-interface-option .alert-checkbox-label { - color: #971e49; -} - -/* Alert Interface: set color for checked alert options (single selection) */ -.my-custom-interface .select-interface-option[aria-checked=true] .alert-radio-label { - color: #79193b; -} - -/* Alert Interface: set color for checked alert options (multiple selection) */ -.my-custom-interface .select-interface-option[aria-checked=true] .alert-checkbox-label { - color: #79193b; -} -``` - -```javascript -// Pass a custom class to each select interface for styling -const selects = document.querySelectorAll('.custom-options'); - -for (var i = 0; i < selects.length; i++) { - selects[i].interfaceOptions = { - cssClass: 'my-custom-interface' - }; -}; -``` - -> Note: In the CSS examples, some of the selectors could be combined together, but are separated out in order to better explain what each selector is for. - -### Customizing Individual Options - -To customize an individual option, set a class on the `ion-select-option`: - -```html - - Select - - Brown - Blonde - Black - Red - - -``` - -```css -/* Popover Interface: set color for the popover using Item's CSS variables */ -.my-custom-interface .brown-option { - --color: #5e3e2c; - --color-hover: #362419; -} -``` - -```javascript -// Pass a custom class to each select interface for styling -const select = document.querySelector('.custom-options'); -select.interfaceOptions = { - cssClass: 'my-custom-interface' -}; -``` - - - - - - -```tsx -import React from 'react'; -import { IonContent, IonItem, IonLabel, IonSelect, IonSelectOption, IonPage } from '@ionic/react'; - -export const SelectOptionExample: React.FC = () => { - return ( - - - - Select - - Brown - Blonde - Black - Red - - - - - ); -}; -``` - -### Customizing Options - -```tsx -import React from 'react'; -import { IonContent, IonItem, IonLabel, IonSelect, IonSelectOption, IonPage } from '@ionic/react'; - -const options = { - cssClass: 'my-custom-interface' -}; - -export const SelectOptionExample: React.FC = () => { - return ( - - - - Select: Alert Interface - - Brown - Blonde - Black - Red - - - - - Select: Alert Interface (Multiple Selection) - - Brown - Blonde - Black - Red - - - - - Select: Popover Interface - - Brown - Blonde - Black - Red - - - - - Select: Action Sheet Interface - - Brown - Blonde - Black - Red - - - - - ); -}; -``` - -```css -/* Popover Interface: set color for the popover using Item's CSS variables */ -.my-custom-interface .select-interface-option { - --color: #971e49; - --color-hover: #79193b; -} - -/* Action Sheet Interface: set color for the action sheet using its button CSS variables */ -.my-custom-interface .select-interface-option { - --button-color: #971e49; - --button-color-hover: #79193b; -} - -/* Alert Interface: set color for alert options (single selection) */ -.my-custom-interface .select-interface-option .alert-radio-label { - color: #971e49; -} - -/* Alert Interface: set color for alert options (multiple selection) */ -.my-custom-interface .select-interface-option .alert-checkbox-label { - color: #971e49; -} - -/* Alert Interface: set color for checked alert options (single selection) */ -.my-custom-interface .select-interface-option[aria-checked=true] .alert-radio-label { - color: #79193b; -} - -/* Alert Interface: set color for checked alert options (multiple selection) */ -.my-custom-interface .select-interface-option[aria-checked=true] .alert-checkbox-label { - color: #79193b; -} -``` - -> Note: In the CSS examples, some of the selectors could be combined together, but are separated out in order to better explain what each selector is for. - - -### Customizing Individual Options - -To customize an individual option, set a class on the `ion-select-option`: - -```tsx -import React from 'react'; -import { IonContent, IonItem, IonLabel, IonSelect, IonSelectOption, IonPage } from '@ionic/react'; - -const options = { - cssClass: 'my-custom-interface' -}; - -export const SelectOptionExample: React.FC = () => { - return ( - - - - Select - - Brown - Blonde - Black - Red - - - - - ); -}; -``` - -```css -/* Popover Interface: set color for the popover using Item's CSS variables */ -.my-custom-interface .brown-option { - --color: #5e3e2c; - --color-hover: #362419; -} -``` - - - - - - -```tsx -import { Component, h } from '@stencil/core'; - -@Component({ - tag: 'select-option-example', - styleUrl: 'select-option-example.css' -}) -export class SelectOptionExample { - render() { - return [ - - Select - - Brown - Blonde - Black - Red - - - ]; - } -} -``` - -### Customizing Options - -```tsx -import { Component, h } from '@stencil/core'; - -@Component({ - tag: 'select-option-example', - styleUrl: 'select-option-example.css' -}) -export class SelectOptionExample { - options = { - cssClass: 'my-custom-interface' - }; - - render() { - return [ - - Select: Alert Interface - - Brown - Blonde - Black - Red - - , - - - Select: Alert Interface (Multiple Selection) - - Brown - Blonde - Black - Red - - , - - - Select: Popover Interface - - Brown - Blonde - Black - Red - - , - - - Select: Action Sheet Interface - - Brown - Blonde - Black - Red - - - ]; - } -} -``` - -```css -/* Popover Interface: set color for the popover using Item's CSS variables */ -.my-custom-interface .select-interface-option { - --color: #971e49; - --color-hover: #79193b; -} - -/* Action Sheet Interface: set color for the action sheet using its button CSS variables */ -.my-custom-interface .select-interface-option { - --button-color: #971e49; - --button-color-hover: #79193b; -} - -/* Alert Interface: set color for alert options (single selection) */ -.my-custom-interface .select-interface-option .alert-radio-label { - color: #971e49; -} - -/* Alert Interface: set color for alert options (multiple selection) */ -.my-custom-interface .select-interface-option .alert-checkbox-label { - color: #971e49; -} - -/* Alert Interface: set color for checked alert options (single selection) */ -.my-custom-interface .select-interface-option[aria-checked=true] .alert-radio-label { - color: #79193b; -} - -/* Alert Interface: set color for checked alert options (multiple selection) */ -.my-custom-interface .select-interface-option[aria-checked=true] .alert-checkbox-label { - color: #79193b; -} -``` - -> Note: In the CSS examples, some of the selectors could be combined together, but are separated out in order to better explain what each selector is for. - -### Customizing Individual Options - -To customize an individual option, set a class on the `ion-select-option`: - -```tsx -import { Component, h } from '@stencil/core'; - -@Component({ - tag: 'select-option-example', - styleUrl: 'select-option-example.css' -}) -export class SelectOptionExample { - options = { - cssClass: 'my-custom-interface' - }; - - render() { - return [ - - Select - - Brown - Blonde - Black - Red - - - ]; - } -} -``` - -```css -/* Popover Interface: set color for the popover using Item's CSS variables */ -.my-custom-interface .brown-option { - --color: #5e3e2c; - --color-hover: #362419; -} -``` - - - - - - -```html - - - -``` - -### Customizing Options - -```html - - - -``` - -```css -/* Popover Interface: set color for the popover using Item's CSS variables */ -.my-custom-interface .select-interface-option { - --color: #971e49; - --color-hover: #79193b; -} - -/* Action Sheet Interface: set color for the action sheet using its button CSS variables */ -.my-custom-interface .select-interface-option { - --button-color: #971e49; - --button-color-hover: #79193b; -} - -/* Alert Interface: set color for alert options (single selection) */ -.my-custom-interface .select-interface-option .alert-radio-label { - color: #971e49; -} - -/* Alert Interface: set color for alert options (multiple selection) */ -.my-custom-interface .select-interface-option .alert-checkbox-label { - color: #971e49; -} - -/* Alert Interface: set color for checked alert options (single selection) */ -.my-custom-interface .select-interface-option[aria-checked=true] .alert-radio-label { - color: #79193b; -} - -/* Alert Interface: set color for checked alert options (multiple selection) */ -.my-custom-interface .select-interface-option[aria-checked=true] .alert-checkbox-label { - color: #79193b; -} -``` - -> Note: In the CSS examples, some of the selectors could be combined together, but are separated out in order to better explain what each selector is for. - - -### Customizing Individual Options - -To customize an individual option, set a class on the `ion-select-option`: - -```html - - - -``` - -```css -/* Popover Interface: set color for the popover using Item's CSS variables */ -.my-custom-interface .brown-option { - --color: #5e3e2c; - --color-hover: #362419; -} -``` +セレクトオプションは、セレクトの子要素となるコンポーネントです。定義された各オプションは、Selectダイアログに渡され表示されます。 - +使用例については、[Select](./select)のドキュメントを参照してください。 - -## Properties +## プロパティ -## Events +## イベント -## Methods +## メソッド ## CSS Shadow Parts -## CSS Custom Properties +## CSSカスタムプロパティ ## Slots diff --git a/docs/api/select.md b/docs/api/select.md index 20d78040333..f43585af367 100644 --- a/docs/api/select.md +++ b/docs/api/select.md @@ -1,138 +1,267 @@ --- title: "ion-select" --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - -import Props from '@site/static/auto-generated/select/props.md'; -import Events from '@site/static/auto-generated/select/events.md'; -import Methods from '@site/static/auto-generated/select/methods.md'; -import Parts from '@site/static/auto-generated/select/parts.md'; -import CustomProps from '@site/static/auto-generated/select/custom-props.md'; -import Slots from '@site/static/auto-generated/select/slots.md'; +import Props from '@ionic-internal/component-api/v8/select/props.md'; +import Events from '@ionic-internal/component-api/v8/select/events.md'; +import Methods from '@ionic-internal/component-api/v8/select/methods.md'; +import Parts from '@ionic-internal/component-api/v8/select/parts.md'; +import CustomProps from '@ionic-internal/component-api/v8/select/custom-props.mdx'; +import Slots from '@ionic-internal/component-api/v8/select/slots.md'; ion-select: Select One or Multiple Value Boxes or Placeholders - + import EncapsulationPill from '@components/page/api/EncapsulationPill'; -import APITOCInline from '@components/page/api/APITOCInline'; -Selects are form controls to select an option, or options, from a set of options, similar to a native ` `, - directives: [forwardRef(() => MyIcon)], // MyIcon has not been defined yet -}) // forwardRef resolves as MyIcon when MyIcon is needed + directives: [forwardRef(() => MyIcon)], // MyIcon はまだ定義されていません +}) // forwardRef は MyIcon が必要なときに MyIcon として解決します class MyButton { constructor() {} } @@ -74,7 +73,7 @@ class MyButton { selector: 'icon', }) class MyIcon { - constructor(containerButton: MyButton) {} // MyButton has been defined + constructor(containerButton: MyButton) {} // MyButton が定義されました } ``` @@ -84,21 +83,21 @@ class MyIcon { No provider for ParamType! (MyClass -> ParamType) ``` -This means Angular knows the type of parameter it is supposed to inject, but it doesn't know how to inject it. +これは、Angular は注入されるべきパラメータの型を知っているが、注入方法を知らないことを意味する。 -If the parameter is a service, make sure you have added the specified class to the list of providers available to your app: +パラメータが Service の場合は、指定したクラスがアプリケーションで使用可能な providers のリストに追加されていることを確認します: ```tsx import { MyService } from 'my-service'; @Component({ templateUrl: 'app/app.html', - providers: [MyService], // Don't forget me! + providers: [MyService], // 私を忘れないで! }) class MyApp {} ``` -If the parameter is another component or directive (for example, a parent component), adding it to your list of providers will make the error go away, but this will have the same effect as the [Multiple instances of a provider](#multiple_instances) above. You'll be creating a new instance of the component class, and you won't get a reference to the component instance you want. Instead, make sure that the directive or component you expect to be injected is available to your component (e.g. that it is actually a parent if you are expecting it to be a parent). This is probably easiest understood with an example: +パラメータが別のコンポーネントまたは Directive(たとえば、親コンポーネント)である場合、パラメータを providers のリストに追加するとエラーはなくなりますが、これは前述の [provider の複数のインスタンス](/docs/faq/runtime#provider-) と同じ効果を持ちます。ここでは、コンポーネントクラスの新しいインスタンスを作成しますが、必要なコンポーネントインスタンスへの参照は取得しません。かわりに、注入されるであろう Directive またはコンポーネントがコンポーネントで使用可能であることを確認します(たとえば、親であることを期待している場合は、実際に親であること)。これはおそらく、例を使用すると最も簡単に理解できます: ```tsx @Component({ @@ -119,23 +118,23 @@ class MyDir { constructor(c: MyComp) { // <-- This is the line of interest - // Errors when directive is on regular div because there is no MyComp in the - // component tree so there is no MyComp to inject + // コンポーネントツリーにMyCompがなく、注入するMyCompがないため、 + // Directiveが通常のdivにある場合のエラーのdivにある場合のエラー console.log("Host component's name: " + c.name); } } @Component({ template: - '' + // No error in MyDir constructor, MyComp is parent of MyDir - '' + // No error in MyDir constructor, MyComp is host of MyDir - '
', // Errors in MyDir constructor + '' + // MyDir コンストラクタ内ではエラーなし、MyComp は MyDir の親 + '' + // MyDir コンストラクタ内ではエラーなし、MyComp は MyDir のホスト + '
', // MyDir コンストラクタ内でエラー directives: [MyComp, MyDir], }) class MyApp {} ``` -Here's a diagram illustrating what injectors are available: +以下に、使用可能な注入するものの図を示します: ``` +-------+ @@ -145,15 +144,15 @@ Here's a diagram illustrating what injectors are available: +-------------+------------+ | | +------+------+ +--------+--------+ -| Div (MyDir) | | MyComp (MyDir) | <- MyComp can be injected +| Div (MyDir) | | MyComp (MyDir) | <- MyComp は注入可能 +-------------+ +--------+--------+ ^ | -No MyComp to inject +------+------+ - | P (MyDir) | <- MyComp can be injected from parent +MyComp の注入なし +------+------+ + | P (MyDir) | <- MyComp は親から注入可能 +-------------+ ``` -To expand on the previous example, you can use the Angular `@Optional` annotation if you don't always expect a component/directive reference: +前の例を拡張するために、コンポーネント/Directive の参照を常に期待しているわけではない場合には、Angular の `@Option` アノテーションを使うことができます: ```tsx @Directive({ @@ -169,26 +168,26 @@ class MyDir { } ``` -### Can't bind to 'propertyName' since it isn't a known property +### 既知のプロパティではないため、`propertyName` にバインドできない ```shell Can't bind to 'propertyName' since it isn't a known property of the 'elementName' element and there are no matching directives with a corresponding property ``` -This happens when you try and bind a property on an element that doesn't have that property. If the element is a component or has one or more directives on it, neither the component nor the directives have that property either. +これは、そのプロパティを持たない要素にプロパティをバインドしようとしたときに発生します。要素がコンポーネントの場合、または要素に 1 つ以上の Directive がある場合、コンポーネントも Directive もそのプロパティを持ちません。 ```html - +
``` -### No provider for ControlContainer +### ControlContainer の Provider がない ```shell No provider for ControlContainer! (NgControlName -> ControlContainer) ``` -This error is a more specific version of the `No provider` error above. It happens when you use a form control like NgControlName without specifying a parent [NgForm](https://angular.io/docs/ts/latest/api/forms/index/NgForm-directive.html) or NgFormModel. In most cases, this can be resolved by making sure your form control is within an actual form element. NgForm uses `form` as a selector so this will instantiate a new NgForm: +このエラーは、上記の `No provider` エラーのより具体的なバージョンです。これは、親の [NgForm](https://angular.jp/docs/ts/latest/api/forms/index/NgForm-directive.html) または NgFormModel を指定せずに NgControlName などのフォームコントロールを使用した場合に発生します。ほとんどの場合、これはフォームコントロールが実際のフォーム要素内にあることを確認することで解決できます。NgForm はセレクタとして `form` を使用するので、これは新しい NgForm をインスタンス化します: ```tsx @Component({ @@ -199,10 +198,10 @@ This error is a more specific version of the `No provider` error above. It happe }) ``` -### No Component Factory Found +### コンポーネントファクトリがない ```shell No component factory found for ``` -This error happens when you are trying to use a component, provider pipe or directive that has not been imported and added to your ngModule. Whenever you add a new component, provider, pipe or directive to your app, you must add it to the `ngModule` in the `src/app/app.module.ts` file for Angular to be able to use it. To fix this error you can import the offending component, provider, pipe or directive into the app.module file and then if it is a provider add it to the `providers` array and for a component, pipe or directive add it to both the declarations array and `entryComponents` array. +このエラーは、ngModule にインポートおよび追加されていない Component、Provider Pipe、Directive を使用しようとしたときに発生します。新しい Component、Provider、Pipe、Directive をアプリケーションに追加する場合は必ず、Angular がそれを使えるようにするために、`src/app/app.module.ts` ファイル内の `ngModule` に追加する必要があります。このエラーを修正するには、問題の Component、Provider、Pipe、Directive を app.module ファイルにインポートし、Provider の場合は `providers` 配列に追加、Component、Pipe、Directive の場合は宣言配列と `entryComponents` 配列の両方に追加します。 diff --git a/docs/troubleshooting/cors.md b/docs/troubleshooting/cors.md index 5b497f74a12..061236ad283 100644 --- a/docs/troubleshooting/cors.md +++ b/docs/troubleshooting/cors.md @@ -238,9 +238,13 @@ If you are trying to connect to a 3rd-party API, first check in its documentatio #### 1. Native-only apps (iOS/Android) -Use the [HTTP plugin from Ionic Native](../native/http.md) to make the requests natively from outside the webview. Please note that this plugin doesn't work in the browser, so the development and testing of the app must always be done in a device or simulator going forward. +##### Capacitor Applications (Recommended) -##### Usage in Ionic Angular 4 +For Capacitor applications, use the [Capacitor HTTP API](https://capacitorjs.com/docs/apis/http). This API patches `fetch` and `XMLHttpRequest` to use native libraries. Please note that if you also deploy the application to a web-based context such as PWA or the local development server (via `ionic serve` for example) you still need to implement CORS for those scenarios. + +##### Legacy Cordova Applications + +For legacy Cordova applications, use the [HTTP plugin with the Awesome Cordova Plugins wrapper](https://danielsogl.gitbook.io/awesome-cordova-plugins/http). Please note that this plugin doesn't work in the browser, so the development and testing of the app must always be done in a device or simulator going forward. ```tsx import { Component } from '@angular/core'; diff --git a/docs/troubleshooting/debugging.md b/docs/troubleshooting/debugging.md index 326f1513653..166df54308e 100644 --- a/docs/troubleshooting/debugging.md +++ b/docs/troubleshooting/debugging.md @@ -14,9 +14,9 @@ title: Debugging width="560" height="315" src="https://www.youtube.com/embed/akh6V6Yw1lw" - frameborder="0" + frameBorder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" - allowfullscreen + allowFullScreen > ## Live Reload diff --git a/docs/troubleshooting/native.md b/docs/troubleshooting/native.md index 3cc2f58e051..865c60ef0f2 100644 --- a/docs/troubleshooting/native.md +++ b/docs/troubleshooting/native.md @@ -1,5 +1,5 @@ --- -title: Native Errors +title: ネイティブエラー --- @@ -10,56 +10,50 @@ title: Native Errors /> -## Code Signing errors +## コードの署名エラー ```shell Code Signing Error: Failed to create provisioning profile. The app ID "com.csform.ionic.yellow" cannot be registered to your development team. Change your bundle identifier to a unique string to try again. Code Signing Error: No profiles for 'com.csform.ionic.yellow' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'com.csform.ionic.yellow'. Code Signing Error: Code signing is required for product type 'Application' in SDK 'iOS 11.1' ``` -Running an app on an iOS device requires a provisioning profile. If a provisioning profile has not been created yet follow these directions: +iOS デバイスでアプリケーションを実行するには、プロビジョニングプロファイルが必要です。プロビジョニングプロファイルが作成されていない場合は、次の手順に従います: -1. Set the [Package ID](../reference/glossary.md#package-id). +1. [Package ID](../reference/glossary.md#package-id) を設定する。 - For Capacitor, open the `capacitor.config.json` file and modify the `appId` property. + Capacitor の場合、`capacitor.config.json` ファイルを開き `appId` プロパティを修正します。 - For Cordova, open the `config.xml` file and modify the `id` attribute of the root element, ``. See [the Cordova documentation](https://cordova.apache.org/docs/en/latest/config_ref/#widget) for more information. + Cordova の場合、`config.xml` ファイルを開き、ルート要素 `` の `id` 属性を修正します。よりくわしい情報は [Cordova ドキュメント](https://cordova.apache.org/docs/en/latest/config_ref/#widget) をご参照ください。 -2. - Open the project in Xcode. - + +2. プロジェクトを Xcode で開く。 - For Capacitor, run the following to open the app in Xcode: + Capacitor の場合、以下を実行し Xcode でアプリケーションを開いてください: ```shell $ ionic capacitor open ios ``` - For Cordova, open Xcode. Use **File** » **Open** and locate the app. Open the app's `platforms/ios` directory. + Cordova の場合、Xcode 開きます。**File** » **Open** からアプリケーションを見つけます。アプリケーション内の `platforms/ios` ディレクトリを開きます。 -3. - In Project navigator, select the project root to open the project editor. Under the **Identity** section, - verify that the Package ID that was set matches the Bundle Identifier. - + +3. プロジェクト ナビゲーターで、プロジェクトのルートを選択しエディタでプロジェクトを開きます。 **Identity** セクションで、設定された Package ID がバンドル識別子と一致することを確認します。 - ![Xcode Identity Setup](/img/running/ios-xcode-identity-setup.png) + ![Xcode showing the Identity section for an iOS app with fields for Display Name, Bundle Identifier, Version, and Build.](/img/running/ios-xcode-identity-setup.png "Xcode Identity Section") -4. - In the same project editor, under the Signing section, ensure Automatically manage signing is - enabled. - Then, select a Development Team. Given a Development Team, Xcode will attempt to automatically prepare provisioning - and signing. + +4. 同じプロジェクトエディタの 署名 セクションで、Automatically manage signing が 有効になっていることを確認します。 次に、Team から開発チームを選択します。開発チームがあれば、Xcode は プロビジョニングと署名を自動的に準備しようとします。 - ![Xcode Signing Setup](/img/running/ios-xcode-signing-setup.png) + ![Xcode showing the Signing section with 'Automatically manage signing' enabled and a Development Team selected.](/img/running/ios-xcode-signing-setup.png "Xcode Signing Section") -## Xcode build error 65 +## Xcode のビルドエラー 65 ```shell Error: Error code 65 for command: xcodebuild with args: -xcconfig,/Users/ionitron/projects/my-project/platforms/ios/cordova/build-debug.xcconfig,-workspace,SC project.xcworkspace,-scheme,SC project,-configuration,Debug,-sdk,iphonesimulator,-destination,platform=iOS Simulator,name=iPhone X,build,CONFIGURATION_BUILD_DIR=/Users/ionitron/projects/my-project/platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=/Users/ionitron/projects/my-project/platforms/ios/build/sharedpch ``` -This error is an error code from Xcode that can be caused by provisioning issues or outdated cordova dependencies. To fix this error first make sure a provisioning profile has been generated using the above instructions and then try to [run the app from Xcode](../developing/ios.md#running-with-xcode). +このエラーは Xcode のエラーコードで、プロビジョニングの問題または古い cordova 依存関係が原因で発生する可能性があります。このエラーを修正するには、まず上記の手順でプロビジョニングプロファイルが生成されていることを確認したのち、[Xcode からアプリケーションを実行します](../developing/ios.md#running-with-xcode)。 -If this does not fix the error then run the following commands: +もしそれでもエラーが解決しない場合は、次のコマンドを実行してください: ```shell rm -rf node_modules @@ -72,25 +66,25 @@ ionic cordova build ios --prod Once these commands have been ran a fresh build can be done. -## Clashing Google Play Services versions +## Google Play Services のバージョンが衝突 ```shell Error: more than one library with package name com.google.android.gms ``` -This error is caused by two separate plugins trying to use different versions of the `Google Play Services`. To fix this issue make sure you are running `cordova` version `7.1.0` or higher and `cordova-android` `6.3.0` or higher. To install latest `cordova` run: +このエラーは、2 つの異なるプラグインが異なるバージョンの `Google Play Services` を使用しようとしたことが原因です。この問題を解決するには、バージョンが `7.1.0` 以上の `cordova` および バージョンが `6.3.0` 以上の `cordova-android` を実行していることを確認してください。最新の `cordova` をインストールするには次を実行してください: ```shell npm install cordova@latest ``` -and to update `cordova-android` run: +また、`cordova-android` をアップデートするには次を実行してください: ```shell cordova platform update android ``` -Plugins that depend on `Google Play Services` can now be updated to use the same version. For example, if `pluginA` uses version 11.0 and `pluginB` uses version 15.0 they can be updated to use the same version with the following snippet in the `config.xml` file: +`Google Play Services` に依存するプラグインをアップデートして、同じバージョンを使用できるようになりました。例えば、`pluginA` ではバージョン 11.0 を使用し、`pluginB` では バージョン 15.0 を使用する場合、`config.xml` ファイルでは以下のスニペットで同じバージョンを使用するように更新できます: ```xml diff --git a/docs/troubleshooting/runtime.md b/docs/troubleshooting/runtime.md index 6163d233ef5..fbcc0e95781 100644 --- a/docs/troubleshooting/runtime.md +++ b/docs/troubleshooting/runtime.md @@ -1,5 +1,5 @@ --- -title: Runtime Issues +title: ランタイムの問題 --- @@ -10,21 +10,21 @@ title: Runtime Issues /> -## Blank App +## 真っ白なアプリケーション :::note -I have no errors in my app. Why does it show a blank screen? +私のアプリケーションにはエラーはありません。なぜ真っ白な画面が表示されるのでしょうか? ::: -There are several different reasons this can happen. If you are unable to find a solution on the [Ionic forums](https://forum.ionicframework.com), make sure: +この事象が発生しうる理由がいくつかあります。もしあなたがフォーラム上で解決策を見つけられなかった場合、これらを確認して下さい: -- Polyfills are not included for older browser/versions of android +- ポリフィルには古い android のブラウザ/バージョンは含まれない -For projects with `@angular/cli@7.3` or above, polyfills will automatically be included. For project created before that, polyfills need to be manually enabled. +`@angular/cli@7.3` 以上のプロジェクトの場合、ポリフィルは自動的に含まれます。その前に作成されたプロジェクトでは、ポリフィルを手動で有効にする必要があります。 -In `src/polyfills.ts`, you must enabled all ES6 polyfills for Android 4.4 support. +`src/polyfills.ts` にて、Android 4.4 をサポートするために ES6 ポリフィルをすべて有効にする必要があります。 -Alternatively, a project could be updated to use the latest release of the `@angular/cli` package & `@angular-devkit` packages and include the `es5BrowserSupport` option in the `angular.json`'s build options object: +あるいは、プロジェクトを更新して、`@angular/cli` パッケージと `@angular-devkit` パッケージの最新リリースを使用し、`angular.json` のビルドオプションオブジェクトに `es5BrowserSupport` オプションを含めることもできます: ```diff "input": "src/global.scss" @@ -38,24 +38,24 @@ Alternatively, a project could be updated to use the latest release of the `@ang "production": { ``` -This will automatically include the polyfills for older browsers that need them. +これにより、古いブラウザに必要なポリフィルが自動的に追加されます。 -## Directive Not Working +## ディレクティブが動作しない :::note -Why is my custom component/directive not working? +なぜ私のカスタムコンポーネント/ディレクティブは動作しないのでしょうか? ::: -There are a few things you can check. Make sure: +あなたが確認できるものがいくつか存在します。 -- Your selector doesn't have any misspellings. -- You're using the selector correctly as an attribute, element or class. -- Your selector has the proper syntax: - - `[attr]` if it's an attribute selector - - `element` if it's an element selector - - `.class` if it's a class selector +- セレクタにスペルミスがない +- 属性、要素、クラスとして、セレクタを正確に使用している +- セレクタの構文が適切: + - 属性セレクタの場合は `[attr]` + - 要素セレクタの場合は `element` + - クラスセレクタの場合は `.class` -Here's an example using an attribute selector: +以下に、属性セレクタの例を挙げます: ```tsx @Directive({ @@ -81,21 +81,21 @@ class MyDir { class MyPage { } ``` -## Click Delays +## クリックの遅延 :::note -Why is there a delay on my click event? +なぜ私のクリックイベントは遅延するのでしょうか? ::: -In general, we recommend only adding `(click)` events to elements that are -normally clickable. This includes `