mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
commit
718a7fcabd
19 changed files with 105 additions and 63 deletions
|
@ -7,7 +7,6 @@
|
||||||
<title>Carbon Components Svelte</title>
|
<title>Carbon Components Svelte</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
|
||||||
<script type="module" src="/src/index.js"></script>
|
<script type="module" src="/src/index.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
import App from "./App.svelte";
|
import App from "./App.svelte";
|
||||||
|
|
||||||
const app = new App({
|
const app = new App({ target: document.body });
|
||||||
target: document.getElementById("app"),
|
|
||||||
hydrate: process.env.NODE_ENV === "production",
|
|
||||||
});
|
|
||||||
|
|
||||||
export default app;
|
export default app;
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
<script context="module">
|
|
||||||
const fetched = new Set();
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { isActive, url, layout, beforeUrlChange } from "@sveltech/routify";
|
import { isActive, url, layout, beforeUrlChange } from "@sveltech/routify";
|
||||||
import {
|
import {
|
||||||
|
@ -162,17 +158,6 @@
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<svelte:body
|
|
||||||
on:mouseover="{async (e) => {
|
|
||||||
if (process.env.NODE_ENV === 'development') return;
|
|
||||||
if (!e.target.href || !e.target
|
|
||||||
.getAttribute('class')
|
|
||||||
.includes('bx--side-nav__link')) return;
|
|
||||||
if (fetched.has(e.target.href)) return;
|
|
||||||
fetched.add(e.target.href);
|
|
||||||
await fetch(e.target.href);
|
|
||||||
}}" />
|
|
||||||
|
|
||||||
<svelte:window bind:innerWidth />
|
<svelte:window bind:innerWidth />
|
||||||
|
|
||||||
<Theme persist>
|
<Theme persist>
|
||||||
|
|
|
@ -22,6 +22,19 @@ items={[
|
||||||
{id: "2", text: "Fax"}
|
{id: "2", text: "Fax"}
|
||||||
]} />
|
]} />
|
||||||
|
|
||||||
|
### Filterable
|
||||||
|
|
||||||
|
<FileSource src="/framed/ComboBox/FilterableComboBox" />
|
||||||
|
|
||||||
|
### Light variant
|
||||||
|
|
||||||
|
<ComboBox light titleText="Contact" placeholder="Select contact method"
|
||||||
|
items={[
|
||||||
|
{id: "0", text: "Slack"},
|
||||||
|
{id: "1", text: "Email"},
|
||||||
|
{id: "2", text: "Fax"}
|
||||||
|
]} />
|
||||||
|
|
||||||
### Extra-large size
|
### Extra-large size
|
||||||
|
|
||||||
<ComboBox titleText="Contact" placeholder="Select contact method"
|
<ComboBox titleText="Contact" placeholder="Select contact method"
|
||||||
|
|
|
@ -7,6 +7,16 @@
|
||||||
|
|
||||||
<Link href="https://www.carbondesignsystem.com/">Carbon Design System</Link>
|
<Link href="https://www.carbondesignsystem.com/">Carbon Design System</Link>
|
||||||
|
|
||||||
|
### Target _blank
|
||||||
|
|
||||||
|
Setting `target` to `"_blank"` opens the link in a new tab.
|
||||||
|
|
||||||
|
If `target="_blank"`, the `Link` component will automatically set `rel="noopener noreferrer"` to guard against [potential cross-origin security exploits](https://web.dev/external-anchors-use-rel-noopener/).
|
||||||
|
|
||||||
|
You can override the `rel` attribute with a custom value.
|
||||||
|
|
||||||
|
<Link href="https://www.carbondesignsystem.com/" target="_blank">Carbon Design System</Link>
|
||||||
|
|
||||||
### Inline variant
|
### Inline variant
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
|
|
@ -5,12 +5,25 @@
|
||||||
|
|
||||||
### Default
|
### Default
|
||||||
|
|
||||||
|
By default, items will be ordered alphabetically based on the `item.text` value. To prevent this, see [#no-alphabetical-ordering](#no-alphabetical-ordering).
|
||||||
|
|
||||||
<MultiSelect titleText="Contact" label="Select contact methods..."
|
<MultiSelect titleText="Contact" label="Select contact methods..."
|
||||||
items="{[{id: "0", text: "Slack"},
|
items="{[{id: "0", text: "Slack"},
|
||||||
{id: "1", text: "Email"},
|
{id: "1", text: "Email"},
|
||||||
{id: "2", text: "Fax"}]}" selectedIds="{["0", "1"]}"
|
{id: "2", text: "Fax"}]}" selectedIds="{["0", "1"]}"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
### No alphabetical ordering
|
||||||
|
|
||||||
|
To prevent alphabetical item ordering, pass an empty function to the `sortItem` prop.
|
||||||
|
|
||||||
|
<MultiSelect titleText="Contact" label="Select contact methods..."
|
||||||
|
items="{[{id: "0", text: "Slack"},
|
||||||
|
{id: "1", text: "Email"},
|
||||||
|
{id: "2", text: "Fax"}]}" selectedIds="{["0", "1"]}"
|
||||||
|
sortItem="{() => {}}"
|
||||||
|
/>
|
||||||
|
|
||||||
### Light variant
|
### Light variant
|
||||||
|
|
||||||
<MultiSelect light titleText="Contact" label="Select contact methods..."
|
<MultiSelect light titleText="Contact" label="Select contact methods..."
|
||||||
|
|
|
@ -19,6 +19,10 @@
|
||||||
|
|
||||||
<Pagination totalItems={102} pageInputDisabled />
|
<Pagination totalItems={102} pageInputDisabled />
|
||||||
|
|
||||||
|
### Hidden page size
|
||||||
|
|
||||||
|
<Pagination totalItems={102} pageSizeInputDisabled />
|
||||||
|
|
||||||
### Skeleton
|
### Skeleton
|
||||||
|
|
||||||
<PaginationSkeleton />
|
<PaginationSkeleton />
|
||||||
|
|
15
docs/src/pages/framed/ComboBox/FilterableComboBox.svelte
Normal file
15
docs/src/pages/framed/ComboBox/FilterableComboBox.svelte
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<script>
|
||||||
|
import { ComboBox } from "carbon-components-svelte";
|
||||||
|
|
||||||
|
function shouldFilterItem(item, value) {
|
||||||
|
if (!value) return true;
|
||||||
|
return item.text.toLowerCase().includes(value.toLowerCase());
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<ComboBox
|
||||||
|
titleText="Contact"
|
||||||
|
placeholder="Select contact method"
|
||||||
|
items="{[{ id: '0', text: 'Slack' }, { id: '1', text: 'Email' }, { id: '2', text: 'Fax' }]}"
|
||||||
|
shouldFilterItem="{shouldFilterItem}"
|
||||||
|
/>
|
|
@ -7,7 +7,6 @@ const { format } = require("prettier");
|
||||||
const pkg = require("../package.json");
|
const pkg = require("../package.json");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const Prism = require("prismjs");
|
const Prism = require("prismjs");
|
||||||
const { replace, postcss } = require("svelte-preprocess");
|
|
||||||
require("prism-svelte");
|
require("prism-svelte");
|
||||||
|
|
||||||
function createImports(source) {
|
function createImports(source) {
|
||||||
|
@ -57,6 +56,7 @@ function createImports(source) {
|
||||||
function plugin() {
|
function plugin() {
|
||||||
function visitor(node) {
|
function visitor(node) {
|
||||||
if (
|
if (
|
||||||
|
node.lang !== "svelte" &&
|
||||||
!node.value.startsWith("<FileSource") &&
|
!node.value.startsWith("<FileSource") &&
|
||||||
!node.value.startsWith("<script>") &&
|
!node.value.startsWith("<script>") &&
|
||||||
!node.value.match(/svx-ignore/g)
|
!node.value.match(/svx-ignore/g)
|
||||||
|
@ -125,19 +125,19 @@ const NODE_ENV = process.env.NODE_ENV || "production";
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
extensions: [".svelte", ".svx"],
|
extensions: [".svelte", ".svx"],
|
||||||
hydratable: NODE_ENV === "production",
|
|
||||||
preprocess: [
|
preprocess: [
|
||||||
require("svelte-preprocess")(),
|
require("svelte-preprocess")({
|
||||||
replace([
|
replace: [
|
||||||
["process.env.VERSION", JSON.stringify(pkg.version)],
|
["process.env.VERSION", JSON.stringify(pkg.version)],
|
||||||
["process.env.NODE_ENV", JSON.stringify(NODE_ENV)],
|
["process.env.NODE_ENV", JSON.stringify(NODE_ENV)],
|
||||||
]),
|
],
|
||||||
postcss({
|
postcss: {
|
||||||
plugins: [
|
plugins: [
|
||||||
require("autoprefixer")({
|
require("autoprefixer")({
|
||||||
overrideBrowserslist: ["last 1 version", "ie >= 11"],
|
overrideBrowserslist: ["last 1 version", "ie >= 11"],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
mdsvex({
|
mdsvex({
|
||||||
remarkPlugins: [plugin, slug, carbonify],
|
remarkPlugins: [plugin, slug, carbonify],
|
||||||
|
|
|
@ -2,7 +2,6 @@ module.exports = {
|
||||||
optimizeDeps: {
|
optimizeDeps: {
|
||||||
include: [
|
include: [
|
||||||
"flatpickr",
|
"flatpickr",
|
||||||
"flatpickr/dist/l10n/index.js",
|
|
||||||
"flatpickr/dist/plugins/rangePlugin",
|
"flatpickr/dist/plugins/rangePlugin",
|
||||||
"clipboard-copy",
|
"clipboard-copy",
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import flatpickr from "flatpickr";
|
import flatpickr from "flatpickr";
|
||||||
import rangePlugin from "flatpickr/dist/plugins/rangePlugin";
|
import rangePlugin from "flatpickr/dist/plugins/rangePlugin";
|
||||||
|
|
||||||
let l10n
|
let l10n;
|
||||||
|
|
||||||
function updateClasses(instance) {
|
function updateClasses(instance) {
|
||||||
const {
|
const {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
export { default as FluidForm } from './FluidForm.svelte'
|
export { default as FluidForm } from "./FluidForm.svelte";
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
bind:this={ref}
|
bind:this="{ref}"
|
||||||
role="listbox"
|
role="listbox"
|
||||||
id="menu-{id}"
|
id="menu-{id}"
|
||||||
class:bx--list-box__menu="{true}"
|
class:bx--list-box__menu="{true}"
|
||||||
|
|
|
@ -20,7 +20,10 @@ export const Default = () => ({
|
||||||
false
|
false
|
||||||
),
|
),
|
||||||
pageInputDisabled: boolean("Disable page input (pageInputDisabled)", false),
|
pageInputDisabled: boolean("Disable page input (pageInputDisabled)", false),
|
||||||
pageSizeInputDisabled: boolean("Disable page size input (pageSizeInputDisabled)", false),
|
pageSizeInputDisabled: boolean(
|
||||||
|
"Disable page size input (pageSizeInputDisabled)",
|
||||||
|
false
|
||||||
|
),
|
||||||
backwardText: text(
|
backwardText: text(
|
||||||
"The description for the backward icon (backwardText)",
|
"The description for the backward icon (backwardText)",
|
||||||
"Previous page"
|
"Previous page"
|
||||||
|
@ -50,7 +53,10 @@ export const Multiple = () => ({
|
||||||
false
|
false
|
||||||
),
|
),
|
||||||
pageInputDisabled: boolean("Disable page input (pageInputDisabled)", false),
|
pageInputDisabled: boolean("Disable page input (pageInputDisabled)", false),
|
||||||
pageSizeInputDisabled: boolean("Disable page size input (pageSizeInputDisabled)", false),
|
pageSizeInputDisabled: boolean(
|
||||||
|
"Disable page size input (pageSizeInputDisabled)",
|
||||||
|
false
|
||||||
|
),
|
||||||
backwardText: text(
|
backwardText: text(
|
||||||
"The description for the backward icon (backwardText)",
|
"The description for the backward icon (backwardText)",
|
||||||
"Previous page"
|
"Previous page"
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
* Set an id for the container div element
|
* Set an id for the container div element
|
||||||
* @type {string} [id]
|
* @type {string} [id]
|
||||||
*/
|
*/
|
||||||
export let id
|
export let id;
|
||||||
|
|
||||||
import { createEventDispatcher, setContext } from "svelte";
|
import { createEventDispatcher, setContext } from "svelte";
|
||||||
import { writable } from "svelte/store";
|
import { writable } from "svelte/store";
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
{id}
|
id="{id}"
|
||||||
class:bx--form-item="{true}"
|
class:bx--form-item="{true}"
|
||||||
{...$$restProps}
|
{...$$restProps}
|
||||||
on:click
|
on:click
|
||||||
|
|
|
@ -38,7 +38,7 @@ export const Default = () => ({
|
||||||
export const Fluid = () => ({
|
export const Fluid = () => ({
|
||||||
Component,
|
Component,
|
||||||
props: {
|
props: {
|
||||||
story: 'fluid',
|
story: "fluid",
|
||||||
size: select("Field size (size)", sizes, undefined) || undefined,
|
size: select("Field size (size)", sizes, undefined) || undefined,
|
||||||
disabled: boolean("Disabled (disabled)", false),
|
disabled: boolean("Disabled (disabled)", false),
|
||||||
light: boolean("Light variant (light)", false),
|
light: boolean("Light variant (light)", false),
|
||||||
|
|
|
@ -57,7 +57,8 @@
|
||||||
isOpen = false;
|
isOpen = false;
|
||||||
dispatch('close');
|
dispatch('close');
|
||||||
}
|
}
|
||||||
}}" />
|
}}"
|
||||||
|
/>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<button
|
<button
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue