Skip to content

Commit

Permalink
add .editorconfig, replace EOLs to LF
Browse files Browse the repository at this point in the history
  • Loading branch information
mskocik committed Sep 15, 2023
1 parent 80042c6 commit 079cb67
Show file tree
Hide file tree
Showing 44 changed files with 2,305 additions and 2,295 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true

[*.{svelte,js,css}]
indent_style = space
indent_size = 2
2 changes: 1 addition & 1 deletion src/constants.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const CONTENT_BASE_PATHS = './routes/documentation';
export const CONTENT_BASE_PATHS = './routes/documentation';
8 changes: 4 additions & 4 deletions src/documentation/00-introduction/01-intro.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# 📆 Svelty Picker [![NPM version](https://img.shields.io/npm/v/svelty-picker.svg?style=flat)](https://www.npmjs.org/package/svelty-picker)

Simple date & time picker implemented in svelte.
Simple date & time picker implemented in svelte.

Features:
Features:
- date/time/datetime/range picker mode
- various formatting options
- keyboard navigation
- replacable slots
- replacable slots
- themable
- customizable disabled dates
<!-- - validator action for `<input>` using `svelte-use-forms` (optional) -->
- custom element
- custom element
2 changes: 1 addition & 1 deletion src/documentation/00-introduction/02-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

```js
npm install svelty-picker
```
```
8 changes: 4 additions & 4 deletions src/documentation/00-introduction/page.svx
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ slug: ''
<div class="flex flex-wrap gap-4 my-10">
<div>
<h4>Date picker</h4>
<SveltyPicker todayBtn mode="datetime" clearBtn pickerOnly autocommit={true}/>
<SveltyPicker todayBtn mode="datetime" clearBtn pickerOnly autocommit={true}/>
</div>

<div>
<h4>Time picker</h4>
<SveltyPicker mode="time" format="hh:ii" pickerOnly />
<SveltyPicker mode="time" format="hh:ii" pickerOnly />
</div>
<div>
<h4>Date range picker</h4>
<SveltyPicker isRange mode="datetime" pickerOnly/>
<SveltyPicker isRange mode="datetime" pickerOnly/>
</div>
</div>

<InstallCode />

2 changes: 1 addition & 1 deletion src/documentation/01-properties/03-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
| clearToggle | `bool` | `true` | Allows to clear selected date when clicking on the same date when in `mode='date'` or `mode='auto'` resolving to `'date'` |
| autocommit | `bool` | `true` | Whether date/time selection is automatic or manual |
| i18n | `object` | `en` | localization object, english is by default |
| validatorAction | `array` | `null` | Bind validator action for inner `<input>` element. Designed to be used with `svelte-use-form`.
| validatorAction | `array` | `null` | Bind validator action for inner `<input>` element. Designed to be used with `svelte-use-form`.
2 changes: 1 addition & 1 deletion src/documentation/01-properties/page.svx
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ title: Properties
import Options from './03-options.md'
</script>

<Options />
<Options />
2 changes: 1 addition & 1 deletion src/documentation/02-principles/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ Parsed date: { !console.log( parseDate('24.7.2023', 'j.n.Y', en, 'php') ) && 'Sh
<p>
☝️ Notice the parsed date is always set to 00:00:00, but in <b>local</b> time. Therefore you can see difference
between numbers in REPL and browser console.
</p>
</p>
20 changes: 10 additions & 10 deletions src/documentation/02-principles/page.svx
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ available if needed.
```js
/**
* String -> date
*
* @param {Date|string} date
* @param {string} format
* @param {i18nType} i18n
* @param {string} type
*
* @param {Date|string} date
* @param {string} format
* @param {i18nType} i18n
* @param {string} type
* @returns {Date}
*/
export function parseDate(date, format, i18n, type) { /* ... */}

/**
* Date -> string
*
* @param {Date} date
* @param {string} format
* @param {i18nType} i18n
* @param {string} type
*
* @param {Date} date
* @param {string} format
* @param {i18nType} i18n
* @param {string} type
* @returns {string}
*/
export function formatDate(date, format, i18n, type) { /* ... */}
Expand Down
4 changes: 2 additions & 2 deletions src/documentation/03-formatting/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
let valueDefault;
let valueDifferent;
let valueTimeOnly;
</script>


