@bigbinary/neeto-time-zones 0.5.9 → 0.5.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +63 -25
  2. package/index.d.ts +24 -0
  3. package/package.json +10 -17
  4. package/react.d.ts +20 -0
package/README.md CHANGED
@@ -7,10 +7,10 @@ A simple and lightweight NPM package for working with time zones. This package p
7
7
 
8
8
  ## Installation
9
9
 
10
- You can install the package using npm:
10
+ You can install the package using yarn:
11
11
 
12
12
  ```bash
13
- npm install @bigbinary/neeto-time-zones
13
+ yarn add @bigbinary/neeto-time-zones
14
14
  ```
15
15
 
16
16
  ## Importing CSS styles to the main stylesheet
@@ -24,10 +24,59 @@ You should add the following to `main.scss` file:
24
24
  ## NeetoTimezoneSelector
25
25
 
26
26
  [Check out the live demo](https://codepen.io/Jijin-Haridas/full/wvQbeOr)
27
- ```js
27
+
28
+ ### Usage 1
29
+
30
+ ```jsx
28
31
  import { NeetoTimezoneSelector } from "@bigbinary/neeto-time-zones";
29
32
 
30
- new NeetoTimezoneSelector(document.getElementById("elementId"));
33
+ const ReactComponent = () => {
34
+ const timezoneRef = useCallback(node => {
35
+ if (!(node !== null)) return;
36
+
37
+ new NeetoTimezoneSelector(node, {
38
+ elementId: "custom-selector-element",
39
+ className: "custom-selector-class",
40
+ initialValue: "initial-timezone",
41
+ position: "top",
42
+ onChange: (timezone) => {
43
+ console.log(timezone);
44
+ },
45
+ onHourFormatChange: (timeFormat) => {
46
+ console.log(timeFormat);
47
+ }
48
+ });
49
+ }, []);
50
+
51
+ return (
52
+ <div
53
+ ref={timezoneRef}
54
+ />
55
+ );
56
+ };
57
+ ```
58
+
59
+ ### Usage 2
60
+
61
+ ```jsx
62
+ import NeetoTimezoneSelector from "@bigbinary/neeto-time-zones/react";
63
+
64
+ const ReactComponent = () => {
65
+ return (
66
+ <NeetoTimezoneSelector
67
+ elementId="custom-selector-element"
68
+ className="custom-selector-class"
69
+ initialValue="initial-timezone"
70
+ position="top"
71
+ onChange={(timezone) => {
72
+ console.log(timezone);
73
+ }}
74
+ onHourFormatChange={(timeFormat) => {
75
+ console.log(timeFormat);
76
+ }}
77
+ />
78
+ );
79
+ }
31
80
  ```
32
81
 
33
82
  ### Configuration
@@ -35,24 +84,13 @@ You can pass options as the second parameter to configure the timezone selector
35
84
 
36
85
  1. elementId: ID for the NeetoTimezoneSelector. By default the ID will be `timezone-selector`
37
86
  2. className: Custom classes that can be added to the component.
38
- 3. onChange: Function to be called when the timezone selector changes.
87
+ 3. initialValue: Initial Value of the timezone selector.
39
88
  4. position: Position in which the selector should open in. Available options: `top`, `bottom`. Default position is `bottom`.
40
- 5. onHourFormatChange: Function to be called when the time format changes.
89
+ 5. onChange: Function to be called when the timezone selector changes.
90
+ 6. onHourFormatChange: Function to be called when the time format changes.
41
91
 
42
- ```js
43
- import { NeetoTimezoneSelector } from "@bigbinary/neeto-time-zones";
44
92
 
45
- new NeetoTimezoneSelector(document.getElementById("elementId"), {
46
- className: "custom-selector-class",
47
- onChange: (timezone) => {
48
- console.log(timezone);
49
- },
50
- elementId: "custom-selector-element",
51
- position: "top",
52
- });
53
- ```
54
-
55
- ### ianaTimezoneToHumanReadble
93
+ ### ianaTimezoneToHumanReadable
56
94
 
57
95
  ```js
58
96
  import { ianaTimezoneToHumanReadable } from "@bigbinary/neeto-time-zones";
@@ -71,12 +109,12 @@ ianaTimezoneToHumanReadable("Europe/Berlin") // => Central Standard Time
71
109
  ```bash
72
110
  git clone git@github.com:bigbinary/neeto-time-zones.git
73
111
  cd neeto-timezones/js
74
- pnpm install
75
- pnpm dev
112
+ yarn install
113
+ yarn dev
76
114
  ```
77
115
 
78
- ### Publishing to npm
116
+ ## Instructions for Publishing
117
+
118
+ A package is released upon merging a PR labeled as patch, minor, or major into the main branch. The patch label addresses bug fixes, minor signifies the addition of new features, and major denotes breaking changes, adhering to the principles outlined in [Semantic Versioning (SemVer)](https://semver.org/).
79
119
 
80
- 1. Bump `package.json` version
81
- 2. Commit and push
82
- 3. `pnpm build && pnpm publish`
120
+ You can checkout the Create and publish releases workflow in GitHub Actions to get a live update.
package/index.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ declare module "@bigbinary/neeto-time-zones" {
2
+ export interface TimezoneObject {
3
+ utc: string[];
4
+ label: string;
5
+ keywords: string;
6
+ isDst: boolean;
7
+ cities: string;
8
+ }
9
+
10
+ export interface NeetoTimezoneSelectorProps {
11
+ className?: string;
12
+ elementId?: string;
13
+ initialValue?: string;
14
+ position?: "top" | "bottom";
15
+ onChange?: (timezone: TimezoneObject) => void;
16
+ onHourFormatChange?: (timeFormat: string) => void;
17
+ }
18
+
19
+ export class NeetoTimezoneSelector {
20
+ constructor(node: HTMLElement, props: NeetoTimezoneSelectorProps);
21
+ }
22
+
23
+ export function ianaTimezoneToHumanReadable(timezone: string): string;
24
+ }
package/package.json CHANGED
@@ -1,20 +1,25 @@
1
1
  {
2
2
  "name": "@bigbinary/neeto-time-zones",
3
- "version": "0.5.9",
3
+ "version": "0.5.10",
4
4
  "license": "MIT",
5
+ "types": "./index.d.ts",
5
6
  "exports": {
6
7
  ".": {
7
8
  "import": "./dist/index.es.js",
8
- "require": "./dist/index.cjs.js"
9
+ "require": "./dist/index.cjs.js",
10
+ "types": "./dist/index.d.ts"
9
11
  },
10
12
  "./react": {
11
13
  "import": "./dist/react.es.js",
12
- "require": "./dist/react.cjs.js"
14
+ "require": "./dist/react.cjs.js",
15
+ "types": "./dist/react.d.ts"
13
16
  }
14
17
  },
15
18
  "type": "module",
16
19
  "files": [
17
- "dist"
20
+ "dist",
21
+ "index.d.ts",
22
+ "react.d.ts"
18
23
  ],
19
24
  "scripts": {
20
25
  "dev": "vite",
@@ -28,18 +33,12 @@
28
33
  },
29
34
  "peerDependencies": {
30
35
  "@bigbinary/neeto-cist": "^1.0.4",
31
- "@bigbinary/neeto-commons-frontend": "^3.0.1",
32
36
  "ramda": "^0.29.1",
33
37
  "react": "^18 || ^17.0.1 || ^16",
34
38
  "react-dom": "^18 || ^17.0.1 || ^16"
35
39
  },
36
40
  "devDependencies": {
37
- "@bigbinary/eslint-plugin-neeto": "^1.1.14",
38
41
  "@bigbinary/neeto-cist": "^1.0.4",
39
- "@bigbinary/neeto-commons-frontend": "^3.0.1",
40
- "@bigbinary/neeto-icons": "^1.11.0",
41
- "@bigbinary/neeto-molecules": "^1.0.19",
42
- "@bigbinary/neetoui": "5.0.2",
43
42
  "@typescript-eslint/eslint-plugin": "^6.2.1",
44
43
  "@typescript-eslint/parser": "^6.2.1",
45
44
  "@vitejs/plugin-react": "^4.0.3",
@@ -47,16 +46,10 @@
47
46
  "cssnano": "4.1.11",
48
47
  "eslint": "8.14.0",
49
48
  "eslint-config-airbnb": "^19.0.4",
50
- "eslint-plugin-import": "2.26.0",
51
- "eslint-plugin-jsx-a11y": "^6.7.1",
52
- "eslint-plugin-react": "7.29.4",
53
- "eslint-plugin-react-hooks": "4.5.0",
54
- "lint-staged": "12.4.1",
49
+ "eslint-plugin-jsx-a11y": "6.7.1",
55
50
  "postcss": "^8.4.17",
56
51
  "postcss-import": "^15.0.0",
57
- "postcss-prefixwrap": "1.40.0",
58
52
  "postcss-preset-env": "7.8.2",
59
- "postcss-wrap": "^0.0.4",
60
53
  "prettier": "2.6.2",
61
54
  "ramda": "^0.29.1",
62
55
  "react": "^18.2.0",
package/react.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ export interface TimezoneObject {
2
+ utc: string[];
3
+ label: string;
4
+ keywords: string;
5
+ isDst: boolean;
6
+ cities: string;
7
+ }
8
+
9
+ export interface NeetoTimezoneSelectorProps {
10
+ className?: string;
11
+ elementId?: string;
12
+ initialValue?: string;
13
+ position?: "top" | "bottom";
14
+ onChange?: (timezone: TimezoneObject) => void;
15
+ onHourFormatChange?: (timeFormat: string) => void;
16
+ }
17
+
18
+ export default function NeetoTimezoneSelector(
19
+ props: NeetoTimezoneSelectorProps
20
+ );