Skip to content

A Blockly advanced date picker field that uses the Google Closure date picker

Notifications You must be signed in to change notification settings

tomas-berg/blockly-field-date

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

blockly-field-date Built on Blockly

A Blockly advanced date picker field that uses the Google Closure date picker.

About

Custom date formats using token option (e.g. yyyy-LL-dd)

blockly-field-date

Installation

npm

npm install --save blockly-field-date

yarn

yarn add blockly-field-date

Build

yarn build

Usage

JavaScript

import * as Blockly from 'blockly';
import FieldDate from 'blockly-field-date';

Blockly.Blocks['test_field_date'] = {
  init: function () {
    this.appendDummyInput()
      .appendField('date: ')
      .appendField(new FieldDate('2022-01-11'), 'FIELDNAME');
  }
};

JSON

import * as Blockly from 'blockly';
import 'blockly-field-date';

Blockly.defineBlocksWithJsonArray([
    {
        type: 'test_field_date',
        message0: 'date: %1',
        args0: [
            {
                type: 'field_date',
                name: 'FIELDNAME',
                date: '2022-01-11
            }
        ]
    }]);

JavaScript - extended options

Blockly.Blocks['test_field_date'] = {
  init: function () {
    this.appendDummyInput()
      .appendField('date: ')
      .appendField(new FieldDate('1/11/2022', null, true, 'L/d/yyyy'), 'FIELDNAME');
  }
};

JSON - extended options

Blockly.defineBlocksWithJsonArray([
    {
        type: 'test_field_date',
        message0: 'date: %1',
        args0: [
            {
                type: 'field_date',
                name: 'FIELDNAME',
                date: '1/11/2022',
                token: 'L/d/yyyy',
                textEdit: true
            }
        ]
    }]);

Run in browser

You need to build the package first.

<script src="./dist/date_compressed.js"></script>

License

Apache 2.0

About

A Blockly advanced date picker field that uses the Google Closure date picker

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published