Expand All @@ -26,5 +26,5 @@
Time only format:<br>Internal value: <code>{valueTimeOnly}</code>
</h4>
<SveltyPicker bind:value={valueTimeOnly} format="hh:ii" displayFormat="HH:ii P"/>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion src/documentation/03-formatting/php-format.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
| `U` | timestamp in seconds. |


☝️ For timestamp with miliseconds use `standard` formatting.
☝️ For timestamp with miliseconds use `standard` formatting.
6 changes: 3 additions & 3 deletions src/documentation/03-formatting/standard-format.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
### Standard format settings:

| Format | Description | Example
| Format | Description | Example
|--------|----------------------------------------------------------------------------------|--------------------------------------
| `d` | day of the month without leading zeros | 1 to 31
| `dd` | day of the month, 2 digits with leading zeros | 01 to 31
| `D` | short textual representation of a weekday (i18n.daysShort) | Mon through Sun
| `DD` | long textual representation of a weekday (i18n.days) | Sunday through Saturday
| `S` | English ordinal suffix for the day of the month, (i18n.suffix) | st, nd, rd or th. Works well with `d`
| `S` | English ordinal suffix for the day of the month, (i18n.suffix) | st, nd, rd or th. Works well with `d`
| `m` | numeric representation of month without leading zeros | 1 to 12
| `mm` | numeric representation of the month, 2 digits with leading zeros | 01 to 12
| `M` | short textual representation of a month, three letters (i18n.monthsShort) | Jan through Dec
Expand All @@ -25,4 +25,4 @@
| `P` | meridian in upper case ('AM' or 'PM') - according to locale file (i18n.meridiem) | AM or PM
| `t` | timestamp in milliseconds (although milliseconds are always 0). |

☝️ For timestamp in seconds use `php` formatting.
☝️ For timestamp in seconds use `php` formatting.
6 changes: 3 additions & 3 deletions src/documentation/04-auto-commit/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
let activeMode = 'date';
let isRange = false;
let autocommit = false;
$: format = activeMode === 'date'
? 'yyyy-mm-dd'
: (activeMode === 'time'
? 'hh:ii'
: 'yyyy-mm-dd hh:ii'
);
let value;
</script>

Expand Down Expand Up @@ -46,4 +46,4 @@ Selected value: {value}<br>
fieldset {
padding: 1rem;
}
</style>
</style>
2 changes: 1 addition & 1 deletion src/documentation/04-auto-commit/page.svx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ For datepicker it's simple. User picks a date, bound value (if any) is updated,
very similar with the exception that picker closes automatically only on _minute_ selection. So you can change hour many
times and picker will stay open. Select minutes and it will close. Also event is triggered etc.

When using keyboard to change date, bound value is not updated immediately, but only on Enter or on input blur. This is
When using keyboard to change date, bound value is not updated immediately, but only on Enter or on input blur. This is
very important distinction against manual vaue settings.

### Manual-commit mode
Expand Down
4 changes: 2 additions & 2 deletions src/documentation/04-disabling-dates/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
let endDate = '2023-07-28';
function disableWeekends(date) {
return date.getDay() === 0 || date.getDay() === 6
}
</script>
Expand All @@ -23,4 +23,4 @@ Restricted selection list:<br>
.my-4 {
margin: 16px 0;
}
</style>
</style>
4 changes: 2 additions & 2 deletions src/documentation/04-disabling-dates/page.svx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Disabling dates
---

Restricting selectable is supported by `startDate` and `endDate` properties. You can provide `string` or `Date`.
Restricting selectable is supported by `startDate` and `endDate` properties. You can provide `string` or `Date`.
When `string` is passed, it must match `format` of given Svelty-picker. These border dates are *INCLUDED* in allowed date range.

It is recommended to pass `strings` and not `Dates` to these properties. When datetime is passed, time range will be restricted as well if applicable.
Expand All @@ -14,4 +14,4 @@ Just take into account that all `Date` objects passed into this function will be
function isDateDisabled(date: Date): bool
```

Both methods can be combined together if needed.
Both methods can be combined together if needed.
4 changes: 2 additions & 2 deletions src/documentation/05-slots/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<input type="text" value={displayValue} placeholder="Custom dislay input"
on:keydown={onKeyDown} on:focus={onInputFocus} on:blur={onInputBlur}
>

</svelte:fragment>
<svelte:fragment slot="action-row"
let:i18n
Expand Down Expand Up @@ -48,4 +48,4 @@
</div>
{/if}
</svelte:fragment>
</SveltyPicker>
</SveltyPicker>
2 changes: 1 addition & 1 deletion src/documentation/05-slots/page.svx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ And here again, all props and handlers needed to recreate even the default imple
- `onClear` - clears current selection
- `onToday` - selects today date
- `isTodayDisabled` - useful when you use `startDate` or `endDate` or `disableDatesFn` to disable dates. Serves for disabled 'Today' button
- `currentMode` - returns currently active mode: `date` or `time`
- `currentMode` - returns currently active mode: `date` or `time`
- `i18n` - current locale

* Default implementation relies also on `isRange` and `autocommit` props, which you will probably provide yourself if needed.
Expand Down
6 changes: 3 additions & 3 deletions src/documentation/06-events/App.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script>
import SveltyPicker from 'svelty-picker';
let log = '';
let counter = 0;
let counter = 0;
function logEvent(e) {
counter++;
log = `#${counter} event: ${e.type}${e.type !== 'blur' ? '; value: ' + e.detail : ''}\n`
Expand Down
2 changes: 1 addition & 1 deletion src/documentation/06-events/page.svx
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ Component emits `input`, `change` and `blur` events.

For custom element:

- `input` is also triggered on underlying `input[value]` and it's value is accessible underas standard input `event.target.value`
- `input` is also triggered on underlying `input[value]` and it's value is accessible underas standard input `event.target.value`
4 changes: 2 additions & 2 deletions src/documentation/07-theme/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import SveltyPicker from 'svelty-picker';
</script>

The picker's mode responds to website light/dark mode setting.
The picker's mode responds to website light/dark mode setting.
<SveltyPicker pickerOnly mode="datetime" />

<style>
Expand Down Expand Up @@ -47,4 +47,4 @@ The picker's mode responds to website light/dark mode setting.
--sdt-clear-hover-color: #fff;
--sdt-clear-hover-bg: #dc3545;
}
</style>
</style>
2 changes: 1 addition & 1 deletion src/documentation/07-theme/page.svx
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ Component exposes following CSS variables to customize it's appearance as you ca
}
```

You can play with them here:
You can play with them here:
2 changes: 1 addition & 1 deletion src/documentation/08-localization/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
display: flex;
gap: 1rem;
}
</style>
</style>
4 changes: 2 additions & 2 deletions src/documentation/08-localization/page.svx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ title: Localization X
const keys = Object.keys(i18n).filter(k => k !== 'default').join(' | ');
</script>

By default date picker uses english locale. And at the moment there is only few locales available
By default date picker uses english locale. And at the moment there is only few locales available
(PRs for additional locales are more than welcome).

Available locales: <code>{keys}</code>

Setting locale is perfect use case for using [global configuration](/global-config).
Setting locale is perfect use case for using [global configuration](/global-config).
2 changes: 1 addition & 1 deletion src/documentation/10-global-config/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
<h3>Japanese override</h3>
<SveltyPicker pickerOnly i18n={jp} weekStart={1} />
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion src/documentation/10-global-config/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ export default {
autocommit: true,
i18n: en
}
```
```
2 changes: 1 addition & 1 deletion src/documentation/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export const factory = {
'theme': async () => (await (import('./07-theme/page.svx'))).default,
'localization': async () => (await (import('./08-localization/page.svx'))).default,
'global-config': async () => (await (import('./10-global-config/page.svx'))).default
}
}
2 changes: 1 addition & 1 deletion src/lib/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ node_modules
.env
.env.*
!.env.example
.vscode
.vscode
Loading

0 comments on commit 079cb67

Please sign in to comment.